| 1: | // FormatCommands.cs | |
| 2: | // Copyright (C) 2002 Mike Krueger | |
| 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.IO; | |
| 20: | using System.Threading; | |
| 21: | using System.Drawing; | |
| 22: | using System.Drawing.Printing; | |
| 23: | using System.Collections; | |
| 24: | using System.ComponentModel; | |
| 25: | using System.Windows.Forms; | |
| 26: | using System.Diagnostics; | |
| 27: | using System.Text; | |
| 28: | ||
| 29: | using Core.AddIns; | |
| 30: | using Core.Util; | |
| 31: | using Core.Properties; | |
| 32: | using Core.Gui; | |
| 33: | using Core.Gui.Creators; | |
| 34: | ||
| 35: | using SharpDevelop.Gui.Dialogs; | |
| 36: | using SharpDevelop.DefaultEditor.Text; | |
| 37: | using SharpDevelop.DefaultEditor.Gui.Editor; | |
| 38: | using SharpDevelop.Gui; | |
| 39: | ||
| 40: | namespace SharpDevelop.DefaultEditor.Commands { | |
| 41: | ||
| 42: | public class ToggleBookmark : AbstractMenuCommand | |
| 43: | { | |
| 44: | public override void Run() | |
| 45: | { | |
| 46: | IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; | |
| 47: | ||
| 48: | if (window == null || !(window.WindowContent.Control is TextAreaControl)) { | |
| 49: | return; | |
| 50: | } | |
| 51: | ||
| 52: | TextAreaControl textarea = (TextAreaControl)window.WindowContent.Control; | |
| 53: | textarea.Document.BookmarkManager.ToggleMarkAt(textarea.Document.GetLineNumberOfOffset(textarea.Document.Caret.Offset)); | |
| 54: | } | |
| 55: | } | |
| 56: | ||
| 57: | public class PrevBookmark : AbstractMenuCommand | |
| 58: | { | |
| 59: | public override void Run() | |
| 60: | { | |
| 61: | IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; | |
| 62: | ||
| 63: | if (window == null || !(window.WindowContent.Control is TextAreaControl)) { | |
| 64: | return; | |
| 65: | } | |
| 66: | ||
| 67: | TextAreaControl textarea = (TextAreaControl)window.WindowContent.Control; | |
| 68: | int lineNumber = textarea.Document.BookmarkManager.GetPrevMark(textarea.Document.GetLineNumberOfOffset(textarea.Document.Caret.Offset)); | |
| 69: | if (lineNumber != -1) { | |
| 70: | textarea.Document.Caret.Offset = textarea.Document.GetLineOffset(lineNumber); | |
| 71: | } | |
| 72: | } | |
| 73: | } | |
| 74: | ||
| 75: | public class NextBookmark : AbstractMenuCommand | |
| 76: | { | |
| 77: | public override void Run() | |
| 78: | { | |
| 79: | IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; | |
| 80: | ||
| 81: | if (window == null || !(window.WindowContent.Control is TextAreaControl)) { | |
| 82: | return; | |
| 83: | } | |
| 84: | ||
| 85: | TextAreaControl textarea = (TextAreaControl)window.WindowContent.Control; | |
| 86: | int lineNumber = textarea.Document.BookmarkManager.GetNextMark(textarea.Document.GetLineNumberOfOffset(textarea.Document.Caret.Offset)); | |
| 87: | if (lineNumber != -1 && lineNumber < textarea.Document.TotalNumberOfLines) { | |
| 88: | textarea.Document.Caret.Offset = textarea.Document.GetLineOffset(lineNumber); | |
| 89: | } | |
| 90: | } | |
| 91: | } | |
| 92: | ||
| 93: | public class ClearBookmarks : AbstractMenuCommand | |
| 94: | { | |
| 95: | public override void Run() | |
| 96: | { | |
| 97: | IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; | |
| 98: | ||
| 99: | if (window == null || !(window.WindowContent.Control is TextAreaControl)) { | |
| 100: | return; | |
| 101: | } | |
| 102: | ||
| 103: | TextAreaControl textarea = (TextAreaControl)window.WindowContent.Control; | |
| 104: | textarea.Document.BookmarkManager.Clear(); | |
| 105: | } | |
| 106: | } | |
| 107: | } |
This page was automatically generated by SharpDevelop.