static void InputBufferDynamic() { String input = ""; //User input1 uint currentAddress = 0; uint line1 = 0; uint line2 = 0; uint line3 = 0; //Stopwatch to test execution time Stopwatch stopWatch = Stopwatch.StartNew(); Parser myParser = new Parser("", 0); TextBufferDynamic tempTextBuffer = new TextBufferDynamic(); //Create temp buffer Doublylinked inputList = new Doublylinked(); // My text buffer DoubleLinkedList headOfList = new DoubleLinkedList(); //First node while (!input.Equals("q", StringComparison.InvariantCultureIgnoreCase)) { inputList.ResetIndex(); Console.Write(""); input = Console.ReadLine(); //Read input string input = input.Replace(" ", ""); //remove space between words myParser = new Parser(input, currentAddress); //Sent input token to parser //Console.WriteLine("Line 1 is " + myParser.line1 + "Line 2 is " + myParser.line2 + "Line 3 is " + myParser.line3); //Console.WriteLine("Current Address is " + currentAddress); if (myParser.accept != true && myParser.line1 != 0) // if only one address is enter { line1 = myParser.line1; } else if (myParser.accept) { if (line1 != 0) { line2 = myParser.line1; } else { line1 = myParser.line1; line2 = myParser.line2; line3 = myParser.line3; } } //After parser read the command the switch statement help it choose what to do if (myParser.accept) { switch (myParser.command) { case 'a': while (input[0] != '.') { input = Console.ReadLine(); if (input[0] == '.') { uint totalLine = inputList.GetIndex(); unsafe { tempTextBuffer.Append(line1, headOfList, totalLine, ¤tAddress); } headOfList.head = null; break; } inputList.InsertLast(headOfList, input); } break; case 'c': while (input[0] != '.') { input = Console.ReadLine(); if (input[0] == '.') { uint totalLine = inputList.GetIndex(); unsafe { tempTextBuffer.Change(line1, line2, headOfList, totalLine, ¤tAddress); } headOfList.head = null; break; } inputList.InsertLast(headOfList, input); } break; case 'd': unsafe { tempTextBuffer.Delete(line1, line2, ¤tAddress); } headOfList.head = null; break; case 'j': unsafe { tempTextBuffer.Join(line1, line2, ¤tAddress); } headOfList.head = null; break; case 'l': unsafe { tempTextBuffer.List(line1, line2, ¤tAddress); } headOfList.head = null; break; case 'm': unsafe { tempTextBuffer.Move(line1, line2, line3, ¤tAddress); } headOfList.head = null; break; case 'n': unsafe { tempTextBuffer.number(line1, line2, ¤tAddress); } headOfList.head = null; break; case 'p': if (line1 != 0 && line2 != 0) { tempTextBuffer.PrintLine(line1, line2, headOfList); headOfList.head = null; } break; case 't': unsafe { tempTextBuffer.Transfer(line1, line2, line3, ¤tAddress); } headOfList.head = null; break; case 'w': tempTextBuffer.Write(myParser.para); headOfList.head = null; break; case 'e': stopWatch.Start(); tempTextBuffer.Edit(myParser.para); stopWatch.Stop(); Console.WriteLine("File load time is " + stopWatch.ElapsedMilliseconds + "ms"); headOfList.head = null; break; default: Console.WriteLine("Wrong command"); break; } line1 = 0; line2 = 0; line3 = 0; } } }