source: trunk/VSlickMacros/kkeys.e@ 665

Last change on this file since 665 was 566, checked in by bird, 19 years ago

Another _command.

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