Example #1
0
 private void Backspace(KeyEventArgs args)
 {
     if (InputForm != InputFormEnum.None)
     {
         var undo = MakeUndoAction();
         if (SelectionLength != 0)
         {
             DeleteSelection();
         }
         else if (GetCursorPosInt() > 0)
         {
             if (args.Control)
             {
                 Regex  r      = new Regex(@"\S*\s*$");
                 string before = Text.Substring(0, GetCursorPosInt());
                 var    match  = r.Match(before);
                 CursorPos       = new CP(match.Index);
                 SelectionLength = match.Length;
                 DeleteSelection();
             }
             else
             {
                 Text = Text.Remove(GetCursorPosInt() - 1, 1);
                 var lines = GetLines().ToList();
                 CursorPos = new CP(Math.Max(0, CursorPos.Pos - 1), CursorPos.GetUV(lines).X == 0);
             }
             Redraw();
         }
         m_additionUndoAction = null;
         undo.SetRedo(m_state);
     }
 }
Example #2
0
 private void MoveUp(KeyEventArgs args)
 {
     if (m_dropDownOpen)
     {
         ItemIndex--;
     }
     else
     {
         if (args.Shift)
         {
             var selectionEnd = GetCursorPosInt() + SelectionLength;
             var point        = CursorToXY(CursorPos.GetUV(GetLines().ToList()));
             point.Y        -= Font.Height;
             CursorPos       = XYToCursor(point.X, point.Y);
             SelectionLength = selectionEnd - GetCursorPosInt();
         }
         else
         {
             SelectionLength = 0;
             var point = CursorToXY(CursorPos.GetUV(GetLines().ToList()));
             point.Y  -= Font.Height;
             CursorPos = XYToCursor(point.X, point.Y);
         }
         Redraw();
         m_additionUndoAction = null;
     }
 }
Example #3
0
        private void Home(KeyEventArgs args)
        {
            if (args.Shift)
            {
                var end   = GetCursorPosInt() + SelectionLength;
                var lines = GetLines().ToList();
                var uv    = CursorPos.GetUV(lines);
                CursorPos       = new CP(lines.Take(uv.Y).Select(l => l.Length).Concat(0.Only()).Sum());
                SelectionLength = end - CursorPos.Pos;
            }
            else
            {
                SelectionLength = 0;
            }

            if (args.Control)
            {
                CursorPos = new CP(0);
            }
            else
            {
                var lines = GetLines().ToList();
                var uv    = CursorPos.GetUV(lines);
                CursorPos = new CP(lines.Take(uv.Y).Select(l => l.Length).Concat(0.Only()).Sum());
            }

            m_additionUndoAction = null;
        }
Example #4
0
 private void MoveCaret()
 {
     //if (InputForm != InputFormEnum.None)
     {
         var pos = CursorToXY(CursorPos.GetUV(GetLines().ToList()));
         if (m_caret != null)
         {
             m_caret.MoveTo((int)(pos.X), (int)pos.Y - Font.Height / 2);
         }
     }
 }