hirc

IRC client
Log | Files | Refs

commit 29f5e29cc87275d59a51bed6ce1909ca3cb438b9
parent 8272f0338924cd897251e913e7e49d8421a31d01
Author: hhvn <dev@hhvn.uk>
Date:   Sat, 30 Oct 2021 20:53:17 +0100

main.c ui.c struct.h hirc.h: try to draw win_input less often

Diffstat:
Mhirc.h | 2+-
Mmain.c | 14+++++++++++---
Mstruct.h | 3++-
Mui.c | 4+---
4 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/hirc.h b/hirc.h @@ -91,7 +91,7 @@ void handle_NICK(char *msg, char **params, struct Server *server, time_t timest /* ui.c */ void ui_init(void); -void ui_read(int refresh); +void ui_read(void); void ui_redraw(void); void ui_draw_input(void); void ui_draw_nicklist(void); diff --git a/main.c b/main.c @@ -240,18 +240,26 @@ main(int argc, char **argv) { oldselected.history = selected.history; oldselected.name = selected.name; - refreshed = 0; + refreshed = inputrefreshed = 0; for (i=0; i < Win_last; i++) { if (windows[i].redraw) { if (windows[i].handler) windows[i].handler(); - wrefresh(windows[i].window); + wnoutrefresh(windows[i].window); windows[i].redraw = 0; refreshed = 1; + if (i == Win_input) + inputrefreshed = 1; } } + doupdate(); - ui_read(refreshed); + /* refresh Win_input after any other window to + * force ncurses to place the cursor here. */ + if (refreshed && !inputrefreshed) + wrefresh(windows[Win_input].window); + + ui_read(); } return 0; diff --git a/struct.h b/struct.h @@ -147,9 +147,10 @@ struct Window { enum { Win_main, - Win_input, Win_nicklist, Win_buflist, + Win_input, /* should always be + last to refresh */ Win_last, }; diff --git a/ui.c b/ui.c @@ -131,7 +131,7 @@ ui_placewindow(struct Window *window) { } void -ui_read(int refresh) { +ui_read(void) { static int needredraw; int key; @@ -150,8 +150,6 @@ ui_read(int refresh) { * that works with all terminals is nice */ windows[Win_input].redraw = 1; needredraw = 0; - } else if (refresh) { - wrefresh(windows[Win_input].window); } return; case KEY_RESIZE: