From ad71c1f4cdf80074214a17f6ab543bdf817bbd43 Mon Sep 17 00:00:00 2001 From: anon Date: Fri, 11 Aug 2023 23:31:25 +0200 Subject: [PATCH] pagin fixed --- README.md | 1 + src/global.h | 6 ++---- src/input.c | 35 +++++++---------------------------- src/keys.h | 3 +++ src/refsfound.c | 7 ++++++- src/vpinit.c | 2 +- 6 files changed, 20 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index e7ab8e4..18a9bf6 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ fixing it would have been a lost cause, if not for Cscope itself. Well, Csope no + library.h...; "private library", in a program using 90 globals; ffs + sort out the global hell + was there really ever a scrollbar? + + handle resizing ## Original + Same capabilities as interactive in non interactive (one shot) mode + Provide some how-do-I-use-this-thing doc. diff --git a/src/global.h b/src/global.h index 234900c..56e0d68 100644 --- a/src/global.h +++ b/src/global.h @@ -207,9 +207,7 @@ extern char* rl_line_buffer; extern char input_line[PATLEN + 1]; extern int rl_point; -#if UNIXPC -extern bool unixpcmouse; /* UNIX PC mouse interface */ -#endif +//extern bool unixpcmouse; /* UNIX PC mouse interface */ /* cscope functions called from more than one function or between files */ @@ -249,7 +247,7 @@ int process_mouse(); extern int input_mode; int changestring(const char* from, const char* to, const bool *const change, const int change_len); -long seekpage(size_t i); +long seekpage(const size_t i); long seekrelline(unsigned i); void PCS_reset(void); diff --git a/src/input.c b/src/input.c index 6e768bb..97de161 100644 --- a/src/input.c +++ b/src/input.c @@ -114,22 +114,14 @@ mygetline(char p[], char s[], unsigned size, int firstchar, bool iscaseless){ s[i++] = sright[--ri]; addch(s[i-1]); } - } else if ( -#ifdef KEY_HOME - c == KEY_HOME || -#endif - c == ctrl('A') ) { + } else if (c == KEY_HOME || c == ctrl('A') ) { while (i > 0) { sright[ri++] = s[--i]; addch('\b'); addch(s[i]); addch('\b'); } - } else if ( -#ifdef KEY_END - c == KEY_END || -#endif - c == ctrl('E') ) { + } else if (c == KEY_END || c == ctrl('E') ) { while (ri > 0) { s[i++] = sright[--ri]; addch(s[i-1]); @@ -174,10 +166,8 @@ mygetline(char p[], char s[], unsigned size, int firstchar, bool iscaseless){ addch(c); /* advance cursor */ } } -#if UNIXPC - } else if (unixpcmouse == true && c == ESC) { /* mouse */ + } else if (/*unixpcmouse == true && */c == ESC) { /* mouse */ getmouseaction(ESC); /* ignore it */ -#endif } else if (mouse == true && c == ctrl('X')) { getmouseaction(ctrl('X')); /* ignore it */ } else if (c == EOF) { /* end-of-file */ @@ -392,21 +382,10 @@ global_input(const int c){ case KEY_PPAGE: if (totallines == 0) { return 0; } /* don't redisplay if there are no lines */ curdispline = 0; - --current_page; - ///* if on first page but not at beginning, go to beginning */ - //nextline -= mdisprefs; /* already at next page */ - //if (nextline > 1 && nextline <= mdisprefs) { - // nextline = 1; - //} else { - // nextline -= mdisprefs; - // if (nextline < 1) { - // nextline = totallines - mdisprefs + 1; - // if (nextline < 1) { - // nextline = 1; - // } - // } - //} - //seekline(nextline); + if(current_page > 0){ + --current_page; + window_change |= CH_RESULT; + } break; case '>': /* write or append the lines to a file */ break; // XXX diff --git a/src/keys.h b/src/keys.h index 712ff03..6ea2ec6 100644 --- a/src/keys.h +++ b/src/keys.h @@ -44,6 +44,9 @@ #ifndef KEY_RESIZE # define KEY_RESIZE KEY_UNDEF_BASE-11 #endif +#ifndef KEY_END +# define KEY_END KEY_UNDEF_BASE-12 +#endif /* Always define these keys */ #ifndef ESC diff --git a/src/refsfound.c b/src/refsfound.c index 88fd6be..f2dd2c1 100644 --- a/src/refsfound.c +++ b/src/refsfound.c @@ -9,9 +9,14 @@ static FILE** hto_page = &refsfound; static size_t PCS_pos[PCS_MAXPAGE] = {0}; static size_t PCS_top = 0; -long seekpage(size_t i){ +long seekpage(const size_t i){ if(i > PCS_MAXPAGE-1){ return -1; } + if(i < PCS_top){ + fseek(*hto_page, PCS_pos[i], SEEK_SET); + return PCS_pos[i]; + } + fseek(*hto_page, PCS_pos[PCS_top], SEEK_SET); size_t lc = 0; diff --git a/src/vpinit.c b/src/vpinit.c index 175b56d..35fd910 100644 --- a/src/vpinit.c +++ b/src/vpinit.c @@ -81,7 +81,7 @@ vpinit(char *current_dir) } /* if not given, get the current directory name */ if (current_dir == NULL && (current_dir = getcwd(buf, MAXPATH)) == NULL) { - (void) fprintf(stderr, PROGRAM_NAME ": cannot get current directory name\n"); + fprintf(stderr, PROGRAM_NAME ": cannot get current directory name\n"); return; } /* see if this directory is in the first view path node */