From: Richard Russon Date: Fri, 27 Sep 2019 15:03:52 +0000 (+0100) Subject: refactor: move() to mutt_window_move_abs() X-Git-Tag: 2019-10-25~30^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7415930d9cfb44e5884c3fc781b73a9b1d41afa6;p=neomutt refactor: move() to mutt_window_move_abs() Encapsulate a curses function to reduce dependencies. This function works with absolute screen coordinates rather than coords based on a MuttWindow. This function should be eliminated soon. --- diff --git a/menu.c b/menu.c index 90b2dd72e..397a02160 100644 --- a/menu.c +++ b/menu.c @@ -143,9 +143,6 @@ static void print_enriched_string(int index, int attr, unsigned char *s, bool do size_t n = mutt_str_strlen((char *) s); mbstate_t mbstate; - if (!stdscr) - return; - memset(&mbstate, 0, sizeof(mbstate)); while (*s) { @@ -362,7 +359,7 @@ void menu_redraw_full(struct Menu *menu) { mutt_curses_set_color(MT_COLOR_NORMAL); /* clear() doesn't optimize screen redraws */ - move(0, 0); + mutt_window_move_abs(0, 0); mutt_window_clrtobot(); if (C_Help) @@ -1085,7 +1082,7 @@ void mutt_menu_pop_current(struct Menu *menu) else { CurrentMenu = MENU_MAIN; - move(0, 0); + mutt_window_move_abs(0, 0); mutt_window_clrtobot(); } } diff --git a/mutt_window.c b/mutt_window.c index 688dda500..f6f9ca6ce 100644 --- a/mutt_window.c +++ b/mutt_window.c @@ -401,3 +401,13 @@ int mutt_window_addstr(const char *str) return addstr(str); #endif } + +/** + * mutt_window_move_abs - Move the cursor to an absolute screen position + * @param row Screen row (0-based) + * @param col Screen column (0-based) + */ +void mutt_window_move_abs(int row, int col) +{ + move(row, col); +} diff --git a/mutt_window.h b/mutt_window.h index 1857b15d7..81d2e94cd 100644 --- a/mutt_window.h +++ b/mutt_window.h @@ -65,6 +65,7 @@ void mutt_window_clearline(struct MuttWindow *win, int row); void mutt_window_clrtobot (void); void mutt_window_clrtoeol (struct MuttWindow *win); int mutt_window_move (struct MuttWindow *win, int row, int col); +void mutt_window_move_abs (int row, int col); int mutt_window_mvaddstr (struct MuttWindow *win, int row, int col, const char *str); int mutt_window_mvprintw (struct MuttWindow *win, int row, int col, const char *fmt, ...); diff --git a/pager.c b/pager.c index 5cc1e820e..bd0a680fc 100644 --- a/pager.c +++ b/pager.c @@ -1943,7 +1943,7 @@ static void pager_custom_redraw(struct Menu *pager_menu) { mutt_curses_set_color(MT_COLOR_NORMAL); /* clear() doesn't optimize screen redraws */ - move(0, 0); + mutt_window_move_abs(0, 0); mutt_window_clrtobot(); if (IsEmail(rd->extra) && Context && ((Context->mailbox->vcount + 1) < C_PagerIndexLines)) @@ -2341,7 +2341,7 @@ int mutt_pager(const char *banner, const char *fname, PagerFlags flags, struct P { if (braille_line != -1) { - move(braille_line + 1, 0); + mutt_window_move_abs(braille_line + 1, 0); braille_line = -1; } } diff --git a/sidebar.c b/sidebar.c index dd0e90b77..ba3521379 100644 --- a/sidebar.c +++ b/sidebar.c @@ -999,7 +999,7 @@ void mutt_sb_draw(void) } draw_sidebar(num_rows, num_cols, div_width); - move(y, x); + mutt_window_move_abs(y, x); } /**