VirtualBox

source: kBuild/trunk/SlickEdit/kkeys.e@ 3550

最後變更 在這個檔案從3550是 3499,由 bird 提交於 4 年 前

SlickEdit/kkeys.e: A little correction to the right-word deletion.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 9.5 KB
 
1/* $Id: kkeys.e 3499 2021-05-10 19:18:13Z bird $ */
2/** @file
3 * Bird's key additions to Visual Slickedit.
4 */
5
6/*
7 * Copyright (c) 2004-2010 knut st. osmundsen <[email protected]>
8 *
9 * This file is part of kBuild.
10 *
11 * kBuild is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * kBuild is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with kBuild. If not, see <http://www.gnu.org/licenses/>
23 *
24 */
25
26/*******************************************************************************
27* Header Files *
28*******************************************************************************/
29#include 'slick.sh'
30
31
32/*******************************************************************************
33* Global Variables *
34*******************************************************************************/
35defeventtab default_keys
36def 'A-UP' = find_prev
37def 'A-DOWN' = find_next
38def 'A-PGUP' = prev_proc
39def 'A-PGDN' = next_proc
40def 'A-d' = delete_line
41def 'A-o' = kkeys_duplicate_line
42def 'A-s' = kkeys_switch_lines
43def 'A-u' = undo_cursor /* will cursor movement in one undo step. */
44def 'A-g' = goto_line
45def 'A-z' = kkeys_fullscreen
46def 'INS' = boxer_paste
47def 'S-INS' = insert_toggle
48def 'C-UP' = kkeys_scroll_down
49def 'C-DOWN' = kkeys_scroll_up
50def 'C-PGUP' = prev_window
51def 'C-PGDN' = next_window
52def 'C-DEL' = kkeys_delete_right
53#if __VERSION__ >= 15.0
54def 'S-C-=' = svn_diff_with_base
55#endif
56#if __VERSION__ >= 22.0
57def 'C-=' = diff;
58def 'C--' = nil;
59def 'S-A-C-=' = wfont_zoom_in;
60def 'S-A-C--' = wfont_zoom_out;
61#endif
62#if __VERSION__ >= 14.0
63def 'C-/' = kkeys_push_ref
64def 'S-C-/' = push_ref
65def 'S-A-]' = next_buff_tab
66def 'S-A-[' = prev_buff_tab
67def 'S-A-U' = kkeys_gen_uuid
68#endif
69/* For the mac (A/M mix, all except A-z): */
70def 'M-1' = cursor_error
71def 'M-UP' = find_prev
72def 'M-DOWN' = find_next
73def 'M-PGUP' = prev_proc
74def 'M-PGDN' = next_proc
75def 'M-d' = delete_line
76def 'M-f' = kkeys_open_file_menu
77def 'M-e' = kkeys_open_edit_menu
78def 'M-o' = kkeys_duplicate_line
79def 'M-s' = kkeys_switch_lines
80def 'M-t' = kkeys_open_tools_menu
81def 'M-u' = undo_cursor
82def 'M-g' = goto_line
83#if __VERSION__ >= 14.0
84def 'S-M-]' = next_buff_tab
85def 'S-M-[' = prev_buff_tab
86def 'S-M-U' = kkeys_gen_uuid
87#endif
88#if __VERSION__ >= 22.0
89def 'S-M-C-=' = wfont_zoom_in;
90def 'S-M-C--' = wfont_zoom_out;
91#endif
92/* Fixing brainfucked slickedit silliness: */
93def 'M-v' = paste
94
95
96/** Saves the cursor position. */
97static long kkeys_save_cur_pos()
98{
99 long offset = _QROffset();
100 message(offset);
101 return offset;
102}
103
104/** Restores a saved cursor position. */
105static void kkeys_restore_cur_pos(long lSavedCurPos)
106{
107 _GoToROffset(lSavedCurPos);
108}
109
110
111_command kkeys_switch_lines()
112{
113 /* Allocate a selection for copying the current line. */
114 cursor_down();
115 mark_id= _alloc_selection();
116 if (mark_id>=0)
117 {
118 _select_line(mark_id);
119 cursor_up();
120 cursor_up();
121 _move_to_cursor(mark_id);
122 cursor_down();
123 _free_selection(mark_id);
124 // This selection can be freed because it is not the active selection.
125 }
126 else
127 message(get_message(mark_id));
128}
129
130_command kkeys_duplicate_line()
131{
132 /* Allocate a selection for copying the current line. */
133 mark_id= _alloc_selection();
134 if (mark_id>=0)
135 {
136 _select_line(mark_id);
137 _copy_to_cursor(mark_id);
138 // This selection can be freed because it is not the active selection.
139 _free_selection(mark_id);
140 cursor_down();
141 }
142 else
143 message(get_message(mark_id));
144}
145
146_command kkeys_delete_right()
147{
148 col=p_col;
149
150 /* virtual space hack */
151 keyin(" ");
152 left();
153 _delete_char();
154
155 /* are we in a word, delete it? */
156 ch = get_text();
157 if (ch != ' ' && ch != "\t" && ch != "\r" && ch != "\n")
158 {
159 /* Delete word and any trailing spaces, but stop at new line.
160 (Don't use delete_word here!) */
161 if (search('([[:alnum:]_]#|?)[ \t]@','r+') == 0)
162 {
163 _nrseek(match_length('s'));
164 _delete_text(match_length());
165 }
166 }
167 else
168 {
169 /* delete spaces and newlines until the next word. */
170 if (search('[ \t\n\r]#','r+') == 0)
171 {
172 _nrseek(match_length('s'));
173 _delete_text(match_length());
174 }
175 }
176
177 p_col=col
178 //retrieve_command_results()
179}
180
181_command kkeys_scroll_up()
182{
183 if (p_cursor_y == 0)
184 down();
185 set_scroll_pos(p_left_edge, p_cursor_y-1);
186}
187
188_command kkeys_scroll_down()
189{
190 if (p_cursor_y intdiv p_font_height == p_char_height-1)
191 up()
192 set_scroll_pos(p_left_edge, p_cursor_y+p_font_height);
193}
194
195_command boxer_paste()
196{
197 long lSavedCurPos = kkeys_save_cur_pos()
198 paste();
199 kkeys_restore_cur_pos(lSavedCurPos);
200}
201
202_command kkeys_fullscreen()
203{
204 fullscreen();
205}
206
207
208/* for later, not used yet. */
209
210_command boxer_select()
211{
212 if (command_state())
213 fSelected = (p_sel_length != 0);
214 else
215 fSelected = select_active();
216
217 key = last_event();
218 if (key :== name2event('s-down'))
219 {
220 if (!fSelected)
221 select_line();
222 else
223 cursor_down();
224 }
225 else if (key :== name2event('s-up'))
226 {
227 if (!fSelected)
228 select_line();
229 else
230 cursor_up();
231 }
232 else if (key :== name2event('s-left'))
233 {
234 if (!fSelected)
235 select_char();
236 else
237 cursor_left();
238 }
239 else if (key :== name2event('s-right'))
240 {
241 if (!fSelected)
242 select_char();
243 else
244 cursor_right();
245 }
246 else if (key :== name2event('s-home'))
247 {
248 if (!fSelected) select_char();
249 begin_line_text_toggle();
250 }
251 else if (key :== name2event('s-end'))
252 {
253 if (!fSelected) select_char();
254 end_line();
255 if (p_col > 0) //this is not identical with boxer...
256 cursor_left();
257 }
258 else if (key :== name2event('c-s-home'))
259 {
260 if (!fSelected) select_char();
261 top_of_buffer();
262 }
263 else if (key :== name2event('c-s-end'))
264 {
265 if (!fSelected) select_char();
266 bottom_of_buffer();
267 }
268 else if (key :== name2event('c-s-left'))
269 {
270 if (!fSelected)
271 {
272 cursor_left();
273 select_char(); /* start this selection non-inclusive */
274 }
275 prev_word();
276 }
277 else if (key :== name2event('c-s-right'))
278 {
279 if (!fSelected)
280 {
281 select_char(); /* start this selection non-inclusive */
282 }
283 /* temporary hack */
284 prevpos = p_col;
285 prevline = p_line;
286 p_col++;
287 next_word();
288 if ((p_line == prevline && p_col > prevpos + 1) || (p_line != prevline && p_col > 0))
289 p_col--;
290 }
291}
292
293#if __VERSION__ >= 14.0
294
295/**
296 * Search for references only in the current workspace.
297 */
298_command kkeys_push_ref()
299{
300 if (_isEditorCtl())
301 {
302 sProjTagFile = project_tags_filename();
303 sLangId = p_LangId;
304 if (sProjTagFile != '')
305 {
306
307# if __VERSION__ < 21.0 /** @todo fix me? */
308 /* HACK ALERT: Make sure gtag_filelist_last_ext has the right value. */
309 _update_tag_filelist_ext(sLangId);
310
311 /* save */
312 boolean saved_gtag_filelist_cache_updated = gtag_filelist_cache_updated;
313 _str saved_gtag_filelist_ext[] = gtag_filelist_ext;
314
315 /* HACK ALERT: Replace the tag file list for this language. */
316 gtag_filelist_ext._makeempty();
317 gtag_filelist_ext[0] = sProjTagFile;
318 gtag_filelist_cache_updated = true;
319# endif
320
321 /* Do the reference searching. */
322 push_ref('-e ' :+ sLangId);
323
324# if __VERSION__ < 21.0
325 /* restore*/
326 gtag_filelist_cache_updated = saved_gtag_filelist_cache_updated;
327 gtag_filelist_ext = saved_gtag_filelist_ext;
328# endif
329 }
330 else
331 push_ref();
332 }
333 else
334 push_ref();
335}
336
337
338_command kkeys_gen_uuid()
339{
340 _str uuid = guid_create_string('G');
341 uuid = lowcase(uuid);
342
343 long lSavedCurPos = kkeys_save_cur_pos();
344 _insert_text(uuid);
345 kkeys_restore_cur_pos(lSavedCurPos);
346}
347
348#endif /* >= 14.0 */
349
350/** @name Mac OS X Hacks: Alt+[fet] -> drop down menu
351 *
352 * This only works when the alt menu hotkeys are enabled in the
353 * settings. Al
354 *
355 * @{
356 */
357_command void kkeys_open_file_menu()
358{
359 call_key(A_F)
360}
361
362_command void kkeys_open_edit_menu()
363{
364 call_key(A_E)
365}
366
367_command void kkeys_open_tools_menu()
368{
369 call_key(A_T)
370}
371/** @} */
372
373void nop()
374{
375
376}
377
378
379#if __VERSION__ >= 14.0
380
381/*
382 * Some diff keyboard hacks for Mac OS X.
383 */
384defeventtab _diff_form
385def 'M-f' = kkeys_diffedit_find
386def 'M-n' = kkeys_diffedit_next
387def 'M-p' = kkeys_diffedit_prev
388
389_command kkeys_diffedit_find()
390{
391 _nocheck _control _ctlfind;
392 _ctlfind.call_event(_ctlfind, LBUTTON_UP);
393}
394
395_command kkeys_diffedit_next()
396{
397 _nocheck _control _ctlfile1;
398 _nocheck _control _ctlfile2;
399 _DiffNextDifference(_ctlfile1, _ctlfile2);
400}
401
402_command kkeys_diffedit_prev()
403{
404 _nocheck _control _ctlfile1;
405 _nocheck _control _ctlfile2;
406 _DiffNextDifference(_ctlfile1, _ctlfile2, '-');
407}
408
409#endif /* >= 14.0 */
410
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette