From 2d31da386cc08e66994cdc41d7ec729b64e60211 Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Tue, 3 Dec 2002 16:01:14 +0000 Subject: [w3m-dev 03515] 2 stroke keybinding * func.c (setKeymap): add map K_MULTI support (getKey2): added (getKey): rewrite to use getKey2() * func.h (K_MULTI): added (MULTI_KEY): added * funcname.tab (MULTIMAP): added * main.c (escKeyProc): added (escmap): rewrite to use escKeyProc() (escbmap): rewrite to use escKeyProc() (escdmap): rewrite to use escKeyProc() (multimap): added * proto.h (multimap): added From: Hironori SAKAMOTO --- main.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 14 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 9fe1825..a0d1cc9 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.156 2002/11/26 18:03:27 ukai Exp $ */ +/* $Id: main.c,v 1.157 2002/12/03 16:01:37 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include @@ -1183,15 +1183,41 @@ pcmap(void) } #endif +static void +escKeyProc(int c, int esc, unsigned char *map) +{ + if (CurrentKey >= 0 && CurrentKey & K_MULTI) { + unsigned char **mmap; + mmap = (unsigned char **)getKeyData(MULTI_KEY(CurrentKey)); + if (!mmap) + return; + switch (esc) { + case K_ESCD: + map = mmap[3]; + break; + case K_ESCB: + map = mmap[2]; + break; + case K_ESC: + map = mmap[1]; + break; + default: + map = mmap[0]; + break; + } + esc |= (CurrentKey & ~0xFFFF); + } + CurrentKey = esc | c; + w3mFuncList[(int)map[c]].func(); +} + void escmap(void) { char c; c = getch(); - if (IS_ASCII(c)) { - CurrentKey = K_ESC | c; - w3mFuncList[(int)EscKeymap[(int)c]].func(); - } + if (IS_ASCII(c)) + escKeyProc((int)c, K_ESC, EscKeymap); } void @@ -1199,29 +1225,36 @@ escbmap(void) { char c; c = getch(); - - if (IS_DIGIT(c)) + if (IS_DIGIT(c)) { escdmap(c); - else if (IS_ASCII(c)) { - CurrentKey = K_ESCB | c; - w3mFuncList[(int)EscBKeymap[(int)c]].func(); + return; } + if (IS_ASCII(c)) + escKeyProc((int)c, K_ESCB, EscBKeymap); } void escdmap(char c) { int d; - d = (int)c - (int)'0'; c = getch(); if (IS_DIGIT(c)) { d = d * 10 + (int)c - (int)'0'; c = getch(); } - if (c == '~') { - CurrentKey = K_ESCD | d; - w3mFuncList[(int)EscDKeymap[d]].func(); + if (c == '~') + escKeyProc((int)d, K_ESCD, EscDKeymap); +} + +void +multimap(void) +{ + char c; + c = getch(); + if (IS_ASCII(c)) { + CurrentKey = K_MULTI | (CurrentKey << 16) | c; + escKeyProc((int)c, 0, NULL); } } -- cgit v1.2.3