uint32_t key,
uint32_t state)
{
+ struct text_entry *entry = data;
const char *state_label;
- const char *key_label;
+ const char *key_label = "released";
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
state_label = "pressed";
- } else {
- state_label = "released";
}
switch (key) {
case XKB_KEY_KP_Enter:
key_label = "Enter";
break;
+ case XKB_KEY_Left:
+ if (entry->cursor > 0) {
+ entry->cursor--;
+ entry->anchor = entry->cursor;
+ widget_schedule_redraw(entry->widget);
+ }
+ break;
+ case XKB_KEY_Right:
+ if (entry->cursor < strlen(entry->text)) {
+ entry->cursor++;
+ entry->anchor = entry->cursor;
+ widget_schedule_redraw(entry->widget);
+ }
+ break;
default:
key_label = "Unknown";
}
keytype_space,
keytype_switch,
keytype_symbols,
- keytype_tab
+ keytype_tab,
+ keytype_arrow_up,
+ keytype_arrow_left,
+ keytype_arrow_right,
+ keytype_arrow_down
};
struct key {
{ keytype_default, ".", ".", 1},
{ keytype_switch, "ABC", "abc", 1},
- { keytype_symbols, "?123", "?123", 2},
- { keytype_space, "", "", 8},
- { keytype_symbols, "?123", "?123", 2}
+ { keytype_symbols, "?123", "?123", 1},
+ { keytype_space, "", "", 6},
+ { keytype_arrow_up, "/\\", "/\\", 1},
+ { keytype_arrow_left, "<", "<", 1},
+ { keytype_arrow_right, ">", ">", 1},
+ { keytype_arrow_down, "\\/", "\\/", 1},
+ { keytype_symbols, "?123", "?123", 1}
};
static const unsigned int columns = 12;
input_method_context_key(keyboard->keyboard->context,
XKB_KEY_Tab, WL_KEYBOARD_KEY_STATE_PRESSED);
break;
+ case keytype_arrow_up:
+ input_method_context_key(keyboard->keyboard->context,
+ XKB_KEY_Up, WL_KEYBOARD_KEY_STATE_PRESSED);
+ break;
+ case keytype_arrow_left:
+ input_method_context_key(keyboard->keyboard->context,
+ XKB_KEY_Left, WL_KEYBOARD_KEY_STATE_PRESSED);
+ break;
+ case keytype_arrow_right:
+ input_method_context_key(keyboard->keyboard->context,
+ XKB_KEY_Right, WL_KEYBOARD_KEY_STATE_PRESSED);
+ break;
+ case keytype_arrow_down:
+ input_method_context_key(keyboard->keyboard->context,
+ XKB_KEY_Down, WL_KEYBOARD_KEY_STATE_PRESSED);
+ break;
}
}