Changeset 3f06dae in mainline for uspace/lib/clui/tinput.c
- Timestamp:
- 2013-04-12T19:40:36Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a2bdcf87
- Parents:
- 902f0906
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/clui/tinput.c
r902f0906 r3f06dae 45 45 #define LIN_TO_COL(ti, lpos) ((lpos) % ((ti)->con_cols)) 46 46 #define LIN_TO_ROW(ti, lpos) ((lpos) / ((ti)->con_cols)) 47 #define LIN_POS(ti, col, row) ((col) + (row) * (ti)->con_cols) 47 48 48 49 /** Seek direction */ … … 383 384 } 384 385 386 static void tinput_seek_scrpos(tinput_t *ti, int col, int line, bool shift_held) 387 { 388 unsigned lpos; 389 tinput_pre_seek(ti, shift_held); 390 391 lpos = LIN_POS(ti, col, line); 392 393 if (lpos > ti->text_coord) 394 ti->pos = lpos - ti->text_coord; 395 else 396 ti->pos = 0; 397 if (ti->pos > ti->nc) 398 ti->pos = ti->nc; 399 400 tinput_post_seek(ti, shift_held); 401 } 402 385 403 static void tinput_seek_max(tinput_t *ti, seek_dir_t dir, bool shift_held) 386 404 { … … 787 805 } 788 806 807 /** Handle key press event. */ 808 static void tinput_key_press(tinput_t *ti, kbd_event_t *kev) 809 { 810 if (((kev->mods & KM_CTRL) != 0) && 811 ((kev->mods & (KM_ALT | KM_SHIFT)) == 0)) 812 tinput_key_ctrl(ti, kev); 813 814 if (((kev->mods & KM_SHIFT) != 0) && 815 ((kev->mods & (KM_CTRL | KM_ALT)) == 0)) 816 tinput_key_shift(ti, kev); 817 818 if (((kev->mods & KM_CTRL) != 0) && 819 ((kev->mods & KM_SHIFT) != 0) && 820 ((kev->mods & KM_ALT) == 0)) 821 tinput_key_ctrl_shift(ti, kev); 822 823 if ((kev->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) 824 tinput_key_unmod(ti, kev); 825 826 if (kev->c >= ' ') { 827 tinput_sel_delete(ti); 828 tinput_insert_char(ti, kev->c); 829 } 830 } 831 832 /** Position event */ 833 static void tinput_pos(tinput_t *ti, pos_event_t *ev) 834 { 835 if (ev->type == POS_PRESS) { 836 tinput_seek_scrpos(ti, ev->hpos, ev->vpos, false); 837 } 838 } 839 789 840 /** Read in one line of input. 790 841 * … … 820 871 return EIO; 821 872 822 if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS) 823 continue; 824 825 kbd_event_t *kev = &ev.ev.key; 826 827 if (((kev->mods & KM_CTRL) != 0) && 828 ((kev->mods & (KM_ALT | KM_SHIFT)) == 0)) 829 tinput_key_ctrl(ti, kev); 830 831 if (((kev->mods & KM_SHIFT) != 0) && 832 ((kev->mods & (KM_CTRL | KM_ALT)) == 0)) 833 tinput_key_shift(ti, kev); 834 835 if (((kev->mods & KM_CTRL) != 0) && 836 ((kev->mods & KM_SHIFT) != 0) && 837 ((kev->mods & KM_ALT) == 0)) 838 tinput_key_ctrl_shift(ti, kev); 839 840 if ((kev->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) 841 tinput_key_unmod(ti, kev); 842 843 if (kev->c >= ' ') { 844 tinput_sel_delete(ti); 845 tinput_insert_char(ti, kev->c); 873 switch (ev.type) { 874 case CEV_KEY: 875 if (ev.ev.key.type == KEY_PRESS) 876 tinput_key_press(ti, &ev.ev.key); 877 break; 878 case CEV_POS: 879 tinput_pos(ti, &ev.ev.pos); 880 break; 846 881 } 847 882 }
Note:
See TracChangeset
for help on using the changeset viewer.