From cad91258377958f8d2304d6fb9349219d5f362d5 Mon Sep 17 00:00:00 2001 From: anon Date: Wed, 16 Aug 2023 15:00:06 +0200 Subject: [PATCH] . --- Makefile | 3 +++ src/display.c | 13 +++++++++++++ src/global.h | 1 + src/input.c | 3 +-- src/main.c | 2 +- src/readline.c | 2 +- 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e52dcd6..fe9aacf 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,9 @@ obj/%.h.gch: src/%.h obj/%.h.gch: config/%.h ${CC} $< -o $@ +install: ${OUTPUT} + cp ${OUTPUT} /usr/bin/ + clean: -rm ${CHDR} -rm ${GENLEX} diff --git a/src/display.c b/src/display.c index 6311bff..2816a2d 100644 --- a/src/display.c +++ b/src/display.c @@ -224,6 +224,7 @@ void dispinit(void) { refresh(); + last_window = &winput; current_window = &winput; } @@ -260,6 +261,18 @@ void exitcurses(void) { fflush(stdout); } +void force_window(){ + switch(input_mode){ + case INPUT_CHANGE: + current_window = &wresult; + break; + case INPUT_CHANGE_TO: + case INPUT_APPEND: + current_window = &winput; + break; + } +} + static inline void display_help() { // XXX: this could be optimized by only overriding the buffer if theres an actual // change diff --git a/src/global.h b/src/global.h index 587b977..681d833 100644 --- a/src/global.h +++ b/src/global.h @@ -271,6 +271,7 @@ void editall(void); void editref(int); void entercurses(void); void exitcurses(void); +void force_window(void); void findcleanup(void); void freesrclist(void); void freeinclist(void); diff --git a/src/input.c b/src/input.c index d6ba510..5c02222 100644 --- a/src/input.c +++ b/src/input.c @@ -260,10 +260,9 @@ static int global_input(const int c) { postmsg("There are no lines to write to a file"); break; } - if(*current_window == wresult){ horswp_window(); } - if(*current_window == wmode){ verswp_window(); } input_mode = INPUT_APPEND; window_change |= CH_INPUT; + force_window(); break; case '<': /* read lines from a file */ break; // XXX diff --git a/src/main.c b/src/main.c index f65e033..c33585c 100644 --- a/src/main.c +++ b/src/main.c @@ -325,7 +325,7 @@ static inline void linemode_event_loop(void) { static inline void screenmode_event_loop(void) { for(;;) { display(); - handle_input(wgetch(stdscr)); // NOTE: getch() does not return key codes + handle_input(wgetch(stdscr)); // NOTE: getch() does not return KEY_* codes } } diff --git a/src/readline.c b/src/readline.c index c86ef6d..eb8a0e3 100644 --- a/src/readline.c +++ b/src/readline.c @@ -97,7 +97,7 @@ static void callback_handler(char *line) { strncpy(newpat, line, PATLEN); change = calloc(totallines, sizeof(*change)); input_mode = INPUT_CHANGE; - horswp_window(); + force_window(); return; case INPUT_APPEND: { char filename[PATHLEN + 1];