[119] | 1 | /* $Id: kkeys.e 2353 2009-08-11 15:11:17Z bird $ */
|
---|
| 2 | /** @file
|
---|
[1590] | 3 | * Bird's key additions to Visual Slickedit.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[2243] | 7 | * Copyright (c) 2004-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
|
---|
[119] | 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
|
---|
[2019] | 13 | * the Free Software Foundation; either version 3 of the License, or
|
---|
[119] | 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
|
---|
[2019] | 22 | * along with kBuild. If not, see <http://www.gnu.org/licenses/>
|
---|
[119] | 23 | *
|
---|
| 24 | */
|
---|
| 25 |
|
---|
[114] | 26 | defeventtab default_keys
|
---|
| 27 | def 'A-UP' = find_prev
|
---|
| 28 | def 'A-DOWN' = find_next
|
---|
[134] | 29 | def 'A-PGUP' = prev_proc
|
---|
| 30 | def 'A-PGDN' = next_proc
|
---|
[116] | 31 | def 'A-d' = delete_line
|
---|
[114] | 32 | def 'A-o' = kkeys_duplicate_line
|
---|
| 33 | def 'A-s' = kkeys_switch_lines
|
---|
| 34 | def 'A-u' = undo_cursor /* will cursor movement in one undo step. */
|
---|
[118] | 35 | def 'A-g' = goto_line
|
---|
[252] | 36 | def 'A-z' = kkeys_fullscreen
|
---|
[114] | 37 | def 'INS' = boxer_paste
|
---|
| 38 | def 'S-INS' = insert_toggle
|
---|
| 39 | def 'C-UP' = kkeys_scroll_down
|
---|
| 40 | def 'C-DOWN' = kkeys_scroll_up
|
---|
[134] | 41 | def 'C-PGUP' = prev_window
|
---|
| 42 | def 'C-PGDN' = next_window
|
---|
[118] | 43 | def 'C-DEL' = kkeys_delete_right
|
---|
[2353] | 44 | #if __VERSION__ >= 14.0
|
---|
| 45 | def 'S-A-]' = next_buff_tab
|
---|
| 46 | def 'S-A-[' = prev_buff_tab
|
---|
| 47 | #endif
|
---|
[1590] | 48 | /* For the mac (A/M mix, all except A-z): */
|
---|
| 49 | def 'M-UP' = find_prev
|
---|
| 50 | def 'M-DOWN' = find_next
|
---|
| 51 | def 'M-PGUP' = prev_proc
|
---|
| 52 | def 'M-PGDN' = next_proc
|
---|
| 53 | def 'M-d' = delete_line
|
---|
| 54 | def 'M-o' = kkeys_duplicate_line
|
---|
| 55 | def 'M-s' = kkeys_switch_lines
|
---|
| 56 | def 'M-u' = undo_cursor
|
---|
| 57 | def 'M-g' = goto_line
|
---|
[2353] | 58 | #if __VERSION__ >= 14.0
|
---|
| 59 | def 'S-M-]' = next_buff_tab
|
---|
| 60 | def 'S-M-[' = prev_buff_tab
|
---|
| 61 | #endif
|
---|
[1590] | 62 | /* Fixing brainfucked slickedit silliness: */
|
---|
| 63 | def 'M-v' = paste
|
---|
[114] | 64 |
|
---|
[561] | 65 | _command kkeys_switch_lines()
|
---|
[114] | 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 |
|
---|
[561] | 84 | _command kkeys_duplicate_line()
|
---|
[114] | 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 |
|
---|
[561] | 100 | _command kkeys_delete_right()
|
---|
[114] | 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 |
|
---|
[561] | 116 | _command kkeys_delete_left()
|
---|
[114] | 117 | {
|
---|
| 118 | //denne virker ikkje som den skal!!!
|
---|
| 119 | message "not implemented"
|
---|
[561] | 120 | /*
|
---|
[114] | 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
|
---|
[561] | 132 | */
|
---|
[114] | 133 | }
|
---|
| 134 |
|
---|
[561] | 135 | _command kkeys_scroll_up()
|
---|
[114] | 136 | {
|
---|
| 137 | if (p_cursor_y == 0)
|
---|
| 138 | down();
|
---|
| 139 | set_scroll_pos(p_left_edge, p_cursor_y-1);
|
---|
| 140 | }
|
---|
| 141 |
|
---|
[561] | 142 | _command kkeys_scroll_down()
|
---|
[114] | 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 |
|
---|
[566] | 149 | _command boxer_paste()
|
---|
[114] | 150 | {
|
---|
| 151 | int rc;
|
---|
[566] | 152 | offset = _QROffset();
|
---|
[114] | 153 | message(offset);
|
---|
| 154 | rc = paste();
|
---|
| 155 | _GoToROffset(offset);
|
---|
| 156 | }
|
---|
| 157 |
|
---|
[252] | 158 | _command kkeys_fullscreen()
|
---|
| 159 | {
|
---|
| 160 | fullscreen();
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 |
|
---|
| 164 | /* for later, not used yet. */
|
---|
| 165 |
|
---|
[114] | 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 |
|
---|
| 250 | void nop()
|
---|
| 251 | {
|
---|
| 252 |
|
---|
| 253 | }
|
---|
| 254 |
|
---|