bak
This commit is contained in:
parent
787aa3279e
commit
e7ea3e3e95
2
Makefile
2
Makefile
@ -1,6 +1,6 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS:=-ggdb
|
CFLAGS:=-ggdb
|
||||||
LDLIBS=-I ${CHDRD} $$(pkg-config --libs ncurses)
|
LDLIBS=-I ${CHDRD} $$(pkg-config --libs ncurses readline)
|
||||||
LEX:=flex
|
LEX:=flex
|
||||||
|
|
||||||
LEXD:=src/
|
LEXD:=src/
|
||||||
|
@ -136,7 +136,7 @@ command(int commandc)
|
|||||||
return(NO);
|
return(NO);
|
||||||
}
|
}
|
||||||
/* if this is a line selection */
|
/* if this is a line selection */
|
||||||
if (p->y1 < FLDLINE) {
|
if (p->y1 > FLDLINE) {
|
||||||
|
|
||||||
/* find the selected line */
|
/* find the selected line */
|
||||||
/* note: the selection is forced into range */
|
/* note: the selection is forced into range */
|
||||||
@ -173,6 +173,7 @@ command(int commandc)
|
|||||||
case '\n': /* go to reference */
|
case '\n': /* go to reference */
|
||||||
if (current_window == &wresult) {
|
if (current_window == &wresult) {
|
||||||
editref(curdispline);
|
editref(curdispline);
|
||||||
|
window_change = CH_ALL;
|
||||||
return(YES);
|
return(YES);
|
||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
@ -304,9 +305,10 @@ command(int commandc)
|
|||||||
clearprompt();
|
clearprompt();
|
||||||
shellpath(filename, sizeof(filename), newpat);
|
shellpath(filename, sizeof(filename), newpat);
|
||||||
if (readrefs(filename) == NO) {
|
if (readrefs(filename) == NO) {
|
||||||
postmsg2("Ignoring an empty file");
|
postmsg2("Ignoring an empty file");
|
||||||
return(NO);
|
return(NO);
|
||||||
}
|
}
|
||||||
|
window_change |= CH_INPUT;
|
||||||
return(YES);
|
return(YES);
|
||||||
}
|
}
|
||||||
clearprompt();
|
clearprompt();
|
||||||
@ -499,6 +501,7 @@ cscope: cannot open pipe to shell command: %s\n", newpat);
|
|||||||
return(NO);
|
return(NO);
|
||||||
}
|
}
|
||||||
} /* switch(commandc) */
|
} /* switch(commandc) */
|
||||||
|
window_change |= CH_INPUT;
|
||||||
return(YES);
|
return(YES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,6 @@
|
|||||||
#define FLDLINE (LINES - FIELDS - 1 - 1) /* first input field line */
|
#define FLDLINE (LINES - FIELDS - 1 - 1) /* first input field line */
|
||||||
#define MSGLINE 0 /* message line */
|
#define MSGLINE 0 /* message line */
|
||||||
#define PRLINE (LINES - 1) /* input prompt line */
|
#define PRLINE (LINES - 1) /* input prompt line */
|
||||||
#define REFLINE 3 /* first displayed reference line */
|
|
||||||
|
|
||||||
/* input fields (value matches field order on screen) */
|
/* input fields (value matches field order on screen) */
|
||||||
#define SYMBOL 0
|
#define SYMBOL 0
|
||||||
|
@ -85,12 +85,7 @@ static int mode_window_height;
|
|||||||
|
|
||||||
#define WRESULT_TABLE_BODY_START 4
|
#define WRESULT_TABLE_BODY_START 4
|
||||||
|
|
||||||
static enum {
|
int window_change = CH_ALL;
|
||||||
CH_RESULT = 0x0001,
|
|
||||||
CH_INPUT = CH_RESULT << 1,
|
|
||||||
CH_MODE = CH_RESULT << 2,
|
|
||||||
CH_ALL = CH_RESULT | CH_INPUT | CH_MODE
|
|
||||||
};
|
|
||||||
|
|
||||||
const char dispchars[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
const char dispchars[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
|
||||||
@ -143,7 +138,7 @@ dispinit(void)
|
|||||||
mode_window_height = LINES - input_window_height - 2 - 1;
|
mode_window_height = LINES - input_window_height - 2 - 1;
|
||||||
first_col_width = 48; // (((COLS - 2)%2 == 0) ? ((COLS-2)/2) : (((COLS-2)/2)+1));
|
first_col_width = 48; // (((COLS - 2)%2 == 0) ? ((COLS-2)/2) : (((COLS-2)/2)+1));
|
||||||
second_col_width = COLS - 2 - 1 - first_col_width; //((COLS - 2) / 2) - 1;
|
second_col_width = COLS - 2 - 1 - first_col_width; //((COLS - 2) / 2) - 1;
|
||||||
mdisprefs = result_window_height - 1;
|
mdisprefs = result_window_height - WRESULT_TABLE_BODY_START - 1 - 1;
|
||||||
|
|
||||||
if (mdisprefs <= 0) {
|
if (mdisprefs <= 0) {
|
||||||
postfatal("%s: screen too small\n", argv0);
|
postfatal("%s: screen too small\n", argv0);
|
||||||
@ -156,6 +151,9 @@ dispinit(void)
|
|||||||
/* allocate the displayed line array */
|
/* allocate the displayed line array */
|
||||||
displine = malloc(mdisprefs * sizeof(*displine));
|
displine = malloc(mdisprefs * sizeof(*displine));
|
||||||
|
|
||||||
|
/* readline */
|
||||||
|
rlinit();
|
||||||
|
|
||||||
/* initialize windows */
|
/* initialize windows */
|
||||||
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);
|
||||||
@ -197,7 +195,7 @@ static inline void display_frame(){
|
|||||||
waddstr(stdscr, helpstring);
|
waddstr(stdscr, helpstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void display_input_fields(){
|
static inline void display_mode(){
|
||||||
for(int i = 0; i < FIELDS; ++i){
|
for(int i = 0; i < FIELDS; ++i){
|
||||||
mvwprintw(wmode, i, 0, "%s %s", fields[i].text1, fields[i].text2);
|
mvwprintw(wmode, i, 0, "%s %s", fields[i].text1, fields[i].text2);
|
||||||
}
|
}
|
||||||
@ -271,7 +269,7 @@ static inline void display_results(){
|
|||||||
/* until the max references have been displayed or
|
/* until the max references have been displayed or
|
||||||
there is no more room */
|
there is no more room */
|
||||||
topline = nextline;
|
topline = nextline;
|
||||||
for (disprefs = 0, screenline = REFLINE;
|
for (disprefs = 0, screenline = WRESULT_TABLE_BODY_START;
|
||||||
disprefs < mdisprefs && screenline <= result_window_height;
|
disprefs < mdisprefs && screenline <= result_window_height;
|
||||||
++disprefs, ++screenline)
|
++disprefs, ++screenline)
|
||||||
{
|
{
|
||||||
@ -392,9 +390,10 @@ static inline void display_results(){
|
|||||||
wmove(wresult, screenline, second_col_width - srctxtw);
|
wmove(wresult, screenline, second_col_width - srctxtw);
|
||||||
} /* for(ever) */
|
} /* for(ever) */
|
||||||
} /* for(reference output lines) */
|
} /* for(reference output lines) */
|
||||||
endrefs:
|
|
||||||
|
endrefs:
|
||||||
/* position the cursor for the message */
|
/* position the cursor for the message */
|
||||||
i = FLDLINE - 1;
|
i = result_window_height - 1;
|
||||||
if (screenline < i) {
|
if (screenline < i) {
|
||||||
waddch(wresult, '\n');
|
waddch(wresult, '\n');
|
||||||
}
|
}
|
||||||
@ -408,7 +407,7 @@ static inline void display_results(){
|
|||||||
wprintw(wresult, "* Lines %d-%d of %d, %d more - press the space bar to display more *", topline, bottomline, totallines, i);
|
wprintw(wresult, "* Lines %d-%d of %d, %d more - press the space bar to display more *", topline, bottomline, totallines, i);
|
||||||
}
|
}
|
||||||
/* if this is the last page of references */
|
/* if this is the last page of references */
|
||||||
else if (topline > 1 && nextline > totallines) {
|
else{ //if (topline > 1 && nextline > totallines) { //XXX: i dont see how this condition is ever userful, but i might be wrong
|
||||||
waddstr(wresult, "* Press the space bar to display the first lines again *");
|
waddstr(wresult, "* Press the space bar to display the first lines again *");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -422,7 +421,7 @@ void display_cursor(void){
|
|||||||
}else if(current_window == &wmode){
|
}else if(current_window == &wmode){
|
||||||
yoffset = field;
|
yoffset = field;
|
||||||
}else if(current_window == &wresult){
|
}else if(current_window == &wresult){
|
||||||
yoffset = WRESULT_TABLE_BODY_START + curdispline;
|
yoffset = displine[curdispline];
|
||||||
}else{
|
}else{
|
||||||
assert(("No window selected.", true));
|
assert(("No window selected.", true));
|
||||||
}
|
}
|
||||||
@ -439,17 +438,29 @@ display(void)
|
|||||||
{
|
{
|
||||||
//drawscrollbar(topline, nextline); /* display the scrollbar */
|
//drawscrollbar(topline, nextline); /* display the scrollbar */
|
||||||
|
|
||||||
display_frame();
|
if(window_change){
|
||||||
display_command_field();
|
if(window_change & CH_ALL){
|
||||||
display_input_fields();
|
display_frame();
|
||||||
display_results();
|
}
|
||||||
|
if(window_change & CH_INPUT){
|
||||||
|
display_command_field();
|
||||||
|
}
|
||||||
|
if(window_change & CH_RESULT){
|
||||||
|
display_results();
|
||||||
|
}
|
||||||
|
if(window_change & CH_MODE){
|
||||||
|
display_mode();
|
||||||
|
}
|
||||||
|
|
||||||
display_cursor();
|
display_cursor();
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
wrefresh(winput);
|
wrefresh(winput);
|
||||||
wrefresh(wmode);
|
wrefresh(wmode);
|
||||||
wrefresh(wresult);
|
wrefresh(wresult);
|
||||||
|
}
|
||||||
|
|
||||||
|
window_change = CH_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -709,7 +720,7 @@ postmsg2(char *msg)
|
|||||||
else {
|
else {
|
||||||
clearmsg2();
|
clearmsg2();
|
||||||
waddstr(wresult, msg);
|
waddstr(wresult, msg);
|
||||||
refresh();
|
wrefresh(wresult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
src/global.h
16
src/global.h
@ -84,6 +84,15 @@ struct cmd { /* command history struct */
|
|||||||
char *text; /* input field text */
|
char *text; /* input field text */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
CH_NONE = 0x0000,
|
||||||
|
CH_RESULT = 0x0001 << 0,
|
||||||
|
CH_INPUT = 0x0001 << 1,
|
||||||
|
CH_MODE = 0x0001 << 2,
|
||||||
|
CH_ALL = CH_RESULT | CH_INPUT | CH_MODE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef DFLT_INCDIR
|
#ifndef DFLT_INCDIR
|
||||||
# define DFLT_INCDIR "/usr/include"
|
# define DFLT_INCDIR "/usr/include"
|
||||||
@ -181,6 +190,7 @@ extern unsigned int topline; /* top line of page */
|
|||||||
extern long searchcount; /* count of files searched */
|
extern long searchcount; /* count of files searched */
|
||||||
extern unsigned int totallines; /* total reference lines */
|
extern unsigned int totallines; /* total reference lines */
|
||||||
extern const char dispchars[]; /* display chars for jumping to lines */
|
extern const char dispchars[]; /* display chars for jumping to lines */
|
||||||
|
extern int window_change;
|
||||||
|
|
||||||
/* find.c global data */
|
/* find.c global data */
|
||||||
extern char block[]; /* cross-reference file block */
|
extern char block[]; /* cross-reference file block */
|
||||||
@ -199,6 +209,10 @@ extern struct keystruct {
|
|||||||
/* mouse.c global data */
|
/* mouse.c global data */
|
||||||
extern BOOL mouse; /* mouse interface */
|
extern BOOL mouse; /* mouse interface */
|
||||||
|
|
||||||
|
/* display.c global data */
|
||||||
|
extern int input_available;
|
||||||
|
extern char input_char;
|
||||||
|
|
||||||
#if UNIXPC
|
#if UNIXPC
|
||||||
extern BOOL unixpcmouse; /* UNIX PC mouse interface */
|
extern BOOL unixpcmouse; /* UNIX PC mouse interface */
|
||||||
#endif
|
#endif
|
||||||
@ -232,6 +246,8 @@ extern char *reflines; /* symbol reference lines file */
|
|||||||
void verswp_field(void);
|
void verswp_field(void);
|
||||||
void horswp_field(void);
|
void horswp_field(void);
|
||||||
|
|
||||||
|
void rlinit(void);
|
||||||
|
|
||||||
void addcmd(int f, char *s);
|
void addcmd(int f, char *s);
|
||||||
void addsrcfile(char *path);
|
void addsrcfile(char *path);
|
||||||
void askforchar(void);
|
void askforchar(void);
|
||||||
|
@ -56,12 +56,9 @@ static void catchint(int sig);
|
|||||||
|
|
||||||
/* catch the interrupt signal */
|
/* catch the interrupt signal */
|
||||||
|
|
||||||
/*ARGSUSED*/
|
|
||||||
static void
|
static void
|
||||||
catchint(int sig)
|
catchint(int sig)
|
||||||
{
|
{
|
||||||
(void) sig; /* 'use' it, to avoid a warning */
|
|
||||||
|
|
||||||
signal(SIGINT, catchint);
|
signal(SIGINT, catchint);
|
||||||
longjmp(env, 1);
|
longjmp(env, 1);
|
||||||
}
|
}
|
||||||
|
@ -681,6 +681,8 @@ static inline void screenmode_event_loop(void){
|
|||||||
display();
|
display();
|
||||||
|
|
||||||
c = mygetch();
|
c = mygetch();
|
||||||
|
input_available = 1;
|
||||||
|
rl_callback_read_char();
|
||||||
|
|
||||||
/* exit if the quit command is entered */
|
/* exit if the quit command is entered */
|
||||||
if (c == EOF || c == ctrl('D')) {
|
if (c == EOF || c == ctrl('D')) {
|
||||||
@ -691,6 +693,5 @@ static inline void screenmode_event_loop(void){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
command(c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
42
src/readline.c
Normal file
42
src/readline.c
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include <readline/readline.h>
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
int input_available = 0;
|
||||||
|
char input_char;
|
||||||
|
|
||||||
|
static void getc_function(FILE* ignore){
|
||||||
|
input_available = 0;
|
||||||
|
return (int)input_char;
|
||||||
|
}
|
||||||
|
|
||||||
|
static input_available_hook(){
|
||||||
|
return input_available;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void redisplay_function(){
|
||||||
|
window_change |= CH_INPUT;
|
||||||
|
//display();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void callback_handler(char* line){
|
||||||
|
// ?!
|
||||||
|
}
|
||||||
|
|
||||||
|
int proxy(int i, int h){
|
||||||
|
horswp_field();
|
||||||
|
}
|
||||||
|
|
||||||
|
void rlinit(){
|
||||||
|
rl_catch_signals = 0;
|
||||||
|
rl_catch_sigwinch = 0;
|
||||||
|
rl_prep_term_function = NULL;
|
||||||
|
rl_deprep_term_function = NULL;
|
||||||
|
rl_change_environment = 0;
|
||||||
|
|
||||||
|
rl_getc_function = getc_function;
|
||||||
|
rl_input_available_hook = input_available_hook;
|
||||||
|
rl_redisplay_function = redisplay_function;
|
||||||
|
rl_callback_handler_install("", callback_handler);
|
||||||
|
|
||||||
|
rl_bind_key('\t', proxy);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user