[119] | 1 | /* $Id: kkeys.e 2243 2009-01-10 02:24:02Z 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
|
---|
[1590] | 44 | /* For the mac (A/M mix, all except A-z): */
|
---|
| 45 | def 'M-UP' = find_prev
|
---|
| 46 | def 'M-DOWN' = find_next
|
---|
| 47 | def 'M-PGUP' = prev_proc
|
---|
| 48 | def 'M-PGDN' = next_proc
|
---|
| 49 | def 'M-d' = delete_line
|
---|
| 50 | def 'M-o' = kkeys_duplicate_line
|
---|
| 51 | def 'M-s' = kkeys_switch_lines
|
---|
| 52 | def 'M-u' = undo_cursor
|
---|
| 53 | def 'M-g' = goto_line
|
---|
| 54 | /* Fixing brainfucked slickedit silliness: */
|
---|
| 55 | def 'M-v' = paste
|
---|
[114] | 56 |
|
---|
[561] | 57 | _command kkeys_switch_lines()
|
---|
[114] | 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 |
|
---|
[561] | 76 | _command kkeys_duplicate_line()
|
---|
[114] | 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 |
|
---|
[561] | 92 | _command kkeys_delete_right()
|
---|
[114] | 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 |
|
---|
[561] | 108 | _command kkeys_delete_left()
|
---|
[114] | 109 | {
|
---|
| 110 | //denne virker ikkje som den skal!!!
|
---|
| 111 | message "not implemented"
|
---|
[561] | 112 | /*
|
---|
[114] | 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
|
---|
[561] | 124 | */
|
---|
[114] | 125 | }
|
---|
| 126 |
|
---|
[561] | 127 | _command kkeys_scroll_up()
|
---|
[114] | 128 | {
|
---|
| 129 | if (p_cursor_y == 0)
|
---|
| 130 | down();
|
---|
| 131 | set_scroll_pos(p_left_edge, p_cursor_y-1);
|
---|
| 132 | }
|
---|
| 133 |
|
---|
[561] | 134 | _command kkeys_scroll_down()
|
---|
[114] | 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 |
|
---|
[566] | 141 | _command boxer_paste()
|
---|
[114] | 142 | {
|
---|
| 143 | int rc;
|
---|
[566] | 144 | offset = _QROffset();
|
---|
[114] | 145 | message(offset);
|
---|
| 146 | rc = paste();
|
---|
| 147 | _GoToROffset(offset);
|
---|
| 148 | }
|
---|
| 149 |
|
---|
[252] | 150 | _command kkeys_fullscreen()
|
---|
| 151 | {
|
---|
| 152 | fullscreen();
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 |
|
---|
| 156 | /* for later, not used yet. */
|
---|
| 157 |
|
---|
[114] | 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 |
|
---|
| 242 | void nop()
|
---|
| 243 | {
|
---|
| 244 |
|
---|
| 245 | }
|
---|
| 246 |
|
---|