VirtualBox

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

Last change on this file since 3279 was 3146, checked in by bird, 7 years ago

Slickedit/k*.e: updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.5 KB
Line 
1/* $Id: kkeys.e 3146 2018-03-15 17:01:15Z 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 delete_word();
161
162 ch = get_text();
163 if (ch == ' ' || ch == "\t" || ch == "\r" || ch == "\n")
164 {
165 if (search('[ \t]#','r+') == 0)
166 {
167 _nrseek(match_length('s'));
168 _delete_text(match_length());
169 }
170 }
171 }
172 else
173 {
174 /* delete spaces and newlines until the next word. */
175 if (search('[ \t\n\r]#','r+') == 0)
176 {
177 _nrseek(match_length('s'));
178 _delete_text(match_length());
179 }
180 }
181
182 p_col=col
183 //retrieve_command_results()
184}
185
186_command kkeys_scroll_up()
187{
188 if (p_cursor_y == 0)
189 down();
190 set_scroll_pos(p_left_edge, p_cursor_y-1);
191}
192
193_command kkeys_scroll_down()
194{
195 if (p_cursor_y intdiv p_font_height == p_char_height-1)
196 up()
197 set_scroll_pos(p_left_edge, p_cursor_y+p_font_height);
198}
199
200_command boxer_paste()
201{
202 long lSavedCurPos = kkeys_save_cur_pos()
203 paste();
204 kkeys_restore_cur_pos(lSavedCurPos);
205}
206
207_command kkeys_fullscreen()
208{
209 fullscreen();
210}
211
212
213/* for later, not used yet. */
214
215_command boxer_select()
216{
217 if (command_state())
218 fSelected = (p_sel_length != 0);
219 else
220 fSelected = select_active();
221
222 key = last_event();
223 if (key :== name2event('s-down'))
224 {
225 if (!fSelected)
226 select_line();
227 else
228 cursor_down();
229 }
230 else if (key :== name2event('s-up'))
231 {
232 if (!fSelected)
233 select_line();
234 else
235 cursor_up();
236 }
237 else if (key :== name2event('s-left'))
238 {
239 if (!fSelected)
240 select_char();
241 else
242 cursor_left();
243 }
244 else if (key :== name2event('s-right'))
245 {
246 if (!fSelected)
247 select_char();
248 else
249 cursor_right();
250 }
251 else if (key :== name2event('s-home'))
252 {
253 if (!fSelected) select_char();
254 begin_line_text_toggle();
255 }
256 else if (key :== name2event('s-end'))
257 {
258 if (!fSelected) select_char();
259 end_line();
260 if (p_col > 0) //this is not identical with boxer...
261 cursor_left();
262 }
263 else if (key :== name2event('c-s-home'))
264 {
265 if (!fSelected) select_char();
266 top_of_buffer();
267 }
268 else if (key :== name2event('c-s-end'))
269 {
270 if (!fSelected) select_char();
271 bottom_of_buffer();
272 }
273 else if (key :== name2event('c-s-left'))
274 {
275 if (!fSelected)
276 {
277 cursor_left();
278 select_char(); /* start this selection non-inclusive */
279 }
280 prev_word();
281 }
282 else if (key :== name2event('c-s-right'))
283 {
284 if (!fSelected)
285 {
286 select_char(); /* start this selection non-inclusive */
287 }
288 /* temporary hack */
289 prevpos = p_col;
290 prevline = p_line;
291 p_col++;
292 next_word();
293 if ((p_line == prevline && p_col > prevpos + 1) || (p_line != prevline && p_col > 0))
294 p_col--;
295 }
296}
297
298#if __VERSION__ >= 14.0
299
300/**
301 * Search for references only in the current workspace.
302 */
303_command kkeys_push_ref()
304{
305 if (_isEditorCtl())
306 {
307 sProjTagFile = project_tags_filename();
308 sLangId = p_LangId;
309 if (sProjTagFile != '')
310 {
311
312# if __VERSION__ < 21.0 /** @todo fix me? */
313 /* HACK ALERT: Make sure gtag_filelist_last_ext has the right value. */
314 _update_tag_filelist_ext(sLangId);
315
316 /* save */
317 boolean saved_gtag_filelist_cache_updated = gtag_filelist_cache_updated;
318 _str saved_gtag_filelist_ext[] = gtag_filelist_ext;
319
320 /* HACK ALERT: Replace the tag file list for this language. */
321 gtag_filelist_ext._makeempty();
322 gtag_filelist_ext[0] = sProjTagFile;
323 gtag_filelist_cache_updated = true;
324# endif
325
326 /* Do the reference searching. */
327 push_ref('-e ' :+ sLangId);
328
329# if __VERSION__ < 21.0
330 /* restore*/
331 gtag_filelist_cache_updated = saved_gtag_filelist_cache_updated;
332 gtag_filelist_ext = saved_gtag_filelist_ext;
333# endif
334 }
335 else
336 push_ref();
337 }
338 else
339 push_ref();
340}
341
342
343_command kkeys_gen_uuid()
344{
345 _str uuid = guid_create_string('G');
346 uuid = lowcase(uuid);
347
348 long lSavedCurPos = kkeys_save_cur_pos();
349 _insert_text(uuid);
350 kkeys_restore_cur_pos(lSavedCurPos);
351}
352
353#endif /* >= 14.0 */
354
355/** @name Mac OS X Hacks: Alt+[fet] -> drop down menu
356 *
357 * This only works when the alt menu hotkeys are enabled in the
358 * settings. Al
359 *
360 * @{
361 */
362_command void kkeys_open_file_menu()
363{
364 call_key(A_F)
365}
366
367_command void kkeys_open_edit_menu()
368{
369 call_key(A_E)
370}
371
372_command void kkeys_open_tools_menu()
373{
374 call_key(A_T)
375}
376/** @} */
377
378void nop()
379{
380
381}
382
383
384#if __VERSION__ >= 14.0
385
386/*
387 * Some diff keyboard hacks for Mac OS X.
388 */
389defeventtab _diff_form
390def 'M-f' = kkeys_diffedit_find
391def 'M-n' = kkeys_diffedit_next
392def 'M-p' = kkeys_diffedit_prev
393
394_command kkeys_diffedit_find()
395{
396 _nocheck _control _ctlfind;
397 _ctlfind.call_event(_ctlfind, LBUTTON_UP);
398}
399
400_command kkeys_diffedit_next()
401{
402 _nocheck _control _ctlfile1;
403 _nocheck _control _ctlfile2;
404 _DiffNextDifference(_ctlfile1, _ctlfile2);
405}
406
407_command kkeys_diffedit_prev()
408{
409 _nocheck _control _ctlfile1;
410 _nocheck _control _ctlfile2;
411 _DiffNextDifference(_ctlfile1, _ctlfile2, '-');
412}
413
414#endif /* >= 14.0 */
415
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