only allow saving/loading/piping in normal mode
This commit is contained in:
parent
45aa9bd63c
commit
3bc43448fc
132
source/input.c
132
source/input.c
@ -30,9 +30,9 @@
|
|||||||
DAMAGE.
|
DAMAGE.
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
|
|
||||||
/* cscope - interactive C symbol cross-reference
|
/* cscope - interactive C symbol cross-reference
|
||||||
*
|
*
|
||||||
* terminal input functions
|
* terminal input functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
@ -277,64 +277,6 @@ static int global_input(const int c) {
|
|||||||
++current_page;
|
++current_page;
|
||||||
window_change |= CH_RESULT;
|
window_change |= CH_RESULT;
|
||||||
break;
|
break;
|
||||||
case '>': /* write or append the lines to a file */
|
|
||||||
if (totallines == 0) {
|
|
||||||
postmsg("There are no lines to write to a file");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
input_mode = INPUT_APPEND;
|
|
||||||
window_change |= CH_INPUT;
|
|
||||||
force_window();
|
|
||||||
break;
|
|
||||||
case '<': /* read lines from a file */
|
|
||||||
input_mode = INPUT_READ;
|
|
||||||
window_change |= CH_INPUT;
|
|
||||||
force_window();
|
|
||||||
break;
|
|
||||||
case '|': /* pipe the lines to a shell command */
|
|
||||||
case '^':
|
|
||||||
break; // XXX fix
|
|
||||||
if(totallines == 0) {
|
|
||||||
postmsg("There are no lines to pipe to a shell command");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/* get the shell command */
|
|
||||||
// move(PRLINE, 0);
|
|
||||||
// addstr(pipeprompt);
|
|
||||||
// if (mygetline("", newpat, COLS - sizeof(pipeprompt), '\0', NO) == 0) {
|
|
||||||
// clearprompt();
|
|
||||||
// return(NO);
|
|
||||||
// }
|
|
||||||
///* if the ^ command, redirect output to a temp file */
|
|
||||||
// if (commandc == '^') {
|
|
||||||
// strcat(strcat(newpat, " >"), temp2);
|
|
||||||
// /* HBB 20020708: somebody might have even
|
|
||||||
// * their non-interactive default shells
|
|
||||||
// * complain about clobbering
|
|
||||||
// * redirections... --> delete before
|
|
||||||
// * overwriting */
|
|
||||||
// remove(temp2);
|
|
||||||
// }
|
|
||||||
// exitcurses();
|
|
||||||
// if ((file = mypopen(newpat, "w")) == NULL) {
|
|
||||||
// fprintf(stderr, "cscope: cannot open pipe to shell command: %s\n",
|
|
||||||
// newpat);
|
|
||||||
// } else {
|
|
||||||
// seekline(1);
|
|
||||||
// while ((c = getc(refsfound)) != EOF) {
|
|
||||||
// putc(c, file);
|
|
||||||
// }
|
|
||||||
// seekline(topline);
|
|
||||||
// mypclose(file);
|
|
||||||
// }
|
|
||||||
// if (commandc == '^') {
|
|
||||||
// if (readrefs(temp2) == NO) {
|
|
||||||
// postmsg("Ignoring empty output of ^ command");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// askforreturn();
|
|
||||||
// entercurses();
|
|
||||||
break;
|
|
||||||
case '!': /* shell escape */
|
case '!': /* shell escape */
|
||||||
execute(shell, shell, NULL);
|
execute(shell, shell, NULL);
|
||||||
current_page = 0;
|
current_page = 0;
|
||||||
@ -364,6 +306,73 @@ static int global_input(const int c) {
|
|||||||
return 1;
|
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");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
input_mode = INPUT_APPEND;
|
||||||
|
window_change |= CH_INPUT;
|
||||||
|
force_window();
|
||||||
|
break;
|
||||||
|
case '<': /* read lines from a file */
|
||||||
|
input_mode = INPUT_READ;
|
||||||
|
window_change |= CH_INPUT;
|
||||||
|
force_window();
|
||||||
|
break;
|
||||||
|
case '|': /* pipe the lines to a shell command */
|
||||||
|
case '^':
|
||||||
|
break; // XXX fix
|
||||||
|
if(totallines == 0) {
|
||||||
|
postmsg("There are no lines to pipe to a shell command");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* get the shell command */
|
||||||
|
// move(PRLINE, 0);
|
||||||
|
// addstr(pipeprompt);
|
||||||
|
// if (mygetline("", newpat, COLS - sizeof(pipeprompt), '\0', NO) == 0) {
|
||||||
|
// clearprompt();
|
||||||
|
// return(NO);
|
||||||
|
// }
|
||||||
|
///* if the ^ command, redirect output to a temp file */
|
||||||
|
// if (commandc == '^') {
|
||||||
|
// strcat(strcat(newpat, " >"), temp2);
|
||||||
|
// /* HBB 20020708: somebody might have even
|
||||||
|
// * their non-interactive default shells
|
||||||
|
// * complain about clobbering
|
||||||
|
// * redirections... --> delete before
|
||||||
|
// * overwriting */
|
||||||
|
// remove(temp2);
|
||||||
|
// }
|
||||||
|
// exitcurses();
|
||||||
|
// if ((file = mypopen(newpat, "w")) == NULL) {
|
||||||
|
// fprintf(stderr, "cscope: cannot open pipe to shell command: %s\n",
|
||||||
|
// newpat);
|
||||||
|
// } else {
|
||||||
|
// seekline(1);
|
||||||
|
// while ((c = getc(refsfound)) != EOF) {
|
||||||
|
// putc(c, file);
|
||||||
|
// }
|
||||||
|
// seekline(topline);
|
||||||
|
// mypclose(file);
|
||||||
|
// }
|
||||||
|
// if (commandc == '^') {
|
||||||
|
// if (readrefs(temp2) == NO) {
|
||||||
|
// postmsg("Ignoring empty output of ^ command");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// askforreturn();
|
||||||
|
// entercurses();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int change_input(const int c) {
|
int change_input(const int c) {
|
||||||
MOUSE *p; /* mouse data */
|
MOUSE *p; /* mouse data */
|
||||||
|
|
||||||
@ -534,6 +543,9 @@ int handle_input(const int c) {
|
|||||||
/* --- mode specific --- */
|
/* --- mode specific --- */
|
||||||
switch(input_mode) {
|
switch(input_mode) {
|
||||||
case INPUT_NORMAL:
|
case INPUT_NORMAL:
|
||||||
|
const int r = normal_global_input(c);
|
||||||
|
if(r) { return 0; }
|
||||||
|
//
|
||||||
if(*current_window == winput) {
|
if(*current_window == winput) {
|
||||||
return interpret(c);
|
return interpret(c);
|
||||||
} else if(*current_window == wmode) {
|
} else if(*current_window == wmode) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user