only allow saving/loading/piping in normal mode

This commit is contained in:
anon 2024-03-01 19:22:21 +01:00
parent 45aa9bd63c
commit 3bc43448fc

@ -277,6 +277,37 @@ static int global_input(const int c) {
++current_page;
window_change |= CH_RESULT;
break;
case '!': /* shell escape */
execute(shell, shell, NULL);
current_page = 0;
break;
case ctrl('U'): /* redraw screen */
case KEY_CLEAR:
window_change = CH_ALL;
break;
case '?': /* help */
window_change = CH_HELP;
break;
case ctrl('E'): /* edit all lines */
editall();
break;
case ctrl('S'): // toggle caseless
caseless = !caseless;
egrepcaseless(caseless);
window_change |= CH_CASE;
break;
case EOF:
myexit(0);
break;
default:
return 0;
}
return 1;
}
int normal_global_input(const int c) {
switch(c) {
case '>': /* write or append the lines to a file */
if (totallines == 0) {
postmsg("There are no lines to write to a file");
@ -296,7 +327,7 @@ static int global_input(const int c) {
break; // XXX fix
if(totallines == 0) {
postmsg("There are no lines to pipe to a shell command");
return 0;
break;
}
/* get the shell command */
// move(PRLINE, 0);
@ -335,28 +366,6 @@ static int global_input(const int c) {
// askforreturn();
// entercurses();
break;
case '!': /* shell escape */
execute(shell, shell, NULL);
current_page = 0;
break;
case ctrl('U'): /* redraw screen */
case KEY_CLEAR:
window_change = CH_ALL;
break;
case '?': /* help */
window_change = CH_HELP;
break;
case ctrl('E'): /* edit all lines */
editall();
break;
case ctrl('S'): // toggle caseless
caseless = !caseless;
egrepcaseless(caseless);
window_change |= CH_CASE;
break;
case EOF:
myexit(0);
break;
default:
return 0;
}
@ -534,6 +543,9 @@ int handle_input(const int c) {
/* --- mode specific --- */
switch(input_mode) {
case INPUT_NORMAL:
const int r = normal_global_input(c);
if(r) { return 0; }
//
if(*current_window == winput) {
return interpret(c);
} else if(*current_window == wmode) {