2006-06-15 Peter Dennis Bartok <pbartok@novell.com>
authorPeter Dennis Bartok <pbartok@mono-cvs.ximian.com>
Mon, 19 Jun 2006 15:48:33 +0000 (15:48 -0000)
committerPeter Dennis Bartok <pbartok@mono-cvs.ximian.com>
Mon, 19 Jun 2006 15:48:33 +0000 (15:48 -0000)
* TextControl.cs:
  - MoveCaret: Implemented PgUp, PgDown, CtrlPgUp and CtrlPgDown
  - Undo(): Added replay of cursor move on DeleteChars action; added
    calling Undo() again if a recorded cursor move is invalid (to
    ensure that some action is performed on Undo)
* TextBoxBase.cs (ProcessKey): Added handling of PgUp and PgDown (#78482)

svn path=/trunk/mcs/; revision=61845

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs

index 138cfc9fa8cebd2ae9a5b2b76ed13d8f544cd003..f6a20fb28a31e2d67b3ed155c8ac42e6b94c96ae 100644 (file)
@@ -1,3 +1,12 @@
+2006-06-15  Peter Dennis Bartok  <pbartok@novell.com> 
+
+       * TextControl.cs:
+         - MoveCaret: Implemented PgUp, PgDown, CtrlPgUp and CtrlPgDown
+         - Undo(): Added replay of cursor move on DeleteChars action; added
+           calling Undo() again if a recorded cursor move is invalid (to
+           ensure that some action is performed on Undo)
+       * TextBoxBase.cs (ProcessKey): Added handling of PgUp and PgDown (#78482)
+
 2006-06-16  Jackson Harper  <jackson@ximian.com>
 
        * MdiClient.cs: Instead of just sizing maximized windows when
index 10cf68573f26e1e069e35370982565ae2a584438..b8740cd584abbeccd8afd8319b3357c01671d1aa 100644 (file)
@@ -1012,6 +1012,24 @@ namespace System.Windows.Forms {
                                        return false;
                                }
 
+                               case Keys.PageUp: {
+                                       if ((Control.ModifierKeys & Keys.Control) != 0) {
+                                               document.MoveCaret(CaretDirection.CtrlPgUp);
+                                       } else {
+                                               document.MoveCaret(CaretDirection.PgUp);
+                                       }
+                                       return true;
+                               }
+
+                               case Keys.PageDown: {
+                                       if ((Control.ModifierKeys & Keys.Control) != 0) {
+                                               document.MoveCaret(CaretDirection.CtrlPgDn);
+                                       } else {
+                                               document.MoveCaret(CaretDirection.PgDn);
+                                       }
+                                       return true;
+                               }
+
                                case Keys.Delete: {
                                        if (shift) {
                                                Cut();
index 09f7ea0a6e994f5186b0075379cfca64974ced31..55df188bd691415688b364b7569ca0b5e8bef163 100644 (file)
@@ -87,6 +87,8 @@ namespace System.Windows.Forms {
                End,            // Move to the end of the line
                PgUp,           // Move one page up
                PgDn,           // Move one page down
+               CtrlPgUp,       // Move caret to the first visible char in the viewport
+               CtrlPgDn,       // Move caret to the last visible char in the viewport
                CtrlHome,       // Move to the beginning of the document
                CtrlEnd,        // Move to the end of the document
                WordBack,       // Move to the beginning of the previous word (or beginning of line)
@@ -1652,10 +1654,116 @@ namespace System.Windows.Forms {
                                }
 
                                case CaretDirection.PgUp: {
+                                       int     index;
+                                       int     new_y;
+                                       Line    line;
+
+                                       if ((viewport_y - viewport_height) < 0) {
+                                               // We're just placing the caret at the end of the document, no scrolling needed
+                                               owner.vscroll.Value = 0;
+                                               line = GetLine(1);
+                                               PositionCaret(line, 0);
+                                               XplatUI.CaretVisible(owner.Handle, true);
+                                               owner.Invalidate();
+                                               return;
+                                       }
+                                       
+                                       new_y = caret.line.Y - viewport_height;
+                                       if (new_y < 0) {
+                                               line = GetLine(1);
+                                               PositionCaret(line, 0);
+                                       } else {
+                                               line = FindTag((int)caret.line.widths[caret.pos], caret.line.Y - viewport_height, out index, false).line;
+                                               if (caret.pos > 0) {
+                                                       PositionCaret(line, index);
+                                               } else {
+                                                       PositionCaret(line, 0);
+                                               }
+                                       }
+
+                                       // Line up to fill line starts
+                                       new_y = viewport_y - viewport_height;
+                                       line = FindTag(0, new_y, out index, false).line;
+                                       if (line != null) {
+                                               owner.vscroll.Value = line.Y;
+                                       } else {
+                                               owner.vscroll.Value = new_y;
+                                       }
+                                       XplatUI.CaretVisible(owner.Handle, true);
+                                       owner.Invalidate();
                                        return;
                                }
 
                                case CaretDirection.PgDn: {
+                                       int     index;
+                                       int     new_y;
+                                       Line    line;
+
+                                       if ((viewport_y + viewport_height) > document_y) {
+                                               // We're just placing the caret at the end of the document, no scrolling needed
+                                               owner.vscroll.Value = owner.vscroll.Maximum;
+                                               line = GetLine(lines);
+                                               PositionCaret(line, line.Text.Length);
+                                               XplatUI.CaretVisible(owner.Handle, true);
+                                               owner.Invalidate();
+                                               return;
+                                       }
+                                       
+                                       new_y = caret.line.Y + viewport_height;
+                                       if (new_y > document_y) {
+                                               line = GetLine(lines);
+                                               PositionCaret(line, line.text.Length);
+                                       } else {
+                                               line = FindTag((int)caret.line.widths[caret.pos], caret.line.Y + viewport_height, out index, false).line;
+                                               if (caret.pos > 0) {
+                                                       PositionCaret(line, index);
+                                               } else {
+                                                       PositionCaret(line, 0);
+                                               }
+                                       }
+
+                                       // Line up to fill line starts
+                                       new_y = viewport_y + viewport_height;
+                                       line = FindTag(0, new_y, out index, false).line;
+                                       if (line != null) {
+                                               if (line.Y > owner.vscroll.Maximum) {
+                                                       owner.vscroll.Value = owner.vscroll.Maximum;
+                                               } else {
+                                                       owner.vscroll.Value = line.Y;
+                                               }
+                                       } else {
+                                               owner.vscroll.Value = new_y;
+                                       }
+                                       XplatUI.CaretVisible(owner.Handle, true);
+                                       owner.Invalidate();
+                                       return;
+                               }
+
+                               case CaretDirection.CtrlPgUp: {
+                                       PositionCaret(0, viewport_y);
+                                       if (!owner.IsHandleCreated) {
+                                               return;
+                                       }
+                                       XplatUI.CaretVisible(owner.Handle, true);
+                                       return;
+                               }
+
+                               case CaretDirection.CtrlPgDn: {
+                                       Line    line;
+                                       LineTag tag;
+                                       int     index;
+
+                                       tag = FindTag(0, viewport_y + viewport_height, out index, false);
+                                       if (tag.line.line_no > 1) {
+                                               line = GetLine(tag.line.line_no - 1);
+                                       } else {
+                                               line = tag.line;
+                                       }
+                                       PositionCaret(line, line.Text.Length);
+                                       if (!owner.IsHandleCreated) {
+                                               return;
+                                       }
+                                       XplatUI.CaretVisible(owner.Handle, true);
                                        return;
                                }
 
@@ -4449,17 +4557,20 @@ namespace System.Windows.Forms {
                        // Do the thing
                        switch(action.type) {
                                case ActionType.InsertChar: {
+                                       // FIXME - implement me
                                        break;
                                }
 
                                case ActionType.DeleteChars: {
                                        this.Insert(document.GetLine(action.line_no), action.pos, (Line)action.data);
+                                       Undo(); // Grab the cursor location
                                        break;
                                }
 
                                case ActionType.CursorMove: {
                                        document.caret.line = document.GetLine(action.line_no);
                                        if (document.caret.line == null) {
+                                               Undo();
                                                break;
                                        }
 
@@ -4508,6 +4619,7 @@ namespace System.Windows.Forms {
                        a.pos = start_pos - 1;
 
                        undo_actions.Push(a);
+                       RecordCursor();
                }
 
                public void RecordCursor() {