mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
a9da075eb5
Form fields and BFU text-input widgets then convert from UCS-4 to UTF-8. If not all UTF-8 bytes fit, they don't insert anything. Thus it is no longer possible to get invalid UTF-8 by hitting the length limit. It is unclear to me which charset is supposed to be used for strings in internal buffers. I made BFU insert UTF-8 whenever CONFIG_UTF_8, but form fields use the charset of the terminal; that may have to be changed. As a side effect, this change should solve bug 782, because term_send_ucs no longer encodes in UTF-8 if CONFIG_UTF_8 is defined. I think the UTF-8 and codepage encoding calls I added are safe, too. A similar bug may still surface somewhere else, but 782 could be closed for now. This change also lays the foundation for binding actions to non-ASCII keys, but the keystroke name parser doesn't yet support that. The CONFIG_UTF_8 mode does not currently support non-ASCII characters in hot keys, either.
91 lines
2.4 KiB
C
91 lines
2.4 KiB
C
#ifndef EL__TERMINAL_KBD_H
|
|
#define EL__TERMINAL_KBD_H
|
|
|
|
struct itrm;
|
|
|
|
struct term_event_keyboard {
|
|
/* Values <= -0x100 are special; e.g. KBD_ENTER.
|
|
* Values between -0xFF and -2 are not used yet; treat as special.
|
|
* Value == -1 is KBD_UNDEF; not sent via socket.
|
|
* Values >= 0 are characters received from the terminal;
|
|
* in UCS-4 #ifdef CONFIG_UTF_8. */
|
|
int key;
|
|
int modifier;
|
|
};
|
|
|
|
struct interlink_event_keyboard {
|
|
/* Values <= -2 are not used, for ELinks 0.11 compatibility.
|
|
* Value == -1 is KBD_UNDEF; not sent via socket.
|
|
* Values between 0 and 0xFF are bytes received from the terminal.
|
|
* Values >= 0x100 are special; e.g. -KBD_ENTER. */
|
|
int key;
|
|
int modifier;
|
|
};
|
|
|
|
#define KBD_UNDEF -1
|
|
|
|
#define KBD_ENTER (-0x100)
|
|
#define KBD_BS (-0x101)
|
|
#define KBD_TAB (-0x102)
|
|
#define KBD_ESC (-0x103)
|
|
#define KBD_LEFT (-0x104)
|
|
#define KBD_RIGHT (-0x105)
|
|
#define KBD_UP (-0x106)
|
|
#define KBD_DOWN (-0x107)
|
|
#define KBD_INS (-0x108)
|
|
#define KBD_DEL (-0x109)
|
|
#define KBD_HOME (-0x10a)
|
|
#define KBD_END (-0x10b)
|
|
#define KBD_PAGE_UP (-0x10c)
|
|
#define KBD_PAGE_DOWN (-0x10d)
|
|
|
|
#define KBD_F1 (-0x120)
|
|
#define KBD_F2 (-0x121)
|
|
#define KBD_F3 (-0x122)
|
|
#define KBD_F4 (-0x123)
|
|
#define KBD_F5 (-0x124)
|
|
#define KBD_F6 (-0x125)
|
|
#define KBD_F7 (-0x126)
|
|
#define KBD_F8 (-0x127)
|
|
#define KBD_F9 (-0x128)
|
|
#define KBD_F10 (-0x129)
|
|
#define KBD_F11 (-0x12a)
|
|
#define KBD_F12 (-0x12b)
|
|
static inline int is_kbd_fkey(int key) { return key <= KBD_F1 && key >= KBD_F12; }
|
|
#define number_to_kbd_fkey(num) (KBD_F1 - (num) + 1)
|
|
#define kbd_fkey_to_number(key) (KBD_F1 - (key) + 1)
|
|
|
|
#define KBD_CTRL_C (-0x200)
|
|
|
|
#define KBD_MOD_NONE 0
|
|
#define KBD_MOD_SHIFT 1
|
|
#define KBD_MOD_CTRL 2
|
|
#define KBD_MOD_ALT 4
|
|
|
|
void
|
|
handle_trm(int std_in, int std_out, int sock_in, int sock_out, int ctl_in,
|
|
void *init_string, int init_len, int remote);
|
|
|
|
void itrm_queue_event(struct itrm *itrm, unsigned char *data, int len);
|
|
void block_itrm(int);
|
|
int unblock_itrm(int);
|
|
void free_all_itrms(void);
|
|
void resize_terminal(void);
|
|
void dispatch_special(unsigned char *);
|
|
void kbd_ctrl_c(void);
|
|
int is_blocked(void);
|
|
|
|
#define kbd_get_key(kbd_) ((kbd_)->key)
|
|
#define kbd_key_is(kbd_, key) (kbd_get_key(kbd_) == (key))
|
|
|
|
#define kbd_get_modifier(kbd_) ((kbd_)->modifier)
|
|
#define kbd_modifier_is(kbd_, mod) (kbd_get_modifier(kbd_) == (mod))
|
|
|
|
#define kbd_set(kbd_, key_, modifier_) do { \
|
|
(kbd_)->key = (key_); \
|
|
(kbd_)->modifier = (modifier_); \
|
|
} while (0)
|
|
|
|
|
|
#endif
|