1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-03 03:56:32 -04:00

Merge with git+ssh://pasky.or.cz/srv/git/elinks.git

This commit is contained in:
Witold Filipczyk 2006-08-12 18:46:43 +02:00 committed by Witold Filipczyk
commit 0a1b522fdd
8 changed files with 56 additions and 22 deletions

View File

@ -948,7 +948,7 @@ menu_kbd_handler(struct menu *menu, struct term_event *ev)
default:
{
int key = get_kbd_key(ev);
term_event_key_T key = get_kbd_key(ev);
if (is_kbd_fkey(key)
|| check_kbd_modifier(ev, KBD_MOD_ALT)) {

View File

@ -354,7 +354,7 @@ static struct key key_table[] = {
{ NULL, 0 }
};
long
term_event_key_T
read_key(unsigned char *key_str)
{
struct key *key;
@ -366,7 +366,7 @@ read_key(unsigned char *key_str)
if (!strcasecmp(key->str, key_str))
return key->num;
return -1;
return KBD_UNDEF;
}
int

View File

@ -173,7 +173,7 @@ action_requires_form(enum keymap_id keymap_id, action_id_T action_id)
return action && (action->flags & ACTION_REQUIRE_FORM);
}
long read_key(unsigned char *);
term_event_key_T read_key(unsigned char *);
unsigned char *get_keymap_name(enum keymap_id);
int parse_keystroke(unsigned char *, struct term_event_keyboard *);
@ -187,7 +187,7 @@ void add_keystroke_to_string(struct string *str, struct term_event_keyboard *kbd
* converted from unicode_val_T to that. \
* #ifdef CONFIG_UTF_8, the code is correct. */ \
kbd.key = accesskey; \
kbd.modifier = 0; \
kbd.modifier = KBD_MOD_NONE; \
add_keystroke_to_string(str, &kbd, 0); \
} while (0)

View File

@ -495,7 +495,6 @@ cp2u_shared(const struct codepage_desc *from, unsigned char c)
return UCS_NO_CHAR;
}
#ifdef CONFIG_UTF_8
/* Slow algorithm, used for converting input from the terminal. */
unicode_val_T
cp2u(int from, unsigned char c)
@ -510,7 +509,6 @@ cp2u(int from, unsigned char c)
if (c < 0x80) return c;
else return cp2u_shared(&codepages[from], c);
}
#endif /* CONFIG_UTF_8 */
/* This slow and ugly code is used by the terminal utf_8_io */
unsigned char *

View File

@ -65,9 +65,9 @@ inline int unicode_to_cell(unicode_val_T);
unicode_val_T unicode_fold_label_case(unicode_val_T);
inline int strlen_utf8(unsigned char **);
inline unicode_val_T utf_8_to_unicode(unsigned char **, unsigned char *);
unicode_val_T cp2u(int, unsigned char);
#endif /* CONFIG_UTF_8 */
unicode_val_T cp2u(int, unsigned char);
unsigned char *cp2utf_8(int, int);
unsigned char *u2cp_(unicode_val_T, int, int no_nbsp_hack);

View File

@ -3,13 +3,15 @@
struct itrm;
/* 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. */
typedef int term_event_key_T;
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;
term_event_key_T key;
int modifier;
};
@ -22,6 +24,8 @@ struct interlink_event_keyboard {
int modifier;
};
/* Values for term_event_key_T */
#define KBD_UNDEF -1
#define KBD_ENTER (-0x100)
@ -51,12 +55,20 @@ struct interlink_event_keyboard {
#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; }
static inline int is_kbd_fkey(term_event_key_T 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)
/* int is_kbd_character(term_event_key_T key);
* Return true if @key is a character in some charset, rather than a
* special key. The character is not necessarily printable. As for
* which charset it is in, see the definition of term_event_key_T. */
#define is_kbd_character(key) ((key) >= 0)
/* Values for term_event_keyboard.modifier and
* interlink_event_keyboard.modifier */
#define KBD_MOD_NONE 0
#define KBD_MOD_SHIFT 1
#define KBD_MOD_CTRL 2

View File

@ -1178,26 +1178,38 @@ enum frame_event_status
try_document_key(struct session *ses, struct document_view *doc_view,
struct term_event *ev)
{
long key;
unicode_val_T key;
int passed = -1;
int i; /* GOD I HATE C! --FF */ /* YEAH, BRAINFUCK RULEZ! --pasky */
assert(ses && doc_view && doc_view->document && doc_view->vs && ev);
if_assert_failed return FRAME_EVENT_IGNORED;
if (!check_kbd_modifier(ev, KBD_MOD_ALT)) {
/* We accept those only in alt-combo. */
if (!check_kbd_modifier(ev, KBD_MOD_ALT)
|| !is_kbd_character(get_kbd_key(ev))) {
/* We accept only alt-character combos. */
return FRAME_EVENT_IGNORED;
}
/* The key is a character. Convert it to Unicode so that it
* can be compared with link.accesskey. */
#ifdef CONFIG_UTF_8
key = get_kbd_key(ev);
#else /* !CONFIG_UTF_8 */
key = cp2u(get_opt_codepage_tree(ses->tab->term->spec,
"charset"),
get_kbd_key(ev));
#endif /* !CONFIG_UTF_8 */
/* If @key now is 0 (which is used in link.accesskey if there
* is no access key) or UCS_REPLACEMENT_CHARACTER, then the
* results may be a little odd, but not really harmful. */
/* Run through all the links and see if one of them is bound to the
* key we test.. */
key = get_kbd_key(ev);
for (i = 0; i < doc_view->document->nlinks; i++) {
struct link *link = &doc_view->document->links[i];
if (key == link->accesskey) { /* FIXME: key vs unicode ... */
if (key == link->accesskey) {
if (passed != i && i <= doc_view->vs->current_link) {
/* This is here in order to rotate between
* links with same accesskey. */

View File

@ -637,7 +637,19 @@ enum frame_event_status
try_mark_key(struct session *ses, struct document_view *doc_view,
struct term_event *ev)
{
unsigned char mark = get_kbd_key(ev);
unsigned char mark;
/* set_mark and goto_mark allow only a subset of the ASCII
* character repertoire as mark characters. If get_kbd_key(ev)
* is something else (i.e. a special key or a non-ASCII
* character), map it to an ASCII character that the functions
* will not accept, so the results are consistent.
* When CONFIG_UTF_8 is not defined, this assumes that codes
* 0 to 0x7F in all codepages match ASCII. */
if (get_kbd_key(ev) >= 0 && get_kbd_key(ev) <= 0x7F)
mark = get_kbd_key(ev);
else
mark = 0;
switch (ses->kbdprefix.mark) {
case KP_MARK_NOTHING: