Compare commits
7 Commits
26294ba596
...
021efa273e
Author | SHA1 | Date | |
---|---|---|---|
021efa273e | |||
1d98020b62 | |||
0c7669df6c | |||
1853d44e82 | |||
263f7e5649 | |||
b16cd5dc63 | |||
4d03ac9ce7 |
@ -4,7 +4,7 @@ While the original's mainentence seems abandoned and as far as I can tell you ne
|
||||
Csope is alive and well.
|
||||
|
||||
# Demo
|
||||
TODO: fill in
|
||||
![demo](docs/csope.GIF)
|
||||
|
||||
# Before/After
|
||||
## After
|
||||
|
BIN
docs/csope.GIF
Normal file
BIN
docs/csope.GIF
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 MiB |
@ -95,9 +95,6 @@ enum {
|
||||
|
||||
#define FIELDS 10
|
||||
|
||||
// XXX
|
||||
#define bazdki 1
|
||||
|
||||
/* file open modes */
|
||||
#ifndef R_OK
|
||||
# define READ R_OK
|
||||
|
@ -66,7 +66,6 @@ unsigned int disprefs; /* displayed references */
|
||||
int field; /* input field */
|
||||
unsigned int mdisprefs; /* maximum displayed references */
|
||||
unsigned int nextline; /* next line to be shown */
|
||||
static int bottomline; /* bottom line of page */
|
||||
long searchcount; /* count of files searched */
|
||||
unsigned int totallines; /* total reference lines */
|
||||
unsigned int curdispline = 0;
|
||||
@ -379,6 +378,7 @@ static inline void display_results() {
|
||||
char linenum[NUMLEN + 1]; /* line number */
|
||||
|
||||
werase(wresult);
|
||||
nextline = 1;
|
||||
|
||||
/* --- Display the message --- */
|
||||
if(totallines == 0) { // Its a real message
|
||||
@ -560,7 +560,7 @@ static inline void display_results() {
|
||||
|
||||
/* if this is the first displayed line,
|
||||
display what will fit on the screen */
|
||||
if(topref == nextline - 1) {
|
||||
if(topref == (nextline-1)) {
|
||||
disprefs++;
|
||||
/* break out of two loops */
|
||||
goto endrefs;
|
||||
@ -599,12 +599,11 @@ endrefs:
|
||||
wattron(wresult, COLOR_PAIR(COLOR_PAIR_PAGER_MSG));
|
||||
/* check for more references */
|
||||
i = totallines - nextline + 1;
|
||||
bottomline = nextline;
|
||||
if(i > 0) {
|
||||
wprintw(wresult,
|
||||
"* Lines %d-%d of %d, %d more. *",
|
||||
topref,
|
||||
bottomline,
|
||||
topref + nextline,
|
||||
totallines,
|
||||
i);
|
||||
}
|
||||
|
@ -1278,7 +1278,6 @@ bool search(const char *query) {
|
||||
cannotopen(temp1);
|
||||
return (false);
|
||||
}
|
||||
nextline = 1;
|
||||
totallines = 0;
|
||||
disprefs = 0;
|
||||
|
||||
|
@ -368,7 +368,7 @@ int change_input(const int c) {
|
||||
|
||||
switch(c) {
|
||||
case '*': /* invert page */
|
||||
for(int i = 0; i < nextline-1; i++) {
|
||||
for(int i = 0; i < (nextline-1); i++) {
|
||||
change[topref + i] = !change[topref + i];
|
||||
}
|
||||
window_change |= CH_RESULT;
|
||||
@ -401,6 +401,7 @@ int change_input(const int c) {
|
||||
case ctrl('D'):
|
||||
changestring(input_line, newpat, change, totallines);
|
||||
free(change);
|
||||
change = NULL;
|
||||
input_mode = INPUT_NORMAL;
|
||||
horswp_window();
|
||||
rebuild_reference();
|
||||
@ -420,8 +421,8 @@ int change_input(const int c) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int changestring(const char *from, const char *to, const bool *const change,
|
||||
const int change_len) {
|
||||
// XXX: move this
|
||||
int changestring(const char *from, const char *to, const bool *const change, const int change_len) {
|
||||
char newfile[PATHLEN + 1]; /* new file name */
|
||||
char oldfile[PATHLEN + 1]; /* old file name */
|
||||
char linenum[NUMLEN + 1]; /* file line number */
|
||||
|
@ -102,12 +102,9 @@ static struct keystruct *hashtab[HASHMOD]; /* pointer table */
|
||||
/* put the keywords into the symbol table */
|
||||
|
||||
void initsymtab(void) {
|
||||
unsigned int i, j;
|
||||
struct keystruct *p;
|
||||
|
||||
for(i = 1; i < KEYWORDS; ++i) {
|
||||
p = keyword + i;
|
||||
j = hash(p->text) % HASHMOD;
|
||||
for(unsigned i = 1; i < KEYWORDS; ++i) {
|
||||
struct keystruct *p = keyword + i;
|
||||
int j = hash(p->text) % HASHMOD;
|
||||
p->next = hashtab[j];
|
||||
hashtab[j] = p;
|
||||
}
|
||||
|
@ -93,13 +93,14 @@ FILE *myfopen(char *path, char *mode) {
|
||||
if(fp && !strchr(mode, 'b')) { SETMODE(fileno(fp), O_TEXT); }
|
||||
#endif /* SETMODE */
|
||||
|
||||
if(fp && (fcntl(fileno(fp), F_SETFD, CLOSE_ON_EXEC) != -1))
|
||||
if(fp && (fcntl(fileno(fp), F_SETFD, CLOSE_ON_EXEC) != -1)) {
|
||||
return (fp);
|
||||
|
||||
else {
|
||||
if(fp) fclose(fp);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if(fp) {
|
||||
fclose(fp);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
FILE *mypopen(char *cmd, char *mode) {
|
||||
@ -126,16 +127,17 @@ FILE *mypopen(char *cmd, char *mode) {
|
||||
close(yourside);
|
||||
execlp(shell, basename(shell), "-c", cmd, (void *)0);
|
||||
_exit(1);
|
||||
} else if(pid > 0)
|
||||
} else if(pid > 0) {
|
||||
tstat = signal(SIGTSTP, SIG_DFL);
|
||||
if(pid == -1) return (NULL);
|
||||
}
|
||||
if(pid == -1) {
|
||||
return (NULL);
|
||||
}
|
||||
popen_pid[myside] = pid;
|
||||
(void)close(yourside);
|
||||
return (fdopen(myside, mode));
|
||||
}
|
||||
|
||||
/* HBB 20010705: renamed from 'pclose', which would collide with
|
||||
* system-supplied function of same name */
|
||||
int mypclose(FILE *ptr) {
|
||||
int f;
|
||||
pid_t r;
|
||||
@ -143,17 +145,17 @@ int mypclose(FILE *ptr) {
|
||||
sighandler_t hstat, istat, qstat;
|
||||
|
||||
f = fileno(ptr);
|
||||
(void)fclose(ptr);
|
||||
UNUSED(fclose(ptr));
|
||||
istat = signal(SIGINT, SIG_IGN);
|
||||
qstat = signal(SIGQUIT, SIG_IGN);
|
||||
hstat = signal(SIGHUP, SIG_IGN);
|
||||
while((r = wait(&status)) != popen_pid[f] && r != -1)
|
||||
; /* nothing */
|
||||
if(r == -1) status = -1;
|
||||
(void)signal(SIGINT, istat);
|
||||
(void)signal(SIGQUIT, qstat);
|
||||
(void)signal(SIGHUP, hstat);
|
||||
(void)signal(SIGTSTP, tstat);
|
||||
UNUSED(signal(SIGINT, istat));
|
||||
UNUSED(signal(SIGQUIT, qstat));
|
||||
UNUSED(signal(SIGHUP, hstat));
|
||||
UNUSED(signal(SIGTSTP, tstat));
|
||||
/* mark this pipe closed */
|
||||
popen_pid[f] = 0;
|
||||
return (status);
|
||||
|
@ -95,7 +95,7 @@ static void callback_handler(char *line) {
|
||||
} break;
|
||||
case INPUT_CHANGE_TO: {
|
||||
strncpy(newpat, line, PATLEN);
|
||||
change = calloc(totallines, sizeof(*change));
|
||||
change = (bool *)calloc(totallines, sizeof(*change));
|
||||
input_mode = INPUT_CHANGE;
|
||||
force_window();
|
||||
} return;
|
||||
|
@ -43,36 +43,3 @@ long seekrelline(unsigned i) {
|
||||
void PCS_reset(void) {
|
||||
PCS_top = 0;
|
||||
}
|
||||
|
||||
///* position references found file at specified line */
|
||||
// void
|
||||
// seekline(unsigned int line)
|
||||
//{
|
||||
// /* verify that there is a references found file */
|
||||
// if (refsfound == NULL) {
|
||||
// return;
|
||||
// }
|
||||
// /* go to the beginning of the file */
|
||||
// rewind(refsfound);
|
||||
// /**/
|
||||
// seekrelline(line);
|
||||
// }
|
||||
//
|
||||
///* XXX: this is just dodging the problem */
|
||||
// void
|
||||
// seekrelline(unsigned int line){
|
||||
// int c;
|
||||
//
|
||||
// /* verify that there is a references found file */
|
||||
// if (refsfound == NULL) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// /* find the requested line */
|
||||
// nextline = 1;
|
||||
// while (nextline < line && (c = getc(refsfound)) != EOF) {
|
||||
// if (c == '\n') {
|
||||
// nextline++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
Loading…
Reference in New Issue
Block a user