From faec45bcfa94f1592759613a24a1ef187f3fd2b6 Mon Sep 17 00:00:00 2001 From: anon Date: Sun, 27 Aug 2023 18:59:47 +0200 Subject: [PATCH] proper resizing --- .gdb_history | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 5 ++--- src/display.c | 17 +++++++++++++++++ src/global.h | 1 + src/input.c | 14 +++++++++++--- src/main.c | 10 +--------- 6 files changed, 84 insertions(+), 15 deletions(-) diff --git a/.gdb_history b/.gdb_history index 6b66ebd..56e3e39 100644 --- a/.gdb_history +++ b/.gdb_history @@ -135,3 +135,55 @@ frame 1 p wtooltip r p tooltip_width +b redisplay +where +l +s +where +s +n +c +c +b redisplay +c +n +where +l +c +b redisplay +c +n +n +where +finish +finish +finish +s +p c +n +b redisplay +c +n +finish +finish +finish +s +n +s +n +p EOF +c +where +frame 11 +until +where +frame 9 +n +frame 9 +finish +where +n +s +n +s +n diff --git a/README.md b/README.md index d4270a9..e7d4780 100644 --- a/README.md +++ b/README.md @@ -106,12 +106,11 @@ All can be configured sucklessly under "config/colors.h". Hopefully the comments | int window_change | Bit mask type of the CH_\* macros. Keeps track of the windows to be refresed on the next run of display(). Could be better utalized. # TODO /*move soon*/ -1. create a step in the mean loop where the cursor us forced into the right window based on mode ++ sort out the global hell + sort out constants.h -+ scrollbar() uses magic int literals? + lineflagafterfile is stupid + library.h...; "private library", in a program using 90 globals; ffs -+ sort out the global hell ++ scrollbar() uses magic int literals? + was there really ever a scrollbar? + handle resizing + a search struct could be great for caching and could ease the global situation diff --git a/src/display.c b/src/display.c index 2816a2d..17240a7 100644 --- a/src/display.c +++ b/src/display.c @@ -854,3 +854,20 @@ void display(void) { window_change = CH_NONE; } + +void redisplay(void) { + delwin(winput); + delwin(wmode); + delwin(wresult); + delwin(whelp ); + delwin(wtooltip); + delwin(wcase); + + endwin(); + + dispinit(); + + window_change = CH_ALL; + + display(); +} diff --git a/src/global.h b/src/global.h index 681d833..4d751db 100644 --- a/src/global.h +++ b/src/global.h @@ -265,6 +265,7 @@ void countrefs(void); void crossref(char *srcfile); void dispinit(void); void display(void); +void redisplay(void); void drawscrollbar(int top, int bot); void edit(char *file, const char *const linenum); void editall(void); diff --git a/src/input.c b/src/input.c index 5c02222..3be5b26 100644 --- a/src/input.c +++ b/src/input.c @@ -328,9 +328,6 @@ static int global_input(const int c) { execute(shell, shell, NULL); current_page = 0; break; - case KEY_RESIZE: - /* XXX: fill in*/ - break; case ctrl('U'): /* redraw screen */ case KEY_CLEAR: window_change = CH_ALL; @@ -505,6 +502,17 @@ int handle_input(const int c) { do_press_any_key = false; return 0; } + /* - Resize - */ + /* it's treated specially because curses treat it specially. + as far as i can tell this is the only key that does not + flush after itself. + */ + if(c == KEY_RESIZE) { + redisplay(); + flushinp(); + return 0; + } + /* --- global --- */ const int r = global_input(c); if(r) { return 0; } diff --git a/src/main.c b/src/main.c index c33585c..afaa0ff 100644 --- a/src/main.c +++ b/src/main.c @@ -105,15 +105,7 @@ static inline void readenv(void); static inline void linemode_event_loop(void); static inline void screenmode_event_loop(void); -#if defined(KEY_RESIZE) && !defined(__DJGPP__) -void sigwinch_handler(int sig, siginfo_t *info, void *unused) { - UNUSED(sig); - UNUSED(info); - UNUSED(unused); - if(incurses == true) { ungetch(KEY_RESIZE); } -} -#endif static inline void siginit(void) { /* if running in the foreground */ @@ -134,7 +126,7 @@ static inline void siginit(void) { */ signal(SIGPIPE, SIG_IGN); - if(linemode == false) { signal(SIGWINCH, sigwinch_handler); } + //if(linemode == false) { signal(SIGWINCH, redisplay); } } void cannotopen(const char *const file) {