| 0: | // HomeEndKeys.cs | |
| 1: | // Copyright (C) 2000 Mike Krueger | |
| 2: | // Copyright (C) 2000 Andrea Paatz | |
| 3: | // | |
| 4: | // This program is free software; you can redistribute it and/or modify | |
| 5: | // it under the terms of the GNU General Public License as published by | |
| 6: | // the Free Software Foundation; either version 2 of the License, or | |
| 7: | // (at your option) any later version. | |
| 8: | // | |
| 9: | // This program is distributed in the hope that it will be useful, | |
| 10: | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11: | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12: | // GNU General Public License for more details. | |
| 13: | // | |
| 14: | // You should have received a copy of the GNU General Public License | |
| 15: | // along with this program; if not, write to the Free Software | |
| 16: | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17: | ||
| 18: | using System; | |
| 19: | using System.Drawing; | |
| 20: | using System.Windows.Forms; | |
| 21: | ||
| 22: | using SharpDevelop.Gui.Edit.Text; | |
| 23: | using SharpDevelop.Actions; | |
| 24: | ||
| 25: | namespace SharpDevelop.Actions.Edit { | |
| 26: | ||
| 27: | public class Home : ISdEditAction | |
| 28: | { | |
| 29: | public virtual void Execute(ISdEditActionExecutor executor) | |
| 30: | { | |
| 31: | Point pos = executor.TextArea.Caret.CaretPos; | |
| 32: | for (pos.X = 0; pos.X < executor.TextArea.Buffer[pos.Y].Text.Length; ++pos.X) | |
| 33: | if (!Char.IsWhiteSpace(executor.TextArea.Buffer[pos.Y].Text[pos.X])) | |
| 34: | break; | |
| 35: | ||
| 36: | if (pos.X == executor.TextArea.Caret.CaretPos.X) | |
| 37: | pos.X = 0; | |
| 38: | ||
| 39: | executor.TextArea.Caret.CaretPos = pos; | |
| 40: | executor.TextArea.Caret.SetUpDownPos(); | |
| 41: | } | |
| 42: | ||
| 43: | } | |
| 44: | ||
| 45: | public class End : ISdEditAction | |
| 46: | { | |
| 47: | public virtual void Execute(ISdEditActionExecutor executor) | |
| 48: | { | |
| 49: | Point pos = executor.TextArea.Caret.CaretPos; | |
| 50: | pos.X = executor.TextArea.Buffer[pos.Y].Text.Length; | |
| 51: | ||
| 52: | executor.TextArea.Caret.CaretPos = pos; | |
| 53: | executor.TextArea.Caret.SetUpDownPos(); | |
| 54: | } | |
| 55: | } | |
| 56: | ||
| 57: | public class ShiftHome : Home | |
| 58: | { | |
| 59: | public override void Execute(ISdEditActionExecutor executor) | |
| 60: | { | |
| 61: | Point oldpos = executor.TextArea.Caret.CaretPos; | |
| 62: | executor.TextArea.ClearSelectionMove = false; | |
| 63: | base.Execute(executor); | |
| 64: | executor.TextArea.ClearSelectionMove = true; | |
| 65: | executor.TextArea.Selection.SetSelectionEnd(oldpos, executor.TextArea.Caret.CaretPos); | |
| 66: | } | |
| 67: | } | |
| 68: | ||
| 69: | public class ShiftEnd : End | |
| 70: | { | |
| 71: | public override void Execute(ISdEditActionExecutor executor) | |
| 72: | { | |
| 73: | Point oldpos = executor.TextArea.Caret.CaretPos; | |
| 74: | executor.TextArea.ClearSelectionMove = false; | |
| 75: | base.Execute(executor); | |
| 76: | executor.TextArea.ClearSelectionMove = true; | |
| 77: | executor.TextArea.Selection.SetSelectionEnd(oldpos, executor.TextArea.Caret.CaretPos); | |
| 78: | } | |
| 79: | } | |
| 80: | ||
| 81: | public class MoveToStart : ISdEditAction | |
| 82: | { | |
| 83: | public virtual void Execute(ISdEditActionExecutor executor) | |
| 84: | { | |
| 85: | executor.TextArea.Caret.CaretPos = new Point(0, executor.TextArea.Caret.GetFirstValidPosGreater(-1)); | |
| 86: | executor.TextArea.Caret.SetUpDownPos(); | |
| 87: | } | |
| 88: | } | |
| 89: | ||
| 90: | public class MoveToEnd : ISdEditAction | |
| 91: | { | |
| 92: | public virtual void Execute(ISdEditActionExecutor executor) | |
| 93: | { | |
| 94: | executor.TextArea.Caret.CaretPos = new Point(executor.TextArea.Buffer[executor.TextArea.Buffer.Length - 1].Text.Length, executor.TextArea.Caret.GetFirstValidPosLower(executor.TextArea.Buffer.Length)); | |
| 95: | executor.TextArea.Caret.SetUpDownPos(); | |
| 96: | } | |
| 97: | } | |
| 98: | ||
| 99: | public class ShiftMoveToStart : MoveToStart | |
| 100: | { | |
| 101: | public override void Execute(ISdEditActionExecutor executor) | |
| 102: | { | |
| 103: | Point oldpos = executor.TextArea.Caret.CaretPos; | |
| 104: | executor.TextArea.ClearSelectionMove = false; | |
| 105: | base.Execute(executor); | |
| 106: | executor.TextArea.ClearSelectionMove = true; | |
| 107: | executor.TextArea.Selection.SetSelectionEnd(oldpos, executor.TextArea.Caret.CaretPos); | |
| 108: | } | |
| 109: | } | |
| 110: | ||
| 111: | public class ShiftMoveToEnd : MoveToEnd | |
| 112: | { | |
| 113: | public override void Execute(ISdEditActionExecutor executor) | |
| 114: | { | |
| 115: | Point oldpos = executor.TextArea.Caret.CaretPos; | |
| 116: | executor.TextArea.ClearSelectionMove = false; | |
| 117: | base.Execute(executor); | |
| 118: | executor.TextArea.ClearSelectionMove = true; | |
| 119: | executor.TextArea.Selection.SetSelectionEnd(oldpos, executor.TextArea.Caret.CaretPos); | |
| 120: | } | |
| 121: | } | |
| 122: | } |
This page was automatically generated by SharpDevelop.