0:   // CursorKeys.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.Drawing;
19:   using System.Windows.Forms;
20:   using System;
21:  
22:   using SharpDevelop.Gui.Edit.Text;
23:   using SharpDevelop.Actions;
24:  
25:   namespace SharpDevelop.Actions.Edit {
26:       
27:       public class CaretLeft : ISdEditAction
28:       {
29:           public virtual void Execute(ISdEditActionExecutor executor)
30:           {
31:               Point caretpos executor.TextArea.Caret.CaretPos;
32:               if (caretpos.> 0) {
33:                   --caretpos.X;
34:               else {
35:                   if (caretpos.> 0) {
36:                       caretpos.executor.TextArea.Caret.GetFirstValidPosLower(caretpos.Y);
37:                       caretpos.executor.TextArea.Buffer[caretpos.Y].Text.Length;
38:                   }
39:               }
40:               if (caretpos.!= -1) {
41:                   executor.TextArea.Caret.CaretPos caretpos;
42:                   executor.TextArea.Caret.SetUpDownPos();
43:               }
44:           }
45:       
46:       
47:       public class CaretRight : ISdEditAction
48:       {
49:           
50:           public virtual void Execute(ISdEditActionExecutor executor)
51:           {
52:               Point caretpos executor.TextArea.Caret.CaretPos;
53:               if (executor.TextArea.Options.CursorBehindEOL || caretpos.< executor.TextArea.Buffer[caretpos.Y].Text.Length) {
54:                   ++caretpos.X;
55:               else {
56:                   if (caretpos.< executor.TextArea.Buffer.Length 1) {
57:                       caretpos.executor.TextArea.Caret.GetFirstValidPosGreater(caretpos.Y);
58:                       caretpos.0;
59:                   }
60:               }
61:               if (caretpos.!= -1) {
62:                   executor.TextArea.Caret.CaretPos caretpos;
63:                   executor.TextArea.Caret.SetUpDownPos();
64:               }
65:           }
66:       }
67:       
68:       
69:       public class CaretUp : ISdEditAction
70:       {
71:           
72:           public virtual void Execute(ISdEditActionExecutor executor)
73:           {
74:               Point caretpos executor.TextArea.Caret.CaretPos;
75:               caretpos.Math.Max(0executor.TextArea.Caret.GetFirstValidPosLower(caretpos.Y));
76:               caretpos.executor.TextArea.Caret.UpDownPos;
77:               
78:   //            if (caretpos != executor.TextArea.Caret.PhysicalCaretPos)
79:               if (caretpos.!= -1
80:                   executor.TextArea.Caret.PhysicalCaretPos caretpos;
81:           }
82:           
83:       }
84:       
85:       public class CaretDown : ISdEditAction
86:       {
87:           public virtual void Execute(ISdEditActionExecutor executor)
88:           {
89:               Point caretpos executor.TextArea.Caret.CaretPos;
90:               caretpos.Math.Min(executor.TextArea.Caret.GetFirstValidPosGreater(caretpos.Y), 
91:                                     executor.TextArea.Caret.GetFirstValidPosLower(executor.TextArea.Buffer.Length));
92:               caretpos.executor.TextArea.Caret.UpDownPos;
93:               
94:               if (caretpos.!= -1)  {
95:                   if (caretpos != executor.TextArea.Caret.PhysicalCaretPos)
96:                       executor.TextArea.Caret.PhysicalCaretPos caretpos;
97:               }
98:           }
99:       }
100:       
101:       
102:       public class ShiftCaretRight : CaretRight
103:       {
104:           public override void Execute(ISdEditActionExecutor executor)
105:           {
106:               Point oldpos executor.TextArea.Caret.CaretPos;
107:               executor.TextArea.ClearSelectionMove false;
108:               base.Execute(executor);
109:               executor.TextArea.ClearSelectionMove true;
110:               executor.TextArea.Selection.SetSelectionEnd(oldposexecutor.TextArea.Caret.CaretPos);
111:           }
112:       }
113:       
114:       public class ShiftCaretLeft : CaretLeft
115:       {
116:           public override void Execute(ISdEditActionExecutor executor)
117:           {
118:               Point oldpos executor.TextArea.Caret.CaretPos;
119:               executor.TextArea.ClearSelectionMove false;
120:               base.Execute(executor);
121:               executor.TextArea.ClearSelectionMove true;
122:               executor.TextArea.Selection.SetSelectionEnd(oldposexecutor.TextArea.Caret.CaretPos);
123:           }
124:       }
125:       
126:       public class ShiftCaretUp : CaretUp
127:       {
128:           public override void Execute(ISdEditActionExecutor executor)
129:           {
130:               Point oldpos executor.TextArea.Caret.CaretPos;
131:               executor.TextArea.ClearSelectionMove false;
132:               base.Execute(executor);
133:               executor.TextArea.ClearSelectionMove true;
134:               executor.TextArea.Selection.SetSelectionEnd(oldposexecutor.TextArea.Caret.CaretPos);
135:           }
136:       }
137:       
138:       public class ShiftCaretDown : CaretDown
139:       {
140:           public override void Execute(ISdEditActionExecutor executor)
141:           {
142:               Point oldpos executor.TextArea.Caret.CaretPos;
143:               executor.TextArea.ClearSelectionMove false;
144:               base.Execute(executor);
145:               executor.TextArea.ClearSelectionMove true;
146:               executor.TextArea.Selection.SetSelectionEnd(oldposexecutor.TextArea.Caret.CaretPos);
147:           }
148:       }
149:       
150:       
151:       public class ScrollLineUp : ISdEditAction
152:       {
153:           public void Execute(ISdEditActionExecutor executor)
154:           {
155:               executor.TextArea.SetScrollTo(Math.Max(0executor.TextArea.GetFirstLine() - 1));
156:           }
157:       }
158:       
159:       public class ScrollLineDown : ISdEditAction
160:       {
161:           public void Execute(ISdEditActionExecutor executor)
162:           {
163:               executor.TextArea.SetScrollTo(Math.Min(executor.TextArea.GetMaxScroll(), executor.TextArea.GetFirstLine() + 1));
164:           }
165:       }
166:       
167:       public class WordRight : ISdEditAction
168:       {
169:           public virtual void Execute(ISdEditActionExecutor executor)
170:           {
171:               Point caretpos executor.TextArea.Caret.CaretPos;
172:               if (caretpos.== executor.TextArea.Buffer[caretpos.Y].Text.Length && 
173:                   caretpos.== executor.TextArea.Buffer.Length 1)
174:                   return;
175:               if (caretpos.== executor.TextArea.Buffer[caretpos.Y].Text.Length) {
176:                   caretpos.0;
177:                   caretpos.Math.Min(executor.TextArea.Caret.GetFirstValidPosGreater(caretpos.Y), 
178:                                         executor.TextArea.Caret.GetFirstValidPosLower(executor.TextArea.Buffer.Length));
179:               else {
180:                   int caretpos.X;
181:                   
182:                   while (< executor.TextArea.Buffer[caretpos.Y].Text.Length && Char.IsLetterOrDigit(executor.TextArea.Buffer[caretpos.Y].Text[i]))
183:                       ++i;
184:                   
185:                   while (< executor.TextArea.Buffer[caretpos.Y].Text.Length && !Char.IsLetterOrDigit(executor.TextArea.Buffer[caretpos.Y].Text[i]))
186:                       ++i;
187:                   
188:                   caretpos.i;
189:               }
190:               executor.TextArea.Caret.CaretPos caretpos;
191:               executor.TextArea.Caret.SetUpDownPos();
192:           }
193:       }
194:       
195:       public class WordLeft : ISdEditAction
196:       {
197:           public virtual void Execute(ISdEditActionExecutor executor)
198:           {
199:               Point caretpos executor.TextArea.Caret.CaretPos;
200:               if (caretpos.== && caretpos.== 0)
201:                   return;
202:               if (caretpos.== 0){
203:                   caretpos.executor.TextArea.Caret.GetFirstValidPosLower(caretpos.Y);
204:                   caretpos.executor.TextArea.Buffer[caretpos.Y].Text.Length;
205:               else {
206:                   int caretpos.X;
207:                   
208:                   while (> && !Char.IsLetterOrDigit(executor.TextArea.Buffer[caretpos.Y].Text[1]))
209:                       --i;
210:                   
211:                   while (> && Char.IsLetterOrDigit(executor.TextArea.Buffer[caretpos.Y].Text[1]))
212:                       --i;
213:                   
214:                   caretpos.i;
215:               }
216:               executor.TextArea.Caret.CaretPos caretpos;
217:               executor.TextArea.Caret.SetUpDownPos();
218:           }
219:       }
220:       
221:       public class ShiftWordRight : WordRight
222:       {
223:           public override void Execute(ISdEditActionExecutor executor)
224:           {
225:               Point oldpos executor.TextArea.Caret.CaretPos;
226:               executor.TextArea.ClearSelectionMove false;
227:               base.Execute(executor);
228:               executor.TextArea.ClearSelectionMove true;
229:               executor.TextArea.Selection.SetSelectionEnd(oldposexecutor.TextArea.Caret.CaretPos);
230:           }
231:       }
232:       
233:       public class ShiftWordLeft : WordLeft
234:       {
235:           public override void Execute(ISdEditActionExecutor executor)
236:           {
237:               Point oldpos executor.TextArea.Caret.CaretPos;
238:               executor.TextArea.ClearSelectionMove false;
239:               base.Execute(executor);
240:               executor.TextArea.ClearSelectionMove true;
241:               executor.TextArea.Selection.SetSelectionEnd(oldposexecutor.TextArea.Caret.CaretPos);
242:           }
243:       }
244:   }

This page was automatically generated by SharpDevelop.