@@ -15,3 +15,16 @@ r | |||||
help handle | help handle | ||||
handle SIGINT stop | handle SIGINT stop | ||||
r | r | ||||
info signal-dispositions | |||||
s | |||||
start | |||||
info signal-dispositions | |||||
c | |||||
where | |||||
s | |||||
where | |||||
frame 0 | |||||
l | |||||
b rl_complete | |||||
c | |||||
where |
@@ -1,4 +1,6 @@ | |||||
# CC=gcc | |||||
DEBUG:=1 | |||||
CC=gcc | |||||
CFLAGS:=-Wall -Wextra -Wpedantic | CFLAGS:=-Wall -Wextra -Wpedantic | ||||
CPPFLAGS:=${shell pkg-config --cflags ncurses readline} | CPPFLAGS:=${shell pkg-config --cflags ncurses readline} | ||||
LDLIBS=-I ${CHDRD} ${shell pkg-config --libs ncurses readline} | LDLIBS=-I ${CHDRD} ${shell pkg-config --libs ncurses readline} | ||||
@@ -21,7 +23,7 @@ CHDR:=$(addsuffix .gch,$(subst ${HDRD},${CHDRD},${HDR})) | |||||
OUTPUT:=csope | OUTPUT:=csope | ||||
ifeq (${DEBUG},1) | ifeq (${DEBUG},1) | ||||
CFLAGS += -Og -ggdb | |||||
CFLAGS += -O0 -ggdb | |||||
else | else | ||||
CFLAGS += -O3 -flto=auto -fomit-frame-pointer | CFLAGS += -O3 -flto=auto -fomit-frame-pointer | ||||
endif | endif | ||||
@@ -16,14 +16,14 @@ Fork of Cscope, with various improvements, because cscope is good and shall not | |||||
# Interface | # Interface | ||||
<-- Tab --> | <-- Tab --> | ||||
+------------Message-------------+ +--------------------------------+ | |||||
A |+--------------+---------------+| |+------------------------------+| | |||||
| || Input Window | Result window || || || | |||||
| |+--------------+ || ? || || | |||||
|| Mode Window | || ---> || Help || | |||||
% || | || <--- || || | |||||
|| | || ESC || || | |||||
| || | || || || | |||||
| || | || || || | |||||
V |+--------------+---------------+| |+------------------------------+| | |||||
+-----------Tool Tips------------+ +--------------------------------+ | |||||
+------------Message-------------+ +--------------------------------+ | |||||
A |+--------------+---------------+| |+------------------------------+| | |||||
| || Input Window | Result window || || || | |||||
| |+--------------+ || ? || || | |||||
|| Mode Window | || ----> || Help || | |||||
% || | || <---- || || | |||||
|| | || ... || || | |||||
| || | || || || | |||||
| || | || || || | |||||
V |+--------------+---------------+| |+------------------------------+| | |||||
+-----------Tool Tips------------+ +--------------------------------+ |
@@ -80,6 +80,7 @@ unsigned int curdispline = 0; | |||||
WINDOW* winput; | WINDOW* winput; | ||||
WINDOW* wmode; | WINDOW* wmode; | ||||
WINDOW* wresult; | WINDOW* wresult; | ||||
WINDOW* whelp; | |||||
WINDOW** current_window; | WINDOW** current_window; | ||||
static WINDOW** last_window; | static WINDOW** last_window; | ||||
@@ -132,11 +133,6 @@ dispinit(void) | |||||
/* initialize the curses display package */ | /* initialize the curses display package */ | ||||
initscr(); /* initialize the screen */ | initscr(); /* initialize the screen */ | ||||
entercurses(); | entercurses(); | ||||
keypad(stdscr, TRUE); /* enable the keypad */ | |||||
//fixkeypad(); /* fix for getch() intermittently returning garbage */ | |||||
standend(); /* turn off reverse video */ | |||||
curs_set(0); | |||||
noecho(); | |||||
/* Calculate section sizes */ | /* Calculate section sizes */ | ||||
result_window_height = LINES - 2; | result_window_height = LINES - 2; | ||||
@@ -164,11 +160,21 @@ dispinit(void) | |||||
winput = newwin(input_window_height, first_col_width, 1, 1); | winput = newwin(input_window_height, first_col_width, 1, 1); | ||||
wmode = newwin(mode_window_height, first_col_width, input_window_height+1 + 1, 1); | wmode = newwin(mode_window_height, first_col_width, input_window_height+1 + 1, 1); | ||||
wresult = newwin(result_window_height, second_col_width, 1, first_col_width + 1 + 1); | wresult = newwin(result_window_height, second_col_width, 1, first_col_width + 1 + 1); | ||||
whelp = newwin(LINES-2, COLS-2, 1, 1); | |||||
refresh(); | refresh(); | ||||
current_window = &winput; | current_window = &winput; | ||||
} | } | ||||
static inline void display_help(){ | |||||
werase(whelp); | |||||
wmove(whelp, 0, 0); | |||||
waddstr(whelp, help()); | |||||
wrefresh(whelp); | |||||
do_press_any_key = true; | |||||
window_change = CH_ALL; | |||||
} | |||||
static inline void display_frame(){ | static inline void display_frame(){ | ||||
box(stdscr, 0, 0); | box(stdscr, 0, 0); | ||||
/* Vertical line */ | /* Vertical line */ | ||||
@@ -452,6 +458,13 @@ display(void) | |||||
//drawscrollbar(topline, nextline); /* display the scrollbar */ | //drawscrollbar(topline, nextline); /* display the scrollbar */ | ||||
if(window_change){ | if(window_change){ | ||||
if(window_change == CH_HELP){ | |||||
display_help(); | |||||
/* Do not display over the help msg and */ | |||||
/* rely on display_help() setting CH_ALL */ | |||||
return; | |||||
} | |||||
/**/ | |||||
if(window_change == CH_ALL){ | if(window_change == CH_ALL){ | ||||
display_frame(); | display_frame(); | ||||
} | } | ||||
@@ -476,7 +489,7 @@ display(void) | |||||
wrefresh(wresult); | wrefresh(wresult); | ||||
} | } | ||||
window_change = CH_falseNE; | |||||
window_change = CH_NONE; | |||||
} | } | ||||
void | void | ||||
@@ -85,7 +85,7 @@ editall(void) | |||||
edit(file, linenum); /* edit it */ | edit(file, linenum); /* edit it */ | ||||
if (editallprompt == true) { | if (editallprompt == true) { | ||||
addstr("Type ^D to stop editing all lines, or any other character to continue: "); | addstr("Type ^D to stop editing all lines, or any other character to continue: "); | ||||
if ((c = mygetch()) == EOF || c == ctrl('D') || c == ctrl('Z')) { | |||||
if ((c = getch()) == EOF || c == ctrl('D') || c == ctrl('Z')) { | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -43,11 +43,7 @@ | |||||
#ifdef __DJGPP__ | #ifdef __DJGPP__ | ||||
#include <process.h> | #include <process.h> | ||||
#endif | #endif | ||||
#if defined(USE_NCURSES) && !defined(RENAMED_NCURSES) | |||||
#include <ncurses.h> | #include <ncurses.h> | ||||
#else | |||||
#include <curses.h> | |||||
#endif | |||||
static sighandler_t oldsigquit; /* old value of quit signal */ | static sighandler_t oldsigquit; /* old value of quit signal */ | ||||
static sighandler_t oldsighup; /* old value of hangup signal */ | static sighandler_t oldsighup; /* old value of hangup signal */ | ||||
@@ -97,7 +93,7 @@ execute(char *a, ...) /* note: "exec" is already defined on u370 */ | |||||
# ifndef __DJGPP__ /* leave CRLF handling as is */ | # ifndef __DJGPP__ /* leave CRLF handling as is */ | ||||
nonl(); | nonl(); | ||||
# endif | # endif | ||||
raw(); /* endwin() turns off cbreak mode so restore it */ | |||||
cbreak(); /* endwin() turns off cbreak mode so restore it */ | |||||
noecho(); | noecho(); | ||||
#endif | #endif | ||||
mousemenu(); | mousemenu(); | ||||
@@ -82,10 +82,11 @@ struct cmd { /* command history struct */ | |||||
}; | }; | ||||
enum { | enum { | ||||
CH_falseNE = 0x0000, | |||||
CH_NONE = 0x0000, | |||||
CH_RESULT = 0x0001 << 0, | CH_RESULT = 0x0001 << 0, | ||||
CH_INPUT = 0x0001 << 1, | CH_INPUT = 0x0001 << 1, | ||||
CH_MODE = 0x0001 << 2, | CH_MODE = 0x0001 << 2, | ||||
CH_HELP = 0x0001 << 3, /* do NOT add to CH_ALL */ | |||||
CH_ALL = CH_RESULT | CH_INPUT | CH_MODE | CH_ALL = CH_RESULT | CH_INPUT | CH_MODE | ||||
}; | }; | ||||
@@ -235,8 +236,9 @@ void error_usage(void); | |||||
void longusage(void); | void longusage(void); | ||||
void usage(void); | void usage(void); | ||||
extern bool remove_symfile_onexit; | extern bool remove_symfile_onexit; | ||||
extern bool onesearch; /* one search only in line mode */ | |||||
extern char *reflines; /* symbol reference lines file */ | |||||
extern bool onesearch; /* one search only in line mode */ | |||||
extern char *reflines; /* symbol reference lines file */ | |||||
extern bool do_press_any_key; /* wait for any key to continue */ | |||||
void verswp_field(void); | void verswp_field(void); | ||||
void horswp_field(void); | void horswp_field(void); | ||||
bool interpret(int c); // XXX: probably rename | bool interpret(int c); // XXX: probably rename | ||||
@@ -267,7 +269,7 @@ void freesrclist(void); | |||||
void freeinclist(void); | void freeinclist(void); | ||||
void freecrossref(void); | void freecrossref(void); | ||||
void freefilelist(void); | void freefilelist(void); | ||||
void help(void); | |||||
const char* help(void); | |||||
void incfile(char *file, char *type); | void incfile(char *file, char *type); | ||||
void includedir(char *_dirname); | void includedir(char *_dirname); | ||||
void initsymtab(void); | void initsymtab(void); | ||||
@@ -308,7 +310,6 @@ struct cmd *nextcmd(void); | |||||
int egrep(char *file, FILE *output, char *format); | int egrep(char *file, FILE *output, char *format); | ||||
int mygetline(char p[], char s[], unsigned size, int firstchar, bool iscaseless); | int mygetline(char p[], char s[], unsigned size, int firstchar, bool iscaseless); | ||||
int mygetch(void); | |||||
int hash(char *ss); | int hash(char *ss); | ||||
int execute(char *a, ...); | int execute(char *a, ...); | ||||
long dbseek(long offset); | long dbseek(long offset); | ||||
@@ -48,104 +48,91 @@ | |||||
*/ | */ | ||||
#define MAXHELP 50 /* maximum number of help strings */ | #define MAXHELP 50 /* maximum number of help strings */ | ||||
void | |||||
static char help_msg[] = | |||||
"Press the RETURN key repeatedly to move to the desired input field, type the\n" | |||||
"pattern to search for, and then press the RETURN key. For the first 4 and\n" | |||||
"last 2 input fields, the pattern can be a regcomp(3) regular expression.\n" | |||||
"If the search is successful, you can use these single-character commands:\n\n" | |||||
"0-9a-zA-Z\tEdit the file containing the displayed line.\n" | |||||
"space bar\tDisplay next set of matching lines.\n" | |||||
"+\t\tDisplay next set of matching lines.\n" | |||||
"^V\t\tDisplay next set of matching lines.\n" | |||||
"-\t\tDisplay previous set of matching lines.\n" | |||||
"^E\t\tEdit all lines.\n" | |||||
">\t\tWrite the list of lines being displayed to a file.\n" | |||||
">>\t\tAppend the list of lines being displayed to a file.\n" | |||||
"<\t\tRead lines from a file.\n" | |||||
"^\t\tFilter all lines through a shell command.\n" | |||||
"|\t\tPipe all lines to a shell command.\n" | |||||
"\nAt any time you can use these single-character commands:\n\n" | |||||
"TAB\t\tSwap positions between input and output areas.\n" | |||||
"RETURN\t\tMove to the next input field.\n" | |||||
"^N\t\tMove to the next input field.\n" | |||||
"^P\t\tMove to the previous input field.\n" | |||||
"^Y / ^A\t\tSearch with the last pattern typed.\n" | |||||
"^B\t\tRecall previous input field and search pattern.\n" | |||||
"^F\t\tRecall next input field and search pattern.\n" | |||||
"^C\t\tToggle ignore/use letter case when searching.\n" | |||||
"^R\t\tRebuild the cross-reference.\n" | |||||
"!\t\tStart an interactive shell (type ^D to return to cscope).\n" | |||||
"^L\t\tRedraw the screen.\n" | |||||
"?\t\tDisplay this list of commands.\n" | |||||
"^D\t\tExit cscope.\n" | |||||
"\nNote: If the first character of the pattern you want to search for matches\n" | |||||
"a command, type a \\ character first.\n" | |||||
"Note: Some ctrl keys may be occupied by your terminal configuration.\n" | |||||
; | |||||
static char changeing_help_msg[] = | |||||
"When changing text, you can use these single-character commands:\n\n" | |||||
"0-9a-zA-Z\tMark or unmark the line to be changed.\n" | |||||
"*\t\tMark or unmark all displayed lines to be changed.\n" | |||||
"space bar\tDisplay next set of lines.\n" | |||||
"+\t\tDisplay next set of lines.\n" | |||||
"-\t\tDisplay previous set of lines.\n" | |||||
"^A\t\tMark or unmark all lines to be changed.\n" | |||||
"^D\t\tChange the marked lines and exit.\n" | |||||
"ESC\t\tExit without changing the marked lines.\n" | |||||
"!\t\tStart an interactive shell (type ^D to return to cscope).\n" | |||||
"^L\t\tRedraw the screen.\n" | |||||
"?\t\tDisplay this list of commands.\n" | |||||
; | |||||
const char* | |||||
help(void) | help(void) | ||||
{ | { | ||||
char **ep, *s, **tp, *text[MAXHELP]; | |||||
int ln; | |||||
//char **ep, *s, **tp, *text[MAXHELP]; | |||||
//int ln; | |||||
tp = text; | |||||
//tp = text; | |||||
if (changing == false) { | if (changing == false) { | ||||
if (mouse) { | |||||
*tp++ = "Point with the mouse and click button 1 to move to the desired input field,\n"; | |||||
*tp++ = "type the pattern to search for, and then press the RETURN key. For the first 4\n"; | |||||
*tp++ = "and last 2 input fields, the pattern can be a regcomp(3) regular expression.\n"; | |||||
*tp++ = "If the search is successful, you can edit the file containing a displayed line\n"; | |||||
*tp++ = "by pointing with the mouse and clicking button 1.\n"; | |||||
*tp++ = "\nYou can either use the button 2 menu or these single-character commands:\n\n"; | |||||
} else { | |||||
*tp++ = "Press the RETURN key repeatedly to move to the desired input field, type the\n"; | |||||
*tp++ = "pattern to search for, and then press the RETURN key. For the first 4 and\n"; | |||||
*tp++ = "last 2 input fields, the pattern can be a regcomp(3) regular expression.\n"; | |||||
*tp++ = "If the search is successful, you can use these single-character commands:\n\n"; | |||||
*tp++ = "0-9a-zA-Z\tEdit the file containing the displayed line.\n"; | |||||
} | |||||
*tp++ = "space bar\tDisplay next set of matching lines.\n"; | |||||
*tp++ = "+\t\tDisplay next set of matching lines.\n"; | |||||
*tp++ = "^V\t\tDisplay next set of matching lines.\n"; | |||||
*tp++ = "-\t\tDisplay previous set of matching lines.\n"; | |||||
*tp++ = "^E\t\tEdit all lines.\n"; | |||||
*tp++ = ">\t\tWrite the list of lines being displayed to a file.\n"; | |||||
*tp++ = ">>\t\tAppend the list of lines being displayed to a file.\n"; | |||||
*tp++ = "<\t\tRead lines from a file.\n"; | |||||
*tp++ = "^\t\tFilter all lines through a shell command.\n"; | |||||
*tp++ = "|\t\tPipe all lines to a shell command.\n"; | |||||
if (!mouse) { | |||||
*tp++ = "\nAt any time you can use these single-character commands:\n\n"; | |||||
*tp++ = "TAB\t\tSwap positions between input and output areas.\n"; | |||||
*tp++ = "RETURN\t\tMove to the next input field.\n"; | |||||
*tp++ = "^N\t\tMove to the next input field.\n"; | |||||
*tp++ = "^P\t\tMove to the previous input field.\n"; | |||||
} | |||||
*tp++ = "^Y / ^A\t\tSearch with the last pattern typed.\n"; | |||||
*tp++ = "^B\t\tRecall previous input field and search pattern.\n"; | |||||
*tp++ = "^F\t\tRecall next input field and search pattern.\n"; | |||||
if(caseless) | |||||
*tp++ = "^C\t\tToggle ignore/use letter case when searching (IGfalseRE).\n"; | |||||
else | |||||
*tp++ = "^C\t\tToggle ignore/use letter case when searching (USE).\n"; | |||||
*tp++ = "^R\t\tRebuild the cross-reference.\n"; | |||||
*tp++ = "!\t\tStart an interactive shell (type ^D to return to cscope).\n"; | |||||
*tp++ = "^L\t\tRedraw the screen.\n"; | |||||
*tp++ = "?\t\tDisplay this list of commands.\n"; | |||||
*tp++ = "^D\t\tExit cscope.\n"; | |||||
*tp++ = "\nNote: If the first character of the pattern you want to search for matches\n"; | |||||
*tp++ = "a command, type a \\ character first.\n"; | |||||
*tp++ = "Note: Some ctrl keys may be occupied by your terminal configuration.\n"; | |||||
return help_msg; | |||||
} else { | } else { | ||||
if (mouse) { | |||||
*tp++ = "Point with the mouse and click button 1 to mark or unmark the line to be\n"; | |||||
*tp++ = "changed. You can also use the button 2 menu or these single-character\n"; | |||||
*tp++ = "commands:\n\n"; | |||||
} | |||||
else { | |||||
*tp++ = "When changing text, you can use these single-character commands:\n\n"; | |||||
*tp++ = "0-9a-zA-Z\tMark or unmark the line to be changed.\n"; | |||||
} | |||||
*tp++ = "*\t\tMark or unmark all displayed lines to be changed.\n"; | |||||
*tp++ = "space bar\tDisplay next set of lines.\n"; | |||||
*tp++ = "+\t\tDisplay next set of lines.\n"; | |||||
*tp++ = "-\t\tDisplay previous set of lines.\n"; | |||||
*tp++ = "^A\t\tMark or unmark all lines to be changed.\n"; | |||||
*tp++ = "^D\t\tChange the marked lines and exit.\n"; | |||||
*tp++ = "ESC\t\tExit without changing the marked lines.\n"; | |||||
*tp++ = "!\t\tStart an interactive shell (type ^D to return to cscope).\n"; | |||||
*tp++ = "^L\t\tRedraw the screen.\n"; | |||||
*tp++ = "?\t\tDisplay this list of commands.\n"; | |||||
} | |||||
/* print help, a screen at a time */ | |||||
ep = tp; | |||||
ln = 0; | |||||
for (tp = text; tp < ep; ) { | |||||
if (ln < LINES - 1) { | |||||
for (s = *tp; *s != '\0'; ++s) { | |||||
if (*s == '\n') { | |||||
++ln; | |||||
} | |||||
} | |||||
(void) addstr(*tp++); | |||||
} | |||||
else { | |||||
(void) addstr("\n"); | |||||
askforchar(); | |||||
(void) clear(); | |||||
ln = 0; | |||||
} | |||||
} | |||||
if (ln) { | |||||
(void) addstr("\n"); | |||||
askforchar(); | |||||
return changeing_help_msg; | |||||
} | } | ||||
///* print help, a screen at a time */ | |||||
//ep = tp; | |||||
//ln = 0; | |||||
//for (tp = text; tp < ep; ) { | |||||
// if (ln < LINES - 1) { | |||||
// for (s = *tp; *s != '\0'; ++s) { | |||||
// if (*s == '\n') { | |||||
// ++ln; | |||||
// } | |||||
// } | |||||
// (void) addstr(*tp++); | |||||
// } | |||||
// else { | |||||
// (void) addstr("\n"); | |||||
// askforchar(); | |||||
// (void) clear(); | |||||
// ln = 0; | |||||
// } | |||||
//} | |||||
//if (ln) { | |||||
// (void) addstr("\n"); | |||||
// askforchar(); | |||||
//} | |||||
} | } | ||||
/* error exit including short usage information */ | /* error exit including short usage information */ | ||||
@@ -48,6 +48,8 @@ | |||||
#include <sys/termios.h> | #include <sys/termios.h> | ||||
#endif | #endif | ||||
bool do_press_any_key = false; | |||||
static jmp_buf env; /* setjmp/longjmp buffer */ | static jmp_buf env; /* setjmp/longjmp buffer */ | ||||
static int prevchar; /* previous, ungotten character */ | static int prevchar; /* previous, ungotten character */ | ||||
@@ -70,38 +72,6 @@ myungetch(int c) | |||||
prevchar = c; | prevchar = c; | ||||
} | } | ||||
/* get a character from the terminal */ | |||||
int | |||||
mygetch(void) | |||||
{ | |||||
sighandler_t savesig = 0; /* old value of signal */ | |||||
int c; | |||||
/* change an interrupt signal to a break key character */ | |||||
if (setjmp(env) == 0) { | |||||
savesig = signal(SIGINT, catchint); | |||||
refresh(); /* update the display */ | |||||
mousereinit(); /* curses can change the menu number */ | |||||
if(prevchar) { | |||||
c = prevchar; | |||||
prevchar = 0; | |||||
} else { | |||||
c = -1; | |||||
while (c == -1) { | |||||
/* get a character from the terminal */ | |||||
c = getch(); | |||||
if ((c == -1) && (errno != EINTR)) | |||||
break; | |||||
} | |||||
} | |||||
} else { /* longjmp to here from signal handler */ | |||||
c = KEY_BREAK; | |||||
} | |||||
signal(SIGINT, savesig); | |||||
return(c); | |||||
} | |||||
/* get a line from the terminal in non-canonical mode */ | /* get a line from the terminal in non-canonical mode */ | ||||
int | int | ||||
mygetline(char p[], char s[], unsigned size, int firstchar, bool iscaseless) | mygetline(char p[], char s[], unsigned size, int firstchar, bool iscaseless) | ||||
@@ -133,7 +103,7 @@ mygetline(char p[], char s[], unsigned size, int firstchar, bool iscaseless) | |||||
s[i++] = firstchar; /* save it */ | s[i++] = firstchar; /* save it */ | ||||
} | } | ||||
/* until the end of the line is reached */ | /* until the end of the line is reached */ | ||||
while ((c = mygetch()) != '\r' && c != '\n' && c != KEY_ENTER) { | |||||
while ((c = getch()) != '\r' && c != '\n' && c != KEY_ENTER) { | |||||
if (c == KEY_LEFT || c == ctrl('B')) { /* left */ | if (c == KEY_LEFT || c == ctrl('B')) { /* left */ | ||||
if (i > 0) { | if (i > 0) { | ||||
addch('\b'); | addch('\b'); | ||||
@@ -240,7 +210,7 @@ void | |||||
askforchar(void) | askforchar(void) | ||||
{ | { | ||||
addstr("Type any character to continue: "); | addstr("Type any character to continue: "); | ||||
mygetch(); | |||||
getch(); | |||||
} | } | ||||
/* ask user to press the RETURN key after reading the message */ | /* ask user to press the RETURN key after reading the message */ | ||||
@@ -462,7 +432,7 @@ global_input(const int c){ | |||||
//move(PRLINE, 0); | //move(PRLINE, 0); | ||||
////addstr("Write to file: "); // XXX | ////addstr("Write to file: "); // XXX | ||||
//s = "w"; | //s = "w"; | ||||
//if ((ch = mygetch()) == '>') { | |||||
//if ((ch = getch()) == '>') { | |||||
//move(PRLINE, 0); | //move(PRLINE, 0); | ||||
////addstr(appendprompt); // XXX fix | ////addstr(appendprompt); // XXX fix | ||||
////ch = '\0'; | ////ch = '\0'; | ||||
@@ -554,10 +524,7 @@ global_input(const int c){ | |||||
window_change = CH_ALL; | window_change = CH_ALL; | ||||
break; | break; | ||||
case '?': /* help */ | case '?': /* help */ | ||||
clear(); | |||||
help(); | |||||
clear(); | |||||
seekline(topline); | |||||
window_change = CH_HELP; | |||||
break; | break; | ||||
case ctrl('E'): /* edit all lines */ | case ctrl('E'): /* edit all lines */ | ||||
editall(); | editall(); | ||||
@@ -576,6 +543,11 @@ extern const void const* const* current_window; | |||||
int | int | ||||
handle_input(const char c){ | handle_input(const char c){ | ||||
/* - was wating for any input - */ | |||||
if(do_press_any_key){ | |||||
do_press_any_key = false; | |||||
return 0; | |||||
} | |||||
/* --- global --- */ | /* --- global --- */ | ||||
const int r = global_input(c); | const int r = global_input(c); | ||||
if(r){ return 0; } | if(r){ return 0; } | ||||
@@ -215,14 +215,17 @@ void | |||||
entercurses(void) | entercurses(void) | ||||
{ | { | ||||
incurses = true; | incurses = true; | ||||
#ifndef __MSDOS__ /* HBB 20010313 */ | |||||
nonl(); /* don't translate an output \n to \n\r */ | |||||
#endif | |||||
raw(); /* single character input */ | |||||
nonl(); /* don't translate an output \n to \n\r */ | |||||
cbreak(); /* single character input */ | |||||
noecho(); /* don't echo input characters */ | noecho(); /* don't echo input characters */ | ||||
curs_set(0); | |||||
clear(); /* clear the screen */ | clear(); /* clear the screen */ | ||||
mouseinit(); /* initialize any mouse interface */ | mouseinit(); /* initialize any mouse interface */ | ||||
drawscrollbar(topline, nextline); | drawscrollbar(topline, nextline); | ||||
keypad(stdscr, TRUE); /* enable the keypad */ | |||||
//fixkeypad(); /* fix for getch() intermittently returning garbage */ | |||||
standend(); /* turn off reverse video */ | |||||
} | } | ||||
@@ -288,13 +288,13 @@ getmouseaction(char leading_char) | |||||
*/ | */ | ||||
/* Check for "[?" being next 2 chars */ | /* Check for "[?" being next 2 chars */ | ||||
if(((i = mygetch()) != '[') || ((i = mygetch()) != '?')) { | |||||
if(((i = getch()) != '[') || ((i = getch()) != '?')) { | |||||
myungetch(i); | myungetch(i); | ||||
return(NULL); | return(NULL); | ||||
} | } | ||||
/* Grab the X position (in pixels) */ | /* Grab the X position (in pixels) */ | ||||
while(isdigit(i = mygetch())) { | |||||
while(isdigit(i = getch())) { | |||||
x = (x*10) + (i - '0'); | x = (x*10) + (i - '0'); | ||||
} | } | ||||
if(i != ';') { | if(i != ';') { | ||||
@@ -303,7 +303,7 @@ getmouseaction(char leading_char) | |||||
} | } | ||||
/* Grab the Y position (in pixels) */ | /* Grab the Y position (in pixels) */ | ||||
while(isdigit(i = mygetch())) { | |||||
while(isdigit(i = getch())) { | |||||
y = (y*10) + (i - '0'); | y = (y*10) + (i - '0'); | ||||
} | } | ||||
if(i != ';') { | if(i != ';') { | ||||
@@ -312,23 +312,23 @@ getmouseaction(char leading_char) | |||||
} | } | ||||
/* Get which button */ | /* Get which button */ | ||||
if((button = mygetch()) > '4') { | |||||
if((button = getch()) > '4') { | |||||
myungetch(button); | myungetch(button); | ||||
return(NULL); | return(NULL); | ||||
} | } | ||||
if((i = mygetch()) != ';') { | |||||
if((i = getch()) != ';') { | |||||
myungetch(i); | myungetch(i); | ||||
return(NULL); | return(NULL); | ||||
} | } | ||||
/* Get the reason for this mouse report */ | /* Get the reason for this mouse report */ | ||||
if((reason = mygetch()) > '8') { | |||||
if((reason = getch()) > '8') { | |||||
myungetch(reason); | myungetch(reason); | ||||
return(NULL); | return(NULL); | ||||
} | } | ||||
/* sequence should terminate with an 'M' */ | /* sequence should terminate with an 'M' */ | ||||
if((i = mygetch()) != 'M') { | |||||
if((i = getch()) != 'M') { | |||||
myungetch(i); | myungetch(i); | ||||
return(NULL); | return(NULL); | ||||
} | } | ||||
@@ -366,9 +366,9 @@ getmouseaction(char leading_char) | |||||
if (mouse == true && leading_char == ctrl('X')) { | if (mouse == true && leading_char == ctrl('X')) { | ||||
switch (mygetch()) { | |||||
switch (getch()) { | |||||
case ctrl('_'): /* click */ | case ctrl('_'): /* click */ | ||||
if ((m.button = mygetch()) == '0') { /* if scrollbar */ | |||||
if ((m.button = getch()) == '0') { /* if scrollbar */ | |||||
m.percent = getpercent(); | m.percent = getpercent(); | ||||
} | } | ||||
else { | else { | ||||
@@ -379,7 +379,7 @@ getmouseaction(char leading_char) | |||||
break; | break; | ||||
case ctrl(']'): /* sweep */ | case ctrl(']'): /* sweep */ | ||||
m.button = mygetch(); | |||||
m.button = getch(); | |||||
m.x1 = getcoordinate(); | m.x1 = getcoordinate(); | ||||
m.y1 = getcoordinate(); | m.y1 = getcoordinate(); | ||||
m.x2 = getcoordinate(); | m.x2 = getcoordinate(); | ||||
@@ -401,11 +401,11 @@ getcoordinate(void) | |||||
{ | { | ||||
int c, next; | int c, next; | ||||
c = mygetch(); | |||||
c = getch(); | |||||
next = 0; | next = 0; | ||||
if (c == ctrl('A')) { | if (c == ctrl('A')) { | ||||
next = 95; | next = 95; | ||||
c = mygetch(); | |||||
c = getch(); | |||||
} | } | ||||
if (c < ' ') { | if (c < ' ') { | ||||
return (0); | return (0); | ||||
@@ -420,7 +420,7 @@ getpercent(void) | |||||
{ | { | ||||
int c; | int c; | ||||
c = mygetch(); | |||||
c = getch(); | |||||
if (c < 16) { | if (c < 16) { | ||||
return(0); | return(0); | ||||
} | } | ||||
@@ -34,16 +34,19 @@ static void redisplay_function(){ | |||||
} | } | ||||
static void callback_handler(char* line){ | static void callback_handler(char* line){ | ||||
if(!line){ return; } | |||||
strncpy(input_line, line, PATLEN); | strncpy(input_line, line, PATLEN); | ||||
search(); | search(); | ||||
} | } | ||||
static int interpret_break(){ | static int interpret_break(){ | ||||
do_terminate = true; | do_terminate = true; | ||||
return 0; | |||||
} | } | ||||
static int ctrl_z(){ | static int ctrl_z(){ | ||||
kill(0, SIGTSTP); | kill(0, SIGTSTP); | ||||
return 0; | |||||
} | } | ||||
static int toggle_caseless(){ | static int toggle_caseless(){ | ||||
@@ -55,6 +58,7 @@ static int toggle_caseless(){ | |||||
postmsg2("Caseless mode is now OFF"); | postmsg2("Caseless mode is now OFF"); | ||||
} | } | ||||
egrepcaseless(caseless); /* turn on/off -i flag */ | egrepcaseless(caseless); /* turn on/off -i flag */ | ||||
return 0; | |||||
} | } | ||||
static int rebuild_reference(){ | static int rebuild_reference(){ | ||||
@@ -132,7 +136,6 @@ void rlinit(){ | |||||
rl_bind_key(KEY_BACKSPACE, rl_rubout); | rl_bind_key(KEY_BACKSPACE, rl_rubout); | ||||
rl_bind_key(EOF, exit); | rl_bind_key(EOF, exit); | ||||
rl_bind_key(ctrl('D'), interpret_break); //XXX: why the fuck does it not work if its the first char? | |||||
rl_bind_key(ctrl('Z'), ctrl_z); | rl_bind_key(ctrl('Z'), ctrl_z); | ||||
rl_bind_key(ctrl('Z'), toggle_caseless); | rl_bind_key(ctrl('Z'), toggle_caseless); | ||||
rl_bind_key(ctrl('R'), rebuild_reference); | rl_bind_key(ctrl('R'), rebuild_reference); | ||||