[119] | 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 <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] | 27 | defeventtab default_keys
|
---|
| 28 | def 'A-UP' = find_prev
|
---|
| 29 | def 'A-DOWN' = find_next
|
---|
| 30 | def 'A-PGUP' = prev_window
|
---|
| 31 | def 'A-PGDN' = next_window
|
---|
[116] | 32 | def 'A-d' = delete_line
|
---|
[114] | 33 | def 'A-o' = kkeys_duplicate_line
|
---|
| 34 | def 'A-s' = kkeys_switch_lines
|
---|
| 35 | def 'A-u' = undo_cursor /* will cursor movement in one undo step. */
|
---|
[118] | 36 | def 'A-g' = goto_line
|
---|
[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
|
---|
| 41 | def 'C-PGUP' = prev_proc
|
---|
| 42 | def 'C-PGDN' = next_proc
|
---|
[118] | 43 | def 'C-DEL' = kkeys_delete_right
|
---|
[114] | 44 |
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 | void 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 |
|
---|
| 66 | void 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 |
|
---|
| 82 | void 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 |
|
---|
| 98 | void 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 |
|
---|
| 115 | void 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 |
|
---|
| 122 | void 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 |
|
---|
| 136 | int 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 |
|
---|
| 230 | void nop()
|
---|
| 231 | {
|
---|
| 232 |
|
---|
| 233 | }
|
---|
| 234 |
|
---|