VirtualBox

source: kBuild/trunk/VSlickMacros/kkeys.e@ 2444

Last change on this file since 2444 was 2437, checked in by bird, 14 years ago

kkeys.e: Finally fixed C+Delete to work correctly across newlines.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.3 KB
Line 
1/* $Id: kkeys.e 2437 2011-03-28 19:17:08Z 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__ >= 14.0
57def 'C-/' = kkeys_push_ref
58def 'S-C-/' = push_ref
59def 'S-A-]' = next_buff_tab
60def 'S-A-[' = prev_buff_tab
61def 'S-A-U' = kkeys_gen_uuid
62#endif
63/* For the mac (A/M mix, all except A-z): */
64def 'M-1' = cursor_error
65def 'M-UP' = find_prev
66def 'M-DOWN' = find_next
67def 'M-PGUP' = prev_proc
68def 'M-PGDN' = next_proc
69def 'M-d' = delete_line
70def 'M-f' = kkeys_open_file_menu
71def 'M-e' = kkeys_open_edit_menu
72def 'M-o' = kkeys_duplicate_line
73def 'M-s' = kkeys_switch_lines
74def 'M-t' = kkeys_open_tools_menu
75def 'M-u' = undo_cursor
76def 'M-g' = goto_line
77#if __VERSION__ >= 14.0
78def 'S-M-]' = next_buff_tab
79def 'S-M-[' = prev_buff_tab
80def 'S-M-U' = kkeys_gen_uuid
81#endif
82/* Fixing brainfucked slickedit silliness: */
83def 'M-v' = paste
84
85
86/** Saves the cursor position. */
87static long kkeys_save_cur_pos()
88{
89 long offset = _QROffset();
90 message(offset);
91 return offset;
92}
93
94/** Restores a saved cursor position. */
95static void kkeys_restore_cur_pos(long lSavedCurPos)
96{
97 _GoToROffset(lSavedCurPos);
98}
99
100
101_command kkeys_switch_lines()
102{
103 /* Allocate a selection for copying the current line. */
104 cursor_down();
105 mark_id= _alloc_selection();
106 if (mark_id>=0)
107 {
108 _select_line(mark_id);
109 cursor_up();
110 cursor_up();
111 _move_to_cursor(mark_id);
112 cursor_down();
113 _free_selection(mark_id);
114 // This selection can be freed because it is not the active selection.
115 }
116 else
117 message(get_message(mark_id));
118}
119
120_command kkeys_duplicate_line()
121{
122 /* Allocate a selection for copying the current line. */
123 mark_id= _alloc_selection();
124 if (mark_id>=0)
125 {
126 _select_line(mark_id);
127 _copy_to_cursor(mark_id);
128 // This selection can be freed because it is not the active selection.
129 _free_selection(mark_id);
130 cursor_down();
131 }
132 else
133 message(get_message(mark_id));
134}
135
136_command kkeys_delete_right()
137{
138 col=p_col;
139
140 /* virtual space hack*/
141 keyin(" ");
142 left();
143 _delete_char();
144
145 /* are we in a word, delete it? */
146 ch = get_text();
147 if (ch != ' ' && ch != "\t" && ch != "\r" && ch != "\n")
148 delete_word();
149
150 /* delete spaces and newlines until the next word. */
151 ch = get_text();
152 if (ch == ' ' || ch == "\t" || ch == "\r" || ch == "\n")
153 {
154 if (search('[ \t\n\r]#','r+') == 0)
155 {
156 _nrseek(match_length('s'));
157 _delete_text(match_length());
158 }
159 }
160
161 p_col=col
162 //retrieve_command_results()
163}
164
165_command kkeys_delete_left()
166{
167 //denne virker ikkje som den skal!!!
168 message "not implemented"
169/*
170 return;
171 col=p_col
172 search('[ \t]#|?|$|^','r-');
173 if ( match_length()&& get_text(1,match_length('s'))=='' )
174 {
175 _nrseek(match_length('s'));
176 _delete_text(match_length());
177 }
178 else
179 delete_word();
180 p_col=col
181*/
182}
183
184_command kkeys_scroll_up()
185{
186 if (p_cursor_y == 0)
187 down();
188 set_scroll_pos(p_left_edge, p_cursor_y-1);
189}
190
191_command kkeys_scroll_down()
192{
193 if (p_cursor_y intdiv p_font_height == p_char_height-1)
194 up()
195 set_scroll_pos(p_left_edge, p_cursor_y+p_font_height);
196}
197
198_command boxer_paste()
199{
200 long lSavedCurPos = kkeys_save_cur_pos()
201 paste();
202 kkeys_restore_cur_pos(lSavedCurPos);
203}
204
205_command kkeys_fullscreen()
206{
207 fullscreen();
208}
209
210
211/* for later, not used yet. */
212
213_command boxer_select()
214{
215 if (command_state())
216 fSelected = (p_sel_length != 0);
217 else
218 fSelected = select_active();
219
220 key = last_event();
221 if (key :== name2event('s-down'))
222 {
223 if (!fSelected)
224 select_line();
225 else
226 cursor_down();
227 }
228 else if (key :== name2event('s-up'))
229 {
230 if (!fSelected)
231 select_line();
232 else
233 cursor_up();
234 }
235 else if (key :== name2event('s-left'))
236 {
237 if (!fSelected)
238 select_char();
239 else
240 cursor_left();
241 }
242 else if (key :== name2event('s-right'))
243 {
244 if (!fSelected)
245 select_char();
246 else
247 cursor_right();
248 }
249 else if (key :== name2event('s-home'))
250 {
251 if (!fSelected) select_char();
252 begin_line_text_toggle();
253 }
254 else if (key :== name2event('s-end'))
255 {
256 if (!fSelected) select_char();
257 end_line();
258 if (p_col > 0) //this is not identical with boxer...
259 cursor_left();
260 }
261 else if (key :== name2event('c-s-home'))
262 {
263 if (!fSelected) select_char();
264 top_of_buffer();
265 }
266 else if (key :== name2event('c-s-end'))
267 {
268 if (!fSelected) select_char();
269 bottom_of_buffer();
270 }
271 else if (key :== name2event('c-s-left'))
272 {
273 if (!fSelected)
274 {
275 cursor_left();
276 select_char(); /* start this selection non-inclusive */
277 }
278 prev_word();
279 }
280 else if (key :== name2event('c-s-right'))
281 {
282 if (!fSelected)
283 {
284 select_char(); /* start this selection non-inclusive */
285 }
286 /* temporary hack */
287 prevpos = p_col;
288 prevline = p_line;
289 p_col++;
290 next_word();
291 if ((p_line == prevline && p_col > prevpos + 1) || (p_line != prevline && p_col > 0))
292 p_col--;
293 }
294}
295
296#if __VERSION__ >= 14.0
297
298/**
299 * Search for references only in the current workspace.
300 */
301_command kkeys_push_ref()
302{
303 if (_isEditorCtl())
304 {
305 sProjTagFile = project_tags_filename();
306 sLangId = p_LangId;
307 if (sProjTagFile != '')
308 {
309
310 /* HACK ALERT: Make sure gtag_filelist_last_ext has the right value. */
311 _update_tag_filelist_ext(sLangId);
312
313 /* save */
314 boolean saved_gtag_filelist_cache_updated = gtag_filelist_cache_updated;
315 _str saved_gtag_filelist_ext[] = gtag_filelist_ext;
316
317 /* HACK ALERT: Replace the tag file list for this language. */
318 gtag_filelist_ext._makeempty();
319 gtag_filelist_ext[0] = sProjTagFile;
320 saved_gtag_filelist_cache_updated = true;
321
322 /* Do the reference searching. */
323 push_ref('-e ' :+ sLangId);
324
325 /* restore*/
326 gtag_filelist_cache_updated = saved_gtag_filelist_cache_updated;
327 gtag_filelist_ext = saved_gtag_filelist_ext;
328 }
329 else
330 push_ref();
331 }
332 else
333 push_ref();
334}
335
336
337_command kkeys_gen_uuid()
338{
339 _str uuid = guid_create_string('G');
340 uuid = lowcase(uuid);
341
342 long lSavedCurPos = kkeys_save_cur_pos();
343 _insert_text(uuid);
344 kkeys_restore_cur_pos(lSavedCurPos);
345}
346
347#endif /* >= 14.0 */
348
349/** @name Mac OS X Hacks: Alt+[fet] -> drop down menu
350 *
351 * This only works when the alt menu hotkeys are enabled in the
352 * settings. Al
353 *
354 * @{
355 */
356_command void kkeys_open_file_menu()
357{
358 call_key(A_F)
359}
360
361_command void kkeys_open_edit_menu()
362{
363 call_key(A_E)
364}
365
366_command void kkeys_open_tools_menu()
367{
368 call_key(A_T)
369}
370/** @} */
371
372void nop()
373{
374
375}
376
377
378#if __VERSION__ >= 14.0
379
380/*
381 * Some diff keyboard hacks for Mac OS X.
382 */
383defeventtab _diff_form
384def 'M-f' = kkeys_diffedit_find
385def 'M-n' = kkeys_diffedit_next
386def 'M-p' = kkeys_diffedit_prev
387
388_command kkeys_diffedit_find()
389{
390 _nocheck _control _ctlfind;
391 _ctlfind.call_event(_ctlfind, LBUTTON_UP);
392}
393
394_command kkeys_diffedit_next()
395{
396 _nocheck _control _ctlfile1;
397 _nocheck _control _ctlfile2;
398 _DiffNextDifference(_ctlfile1, _ctlfile2);
399}
400
401_command kkeys_diffedit_prev()
402{
403 _nocheck _control _ctlfile1;
404 _nocheck _control _ctlfile2;
405 _DiffNextDifference(_ctlfile1, _ctlfile2, '-');
406}
407
408#endif /* >= 14.0 */
409
Note: See TracBrowser for help on using the repository browser.

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