VirtualBox

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

Last change on this file since 2353 was 2353, checked in by bird, 16 years ago

kkeys.e: mac-style tab switching.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1/* $Id: kkeys.e 2353 2009-08-11 15:11:17Z bird $ */
2/** @file
3 * Bird's key additions to Visual Slickedit.
4 */
5
6/*
7 * Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
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
26defeventtab default_keys
27def 'A-UP' = find_prev
28def 'A-DOWN' = find_next
29def 'A-PGUP' = prev_proc
30def 'A-PGDN' = next_proc
31def 'A-d' = delete_line
32def 'A-o' = kkeys_duplicate_line
33def 'A-s' = kkeys_switch_lines
34def 'A-u' = undo_cursor /* will cursor movement in one undo step. */
35def 'A-g' = goto_line
36def 'A-z' = kkeys_fullscreen
37def 'INS' = boxer_paste
38def 'S-INS' = insert_toggle
39def 'C-UP' = kkeys_scroll_down
40def 'C-DOWN' = kkeys_scroll_up
41def 'C-PGUP' = prev_window
42def 'C-PGDN' = next_window
43def 'C-DEL' = kkeys_delete_right
44#if __VERSION__ >= 14.0
45def 'S-A-]' = next_buff_tab
46def 'S-A-[' = prev_buff_tab
47#endif
48/* For the mac (A/M mix, all except A-z): */
49def 'M-UP' = find_prev
50def 'M-DOWN' = find_next
51def 'M-PGUP' = prev_proc
52def 'M-PGDN' = next_proc
53def 'M-d' = delete_line
54def 'M-o' = kkeys_duplicate_line
55def 'M-s' = kkeys_switch_lines
56def 'M-u' = undo_cursor
57def 'M-g' = goto_line
58#if __VERSION__ >= 14.0
59def 'S-M-]' = next_buff_tab
60def 'S-M-[' = prev_buff_tab
61#endif
62/* Fixing brainfucked slickedit silliness: */
63def 'M-v' = paste
64
65_command kkeys_switch_lines()
66{
67 /* Allocate a selection for copying the current line. */
68 cursor_down();
69 mark_id= _alloc_selection();
70 if (mark_id>=0)
71 {
72 _select_line(mark_id);
73 cursor_up();
74 cursor_up();
75 _move_to_cursor(mark_id);
76 cursor_down();
77 _free_selection(mark_id);
78 // This selection can be freed because it is not the active selection.
79 }
80 else
81 message(get_message(mark_id));
82}
83
84_command kkeys_duplicate_line()
85{
86 /* Allocate a selection for copying the current line. */
87 mark_id= _alloc_selection();
88 if (mark_id>=0)
89 {
90 _select_line(mark_id);
91 _copy_to_cursor(mark_id);
92 // This selection can be freed because it is not the active selection.
93 _free_selection(mark_id);
94 cursor_down();
95 }
96 else
97 message(get_message(mark_id));
98}
99
100_command kkeys_delete_right()
101{
102 col=p_col
103 search('[ \t]#|?|$|^','r+');
104 if ( match_length()&& get_text(1,match_length('s'))=='' )
105 {
106 _nrseek(match_length('s'));
107 _delete_text(match_length());
108 }
109 else
110 delete_word();
111 p_col=col
112 //retrieve_command_results()
113
114}
115
116_command kkeys_delete_left()
117{
118 //denne virker ikkje som den skal!!!
119 message "not implemented"
120/*
121 return;
122 col=p_col
123 search('[ \t]#|?|$|^','r-');
124 if ( match_length()&& get_text(1,match_length('s'))=='' )
125 {
126 _nrseek(match_length('s'));
127 _delete_text(match_length());
128 }
129 else
130 delete_word();
131 p_col=col
132*/
133}
134
135_command kkeys_scroll_up()
136{
137 if (p_cursor_y == 0)
138 down();
139 set_scroll_pos(p_left_edge, p_cursor_y-1);
140}
141
142_command kkeys_scroll_down()
143{
144 if (p_cursor_y intdiv p_font_height == p_char_height-1)
145 up()
146 set_scroll_pos(p_left_edge, p_cursor_y+p_font_height);
147}
148
149_command boxer_paste()
150{
151 int rc;
152 offset = _QROffset();
153 message(offset);
154 rc = paste();
155 _GoToROffset(offset);
156}
157
158_command kkeys_fullscreen()
159{
160 fullscreen();
161}
162
163
164/* for later, not used yet. */
165
166_command boxer_select()
167{
168 if (command_state())
169 fSelected = (p_sel_length != 0);
170 else
171 fSelected = select_active();
172
173 key = last_event();
174 if (key :== name2event('s-down'))
175 {
176 if (!fSelected)
177 select_line();
178 else
179 cursor_down();
180 }
181 else if (key :== name2event('s-up'))
182 {
183 if (!fSelected)
184 select_line();
185 else
186 cursor_up();
187 }
188 else if (key :== name2event('s-left'))
189 {
190 if (!fSelected)
191 select_char();
192 else
193 cursor_left();
194 }
195 else if (key :== name2event('s-right'))
196 {
197 if (!fSelected)
198 select_char();
199 else
200 cursor_right();
201 }
202 else if (key :== name2event('s-home'))
203 {
204 if (!fSelected) select_char();
205 begin_line_text_toggle();
206 }
207 else if (key :== name2event('s-end'))
208 {
209 if (!fSelected) select_char();
210 end_line();
211 if (p_col > 0) //this is not identical with boxer...
212 cursor_left();
213 }
214 else if (key :== name2event('c-s-home'))
215 {
216 if (!fSelected) select_char();
217 top_of_buffer();
218 }
219 else if (key :== name2event('c-s-end'))
220 {
221 if (!fSelected) select_char();
222 bottom_of_buffer();
223 }
224 else if (key :== name2event('c-s-left'))
225 {
226 if (!fSelected)
227 {
228 cursor_left();
229 select_char(); /* start this selection non-inclusive */
230 }
231 prev_word();
232 }
233 else if (key :== name2event('c-s-right'))
234 {
235 if (!fSelected)
236 {
237 select_char(); /* start this selection non-inclusive */
238 }
239 /* temporary hack */
240 prevpos = p_col;
241 prevline = p_line;
242 p_col++;
243 next_word();
244 if ((p_line == prevline && p_col > prevpos + 1) || (p_line != prevline && p_col > 0))
245 p_col--;
246 }
247}
248
249
250void nop()
251{
252
253}
254
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