Exemplo n.º 1
0
 public void AddTextOnCurrentPosition(string text)
 {
     if (IsInsertMode && CurrentChar < TextLines[CurrentString].Length)
     {
         TextLines.RemoveInLine(CurrentString, CurrentChar,
                                Math.Min(text.Length, TextLines[CurrentString].Length - CurrentChar));
     }
     TextLines.InsertInLine(CurrentString, text, CurrentChar);
     CurrentPosition.Chr += text.Length;
 }
Exemplo n.º 2
0
 public void NewLineFromCurrentPosition()
 {
     TextLines.InsertLine(
         CurrentString + 1,
         CurrentChar < TextLines[CurrentString].Length
             ? TextLines[CurrentString].Substring(CurrentChar)
             : string.Empty);
     if (CurrentChar < TextLines[CurrentString].Length)
     {
         TextLines.RemoveInLine(CurrentString, CurrentChar);
     }
     CurrentPosition.Str++;
     CurrentPosition.Chr = 0;
 }
Exemplo n.º 3
0
 public void DeleteAfterCurrentPosition()
 {
     if (CurrentChar == TextLines[CurrentString].Length)
     {
         if (CurrentString == TextLines.Count - 1)
         {
             return;
         }
         var nextString = CurrentString + 1;
         TextLines.AddInLine(CurrentString, TextLines[nextString]);
         TextLines.RemoveLineAt(nextString);
     }
     else
     {
         TextLines.RemoveInLine(CurrentString, CurrentChar, 1);
     }
 }
Exemplo n.º 4
0
 public void DeleteBeforeCurrentPosition()
 {
     if (CurrentChar == 0)
     {
         if (CurrentString == 0)
         {
             return;
         }
         var newPosition = TextLines[CurrentString - 1].Length;
         TextLines.AddInLine(CurrentString - 1, TextLines[CurrentString]);
         TextLines.RemoveLineAt(CurrentString);
         CurrentPosition.Str--;
         CurrentPosition.Chr = newPosition;
     }
     else
     {
         TextLines.RemoveInLine(CurrentString, CurrentChar - 1, 1);
         CurrentPosition.Chr--;
     }
 }