From c8bd15377ed657b7afbed1f74c6b052e06b19d23 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Wed, 27 Apr 2016 17:56:58 -0700 Subject: [PATCH] Fix remaining direct usages of COLS/LINES to use mutt window functions. Most of these were just message update/clearing. --- buffy.c | 3 ++- commands.c | 10 +++++----- flags.c | 9 +++++---- handler.c | 3 ++- help.c | 10 +++++----- init.c | 2 +- keymap.c | 2 +- mutt_curses.h | 4 ++-- muttlib.c | 2 +- recvattach.c | 2 +- recvcmd.c | 8 ++++---- sendlib.c | 4 ++-- 12 files changed, 31 insertions(+), 28 deletions(-) diff --git a/buffy.c b/buffy.c index c713d160..dd3def0f 100644 --- a/buffy.c +++ b/buffy.c @@ -511,7 +511,8 @@ int mutt_buffy_list (void) strfcpy (path, tmp->path, sizeof (path)); mutt_pretty_mailbox (path, sizeof (path)); - if (!first && (COLS - 7 >= 0) && (pos + strlen (path) >= (size_t)COLS - 7)) + if (!first && (MuttMessageWindow->cols >= 7) && + (pos + strlen (path) >= (size_t)MuttMessageWindow->cols - 7)) break; if (!first) diff --git a/commands.c b/commands.c index 2a0cdc9c..38c54748 100644 --- a/commands.c +++ b/commands.c @@ -309,10 +309,10 @@ void ci_bounce_message (HEADER *h, int *redraw) snprintf (scratch, sizeof (scratch), (h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf); - if (mutt_strwidth (prompt) > COLS - extra_space) + if (mutt_strwidth (prompt) > MuttMessageWindow->cols - extra_space) { mutt_format_string (prompt, sizeof (prompt), - 0, COLS-extra_space, FMT_LEFT, 0, + 0, MuttMessageWindow->cols-extra_space, FMT_LEFT, 0, scratch, sizeof (scratch), 0); safe_strcat (prompt, sizeof (prompt), "...?"); } @@ -322,12 +322,12 @@ void ci_bounce_message (HEADER *h, int *redraw) if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) { rfc822_free_address (&adr); - CLEARLINE (LINES - 1); + mutt_window_clearline (MuttMessageWindow, 0); mutt_message (h ? _("Message not bounced.") : _("Messages not bounced.")); return; } - CLEARLINE (LINES - 1); + mutt_window_clearline (MuttMessageWindow, 0); rc = mutt_bounce_message (NULL, h, adr); rfc822_free_address (&adr); @@ -598,7 +598,7 @@ void mutt_shell_escape (void) strfcpy (buf, Shell, sizeof (buf)); if(buf[0]) { - CLEARLINE (LINES-1); + mutt_window_clearline (MuttMessageWindow, 0); mutt_endwin (NULL); fflush (stdout); if (mutt_system (buf) != 0 || option (OPTWAITKEY)) diff --git a/flags.c b/flags.c index f0f3d812..f34b3755 100644 --- a/flags.c +++ b/flags.c @@ -322,18 +322,19 @@ int mutt_change_flag (HEADER *h, int bf) int i, flag; event_t event; - mvprintw (LINES - 1, 0, "%s? (D/N/O/r/*/!): ", bf ? _("Set flag") : _("Clear flag")); - clrtoeol (); + mutt_window_mvprintw (MuttMessageWindow, 0, 0, + "%s? (D/N/O/r/*/!): ", bf ? _("Set flag") : _("Clear flag")); + mutt_window_clrtoeol (MuttMessageWindow); event = mutt_getch(); i = event.ch; if (i < 0) { - CLEARLINE (LINES-1); + mutt_window_clearline (MuttMessageWindow, 0); return (-1); } - CLEARLINE (LINES-1); + mutt_window_clearline (MuttMessageWindow, 0); switch (i) { diff --git a/handler.c b/handler.c index 4944d49a..670b27bb 100644 --- a/handler.c +++ b/handler.c @@ -791,7 +791,8 @@ static int text_enriched_handler (BODY *a, STATE *s) memset (&stte, 0, sizeof (stte)); stte.s = s; - stte.WrapMargin = ((s->flags & M_DISPLAY) ? (COLS-4) : ((COLS-4)<72)?(COLS-4):72); + stte.WrapMargin = ((s->flags & M_DISPLAY) ? (MuttIndexWindow->cols-4) : + ((MuttIndexWindow->cols-4)<72)?(MuttIndexWindow->cols-4):72); stte.line_max = stte.WrapMargin * 4; stte.line = (wchar_t *) safe_calloc (1, (stte.line_max + 1) * sizeof (wchar_t)); stte.param = (wchar_t *) safe_calloc (1, (STRING) * sizeof (wchar_t)); diff --git a/help.c b/help.c index c48c68f4..3f0cf953 100644 --- a/help.c +++ b/help.c @@ -209,7 +209,7 @@ static void format_line (FILE *f, int ismacro, /* don't try to press string into one line with less than 40 characters. The double parenthesis avoids a gcc warning, sigh ... */ - if ((split = COLS < 40)) + if ((split = MuttIndexWindow->cols < 40)) { col_a = col = 0; col_b = LONG_STRING; @@ -217,8 +217,8 @@ static void format_line (FILE *f, int ismacro, } else { - col_a = COLS > 83 ? (COLS - 32) >> 2 : 12; - col_b = COLS > 49 ? (COLS - 10) >> 1 : 19; + col_a = MuttIndexWindow->cols > 83 ? (MuttIndexWindow->cols - 32) >> 2 : 12; + col_b = MuttIndexWindow->cols > 49 ? (MuttIndexWindow->cols - 10) >> 1 : 19; col = pad (f, mutt_strwidth(t1), col_a); } @@ -252,7 +252,7 @@ static void format_line (FILE *f, int ismacro, { while (*t3) { - n = COLS - col; + n = MuttIndexWindow->cols - col; if (ismacro >= 0) { @@ -271,7 +271,7 @@ static void format_line (FILE *f, int ismacro, } else { - n += col - COLS; + n += col - MuttIndexWindow->cols; if (option (OPTMARKERS)) ++n; } diff --git a/init.c b/init.c index 209cf578..e82795f6 100644 --- a/init.c +++ b/init.c @@ -113,7 +113,7 @@ int query_quadoption (int opt, const char *prompt) default: v = mutt_yesorno (prompt, (v == M_ASKYES)); - CLEARLINE (LINES - 1); + mutt_window_clearline (MuttMessageWindow, 0); return (v); } diff --git a/keymap.c b/keymap.c index 43a90504..3e287325 100644 --- a/keymap.c +++ b/keymap.c @@ -1129,7 +1129,7 @@ void mutt_what_key (void) { int ch; - mvprintw(LINES-1,0, _("Enter keys (^G to abort): ")); + mutt_window_mvprintw (MuttMessageWindow, 0, 0, _("Enter keys (^G to abort): ")); do { ch = getch(); if (ch != ERR && ch != ctrl ('G')) diff --git a/mutt_curses.h b/mutt_curses.h index 1156c4ac..d3efd70c 100644 --- a/mutt_curses.h +++ b/mutt_curses.h @@ -64,8 +64,8 @@ #undef lines #endif /* lines */ -#define CLEARLINE(x) move(x,0), clrtoeol() -#define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x) +#define CLEARLINE(win,x) mutt_window_clearline(win, x) +#define CENTERLINE(win,x,y) mutt_window_move(win, y, (win->cols-strlen(x))/2), addstr(x) #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0) #if ! (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET)) diff --git a/muttlib.c b/muttlib.c index 9096590e..b18e3d91 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1573,7 +1573,7 @@ int mutt_save_confirm (const char *s, struct stat *st) } } - CLEARLINE (LINES-1); + mutt_window_clearline (MuttMessageWindow, 0); return (ret); } diff --git a/recvattach.c b/recvattach.c index 5424eda0..0669038b 100644 --- a/recvattach.c +++ b/recvattach.c @@ -590,7 +590,7 @@ mutt_query_pipe_attachment (char *command, FILE *fp, BODY *body, int filter) _("WARNING! You are about to overwrite %s, continue?"), body->filename); if (mutt_yesorno (warning, M_NO) != M_YES) { - CLEARLINE (LINES-1); + mutt_window_clearline (MuttMessageWindow, 0); return; } mutt_mktemp (tfile, sizeof (tfile)); diff --git a/recvcmd.c b/recvcmd.c index 13cb3a65..45c0c261 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -203,10 +203,10 @@ void mutt_attach_bounce (FILE * fp, HEADER * hdr, snprintf (prompt, sizeof (prompt) - 4, (p ? _("Bounce message to %s") : _("Bounce messages to %s")), buf); - if (mutt_strwidth (prompt) > COLS - extra_space) + if (mutt_strwidth (prompt) > MuttMessageWindow->cols - extra_space) { mutt_format_string (prompt, sizeof (prompt) - 4, - 0, COLS-extra_space, FMT_LEFT, 0, + 0, MuttMessageWindow->cols-extra_space, FMT_LEFT, 0, prompt, sizeof (prompt), 0); safe_strcat (prompt, sizeof (prompt), "...?"); } @@ -216,12 +216,12 @@ void mutt_attach_bounce (FILE * fp, HEADER * hdr, if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) { rfc822_free_address (&adr); - CLEARLINE (LINES - 1); + mutt_window_clearline (MuttMessageWindow, 0); mutt_message (p ? _("Message not bounced.") : _("Messages not bounced.")); return; } - CLEARLINE (LINES - 1); + mutt_window_clearline (MuttMessageWindow, 0); if (cur) ret = mutt_bounce_message (fp, cur->hdr, adr); diff --git a/sendlib.c b/sendlib.c index e6b6a793..48c61522 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1856,8 +1856,8 @@ int mutt_write_one_header (FILE *fp, const char *tag, const char *value, else wraplen = WrapHeaders; } - else if (wraplen <= 0 || wraplen > COLS) - wraplen = COLS; + else if (wraplen <= 0 || wraplen > MuttIndexWindow->cols) + wraplen = MuttIndexWindow->cols; if (tag) { -- 2.40.0