VirtualBox

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

Last change on this file since 119 was 119, checked in by bird, 21 years ago

more keys.

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