Changeset 25eec4e in mainline for uspace/app/edit/edit.c
- Timestamp:
- 2013-04-19T18:38:18Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6d717a4
- Parents:
- a1e2df13 (diff), 289cb7dd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
ra1e2df13 r25eec4e 47 47 #include <macros.h> 48 48 #include <clipboard.h> 49 #include < bool.h>49 #include <stdbool.h> 50 50 51 51 #include "sheet.h" … … 80 80 tag_t sel_start; 81 81 82 /** Active keyboard modifiers */ 83 keymod_t keymod; 84 82 85 /** 83 86 * Ideal column where the caret should try to get. This is used … … 119 122 static void cursor_setvis(bool visible); 120 123 124 static void key_handle_press(kbd_event_t *ev); 121 125 static void key_handle_unmod(kbd_event_t const *ev); 122 126 static void key_handle_ctrl(kbd_event_t const *ev); … … 124 128 static void key_handle_shift_ctrl(kbd_event_t const *ev); 125 129 static void key_handle_movement(unsigned int key, bool shift); 130 131 static void pos_handle(pos_event_t *ev); 126 132 127 133 static int file_save(char const *fname); … … 182 188 int main(int argc, char *argv[]) 183 189 { 184 kbd_event_t ev;190 cons_event_t ev; 185 191 bool new_file; 186 192 int rc; … … 245 251 246 252 while (!done) { 247 console_get_ kbd_event(con, &ev);253 console_get_event(con, &ev); 248 254 pane.rflags = 0; 249 255 250 if (ev.type == KEY_PRESS) { 251 /* Handle key press. */ 252 if (((ev.mods & KM_ALT) == 0) && 253 ((ev.mods & KM_SHIFT) == 0) && 254 (ev.mods & KM_CTRL) != 0) { 255 key_handle_ctrl(&ev); 256 } else if (((ev.mods & KM_ALT) == 0) && 257 ((ev.mods & KM_CTRL) == 0) && 258 (ev.mods & KM_SHIFT) != 0) { 259 key_handle_shift(&ev); 260 } else if (((ev.mods & KM_ALT) == 0) && 261 ((ev.mods & KM_CTRL) != 0) && 262 (ev.mods & KM_SHIFT) != 0) { 263 key_handle_shift_ctrl(&ev); 264 } else if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) { 265 key_handle_unmod(&ev); 266 } 256 switch (ev.type) { 257 case CEV_KEY: 258 pane.keymod = ev.ev.key.mods; 259 if (ev.ev.key.type == KEY_PRESS) 260 key_handle_press(&ev.ev.key); 261 break; 262 case CEV_POS: 263 pos_handle(&ev.ev.pos); 264 break; 267 265 } 268 266 … … 286 284 287 285 return 0; 286 } 287 288 /* Handle key press. */ 289 static void key_handle_press(kbd_event_t *ev) 290 { 291 if (((ev->mods & KM_ALT) == 0) && 292 ((ev->mods & KM_SHIFT) == 0) && 293 (ev->mods & KM_CTRL) != 0) { 294 key_handle_ctrl(ev); 295 } else if (((ev->mods & KM_ALT) == 0) && 296 ((ev->mods & KM_CTRL) == 0) && 297 (ev->mods & KM_SHIFT) != 0) { 298 key_handle_shift(ev); 299 } else if (((ev->mods & KM_ALT) == 0) && 300 ((ev->mods & KM_CTRL) != 0) && 301 (ev->mods & KM_SHIFT) != 0) { 302 key_handle_shift_ctrl(ev); 303 } else if ((ev->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) { 304 key_handle_unmod(ev); 305 } 288 306 } 289 307 … … 462 480 } 463 481 482 static void pos_handle(pos_event_t *ev) 483 { 484 coord_t bc; 485 spt_t pt; 486 bool select; 487 488 if (ev->type == POS_PRESS && ev->vpos < (unsigned)pane.rows) { 489 bc.row = pane.sh_row + ev->vpos; 490 bc.column = pane.sh_column + ev->hpos; 491 sheet_get_cell_pt(doc.sh, &bc, dir_before, &pt); 492 493 select = (pane.keymod & KM_SHIFT) != 0; 494 495 caret_move(pt, select, true); 496 } 497 } 498 464 499 /** Move caret while preserving or resetting selection. */ 465 500 static void caret_move(spt_t new_caret_pt, bool select, bool update_ideal_column) … … 592 627 static char *prompt(char const *prompt, char const *init_value) 593 628 { 594 kbd_event_t ev; 629 cons_event_t ev; 630 kbd_event_t *kev; 595 631 char *str; 596 632 wchar_t buffer[INFNAME_MAX_LEN + 1]; … … 612 648 613 649 while (!done) { 614 console_get_kbd_event(con, &ev); 615 616 if (ev.type == KEY_PRESS) { 650 console_get_event(con, &ev); 651 652 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) { 653 kev = &ev.ev.key; 654 617 655 /* Handle key press. */ 618 if ((( ev.mods & KM_ALT) == 0) &&619 ( ev.mods & KM_CTRL) != 0) {656 if (((kev->mods & KM_ALT) == 0) && 657 (kev->mods & KM_CTRL) != 0) { 620 658 ; 621 } else if (( ev.mods & (KM_CTRL | KM_ALT)) == 0) {622 switch ( ev.key) {659 } else if ((kev->mods & (KM_CTRL | KM_ALT)) == 0) { 660 switch (kev->key) { 623 661 case KC_ESCAPE: 624 662 return NULL; … … 634 672 break; 635 673 default: 636 if ( ev.c >= 32 && nc < max_len) {637 putchar( ev.c);674 if (kev->c >= 32 && nc < max_len) { 675 putchar(kev->c); 638 676 console_flush(con); 639 buffer[nc++] = ev.c;677 buffer[nc++] = kev->c; 640 678 } 641 679 break;
Note:
See TracChangeset
for help on using the changeset viewer.