win-common.kmk,tools/VCC14[012]*.kmk,retry-10-delay-500ms.sh: Retry mt.exe operations...
[kbuild-mirror.git] / SlickEdit / kkeys.e
blobb80a322d7ce4f9d7969df03db87817aa65818d05
1 /* $Id$ */
2 /** @file
3 * Bird's key additions to Visual Slickedit.
4 */
6 /*
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 /*******************************************************************************
27 * Header Files *
28 *******************************************************************************/
29 #include 'slick.sh'
32 /*******************************************************************************
33 * Global Variables *
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. */
44 def 'A-g' = goto_line
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
56 #endif
57 #if __VERSION__ >= 22.0
58 def 'C-=' = diff;
59 def 'C--' = nil;
60 def 'S-A-C-=' = wfont_zoom_in;
61 def 'S-A-C--' = wfont_zoom_out;
62 #endif
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
69 #endif
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
83 def 'M-g' = goto_line
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
88 #endif
89 #if __VERSION__ >= 22.0
90 def 'S-M-C-=' = wfont_zoom_in;
91 def 'S-M-C--' = wfont_zoom_out;
92 #endif
93 /* Fixing brainfucked slickedit silliness: */
94 def 'M-v' = paste
96 /* Want proper shift-space in C. */
97 defeventtab c_keys
98 def 'S- ' = kkey_space;
101 /** Saves the cursor position. */
102 static long kkeys_save_cur_pos()
104 long offset = _QROffset();
105 message(offset);
106 return offset;
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')
123 keyin(' ');
124 else
125 block_insert_text(' ');
128 _command kkeys_switch_lines()
130 /* Allocate a selection for copying the current line. */
131 cursor_down();
132 mark_id= _alloc_selection();
133 if (mark_id>=0)
135 _select_line(mark_id);
136 cursor_up();
137 cursor_up();
138 _move_to_cursor(mark_id);
139 cursor_down();
140 _free_selection(mark_id);
141 // This selection can be freed because it is not the active selection.
143 else
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();
151 if (mark_id>=0)
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);
157 cursor_down();
159 else
160 message(get_message(mark_id));
163 _command kkeys_delete_right()
165 col=p_col;
167 /* virtual space hack */
168 keyin(" ");
169 left();
170 _delete_char();
172 /* are we in a word, delete it? */
173 ch = get_text();
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());
184 else
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());
194 p_col=col
195 //retrieve_command_results()
198 _command kkeys_scroll_up()
200 if (p_cursor_y == 0)
201 down();
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)
208 up()
209 set_scroll_pos(p_left_edge, p_cursor_y+p_font_height);
212 _command boxer_paste()
214 long lSavedCurPos = kkeys_save_cur_pos()
215 paste();
216 kkeys_restore_cur_pos(lSavedCurPos);
219 _command kkeys_fullscreen()
221 fullscreen();
225 /* for later, not used yet. */
227 _command boxer_select()
229 if (command_state())
230 fSelected = (p_sel_length != 0);
231 else
232 fSelected = select_active();
234 key = last_event();
235 if (key :== name2event('s-down'))
237 if (!fSelected)
238 select_line();
239 else
240 cursor_down();
242 else if (key :== name2event('s-up'))
244 if (!fSelected)
245 select_line();
246 else
247 cursor_up();
249 else if (key :== name2event('s-left'))
251 if (!fSelected)
252 select_char();
253 else
254 cursor_left();
256 else if (key :== name2event('s-right'))
258 if (!fSelected)
259 select_char();
260 else
261 cursor_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();
271 end_line();
272 if (p_col > 0) //this is not identical with boxer...
273 cursor_left();
275 else if (key :== name2event('c-s-home'))
277 if (!fSelected) select_char();
278 top_of_buffer();
280 else if (key :== name2event('c-s-end'))
282 if (!fSelected) select_char();
283 bottom_of_buffer();
285 else if (key :== name2event('c-s-left'))
287 if (!fSelected)
289 cursor_left();
290 select_char(); /* start this selection non-inclusive */
292 prev_word();
294 else if (key :== name2event('c-s-right'))
296 if (!fSelected)
298 select_char(); /* start this selection non-inclusive */
300 /* temporary hack */
301 prevpos = p_col;
302 prevline = p_line;
303 p_col++;
304 next_word();
305 if ((p_line == prevline && p_col > prevpos + 1) || (p_line != prevline && p_col > 0))
306 p_col--;
310 #if __VERSION__ >= 14.0
313 * Search for references only in the current workspace.
315 _command kkeys_push_ref()
317 if (_isEditorCtl())
319 sProjTagFile = project_tags_filename();
320 sLangId = p_LangId;
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);
328 /* save */
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;
336 # endif
338 /* Do the reference searching. */
339 push_ref('-e ' :+ sLangId);
341 # if __VERSION__ < 21.0
342 /* restore*/
343 gtag_filelist_cache_updated = saved_gtag_filelist_cache_updated;
344 gtag_filelist_ext = saved_gtag_filelist_ext;
345 # endif
347 else
348 push_ref();
350 else
351 push_ref();
355 _command kkeys_gen_uuid()
357 _str uuid = guid_create_string('G');
358 uuid = lowcase(uuid);
360 long lSavedCurPos = kkeys_save_cur_pos();
361 _insert_text(uuid);
362 kkeys_restore_cur_pos(lSavedCurPos);
365 #endif /* >= 14.0 */
367 /** @name Mac OS X Hacks: Alt+[fet] -> drop down menu
369 * This only works when the alt menu hotkeys are enabled in the
370 * settings. Al
372 * @{
374 _command void kkeys_open_file_menu()
376 call_key(A_F)
379 _command void kkeys_open_edit_menu()
381 call_key(A_E)
384 _command void kkeys_open_tools_menu()
386 call_key(A_T)
388 /** @} */
390 void nop()
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, '-');
426 #endif /* >= 14.0 */