less buggy input

This commit is contained in:
anon 2023-08-04 20:19:06 +02:00
parent a7676c3a50
commit 2dc1f57978
2 changed files with 20 additions and 10 deletions

View File

@ -340,21 +340,26 @@ wmode_input(const int c){
case KEY_RIGHT: case KEY_RIGHT:
field = (field + 1) % FIELDS; field = (field + 1) % FIELDS;
resetcmd(); resetcmd();
return(NO); break;
case ctrl('P'): /* go to previous input field */ case ctrl('P'): /* go to previous input field */
case KEY_UP: case KEY_UP:
case KEY_LEFT: case KEY_LEFT:
field = (field + (FIELDS - 1)) % FIELDS; field = (field + (FIELDS - 1)) % FIELDS;
resetcmd(); resetcmd();
return(NO); break;
case KEY_HOME: /* go to first input field */ case KEY_HOME: /* go to first input field */
field = 0; field = 0;
resetcmd(); resetcmd();
return(NO); break;
case KEY_LL: /* go to last input field */ case KEY_LL: /* go to last input field */
curdispline = disprefs; curdispline = disprefs;
return(YES); break;
default:
return 0;
} }
window_change |= CH_MODE;
return 1;
} }
static int static int
@ -365,33 +370,38 @@ wresult_input(const int c){
case '\n': case '\n':
editref(curdispline); editref(curdispline);
window_change = CH_ALL; window_change = CH_ALL;
return(YES); break;
case ctrl('N'): case ctrl('N'):
case KEY_DOWN: case KEY_DOWN:
case KEY_RIGHT: case KEY_RIGHT:
if ((curdispline + 1) < disprefs) { if ((curdispline + 1) < disprefs) {
++curdispline; ++curdispline;
} }
return(NO); break;
case ctrl('P'): case ctrl('P'):
case KEY_UP: case KEY_UP:
case KEY_LEFT: case KEY_LEFT:
if (curdispline) { if (curdispline) {
--curdispline; --curdispline;
} }
return(NO); break;
case KEY_HOME: case KEY_HOME:
curdispline = 0; curdispline = 0;
return(NO); break;
case KEY_LL: case KEY_LL:
field = FIELDS - 1; field = FIELDS - 1;
resetcmd(); resetcmd();
return(NO); break;
default: default:
char *e; char *e;
if ((e = strchr(dispchars, c))) if ((e = strchr(dispchars, c)))
editref(e - dispchars); editref(e - dispchars);
goto noredisp;
} }
window_change |= CH_RESULT;
noredisp:
return 1;
} }
static int static int

View File

@ -399,7 +399,7 @@ static inline void linemode_event_loop(void){
static inline void screenmode_event_loop(void){ static inline void screenmode_event_loop(void){
for (;;) { for (;;) {
display(); display();
if(handle_input(getch())){ break; } handle_input(getch());
} }
} }