1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

terminal UTF-8: New type term_event_char_T.

It is either unicode_val_T or unsigned char.
This commit is contained in:
Kalle Olavi Niemitalo 2006-08-13 23:23:54 +03:00 committed by Kalle Olavi Niemitalo
parent 4d80fe6453
commit 7ebc8d8281
2 changed files with 21 additions and 14 deletions

View File

@ -285,11 +285,9 @@ select_button_by_flag(struct dialog_data *dlg_data, int flag)
static void static void
select_button_by_key(struct dialog_data *dlg_data) select_button_by_key(struct dialog_data *dlg_data)
{ {
term_event_char_T key;
#ifdef CONFIG_UTF_8 #ifdef CONFIG_UTF_8
unicode_val_T key;
int codepage; int codepage;
#else
unsigned char key;
#endif #endif
struct widget_data *widget_data; struct widget_data *widget_data;
@ -307,11 +305,7 @@ select_button_by_key(struct dialog_data *dlg_data)
foreach_widget(dlg_data, widget_data) { foreach_widget(dlg_data, widget_data) {
int hk_pos; int hk_pos;
unsigned char *hk_ptr; unsigned char *hk_ptr;
#ifdef CONFIG_UTF_8 term_event_char_T hk_char;
unicode_val_T hk_char;
#else
unsigned char hk_char;
#endif
if (widget_data->widget->type != WIDGET_BUTTON) if (widget_data->widget->type != WIDGET_BUTTON)
continue; continue;

View File

@ -1,13 +1,25 @@
#ifndef EL__TERMINAL_KBD_H #ifndef EL__TERMINAL_KBD_H
#define EL__TERMINAL_KBD_H #define EL__TERMINAL_KBD_H
#include "intl/charsets.h"
struct itrm; struct itrm;
/* Values <= -0x100 are special; from enum term_event_special_key. /* A character received from a terminal. */
#ifdef CONFIG_UTF_8
typedef unicode_val_T term_event_char_T; /* in UCS-4 */
#else
typedef unsigned char term_event_char_T; /* in the charset of the terminal */
#endif
/* A key received from a terminal, without modifiers. The value is
* either from term_event_char_T or from enum term_event_special_key.
* To check which one it is, use is_kbd_character().
*
* Values <= -0x100 are special; from enum term_event_special_key.
* Values between -0xFF and -2 are not used yet; treat as special. * Values between -0xFF and -2 are not used yet; treat as special.
* Value == -1 is KBD_UNDEF; not sent via socket. * Value == -1 is KBD_UNDEF; not sent via socket.
* Values >= 0 are characters received from the terminal; * Values >= 0 are characters; from term_event_char_T.
* in UCS-4 #ifdef CONFIG_UTF_8. Test with is_kbd_character().
* *
* Any at least 32-bit signed integer type would work here; using an * Any at least 32-bit signed integer type would work here; using an
* exact-width type hurts portability in principle, but some other * exact-width type hurts portability in principle, but some other
@ -84,9 +96,10 @@ static inline int is_kbd_fkey(term_event_key_T key) { return key <= KBD_F1 && ke
#define kbd_fkey_to_number(key) (KBD_F1 - (key) + 1) #define kbd_fkey_to_number(key) (KBD_F1 - (key) + 1)
/* int is_kbd_character(term_event_key_T key); /* int is_kbd_character(term_event_key_T key);
* Return true if @key is a character in some charset, rather than a * Check whether @key is a character or a special key.
* special key. The character is not necessarily printable. As for * Return true if @key is a character from term_event_char_T.
* which charset it is in, see the definition of term_event_key_T. */ * (The character is not necessarily printable.)
* Return false if @key is a special key from enum term_event_special_key. */
#define is_kbd_character(key) ((key) >= 0) #define is_kbd_character(key) ((key) >= 0)
void void