VirtualBox

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

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

*: Updated copyright to 2009 and normalized name & email.

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