Fix #1428: handle unicode keybinds

This commit is contained in:
Arun Prakash Jana 2022-07-20 19:48:27 +05:30
parent a937265833
commit 12b5416b2c
No known key found for this signature in database
GPG key ID: A75979F35C080412
2 changed files with 15 additions and 13 deletions

View file

@ -104,7 +104,6 @@
#define __USE_XOPEN_EXTENDED 1 #define __USE_XOPEN_EXTENDED 1
#endif #endif
#include <ftw.h> #include <ftw.h>
#include <wchar.h>
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>
@ -1362,25 +1361,27 @@ static inline bool xconfirm(int c)
static int get_input(const char *prompt) static int get_input(const char *prompt)
{ {
wint_t ch[1];
if (prompt) if (prompt)
printmsg(prompt); printmsg(prompt);
cleartimeout(); cleartimeout();
int r = getch(); get_wch(ch);
#ifdef KEY_RESIZE #ifdef KEY_RESIZE
while (r == KEY_RESIZE) { while (*ch == KEY_RESIZE) {
if (prompt) { if (prompt) {
clearoldprompt(); clearoldprompt();
xlines = LINES; xlines = LINES;
printmsg(prompt); printmsg(prompt);
} }
r = getch(); get_wch(ch);
} }
#endif #endif
settimeout(); settimeout();
return r; return (int)*ch;
} }
static bool isselfileempty(void) static bool isselfileempty(void)
@ -3010,13 +3011,13 @@ static int nextsel(int presel)
#ifdef BENCH #ifdef BENCH
return SEL_QUIT; return SEL_QUIT;
#endif #endif
int c = presel; wint_t c = presel;
uint_t i; int i = ERR;
bool escaped = FALSE; bool escaped = FALSE;
if (c == 0 || c == MSGWAIT) { if (c == 0 || c == MSGWAIT) {
try_quit: try_quit:
c = getch(); i = get_wch(&c);
//DPRINTF_D(c); //DPRINTF_D(c);
//DPRINTF_S(keyname(c)); //DPRINTF_S(keyname(c));
@ -3028,8 +3029,8 @@ try_quit:
/* Handle Alt+key */ /* Handle Alt+key */
if (c == ESC) { if (c == ESC) {
timeout(0); timeout(0);
c = getch(); i = get_wch(&c);
if (c != ERR) { if (i != ERR) {
if (c == ESC) if (c == ESC)
c = CONTROL('L'); c = CONTROL('L');
else { else {
@ -3051,14 +3052,14 @@ try_quit:
} }
} }
if (c == ERR && presel == MSGWAIT) if (i == ERR && presel == MSGWAIT)
c = (cfg.filtermode || filterset()) ? FILTER : CONTROL('L'); c = (cfg.filtermode || filterset()) ? FILTER : CONTROL('L');
else if (c == FILTER || c == CONTROL('L')) else if (c == FILTER || c == CONTROL('L'))
/* Clear previous filter when manually starting */ /* Clear previous filter when manually starting */
clearfilter(); clearfilter();
} }
if (c == -1) { if (i == ERR) {
++idle; ++idle;
/* /*

View file

@ -31,6 +31,7 @@
#pragma once #pragma once
#include <curses.h> #include <curses.h>
#include <wchar.h>
#define CONTROL(c) ((c) & 0x1f) #define CONTROL(c) ((c) & 0x1f)
@ -121,7 +122,7 @@ enum action {
/* Associate a pressed key to an action */ /* Associate a pressed key to an action */
struct key { struct key {
int sym; /* Key pressed */ wint_t sym; /* Key pressed */
enum action act; /* Action */ enum action act; /* Action */
}; };