source: trunk/VSlickMacros/kkeys.e@ 2389

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

kkeys.e: uuid.

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