3 * Bird
's key additions to Visual Slickedit.
7 * Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
9 * This file is part of kBuild.
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.
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.
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/>
26 /*******************************************************************************
28 *******************************************************************************/
32 /*******************************************************************************
34 *******************************************************************************/
35 defeventtab default_keys
36 def 'A
-UP
' = find_prev
37 def 'A
-DOWN
' = find_next
38 def 'A
-PGUP
' = prev_proc
39 def 'A
-PGDN
' = next_proc
40 def 'A
-d
' = delete_line
41 def 'A
-o
' = kkeys_duplicate_line
42 def 'A
-s
' = kkeys_switch_lines
43 def 'A
-u
' = undo_cursor /* will cursor movement in one undo step. */
45 def 'A
-z
' = kkeys_fullscreen
46 def 'INS
' = boxer_paste
47 def 'S
-INS
' = insert_toggle
48 def 'S
- ' = kkey_space;
49 def 'C
-UP
' = kkeys_scroll_down
50 def 'C
-DOWN
' = kkeys_scroll_up
51 def 'C
-PGUP
' = prev_window
52 def 'C
-PGDN
' = next_window
53 def 'C
-DEL
' = kkeys_delete_right
54 #if __VERSION__ >= 15.0
55 def 'S
-C
-=' = svn_diff_with_base
57 #if __VERSION__ >= 22.0
60 def
'S-A-C-=' = wfont_zoom_in
;
61 def
'S-A-C--' = wfont_zoom_out
;
63 #
if __VERSION__
>= 14.0
64 def
'C-/' = kkeys_push_ref
65 def
'S-C-/' = push_ref
66 def
'S-A-]' = next_buff_tab
67 def
'S-A-[' = prev_buff_tab
68 def
'S-A-U' = kkeys_gen_uuid
70 /* For the
mac (A
/M mix
, all except A
-z
): */
71 def
'M-1' = cursor_error
72 def
'M-UP' = find_prev
73 def
'M-DOWN' = find_next
74 def
'M-PGUP' = prev_proc
75 def
'M-PGDN' = next_proc
76 def
'M-d' = delete_line
77 def
'M-f' = kkeys_open_file_menu
78 def
'M-e' = kkeys_open_edit_menu
79 def
'M-o' = kkeys_duplicate_line
80 def
'M-s' = kkeys_switch_lines
81 def
'M-t' = kkeys_open_tools_menu
82 def
'M-u' = undo_cursor
84 #
if __VERSION__
>= 14.0
85 def
'S-M-]' = next_buff_tab
86 def
'S-M-[' = prev_buff_tab
87 def
'S-M-U' = kkeys_gen_uuid
89 #
if __VERSION__
>= 22.0
90 def
'S-M-C-=' = wfont_zoom_in
;
91 def
'S-M-C--' = wfont_zoom_out
;
93 /* Fixing brainfucked slickedit silliness
: */
96 /* Want proper shift
-space in C
. */
98 def
'S- ' = kkey_space
;
101 /** Saves the cursor position
. */
102 static long
kkeys_save_cur_pos()
104 long offset
= _QROffset();
109 /** Restores a saved cursor position
. */
110 static void
kkeys_restore_cur_pos(long lSavedCurPos
)
112 _GoToROffset(lSavedCurPos
);
115 /** Fixes shift
-space while in block select
, default slickedit since a while
116 * is to exit selection mode
and insert a single space
. A long long time
117 * ago
, I think slickedit would ask
if you wanted the normal
'space'
118 * behaviour for this
. */
119 _command void
kkey_space()
121 /** @todo figure out when these functions were added
and such
. */
122 if (!select_active() ||
_select_type('') != 'BLOCK')
125 block_insert_text(' ');
128 _command
kkeys_switch_lines()
130 /* Allocate a selection for copying the
current line
. */
132 mark_id
= _alloc_selection();
135 _select_line(mark_id
);
138 _move_to_cursor(mark_id
);
140 _free_selection(mark_id
);
141 // This selection can be freed because it
is not the active selection
.
144 message(get_message(mark_id
));
147 _command
kkeys_duplicate_line()
149 /* Allocate a selection for copying the
current line
. */
150 mark_id
= _alloc_selection();
153 _select_line(mark_id
);
154 _copy_to_cursor(mark_id
);
155 // This selection can be freed because it
is not the active selection
.
156 _free_selection(mark_id
);
160 message(get_message(mark_id
));
163 _command
kkeys_delete_right()
167 /* virtual space hack
*/
172 /* are we in a word
, delete it?
*/
174 if (ch
!= ' ' && ch
!= "\t" && ch
!= "\r" && ch
!= "\n")
176 /* Delete word
and any trailing spaces
, but stop at new line
.
177 (Don
't use delete_word here!) */
178 if (search('([[:alnum
:]_
]#|?
)[ \t
]@
','r
+') == 0)
180 _nrseek(match_length('s
'));
181 _delete_text(match_length());
186 /* delete spaces and newlines until the next word. */
187 if (search('[ \t\n\r
]#
','r
+') == 0)
189 _nrseek(match_length('s
'));
190 _delete_text(match_length());
195 //retrieve_command_results()
198 _command kkeys_scroll_up()
202 set_scroll_pos(p_left_edge, p_cursor_y-1);
205 _command kkeys_scroll_down()
207 if (p_cursor_y intdiv p_font_height == p_char_height-1)
209 set_scroll_pos(p_left_edge, p_cursor_y+p_font_height);
212 _command boxer_paste()
214 long lSavedCurPos = kkeys_save_cur_pos()
216 kkeys_restore_cur_pos(lSavedCurPos);
219 _command kkeys_fullscreen()
225 /* for later, not used yet. */
227 _command boxer_select()
230 fSelected = (p_sel_length != 0);
232 fSelected = select_active();
235 if (key :== name2event('s
-down
'))
242 else if (key :== name2event('s
-up
'))
249 else if (key :== name2event('s
-left
'))
256 else if (key :== name2event('s
-right
'))
263 else if (key :== name2event('s
-home
'))
265 if (!fSelected) select_char();
266 begin_line_text_toggle();
268 else if (key :== name2event('s
-end'))
270 if (!fSelected) select_char();
272 if (p_col > 0) //this is not identical with boxer...
275 else if (key :== name2event('c
-s
-home
'))
277 if (!fSelected) select_char();
280 else if (key :== name2event('c
-s
-end'))
282 if (!fSelected) select_char();
285 else if (key :== name2event('c
-s
-left
'))
290 select_char(); /* start this selection non-inclusive */
294 else if (key :== name2event('c
-s
-right
'))
298 select_char(); /* start this selection non-inclusive */
305 if ((p_line == prevline && p_col > prevpos + 1) || (p_line != prevline && p_col > 0))
310 #if __VERSION__ >= 14.0
313 * Search for references only in the current workspace.
315 _command kkeys_push_ref()
319 sProjTagFile = project_tags_filename();
321 if (sProjTagFile != '')
324 # if __VERSION__ < 21.0 /** @todo fix me? */
325 /* HACK ALERT: Make sure gtag_filelist_last_ext has the right value. */
326 _update_tag_filelist_ext(sLangId);
329 boolean saved_gtag_filelist_cache_updated = gtag_filelist_cache_updated;
330 _str saved_gtag_filelist_ext[] = gtag_filelist_ext;
332 /* HACK ALERT: Replace the tag file list for this language. */
333 gtag_filelist_ext._makeempty();
334 gtag_filelist_ext[0] = sProjTagFile;
335 gtag_filelist_cache_updated = true;
338 /* Do the reference searching. */
339 push_ref('-e
' :+ sLangId);
341 # if __VERSION__ < 21.0
343 gtag_filelist_cache_updated = saved_gtag_filelist_cache_updated;
344 gtag_filelist_ext = saved_gtag_filelist_ext;
355 _command kkeys_gen_uuid()
357 _str uuid = guid_create_string('G
');
358 uuid = lowcase(uuid);
360 long lSavedCurPos = kkeys_save_cur_pos();
362 kkeys_restore_cur_pos(lSavedCurPos);
367 /** @name Mac OS X Hacks: Alt+[fet] -> drop down menu
369 * This only works when the alt menu hotkeys are enabled in the
374 _command void kkeys_open_file_menu()
379 _command void kkeys_open_edit_menu()
384 _command void kkeys_open_tools_menu()
396 #if __VERSION__ >= 14.0
399 * Some diff keyboard hacks for Mac OS X.
401 defeventtab _diff_form
402 def 'M
-f
' = kkeys_diffedit_find
403 def 'M
-n
' = kkeys_diffedit_next
404 def 'M
-p
' = kkeys_diffedit_prev
406 _command kkeys_diffedit_find()
408 _nocheck _control _ctlfind;
409 _ctlfind.call_event(_ctlfind, LBUTTON_UP);
412 _command kkeys_diffedit_next()
414 _nocheck _control _ctlfile1;
415 _nocheck _control _ctlfile2;
416 _DiffNextDifference(_ctlfile1, _ctlfile2);
419 _command kkeys_diffedit_prev()
421 _nocheck _control _ctlfile1;
422 _nocheck _control _ctlfile2;
423 _DiffNextDifference(_ctlfile1, _ctlfile2, '-');