VirtualBox

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

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

kkdev.e: Mac OS X Command+F/E/T menu hacks.

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