diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2012-08-01 14:47:20 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2012-08-01 14:47:20 +0100 |
commit | b238791002697efbda1ece31985ca15331511fa8 (patch) | |
tree | 099a9c336f66ada1daff6642649d1059505ea571 /framebuffer/fbtk/event.c | |
parent | 46527795dbf69f08d55692fa1ca85b54a6bcc4dc (diff) | |
download | netsurf-b238791002697efbda1ece31985ca15331511fa8.tar.gz netsurf-b238791002697efbda1ece31985ca15331511fa8.tar.bz2 |
Use enum instead of magic numbers for tracking key modifier states. Pass special keys to core (e.g. WORD_LEFT, SELECT_ALL, etc).
Diffstat (limited to 'framebuffer/fbtk/event.c')
-rw-r--r-- | framebuffer/fbtk/event.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/framebuffer/fbtk/event.c b/framebuffer/fbtk/event.c index 570c82929..67f930622 100644 --- a/framebuffer/fbtk/event.c +++ b/framebuffer/fbtk/event.c @@ -34,6 +34,7 @@ #include "css/css.h" #include "desktop/browser.h" #include "desktop/plotters.h" +#include "desktop/textinput.h" #include "framebuffer/gui.h" #include "framebuffer/fbtk.h" @@ -292,16 +293,46 @@ static int sh_keymap[] = { /* exported function documented in fbtk.h */ int -fbtk_keycode_to_ucs4(int code, uint8_t mods) +fbtk_keycode_to_ucs4(int code, fbtk_modifier_type mods) { int ucs4 = -1; - if (mods) { + if (mods & FBTK_MOD_LSHIFT || mods & FBTK_MOD_RSHIFT) { if ((code >= 0) && (code < (int) NOF_ELEMENTS(sh_keymap))) ucs4 = sh_keymap[code]; - } else { + + } else if (mods == FBTK_MOD_CLEAR) { if ((code >= 0) && (code < (int) NOF_ELEMENTS(keymap))) ucs4 = keymap[code]; + + } else if (mods & FBTK_MOD_LCTRL || mods & FBTK_MOD_RCTRL) { + switch (code) { + case NSFB_KEY_a: + ucs4 = KEY_SELECT_ALL; + break; + + case NSFB_KEY_c: + ucs4 = KEY_COPY_SELECTION; + break; + + case NSFB_KEY_u: + ucs4 = KEY_CUT_LINE; + break; + + case NSFB_KEY_v: + ucs4 = KEY_PASTE; + break; + + case NSFB_KEY_x: + ucs4 = KEY_CUT_SELECTION; + break; + + case NSFB_KEY_z: + ucs4 = KEY_CLEAR_SELECTION; + break; + default: + break; + } } return ucs4; } |