--- funcname.tab.orig Fri Jan 24 09:32:53 2003 +++ funcname.tab Fri Feb 21 15:18:09 2003 @@ -40,6 +40,7 @@ HELP ldhelp HISTORY ldHist INFO pginfo +INPUT_KEYS inputKeys INTERRUPT susp ISEARCH isrchfor ISEARCH_BACK isrchbak --- buffer.c.orig Tue Feb 4 23:48:31 2003 +++ buffer.c Fri Feb 21 14:34:02 2003 @@ -5,11 +5,8 @@ #ifdef USE_GPM #include #endif -#if defined(USE_GPM) || defined(USE_SYSMOUSE) -extern int do_getch(); -#define getch() do_getch() -#endif /* USE_GPM */ #endif /* USE_MOUSE */ +#define getch() get_input_keys() #ifdef __EMX__ #include --- display.c.orig Fri Feb 7 20:35:57 2003 +++ display.c Fri Feb 21 14:39:24 2003 @@ -1221,7 +1221,8 @@ if (mouse && use_mouse) mouse_active(); #endif - sleep_till_anykey(sec, purge); + if (!have_input_keys()) + sleep_till_anykey(sec, purge); #ifdef USE_MOUSE if (mouse && use_mouse) mouse_inactive(); --- linein.c.orig Sun Feb 9 18:25:45 2003 +++ linein.c Fri Feb 21 14:35:22 2003 @@ -6,12 +6,9 @@ #ifdef USE_MOUSE #ifdef USE_GPM #include -#endif -#if defined(USE_GPM) || defined(USE_SYSMOUSE) -extern int do_getch(); -#define getch() do_getch() #endif /* USE_GPM */ #endif /* USE_MOUSE */ +#define getch() get_input_keys() #ifdef __EMX__ #include --- main.c.orig Wed Feb 19 00:43:49 2003 +++ main.c Fri Feb 21 16:25:54 2003 @@ -20,9 +20,9 @@ #endif /* USE_GPM */ #if defined(USE_GPM) || defined(USE_SYSMOUSE) extern int do_getch(); -#define getch() do_getch() #endif /* defined(USE_GPM) || defined(USE_SYSMOUSE) */ #endif +#define getch() get_input_keys() #define DSTR_LEN 256 @@ -683,6 +683,11 @@ usage(); } } + else if (!strcmp("-K", argv[i])) { + if (++i >= argc) + usage(); + set_input_keys(argv[i]); + } else if (!strcmp("-dummy", argv[i])) { /* do nothing */ } @@ -1040,7 +1045,7 @@ !Currentbuf->image_loaded) { do { loadImage(Currentbuf, IMG_FLAG_NEXT); - } while (sleep_till_anykey(1, 0) <= 0); + } while (!have_input_keys() && sleep_till_anykey(1, 0) <= 0); } #endif c = getch(); @@ -6393,4 +6398,99 @@ return; for (i = 0; i < PREC_NUM && b->next; i++, b = b->next) ; resetPos(b); +} + +static struct input_keys_st { + char *ptr; + int size; + int pos; +} CurrentInputKeys = { + "", + 0, + 0, +}; + +void +inputKeys(void) +{ + char *data; + + CurrentKeyData = NULL; /* not allowed in w3m-control: */ + data = searchKeyData(); + if (data == NULL || *data == '\0') { + data = inputStrHist("Input Keys: ", "", TextHist); + if (data == NULL || *data == '\0') { + displayBuffer(Currentbuf, B_NORMAL); + return; + } + } + set_input_keys(data); + displayBuffer(Currentbuf, B_NORMAL); +} + +#define IS_ODIGIT(c) ((c) >= '0' && (c) < '8') + +int +set_input_keys(char *str) +{ + char *p; + int c; + Str tmp; + + if (!str || !*str) { + CurrentInputKeys.ptr = ""; + CurrentInputKeys.size = 0; + CurrentInputKeys.pos = 0; + return 0; + } + tmp = Strnew(); + for (p = str; *p; p++) { + if (*p == '\\') { + p++; + if (IS_ODIGIT(*p)) { + c = *p - '0'; + if (IS_ODIGIT(*(p + 1))) { + c = c * 8 + *(++p) - '0'; + if (c < 32 && IS_DIGIT(*(p + 1))) + c = c * 8 + *(++p) - '0'; + } + } + else { + switch (*p) { + case 'a': c = CTRL_G; break; + case 'b': c = CTRL_H; break; + case 'e': c = ESC_CODE; break; + case 'f': c = CTRL_L; break; + case 'n': c = CTRL_J; break; + case 'r': c = CTRL_M; break; + case 't': c = CTRL_I; break; + default: c = *p; break; + } + } + } + else + c = *p; + Strcat_char(tmp, (char)c); + } + CurrentInputKeys.ptr = tmp->ptr; + CurrentInputKeys.size = tmp->length; + CurrentInputKeys.pos = 0; + return CurrentInputKeys.size; +} + +int +get_input_keys(void) +{ + if (CurrentInputKeys.pos < CurrentInputKeys.size) + return CurrentInputKeys.ptr[CurrentInputKeys.pos++]; +#if defined(USE_MOUSE) && (defined(USE_GPM) || defined(USE_SYSMOUSE)) + return do_getch(); +#endif + return getch(); +} + +int +have_input_keys(void) +{ + return (CurrentInputKeys.pos < CurrentInputKeys.size); } --- menu.c.orig Sun Feb 9 18:25:45 2003 +++ menu.c Fri Feb 21 14:35:15 2003 @@ -24,10 +24,9 @@ #if defined(USE_GPM) || defined(USE_SYSMOUSE) #define X_MOUSE_SELECTED (char)0xff static int X_Mouse_Selection; -extern int do_getch(); -#define getch() do_getch() #endif /* defined(USE_GPM) || defined(USE_SYSMOUSE) */ #endif /* USE_MOUSE */ +#define getch() get_input_keys() #ifdef USE_MENU --- proto.h.orig Wed Feb 19 00:43:49 2003 +++ proto.h Fri Feb 21 15:19:21 2003 @@ -150,6 +150,10 @@ #endif extern void undoPos(void); extern void redoPos(void); +extern void inputKeys(void); +extern int set_input_keys(char *str); +extern int get_input_keys(void); +extern int have_input_keys(void); extern int currentLn(Buffer *buf); extern void tmpClearBuffer(Buffer *buf);