stuff
This commit is contained in:
parent
78e6031e94
commit
8cc5a5d761
25
.gdb_history
25
.gdb_history
@ -46,3 +46,28 @@ n
|
||||
b siginit
|
||||
r
|
||||
n
|
||||
b wresult_input
|
||||
c
|
||||
n
|
||||
s
|
||||
n
|
||||
s
|
||||
n
|
||||
p editor
|
||||
p plusnum
|
||||
p file
|
||||
s
|
||||
n
|
||||
b wresult_input
|
||||
c
|
||||
n
|
||||
s
|
||||
n
|
||||
p refsfound
|
||||
p file
|
||||
p linenum
|
||||
b editref
|
||||
c
|
||||
n
|
||||
p i
|
||||
p topline
|
||||
|
15
README.md
15
README.md
@ -1,6 +1,6 @@
|
||||
# Csope
|
||||
Fork of Cscope, with various improvements, because cscope is good and shall not be forgotten.
|
||||
While the originals mainentence seems abandoned and as far as I can tell you need a PhD in autoconf to compile the latest version,
|
||||
While the original's mainentence seems abandoned and as far as I can tell you need a PhD in autoconf to compile the latest version,
|
||||
Csope is alive and well.
|
||||
|
||||
# Usacases
|
||||
@ -15,6 +15,9 @@ fixing it would have been a lost cause, if not for Cscope itself. Well, Csope no
|
||||
# Demo
|
||||
TODO: fill in
|
||||
|
||||
# Before/After
|
||||
TODO: fill in
|
||||
|
||||
# Interface
|
||||
<-- Tab -->
|
||||
+------------Message-------------+ +--------------------------------+
|
||||
@ -44,5 +47,15 @@ fixing it would have been a lost cause, if not for Cscope itself. Well, Csope no
|
||||
+ use stdbool instead of YES/NO macros
|
||||
+ saved kilobytes by stripping trailing whitespace
|
||||
|
||||
# Project structure /*probably move to documentation*/
|
||||
| Component | Purpose |
|
||||
| :-------: | :-----: |
|
||||
| main.c | generic init functions, main() and primary event loops (and junk)
|
||||
| display.c | all functions directly dealing with NCurses |
|
||||
| input.c | top layer of functions dealing with user input; migth dispatch to readline |
|
||||
| globals.h | an inherited curse; global var/prototype hell |
|
||||
| readline.c | all functions directly dealing with GNU Readline; responsible for line editing in *input mode* |
|
||||
| help.c | all functions dealing with help messages |
|
||||
|
||||
# Future features / contributor wishlist
|
||||
+ providing support for other languages by integrating new lexers (e.g. ctag's)
|
||||
|
1
TODO
1
TODO
@ -9,3 +9,4 @@
|
||||
|
||||
# Misc
|
||||
+ recursive macro function to assign KEY_* default values; look for a new and shiny preprocessor?
|
||||
+ sort out constants.h
|
||||
|
@ -157,11 +157,4 @@
|
||||
# define KEY_RESIZE KEY_UNDEF_BASE-11
|
||||
#endif
|
||||
|
||||
/**/
|
||||
#if (BSD || V9) && !__NetBSD__ && !__FreeBSD__ && !__APPLE__
|
||||
# define TERMINFO 0 /* no terminfo curses */
|
||||
#else
|
||||
# define TERMINFO 1
|
||||
#endif
|
||||
|
||||
#endif /* CSCOPE_CONSTANTS_H */
|
||||
|
@ -76,6 +76,10 @@ long searchcount; /* count of files searched */
|
||||
unsigned int totallines; /* total reference lines */
|
||||
unsigned fldcolumn; /* input field column */
|
||||
unsigned int curdispline = 0;
|
||||
static bool do_turn = false;
|
||||
void set_do_turn(){
|
||||
do_turn = true;
|
||||
}
|
||||
|
||||
WINDOW* winput;
|
||||
WINDOW* wmode;
|
||||
@ -225,15 +229,18 @@ static inline void display_command_field(){
|
||||
}
|
||||
|
||||
static inline void display_results(){
|
||||
static long prev_cursor = 0; /* signals where to possibly rewind page_cursor to */
|
||||
static long page_cursor = 0; /* signals where to output from */
|
||||
int screenline; /* screen line number */
|
||||
int srctxtw; /* source line display width */
|
||||
int i;
|
||||
char *s;
|
||||
/* column headings */
|
||||
char *subsystem; /* OGS subsystem name */
|
||||
char *book; /* OGS book name */
|
||||
char file[PATHLEN + 1]; /* file name */
|
||||
char function[PATLEN + 1]; /* function name */
|
||||
char linenum[NUMLEN + 1]; /* line number */
|
||||
int screenline; /* screen line number */
|
||||
int srctxtw; /* source line display width */
|
||||
int i;
|
||||
char *s;
|
||||
|
||||
werase(wresult);
|
||||
|
||||
@ -242,17 +249,18 @@ static inline void display_results(){
|
||||
/* redisplay the last message */
|
||||
waddstr(wresult, lastmsg);
|
||||
return;
|
||||
/* falseTREACHED */
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* display the pattern */
|
||||
|
||||
/* --- Display the pattern --- */
|
||||
if (changing == true) {
|
||||
wprintw(wresult, "Change \"%s\" to \"%s\"", input_line, newpat);
|
||||
} else {
|
||||
wprintw(wresult, "%c%s: %s", toupper((unsigned char)fields[field].text2[0]),
|
||||
fields[field].text2 + 1, input_line);
|
||||
}
|
||||
/* display the column headings */
|
||||
/* --- Display the column headings --- */
|
||||
wmove(wresult, 2, 2);
|
||||
if (ogs == true && field != FILENAME) {
|
||||
wprintw(wresult, "%-*s ", subsystemlen, "Subsystem");
|
||||
@ -268,10 +276,11 @@ static inline void display_results(){
|
||||
waddstr(wresult, "Line");
|
||||
}
|
||||
|
||||
/* --- Display table entries --- */
|
||||
wmove(wresult, WRESULT_TABLE_BODY_START, 0);
|
||||
|
||||
/* calculate the source text column */
|
||||
/* falseTE: the +1s are column gaps */
|
||||
/* NOTE: the +1s are column gaps */
|
||||
srctxtw = second_col_width;
|
||||
srctxtw -= 1+1; // dispchars
|
||||
if (ogs == true) {
|
||||
@ -285,6 +294,9 @@ static inline void display_results(){
|
||||
}
|
||||
srctxtw -= numlen+1;
|
||||
|
||||
/* decide where to list from */
|
||||
do_turn ? (page_cursor = ftell(refsfound)) : fseek(refsfound, page_cursor, SEEK_SET) ;
|
||||
|
||||
/* until the max references have been displayed or
|
||||
there is no more room */
|
||||
topline = nextline;
|
||||
@ -387,7 +399,7 @@ static inline void display_results(){
|
||||
|
||||
/* if this is the first displayed line,
|
||||
display what will fit on the screen */
|
||||
if (topline == nextline -1) {
|
||||
if (topline == nextline-1) {
|
||||
disprefs++;
|
||||
/* break out of two loops */
|
||||
goto endrefs;
|
||||
@ -426,9 +438,11 @@ endrefs:
|
||||
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 */
|
||||
else{ //if (topline > 1 && nextline > totallines) { //XXX: i dont see how this condition is ever userful, but i might be wrong
|
||||
else{if (topline > 1 && nextline > totallines) {
|
||||
waddstr(wresult, "* Press the space bar to display the first lines again *");
|
||||
}
|
||||
|
||||
do_turn = false;
|
||||
}
|
||||
|
||||
void display_cursor(void){
|
||||
@ -474,7 +488,7 @@ display(void)
|
||||
}
|
||||
if(window_change & CH_RESULT){
|
||||
werase(wresult);
|
||||
display_results();
|
||||
display_results(do_turn);
|
||||
}
|
||||
if(window_change & CH_MODE){
|
||||
werase(wmode);
|
||||
|
@ -243,6 +243,7 @@ void verswp_field(void);
|
||||
void horswp_field(void);
|
||||
bool interpret(int c); // XXX: probably rename
|
||||
int handle_input(const char c);
|
||||
void set_do_turn(void); /* initiate turning to the next result page */
|
||||
|
||||
void rlinit(void);
|
||||
|
||||
|
36
src/help.c
36
src/help.c
@ -101,38 +101,11 @@ static char changeing_help_msg[] =
|
||||
const char*
|
||||
help(void)
|
||||
{
|
||||
//char **ep, *s, **tp, *text[MAXHELP];
|
||||
//int ln;
|
||||
|
||||
//tp = text;
|
||||
if (changing == false) {
|
||||
return help_msg;
|
||||
} else {
|
||||
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 */
|
||||
@ -140,7 +113,7 @@ void
|
||||
error_usage(void)
|
||||
{
|
||||
usage();
|
||||
fprintf(stderr, "Try the -h option for more information.\n");
|
||||
fputs("Try the -h option for more information.\n", stderr);
|
||||
myexit(1);
|
||||
}
|
||||
|
||||
@ -148,8 +121,11 @@ error_usage(void)
|
||||
void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: cscope [-bcCdehklLqRTuUvV] [-f file] [-F file] [-i file] [-I dir] [-s dir]\n");
|
||||
fprintf(stderr, " [-p number] [-P path] [-[0-8] pattern] [source files]\n");
|
||||
fputs(
|
||||
"Usage: cscope [-bcCdehklLqRTuUvV] [-f file] [-F file] [-i file] [-I dir] [-s dir]\n"
|
||||
" [-p number] [-P path] [-[0-8] pattern] [source files]\n",
|
||||
stderr
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
11
src/input.c
11
src/input.c
@ -388,22 +388,15 @@ global_input(const int c){
|
||||
case ctrl('V'):
|
||||
case KEY_NPAGE:
|
||||
if (totallines == 0) { return 0; } /* don't redisplay if there are no lines */
|
||||
/* XXX: figure out whether this comment is useful or not */
|
||||
/* NOTE: seekline() is not used to move to the next
|
||||
* page because display() leaves the file pointer at
|
||||
* the next page to optimize paging forward
|
||||
*/
|
||||
curdispline = 0;
|
||||
set_do_turn();
|
||||
window_change |= CH_RESULT;
|
||||
break;
|
||||
case ctrl('H'): /* display previous page */
|
||||
case '-':
|
||||
case KEY_PPAGE:
|
||||
if (totallines == 0) { return 0; } /* don't redisplay if there are no lines */
|
||||
curdispline = 0;
|
||||
/* if there are only two pages, just go to the other one */
|
||||
if (totallines <= 2 * mdisprefs) {
|
||||
break;
|
||||
}
|
||||
/* if on first page but not at beginning, go to beginning */
|
||||
nextline -= mdisprefs; /* already at next page */
|
||||
if (nextline > 1 && nextline <= mdisprefs) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
||||
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT falseT LIMITED TO,
|
||||
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
@ -61,9 +61,9 @@ myopen(char *path, int flag, int mode)
|
||||
/* opens a file descriptor and then sets close-on-exec for the file */
|
||||
int fd;
|
||||
|
||||
/* 20020103: if file is not explicitly in Binary mode, make
|
||||
* sure we override silly Cygwin behaviour of automatic binary
|
||||
* mode for files in "binary mounted" paths */
|
||||
/* If file is not explicitly in Binary mode, make
|
||||
* sure we override silly Cygwin behaviour of automatic binary
|
||||
* mode for files in "binary mounted" paths */
|
||||
#if O_BINARY != O_TEXT
|
||||
if (! (flag | O_BINARY))
|
||||
flag |= O_TEXT;
|
||||
@ -73,12 +73,6 @@ myopen(char *path, int flag, int mode)
|
||||
else
|
||||
fd = open(path, flag);
|
||||
|
||||
#ifdef __DJGPP__ /* FIXME: test feature, not platform */
|
||||
/* HBB 20010312: DOS GCC doesn't have FD_CLOEXEC (yet), so it
|
||||
* always fails this call. Have to skip that step */
|
||||
if(fd != -1)
|
||||
return(fd);
|
||||
#endif
|
||||
if(fd != -1 && (fcntl(fd, F_SETFD, CLOSE_ON_EXEC) != -1))
|
||||
return(fd);
|
||||
|
||||
@ -110,13 +104,7 @@ myfopen(char *path, char *mode)
|
||||
}
|
||||
#endif /* SETMODE */
|
||||
|
||||
#ifdef __DJGPP__ /* FIXME: test feature, not platform */
|
||||
/* HBB 20010312: DOS GCC doesn't have FD_CLOEXEC (yet), so it
|
||||
* always fails this call. Have to skip that step */
|
||||
if(fp)
|
||||
#else
|
||||
if(fp && (fcntl(fileno(fp), F_SETFD, CLOSE_ON_EXEC) != -1))
|
||||
#endif
|
||||
return(fp);
|
||||
|
||||
else {
|
||||
@ -129,11 +117,6 @@ myfopen(char *path, char *mode)
|
||||
FILE *
|
||||
mypopen(char *cmd, char *mode)
|
||||
{
|
||||
#ifdef __DJGPP__
|
||||
/* HBB 20010312: Has its own implementation of popen(), which
|
||||
* is better suited to the platform than cscope's */
|
||||
return (popen)(cmd, mode);
|
||||
#else
|
||||
int p[2];
|
||||
pid_t *poptr;
|
||||
int myside, yourside;
|
||||
@ -155,11 +138,7 @@ mypopen(char *cmd, char *mode)
|
||||
stdio = tst(0, 1);
|
||||
close(myside);
|
||||
close(stdio);
|
||||
#if V9
|
||||
dup2(yourside, stdio);
|
||||
#else
|
||||
fcntl(yourside, F_DUPFD, stdio);
|
||||
#endif
|
||||
close(yourside);
|
||||
execlp(shell, basename(shell), "-c", cmd, (void *)0);
|
||||
_exit(1);
|
||||
@ -170,7 +149,6 @@ mypopen(char *cmd, char *mode)
|
||||
popen_pid[myside] = pid;
|
||||
(void) close(yourside);
|
||||
return(fdopen(myside, mode));
|
||||
#endif /* DJGPP */
|
||||
}
|
||||
|
||||
/* HBB 20010705: renamed from 'pclose', which would collide with
|
||||
@ -178,11 +156,6 @@ mypopen(char *cmd, char *mode)
|
||||
int
|
||||
mypclose(FILE *ptr)
|
||||
{
|
||||
#ifdef __DJGPP__
|
||||
/* HBB 20010705: This system has its own pclose(), which we
|
||||
* don't want to replace */
|
||||
return (pclose)(ptr);
|
||||
#else
|
||||
int f;
|
||||
pid_t r;
|
||||
int status = -1;
|
||||
@ -204,5 +177,4 @@ mypclose(FILE *ptr)
|
||||
/* mark this pipe closed */
|
||||
popen_pid[f] = 0;
|
||||
return(status);
|
||||
#endif /* DJGPP */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user