VirtualBox

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

Last change on this file since 2410 was 2410, checked in by bird, 15 years ago

kkeys.e: Ctrl+Shift+= -> svn-diff-with-base

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

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