Only the input line remains in stdscr ... for now.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
static void alias_entry(char *s, ssize_t slen, MUTTMENU *m, int num)
{
- m_strformat(s, slen, COLS - SW, MAlias.alias_format, alias_format_str,
+ m_strformat(s, slen, getmaxx(main_w), MAlias.alias_format, alias_format_str,
((alias_t **)m->data)[num], 0);
}
#ifdef USE_NNTP
if (option (OPTNEWS))
- m_strformat(s, slen, COLS - SW, GroupFormat, newsgroup_format_str,
+ m_strformat(s, slen, getmaxx(main_w), GroupFormat, newsgroup_format_str,
&folder, 0);
else
#endif
- m_strformat(s, slen, COLS - SW, FolderFormat, folder_format_str,
+ m_strformat(s, slen, getmaxx(main_w), FolderFormat, folder_format_str,
&folder, 0);
}
buf);
#define extra_space (15 + 7 + 2)
- if (m_strwidth(prompt) > COLS - extra_space) {
- mutt_format_string(prompt, sizeof(prompt), 0, COLS - extra_space, 0, 0,
- prompt, sizeof(prompt), 0);
+ if (m_strwidth(prompt) > getmaxx(main_w) - extra_space) {
+ mutt_format_string(prompt, sizeof(prompt), 0,
+ getmaxx(main_w) - extra_space, 0, 0, prompt,
+ sizeof(prompt), 0);
m_strcat(prompt, sizeof(prompt), "...?");
} else {
m_strcat(prompt, sizeof(prompt), "?");
if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
address_list_wipe(&adr);
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
mutt_message (h ? _("Message not bounced.") : _("Messages not bounced."));
return;
}
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
rc = mutt_bounce_message (NULL, h, adr);
address_list_wipe(&adr);
if (!buf[0])
m_strcpy(buf, sizeof(buf), mod_core.shell);
if (buf[0]) {
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
mutt_endwin (NULL);
fflush (stdout);
if (mutt_system (buf) != 0 || option (OPTWAITKEY))
#define HDR_XOFFSET 14
#define TITLE_FMT "%14s" /* Used for Prompts, which are ASCII */
-#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
-#define W (COLS - HDR_XOFFSET - SW)
+#define W (getmaxx(main_w) - HDR_XOFFSET)
static const char *Prompts[] = {
"From: ",
};
static void snd_entry (char *b, ssize_t blen, MUTTMENU * menu, int num) {
- m_strformat(b, blen, COLS - SW, AttachFormat, mutt_attach_fmt,
+ m_strformat(b, blen, getmaxx(main_w), AttachFormat, mutt_attach_fmt,
((ATTACHPTR **)menu->data)[num], M_FORMAT_STAT_FILE);
}
int off = 0;
if (!msg->security)
- mvwaddstr (stdscr, HDR_CRYPT, SW, " Security: ");
+ mvwaddstr (main_w, HDR_CRYPT, 0, " Security: ");
else if (msg->security & APPLICATION_SMIME)
- mvwaddstr (stdscr, HDR_CRYPT, SW, " S/MIME: ");
+ mvwaddstr (main_w, HDR_CRYPT, 0, " S/MIME: ");
else if (msg->security & APPLICATION_PGP)
- mvwaddstr (stdscr, HDR_CRYPT, SW, " PGP: ");
+ mvwaddstr (main_w, HDR_CRYPT, 0, " PGP: ");
if ((msg->security & (ENCRYPT | SIGN)) == (ENCRYPT | SIGN))
- waddstr (stdscr, _("Sign, Encrypt"));
+ waddstr (main_w, _("Sign, Encrypt"));
else if (msg->security & ENCRYPT)
- waddstr (stdscr, _("Encrypt"));
+ waddstr (main_w, _("Encrypt"));
else if (msg->security & SIGN)
- waddstr (stdscr, _("Sign"));
+ waddstr (main_w, _("Sign"));
else
- waddstr (stdscr, _("Clear"));
+ waddstr (main_w, _("Clear"));
if ((msg->security & APPLICATION_PGP)
&& (msg->security & (ENCRYPT | SIGN))) {
if ((msg->security & INLINE))
- waddstr (stdscr, _(" (inline)"));
+ waddstr (main_w, _(" (inline)"));
else
- waddstr (stdscr, _(" (PGP/MIME)"));
+ waddstr (main_w, _(" (PGP/MIME)"));
}
- wclrtoeol (stdscr);
+ wclrtoeol (main_w);
- wmove (stdscr, HDR_CRYPTINFO, SW);
- wclrtoeol (stdscr);
+ wmove (main_w, HDR_CRYPTINFO, 0);
+ wclrtoeol (main_w);
if (msg->security & APPLICATION_PGP && msg->security & SIGN)
- wprintw (stdscr, "%s%s", _(" sign as: "),
+ wprintw (main_w, "%s%s", _(" sign as: "),
PgpSignAs ? PgpSignAs : _("<default>"));
if (msg->security & APPLICATION_SMIME && msg->security & SIGN) {
- wprintw (stdscr, "%s%s", _(" sign as: "),
+ wprintw (main_w, "%s%s", _(" sign as: "),
SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
}
if ((msg->security & APPLICATION_SMIME)
&& (msg->security & ENCRYPT)
&& SmimeCryptAlg && *SmimeCryptAlg) {
- mvwprintw (stdscr, HDR_CRYPTINFO, SW + 40, "%s%s", _("Encrypt with: "),
+ mvwprintw (main_w, HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
NONULL (SmimeCryptAlg));
off = 20;
}
buf[0] = 0;
rfc822_addrcat(buf, sizeof (buf), addr, 1);
- mvwprintw (stdscr, line, SW, TITLE_FMT, Prompts[line - 1]);
- mutt_paddstr (W, buf);
+ mvwprintw (main_w, line, 0, TITLE_FMT, Prompts[line - 1]);
+ mutt_paddstr (main_w, W, buf);
}
static void draw_envelope (HEADER * msg, char *fcc)
draw_envelope_addr (HDR_BCC, msg->env->bcc);
#ifdef USE_NNTP
} else {
- mvwprintw (stdscr, HDR_TO, SW, TITLE_FMT, Prompts[HDR_NEWSGROUPS - 1]);
- mutt_paddstr (W, NONULL (msg->env->newsgroups));
- mvwprintw (stdscr, HDR_CC, SW, TITLE_FMT, Prompts[HDR_FOLLOWUPTO - 1]);
- mutt_paddstr (W, NONULL (msg->env->followup_to));
+ mvwprintw (main_w, HDR_TO, 0, TITLE_FMT, Prompts[HDR_NEWSGROUPS - 1]);
+ mutt_paddstr (main_w, W, NONULL (msg->env->newsgroups));
+ mvwprintw (main_w, HDR_CC, 0, TITLE_FMT, Prompts[HDR_FOLLOWUPTO - 1]);
+ mutt_paddstr (main_w, W, NONULL (msg->env->followup_to));
}
#endif
- mvwprintw (stdscr, HDR_SUBJECT, SW, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
- mutt_paddstr (W, NONULL (msg->env->subject));
+ mvwprintw (main_w, HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
+ mutt_paddstr (main_w, W, NONULL (msg->env->subject));
draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
- mvwprintw (stdscr, HDR_FCC, SW, TITLE_FMT, Prompts[HDR_FCC - 1]);
- mutt_paddstr (W, fcc);
+ mvwprintw (main_w, HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
+ mutt_paddstr (main_w, W, fcc);
redraw_crypt_lines (msg);
- SETCOLOR (MT_COLOR_STATUS);
- mvwaddstr (stdscr, HDR_ATTACH - 1, SW, _("-- Attachments"));
- BKGDSET (MT_COLOR_STATUS);
- wclrtoeol (stdscr);
+ SETCOLOR(main_w, MT_COLOR_STATUS);
+ mvwaddstr (main_w, HDR_ATTACH - 1, 0, _("-- Attachments"));
+ BKGDSET(main_w, MT_COLOR_STATUS);
+ wclrtoeol (main_w);
- BKGDSET (MT_COLOR_NORMAL);
- SETCOLOR (MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
}
static int edit_address_list (int line, address_t ** addr)
/* redraw the expanded list so the user can see the result */
buf[0] = 0;
rfc822_addrcat(buf, sizeof (buf), *addr, 1);
- wmove (stdscr, line, HDR_XOFFSET + SW);
- mutt_paddstr (W, buf);
+ wmove (main_w, line, HDR_XOFFSET);
+ mutt_paddstr (main_w, W, buf);
return 0;
}
static void compose_status_line (char *buf, ssize_t buflen, MUTTMENU * menu,
const char *p)
{
- m_strformat(buf, buflen, COLS - SW, p, compose_format_str, menu, 0);
+ m_strformat(buf, buflen, getmaxx(main_w), p, compose_format_str, menu, 0);
}
/* return values:
p_delete(&msg->env->newsgroups);
m_strrtrim(buf);
msg->env->newsgroups = m_strdup(skipspaces(buf));
- wmove (stdscr, HDR_TO, HDR_XOFFSET);
- wclrtoeol (stdscr);
+ wmove (main_w, HDR_TO, HDR_XOFFSET);
+ wclrtoeol (main_w);
if (msg->env->newsgroups)
- wprintw (stdscr, "%-*.*s", W, W, msg->env->newsgroups);
+ wprintw (main_w, "%-*.*s", W, W, msg->env->newsgroups);
}
}
break;
p_delete(&msg->env->followup_to);
m_strrtrim(buf);
msg->env->followup_to = m_strdup(skipspaces(buf));
- wmove (stdscr, HDR_CC, HDR_XOFFSET);
- wclrtoeol (stdscr);
+ wmove (main_w, HDR_CC, HDR_XOFFSET);
+ wclrtoeol (main_w);
if (msg->env->followup_to)
- wprintw (stdscr, "%-*.*s", W, W, msg->env->followup_to);
+ wprintw (main_w, "%-*.*s", W, W, msg->env->followup_to);
}
}
break;
buf[0] = 0;
if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) {
m_strreplace(&msg->env->subject, buf);
- wmove (stdscr, HDR_SUBJECT, HDR_XOFFSET + SW);
- wclrtoeol (stdscr);
+ wmove (main_w, HDR_SUBJECT, HDR_XOFFSET);
+ wclrtoeol (main_w);
if (msg->env->subject)
- mutt_paddstr (W, msg->env->subject);
+ mutt_paddstr (main_w, W, msg->env->subject);
}
mutt_message_hook (NULL, msg, M_SEND2HOOK);
break;
if (mutt_get_field ("Fcc: ", buf, sizeof (buf), M_FILE | M_CLEAR) == 0) {
m_strcpy(fcc, _POSIX_PATH_MAX, buf);
mutt_pretty_mailbox (fcc);
- wmove (stdscr, HDR_FCC, HDR_XOFFSET + SW);
- mutt_paddstr (W, fcc);
+ wmove (main_w, HDR_FCC, HDR_XOFFSET);
+ mutt_paddstr (main_w, W, fcc);
fccSet = 1;
}
MAYBE_REDRAW (menu->redraw);
int itype;
FILE *fp;
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
fname[0] = 0;
if (mutt_get_field (_("New file: "), fname, sizeof (fname), M_FILE)
!= 0 || !fname[0])
/* Draw formated compose status line */
if (menu->redraw & REDRAW_STATUS) {
compose_status_line (buf, sizeof (buf), menu, NONULL (ComposeFormat));
- CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES - 2);
- SETCOLOR (MT_COLOR_STATUS);
- wmove (stdscr, option (OPTSTATUSONTOP) ? 0 : LINES - 2, SW);
- wprintw (stdscr, "%-*.*s", COLS-SW, COLS-SW, buf);
- SETCOLOR (MT_COLOR_NORMAL);
+ CLEARLINE(main_w, option (OPTSTATUSONTOP) ? 0 : LINES - 2);
+ SETCOLOR(main_w, MT_COLOR_STATUS);
+ wmove (main_w, option (OPTSTATUSONTOP) ? 0 : LINES - 2, 0);
+ wprintw (main_w, "%-*.*s", getmaxx(main_w), getmaxx(main_w), buf);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
menu->redraw &= ~REDRAW_STATUS;
}
}
entry.key = cryptkey_table[num];
entry.num = num + 1;
- m_strformat(s, l, COLS - SW, mod_crypt.pgp_entry_format, crypt_entry_fmt,
- &entry, 0);
+ m_strformat(s, l, getmaxx(main_w), mod_crypt.pgp_entry_format,
+ crypt_entry_fmt, &entry, 0);
}
/* Compare two addresses and the keyid to be used for sorting. */
int c;
- mvwprintw(stdscr, LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
+ mvwprintw(main_w, LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
bf ? _("Set flag") : _("Clear flag"));
- wclrtoeol(stdscr);
+ wclrtoeol(main_w);
c = mutt_getch().ch;
if (c == -1) {
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
return (-1);
}
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
if (c < 0 || c > countof(actions) || !actions[c]) {
BEEP();
p_clear(&stte, 1);
stte.s = s;
- stte.WrapMargin =
- ((s->flags & M_DISPLAY) ? (COLS - 4) : ((COLS - 4) <
- 72) ? (COLS - 4) : 72);
+ stte.WrapMargin = ((s->flags & M_DISPLAY) ? (getmaxx(main_w) - 4) :
+ ((getmaxx(main_w) - 4) < 72) ? (getmaxx(main_w) - 4) : 72);
stte.line_max = stte.WrapMargin * 4;
stte.line = p_new(char, stte.line_max + 1);
stte.param = p_new(char, STRING);
fputs (t1, f);
/* don't try to press string into one line with less than 40 characters. */
- if ((split = COLS < 40)) {
+ if ((split = getmaxx(main_w) < 40)) {
col_a = col = 0;
col_b = LONG_STRING;
fputc ('\n', f);
}
else {
- col_a = COLS > 83 ? (COLS - 32) >> 2 : 12;
- col_b = COLS > 49 ? (COLS - 10) >> 1 : 19;
+ col_a = getmaxx(main_w) > 83 ? (getmaxx(main_w) - 32) >> 2 : 12;
+ col_b = getmaxx(main_w) > 49 ? (getmaxx(main_w) - 10) >> 1 : 19;
col = pad (f, m_strlen(t1), col_a);
}
}
else {
while (*t3) {
- n = COLS - col;
+ n = getmaxx(main_w) - col;
if (ismacro >= 0) {
t3 = vskipspaces(t3);
/* FIXME: this is completely wrong */
- if ((n = m_strlen(t3)) > COLS - col) {
- n = COLS - col;
+ if ((n = m_strlen(t3)) > getmaxx(main_w) - col) {
+ n = getmaxx(main_w) - col;
for (col_a = n; col_a > 0 && t3[col_a] != ' '; col_a--);
if (col_a)
n = col_a;
print_macro (f, n, &t3);
if (*t3) {
- n += col - COLS;
+ n += col - getmaxx(main_w);
if (option (OPTMARKERS))
++n;
col = pad (f, n, col_b);
default:
v = mutt_yesorno(prompt, (v == M_ASKYES));
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
return (v);
}
}
default:
v = mutt_yesorno (prompt, (v == M_ASKYES));
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
return (v);
}
** \fTDelivered-To:\fP header fields when bouncing messages.
** Postfix users may wish to \fIunset\fP this variable.
*/
- { "braille_friendly", DT_BOOL, R_NONE, OPTBRAILLEFRIENDLY, "no" },
- /*
- ** .pp
- ** When this variable is set, mutt will place the cursor at the beginning
- ** of the current line in menus, even when the arrow_cursor variable
- ** is unset, making it easier for blind persons using Braille displays to
- ** follow these menus. The option is disabled by default because many
- ** visual terminals don't permit making the cursor invisible.
- */
{"check_new", DT_BOOL, R_NONE, OPTCHECKNEW, "yes" },
/*
** .pp
for (;;) {
/* ncurses doesn't return on resized screen when timeout is set to zero */
if (menu != MENU_EDITOR)
- wtimeout (stdscr, (Timeout > 0 ? Timeout : 60) * 1000);
+ wtimeout (main_w, (Timeout > 0 ? Timeout : 60) * 1000);
tmp = mutt_getch ();
if (menu != MENU_EDITOR)
- wtimeout (stdscr, -1); /* restore blocking operation */
+ wtimeout (main_w, -1); /* restore blocking operation */
LastKey = tmp.ch;
if (LastKey == -1)
width = MaxLineLength;
}
else {
- if (option (OPTMBOXPANE))
- width = COLS - SidebarWidth - WrapMargin - ql - 1;
- else
- width = COLS - WrapMargin - ql - 1;
+ width = getmaxx(main_w) - WrapMargin - ql - 1;
if (!(s->flags & M_REPLYING) && option (OPTSTUFFQUOTED))
--width;
if (width < 0)
- width = COLS;
+ width = getmaxx(main_w);
}
if (m_strlen(line) == 0) {
case SIGCONT:
if (!IsEndwin)
- wrefresh (stdscr);
+ refresh();
mutt_curs_set (-1);
/* We don't receive SIGWINCH when suspended; however, no harm is done by
* just assuming we received one, and triggering the 'resize' anyway. */
ColorDefs[object] = fgbgattr_to_color (fg, bg, attr);
if (object == MT_COLOR_NORMAL && !option (OPTNOCURSES) && has_colors ())
- BKGDSET (MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
return (r);
}
SigInt = 0;
mutt_allow_interrupt (1);
- ch = wgetch (stdscr);
+ ch = getch();
mutt_allow_interrupt (0);
if (SigInt)
return (ch == ctrl ('G') ? err : ret);
}
+#ifndef waddnwstr
+int waddwch(WINDOW *win, wchar_t wc)
+{
+ char buf[MB_LEN_MAX * 2];
+ mbstate_t mbstate;
+ ssize_t n1, n2;
+
+ p_clear(&mbstate, 1);
+ if ((n1 = wcrtomb(buf, wc, &mbstate)) == -1
+ || (n2 = wcrtomb(buf + n1, 0, &mbstate)) == -1)
+ return -1; /* ERR */
+ return waddstr(win, buf);
+}
+#endif
+
+
int _mutt_get_field ( const char *field, char *buf, ssize_t buflen,
int complete, int multiple, char ***files, int *numfiles)
{
ENTER_STATE *es = mutt_new_enter_state ();
do {
- CLEARLINE (LINES - 1);
+ CLEARLINE(stdscr, LINES - 1);
waddstr (stdscr, field);
mutt_refresh ();
getyx (stdscr, y, x);
ret = _mutt_enter_string(buf, buflen, y, x, complete, multiple, files,
numfiles, es);
} while (ret == 1);
- CLEARLINE (LINES - 1);
+ CLEARLINE(stdscr, LINES - 1);
mutt_free_enter_state (&es);
return (ret);
{
Errorbuf[0] = 0;
if (!option (OPTNOCURSES))
- CLEARLINE (LINES - 1);
+ CLEARLINE(stdscr, LINES - 1);
}
void mutt_edit_file(const char *data)
reno_ok = (expr = nl_langinfo (NOEXPR)) && expr[0] == '^' &&
!regcomp (&reno, expr, REG_NOSUB | REG_EXTENDED);
- CLEARLINE (LINES - 1);
+ CLEARLINE(stdscr, LINES - 1);
/*
* In order to prevent the default answer to the question to wrapped
* ensure there is enough room for the answer and truncate the question
* to fit.
*/
- answer_string = p_new(char, COLS + 1);
- snprintf (answer_string, COLS + 1, " ([%s]/%s): ", def == M_YES ? yes : no,
+ answer_string = p_new(char, getmaxx(stdscr) + 1);
+ snprintf (answer_string, getmaxx(stdscr) + 1, " ([%s]/%s): ", def == M_YES ? yes : no,
def == M_YES ? no : yes);
answer_string_len = m_strlen(answer_string);
- wprintw (stdscr, "%.*s%s", COLS - answer_string_len, msg, answer_string);
+ wprintw (stdscr, "%.*s%s", getmaxx(stdscr) - answer_string_len, msg, answer_string);
p_delete(&answer_string);
for (;;) {
va_end (ap);
mutt_format_string (TmpErrorbuf, sizeof (TmpErrorbuf),
- 0, COLS - 2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
+ 0, getmaxy(stdscr) - 2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
snprintf (Errorbuf, sizeof (Errorbuf), "%s", TmpErrorbuf); /* overkill */
if (!option (OPTKEEPQUIET)) {
BEEP ();
- SETCOLOR (MT_COLOR_ERROR);
+ SETCOLOR(stdscr, MT_COLOR_ERROR);
mvwaddstr (stdscr, LINES - 1, 0, Errorbuf);
wclrtoeol (stdscr);
- SETCOLOR (MT_COLOR_NORMAL);
+ SETCOLOR(stdscr, MT_COLOR_NORMAL);
mutt_refresh ();
}
va_end (ap);
mutt_format_string (TmpErrorbuf, sizeof (TmpErrorbuf),
- 0, COLS - 2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
+ 0, getmaxx(stdscr) - 2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
snprintf (Errorbuf, sizeof (Errorbuf), "%s", TmpErrorbuf); /* overkill */
if (!option (OPTKEEPQUIET)) {
- SETCOLOR (MT_COLOR_MESSAGE);
+ SETCOLOR(stdscr, MT_COLOR_MESSAGE);
mvwaddstr (stdscr, LINES - 1, 0, Errorbuf);
wclrtoeol (stdscr);
- SETCOLOR (MT_COLOR_NORMAL);
+ SETCOLOR(stdscr, MT_COLOR_NORMAL);
mutt_refresh ();
}
if (option (OPTKEEPQUIET))
return;
- SETCOLOR (option (OPTMSGERR) ? MT_COLOR_ERROR : MT_COLOR_MESSAGE);
- CLEARLINE (LINES - 1);
+ SETCOLOR(stdscr, option (OPTMSGERR) ? MT_COLOR_ERROR : MT_COLOR_MESSAGE);
+ CLEARLINE(stdscr, LINES - 1);
waddstr (stdscr, Errorbuf);
- SETCOLOR (MT_COLOR_NORMAL);
+ SETCOLOR(stdscr, MT_COLOR_NORMAL);
}
void curses_initialize(void)
{
ci_start_color();
- keypad(stdscr, TRUE);
+ keypad(stdscr, true);
cbreak();
noecho();
typeahead (-1); /* simulate smooth scrolling */
- meta(stdscr, TRUE);
+ meta(stdscr, true);
}
void _mutt_perror (const char *s, const char* filename, int line)
{
int ch;
- mvwprintw (stdscr, LINES - 1, 0, _("Enter keys (^G to abort): "));
+ mvwprintw(stdscr, LINES - 1, 0, _("Enter keys (^G to abort): "));
do {
- ch = wgetch (stdscr);
+ ch = getch();
if (ch != ERR && ch != ctrl ('G')) {
mutt_message (_("Char = %s, Octal = %o, Decimal = %d"),
km_keyname (ch), ch, ch);
{
event_t ch;
- mvwaddstr (stdscr, LINES - 1, 0, (char *) prompt);
- waddstr (stdscr, _(" ('?' for list): "));
+ mvwaddstr(stdscr, LINES - 1, 0, (char *) prompt);
+ waddstr(stdscr, _(" ('?' for list): "));
if (buf[0])
waddstr (stdscr, buf);
wclrtoeol (stdscr);
ch = mutt_getch ();
if (ch.ch == -1) {
- CLEARLINE (LINES - 1);
+ CLEARLINE(stdscr, LINES - 1);
return (-1);
}
else if (ch.ch == '?') {
}
BEEP ();
}
- CLEARLINE (LINES - 1);
+ CLEARLINE(stdscr, LINES - 1);
mutt_refresh ();
return choice;
}
-/*
- * addwch would be provided by an up-to-date curses library
- */
-
-int mutt_addwch (wchar_t wc)
-{
- char buf[MB_LEN_MAX * 2];
- mbstate_t mbstate;
- ssize_t n1, n2;
-
- p_clear(&mbstate, 1);
- if ((n1 = wcrtomb(buf, wc, &mbstate)) == -1 ||
- (n2 = wcrtomb(buf + n1, 0, &mbstate)) == -1)
- return -1; /* ERR */
- else
- return waddstr (stdscr, buf);
-}
-
ssize_t mutt_pretty_size(char *s, ssize_t len, ssize_t n)
{
if (n == 0)
/*
* mutt_paddstr (n, s) is almost equivalent to
- * mutt_format_string (bigbuf, big, n, n, 0, ' ', s, big, 0), waddstr (stdscr, bigbuf)
+ * mutt_format_string (bigbuf, big, n, n, 0, ' ', s, big, 0), waddstr (main_w, bigbuf)
*/
-void mutt_paddstr (int n, const char *s)
+void mutt_paddstr(WINDOW *win, int n, const char *s)
{
wchar_t wc;
int w;
if (w >= 0) {
if (w > n)
break;
- waddnstr (stdscr, (char *) s, k);
+ waddnstr(win, (char *) s, k);
n -= w;
}
}
while (n-- > 0)
- waddch (stdscr, ' ');
+ waddch(win, ' ');
}
#define CURHDR Context->hdrs[Context->v2r[menu->current]]
#define OLDHDR Context->hdrs[Context->v2r[menu->oldcurrent]]
#define UNREAD(h) mutt_thread_contains_unread (Context, h)
-#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
extern size_t UngetCount;
if (menu->redraw & REDRAW_STATUS) {
menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
- CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES - 2);
- SETCOLOR (MT_COLOR_STATUS);
- BKGDSET (MT_COLOR_STATUS);
- wmove(stdscr, option (OPTSTATUSONTOP) ? 0 : LINES - 2,SW);
- mutt_paddstr (COLS-SW, buf);
- SETCOLOR (MT_COLOR_NORMAL);
- BKGDSET (MT_COLOR_NORMAL);
+ CLEARLINE(main_w, option (OPTSTATUSONTOP) ? 0 : LINES - 2);
+ SETCOLOR(main_w, MT_COLOR_STATUS);
+ BKGDSET(main_w, MT_COLOR_STATUS);
+ wmove(main_w, option (OPTSTATUSONTOP) ? 0 : LINES - 2, 0);
+ mutt_paddstr (main_w, getmaxx(main_w), buf);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
sidebar_set_buffystats (Context);
menu->redraw &= ~REDRAW_STATUS;
if (option (OPTXTERMSETTITLES)) {
menu->oldcurrent = menu->current;
else
menu->oldcurrent = -1;
-
- if (option (OPTBRAILLEFRIENDLY))
- wmove (stdscr, menu->current - menu->top + menu->offset, 0);
- else
- wmove (stdscr, menu->current - menu->top + menu->offset, COLS - 1);
mutt_refresh ();
if (SigWinch) {
tag = 1;
/* give visual indication that the next command is a tag- command */
- mvwaddstr (stdscr, LINES - 1, 0, "tag-");
- wclrtoeol (stdscr);
+ mvwaddstr (main_w, LINES - 1, 0, "tag-");
+ wclrtoeol (main_w);
/* get the real command */
if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
/* abort tag sequence */
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
continue;
}
}
tag = 1;
/* give visual indication that the next command is a tag- command */
- mvwaddstr (stdscr, LINES - 1, 0, "tag-");
- wclrtoeol (stdscr);
+ mvwaddstr (main_w, LINES - 1, 0, "tag-");
+ wclrtoeol (main_w);
/* get the real command */
if ((op = km_dokey (MENU_MAIN)) == OP_TAG_PREFIX) {
/* abort tag sequence */
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
continue;
}
}
break;
case OP_REDRAW:
-
- clearok (stdscr, TRUE);
+ clearok (main_w, TRUE);
menu->redraw = REDRAW_FULL;
break;
break;
}
if (!buf[0]) {
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
break;
}
#undef lines
#endif /* lines */
-#define CLEARLINE_WIN(x) wmove(stdscr, x,(option(OPTMBOXPANE)?SidebarWidth:0)), wclrtoeol(stdscr)
-#define CLEARLINE(x) wmove(stdscr, x,0), wclrtoeol(stdscr)
-#define CENTERLINE(x,y) wmove(stdscr, y, (COLS-strlen(x))/2), waddstr(stdscr, x)
+#define CLEARLINE(W, x) wmove(W, x,0), wclrtoeol(W)
#define BEEP() do { if (mod_core.beep) beep(); } while (0)
-#define BKGDSET(x) wbkgdset(stdscr, ColorDefs[x] | ' ')
+#define BKGDSET(W, x) wbkgdset(W, ColorDefs[x] | ' ')
+#define SETCOLOR(W, X) wattrset(W, ColorDefs[X])
+#define ADDCOLOR(W, X) wattron(W, ColorDefs[X])
void mutt_curs_set (int);
-#define PAGELEN (LINES-3)
#define ctrl(c) ((c)-'@')
#endif
event_t mutt_getch (void);
+#ifndef waddnwstr
+int waddwch(WINDOW *win, wchar_t w);
+#else
+#define waddwch(win, w) waddnwstr(win, &(w), 1)
+#endif
void curses_initialize(void);
void curses_install(void);
void mutt_format_s (char *, ssize_t, const char *, const char *);
void mutt_format_s_tree (char *, ssize_t, const char *, const char *);
void mutt_free_color (int fg, int bg);
-void mutt_paddstr (int, const char *);
+void mutt_paddstr(WINDOW *, int, const char *);
#define mutt_perror(a) _mutt_perror (a, __FILE__, __LINE__)
void _mutt_perror (const char*, const char*,int);
void mutt_query_exit (void);
void mutt_show_error (void);
ssize_t mutt_pretty_size(char *s, ssize_t len, ssize_t n);
-int mutt_addwch (wchar_t);
int mutt_alloc_color (int fg, int bg);
int mutt_any_key_to_continue (const char *);
void mutt_what_key (void);
void _mutt_make_string (char *, ssize_t, const char *, CONTEXT *,
HEADER *, format_flag);
-
-#define WSETCOLOR(w, X) wattrset(w, ColorDefs[X])
-#define SETCOLOR(X) wattrset(stdscr, ColorDefs[X])
-#define ADDCOLOR(X) wattron(stdscr, ColorDefs[X])
-
#define MAYBE_REDRAW(x) if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); x = REDRAW_FULL; }
-#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
-
#endif /* !_MUTT_CURSES_H */
int n = wcwidth (wc);
if (iswprint(wc) && n > 0)
- return mutt_addwch (wc);
+ return waddwch(stdscr, wc);
if (!(wc & ~0x7f))
return wprintw (stdscr, "^%c", ((int) wc + 0x40) & 0x7f);
if (!(wc & ~0xffff))
hfi.hdr = hdr;
hfi.ctx = ctx;
- m_strformat(dest, destlen, COLS - SW, s, hdr_format_str, &hfi, flags);
+ m_strformat(dest, destlen, getmaxx(main_w), s, hdr_format_str, &hfi, flags);
}
void mutt_need_hard_redraw(void)
{
- keypad(stdscr, true);
- clearok(stdscr, true);
+ keypad(main_w, true);
+ clearok(main_w, true);
set_option(OPTNEEDREDRAW);
}
return;
/* else */
- wrefresh(stdscr);
if (sidebar_w)
- wrefresh(sidebar_w);
- wrefresh(main_w);
- main_w = NULL;
+ wnoutrefresh(sidebar_w);
+ if (main_w)
+ wnoutrefresh(main_w);
+ wrefresh(stdscr);
}
void mutt_endwin(const char *msg)
{
if (!option(OPTNOCURSES)) {
- CLEARLINE(LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
if (sidebar_w) {
delwin(sidebar_w);
sidebar_w = NULL;
}
+#if 0
if (main_w) {
delwin(main_w);
main_w = NULL;
}
+#endif
wattrset(stdscr, A_NORMAL);
mutt_refresh();
void ui_layout_init(void)
{
- SETCOLOR(MT_COLOR_NORMAL);
- wclear(stdscr);
+ main_w = newwin(LINES - 1, COLS, 0, 0);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ wclear(main_w);
mutt_error = mutt_curses_error;
mutt_message = mutt_curses_message;
-
- main_w = newwin(LINES - 1, COLS, 0, 0);
}
void ui_layout_resize(void)
resizeterm(rows, cols);
SigWinch = 0;
/* force a real complete redraw. */
- clearok(stdscr, true);
+ clearok(main_w, true);
}
}
if (!sidebar_w) {
sidebar_w = newwin(LINES - 1, SidebarWidth, 0, 0);
wresize(main_w, LINES - 1, COLS - SidebarWidth);
+ mvwin(main_w, 0, SidebarWidth);
}
getmaxyx(sidebar_w, sh, sw);
if (sh != LINES - 1 || sw != SidebarWidth) {
wresize(sidebar_w, LINES - 1, SidebarWidth);
wresize(main_w, LINES - 1, COLS - SidebarWidth);
+ mvwin(main_w, 0, SidebarWidth);
}
} else {
if (sidebar_w) {
delwin(sidebar_w);
sidebar_w = NULL;
wresize(main_w, LINES - 1, COLS);
+ mvwin(main_w, 0, 0);
}
}
return sidebar_w;
#include <imap/imap.h>
#include <lib-ui/sidebar.h>
-#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
-
extern size_t UngetCount;
static void print_enriched_string (int attr, unsigned char *s, int do_color)
while (*s) {
if (*s < M_TREE_MAX) {
if (do_color)
- SETCOLOR (MT_COLOR_TREE);
+ SETCOLOR(main_w, MT_COLOR_TREE);
while (*s && *s < M_TREE_MAX) {
switch (*s) {
case M_TREE_LLCORNER:
- waddch (stdscr, ACS_LLCORNER);
+ waddch (main_w, ACS_LLCORNER);
break;
case M_TREE_ULCORNER:
- waddch (stdscr, ACS_ULCORNER);
+ waddch (main_w, ACS_ULCORNER);
break;
case M_TREE_LTEE:
- waddch (stdscr, ACS_LTEE);
+ waddch (main_w, ACS_LTEE);
break;
case M_TREE_HLINE:
- waddch (stdscr, ACS_HLINE);
+ waddch (main_w, ACS_HLINE);
break;
case M_TREE_VLINE:
- waddch (stdscr, ACS_VLINE);
+ waddch (main_w, ACS_VLINE);
break;
case M_TREE_TTEE:
- waddch (stdscr, ACS_TTEE);
+ waddch (main_w, ACS_TTEE);
break;
case M_TREE_BTEE:
- waddch (stdscr, ACS_BTEE);
+ waddch (main_w, ACS_BTEE);
break;
case M_TREE_SPACE:
- waddch (stdscr, ' ');
+ waddch (main_w, ' ');
break;
case M_TREE_RARROW:
- waddch (stdscr, '>');
+ waddch (main_w, '>');
break;
case M_TREE_STAR:
- waddch (stdscr, '*'); /* fake thread indicator */
+ waddch (main_w, '*'); /* fake thread indicator */
break;
case M_TREE_HIDDEN:
- waddch (stdscr, '&');
+ waddch (main_w, '&');
break;
case M_TREE_EQUALS:
- waddch (stdscr, '=');
+ waddch (main_w, '=');
break;
case M_TREE_MISSING:
- waddch (stdscr, '?');
+ waddch (main_w, '?');
break;
}
s++, n--;
}
if (do_color)
- wattrset (stdscr, attr);
+ wattrset (main_w, attr);
}
else if ((k = mbrtowc (&wc, (char *) s, n, &mbstate)) != (size_t)-1) {
- waddnstr (stdscr, (char *) s, k);
+ waddnstr (main_w, (char *) s, k);
s += k, n -= k;
}
else
static void menu_pad_string (char *s, size_t n)
{
- int cols = COLS - SW;
+ int cols = getmaxx(main_w);
char *tmpbuf = p_new(char, n);
mutt_format_string (tmpbuf, n, cols, cols, 0, ' ', s, m_strlen(s), 1);
void menu_redraw_full (MUTTMENU * menu)
{
- SETCOLOR (MT_COLOR_NORMAL);
- /* wclear(stdscr) doesn't optimize screen redraws */
- wmove (stdscr, 0, 0);
- wclrtobot (stdscr);
-
- SETCOLOR (MT_COLOR_STATUS);
- wmove (stdscr, option (OPTSTATUSONTOP) ? LINES - 2 : 0, SW);
- mutt_paddstr (COLS-SW, "");
- SETCOLOR (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ /* wclear() doesn't optimize screen redraws */
+ wmove (main_w, 0, 0);
+ wclrtobot (main_w);
+
+ SETCOLOR(main_w, MT_COLOR_STATUS);
+ wmove (main_w, option (OPTSTATUSONTOP) ? LINES - 2 : 0, 0);
+ mutt_paddstr (main_w, getmaxx(main_w), "");
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
menu->offset = 1;
menu->pagelen = LINES - 3;
mutt_show_error ();
char buf[STRING];
snprintf (buf, sizeof (buf), M_MODEFMT, menu->title);
- SETCOLOR (MT_COLOR_STATUS);
- wmove (stdscr, option (OPTSTATUSONTOP) ? 0 : LINES - 2, SW);
- mutt_paddstr (COLS-SW, buf);
- SETCOLOR (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_STATUS);
+ wmove (main_w, option (OPTSTATUSONTOP) ? 0 : LINES - 2, 0);
+ mutt_paddstr (main_w, getmaxx(main_w), buf);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
menu->redraw &= ~REDRAW_STATUS;
}
menu_make_entry (buf, sizeof (buf), menu, i);
menu_pad_string (buf, sizeof (buf));
- wattrset (stdscr, menu->color (i));
+ wattrset (main_w, menu->color (i));
if (i == menu->current) {
- ADDCOLOR (MT_COLOR_INDICATOR);
- BKGDSET (MT_COLOR_INDICATOR);
+ ADDCOLOR(main_w, MT_COLOR_INDICATOR);
+ BKGDSET(main_w, MT_COLOR_INDICATOR);
}
- CLEARLINE_WIN (i - menu->top + menu->offset);
+ CLEARLINE(main_w, i - menu->top + menu->offset);
- wmove (stdscr, i - menu->top + menu->offset, SW);
+ wmove (main_w, i - menu->top + menu->offset, 0);
print_enriched_string (menu->color (i), (unsigned char *) buf,
i != menu->current);
- SETCOLOR (MT_COLOR_NORMAL);
- BKGDSET (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
} else {
- CLEARLINE_WIN (i - menu->top + menu->offset);
+ CLEARLINE(main_w, i - menu->top + menu->offset);
}
}
sidebar_draw ();
return;
}
- wmove (stdscr, menu->oldcurrent + menu->offset - menu->top, SW);
- SETCOLOR (MT_COLOR_NORMAL);
- BKGDSET (MT_COLOR_NORMAL);
+ wmove (main_w, menu->oldcurrent + menu->offset - menu->top, 0);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
/* erase the current indicator */
- wattrset (stdscr, menu->color (menu->oldcurrent));
- wclrtoeol (stdscr);
+ wattrset (main_w, menu->color (menu->oldcurrent));
+ wclrtoeol (main_w);
menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
menu_pad_string (buf, sizeof (buf));
print_enriched_string (menu->color (menu->oldcurrent),
/* now draw the new one to reflect the change */
menu_make_entry (buf, sizeof (buf), menu, menu->current);
menu_pad_string (buf, sizeof (buf));
- wattrset (stdscr, menu->color (menu->current));
- ADDCOLOR (MT_COLOR_INDICATOR);
- BKGDSET (MT_COLOR_INDICATOR);
- CLEARLINE_WIN (menu->current - menu->top + menu->offset);
- wmove (stdscr, menu->current + menu->offset - menu->top, SW);
+ wattrset (main_w, menu->color (menu->current));
+ ADDCOLOR(main_w, MT_COLOR_INDICATOR);
+ BKGDSET(main_w, MT_COLOR_INDICATOR);
+ CLEARLINE(main_w, menu->current - menu->top + menu->offset);
+ wmove (main_w, menu->current + menu->offset - menu->top, 0);
print_enriched_string (menu->color (menu->current), (unsigned char *) buf,
0);
- SETCOLOR (MT_COLOR_NORMAL);
- BKGDSET (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
menu->redraw &= REDRAW_STATUS;
}
{
char buf[STRING];
- wmove (stdscr, menu->current + menu->offset - menu->top, SW);
+ wmove (main_w, menu->current + menu->offset - menu->top, 0);
menu_make_entry (buf, sizeof (buf), menu, menu->current);
menu_pad_string (buf, sizeof (buf));
- wattrset (stdscr, menu->color (menu->current));
- ADDCOLOR (MT_COLOR_INDICATOR);
- BKGDSET (MT_COLOR_INDICATOR);
- wclrtoeol (stdscr);
+ wattrset (main_w, menu->color (menu->current));
+ ADDCOLOR(main_w, MT_COLOR_INDICATOR);
+ BKGDSET(main_w, MT_COLOR_INDICATOR);
+ wclrtoeol (main_w);
print_enriched_string (menu->color (menu->current), (unsigned char *) buf,
0);
- SETCOLOR (MT_COLOR_NORMAL);
- BKGDSET (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
menu->redraw &= REDRAW_STATUS;
}
if (*Errorbuf)
mutt_clear_error ();
- SETCOLOR (MT_COLOR_NORMAL);
- mvwaddstr (stdscr, LINES - 1, 0, menu->prompt);
- wclrtoeol (stdscr);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ mvwaddstr (main_w, LINES - 1, 0, menu->prompt);
+ wclrtoeol (main_w);
}
}
p->top = 0;
p->offset = 1;
p->redraw = REDRAW_FULL;
- p->pagelen = PAGELEN;
+ p->pagelen = LINES - 3;
p->color = default_color;
p->search = menu_search_generic;
return (p);
return OP_REDRAW;
menu->oldcurrent = menu->current;
-
- if (option (OPTBRAILLEFRIENDLY))
- wmove (stdscr, menu->current - menu->top + menu->offset, SW);
- else
- wmove (stdscr, menu->current - menu->top + menu->offset, COLS - 1);
-
mutt_refresh ();
-
/* try to catch dialog keys before ops */
if (menu->dialog && menu_dialog_dokey (menu, &i) == 0)
return i;
i = km_dokey (menu->menu);
if (i == OP_TAG_PREFIX || i == OP_TAG_PREFIX_COND) {
if (menu->tagged) {
- mvwaddstr (stdscr, LINES - 1, 0, "Tag-");
- wclrtoeol (stdscr);
+ mvwaddstr (main_w, LINES - 1, 0, "Tag-");
+ wclrtoeol (main_w);
i = km_dokey (menu->menu);
menu->tagprefix = 1;
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
}
else if (i == OP_TAG_PREFIX) {
mutt_error _("No tagged entries.");
break;
case OP_REDRAW:
- clearok (stdscr, TRUE);
+ clearok (main_w, TRUE);
menu->redraw = REDRAW_FULL;
break;
memset(&blank, ' ', sizeof(blank));
wmove(sw, 0, 0);
- WSETCOLOR(sw, MT_COLOR_STATUS);
+ SETCOLOR(sw, MT_COLOR_STATUS);
waddnstr(sw, blank, x);
line = 1;
BUFFY *tmp = Incoming.arr[i];
if (i == CurBuffy)
- WSETCOLOR(sw, MT_COLOR_INDICATOR);
+ SETCOLOR(sw, MT_COLOR_INDICATOR);
else if (tmp->new > 0)
- WSETCOLOR(sw, MT_COLOR_NEW);
+ SETCOLOR(sw, MT_COLOR_NEW);
else if (tmp->msg_flagged > 0)
- WSETCOLOR(sw, MT_COLOR_FLAGGED);
+ SETCOLOR(sw, MT_COLOR_FLAGGED);
else
- WSETCOLOR(sw, MT_COLOR_NORMAL);
+ SETCOLOR(sw, MT_COLOR_NORMAL);
if (make_sidebar_entry(sw, tmp->path, i, x - 1)) {
- WSETCOLOR(sw, MT_COLOR_SIDEBAR);
+ SETCOLOR(sw, MT_COLOR_SIDEBAR);
waddch(sw, ACS_VLINE);
line++;
}
}
while (line < y - 1) {
- WSETCOLOR(sw, MT_COLOR_NORMAL);
+ SETCOLOR(sw, MT_COLOR_NORMAL);
waddnstr(sw, blank, x - 1);
- WSETCOLOR(sw, MT_COLOR_SIDEBAR);
+ SETCOLOR(sw, MT_COLOR_SIDEBAR);
waddch(sw, ACS_VLINE);
line++;
}
- WSETCOLOR(sw, MT_COLOR_STATUS);
+ SETCOLOR(sw, MT_COLOR_STATUS);
waddnstr(sw, blank, x);
- WSETCOLOR(sw, MT_COLOR_NORMAL);
+ SETCOLOR(sw, MT_COLOR_NORMAL);
return 0;
}
#include "sort.h"
#include "buffy.h"
-#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
-
static char *get_sort_str (char *buf, ssize_t buflen, int method)
{
snprintf (buf, buflen, "%s%s%s",
void menu_status_line(char* buf, ssize_t len, MUTTMENU* menu, const char* p)
{
- m_strformat(buf, len, COLS - SW, p, status_format_str, menu, 0);
+ m_strformat(buf, len, getmaxx(main_w), p, status_format_str, menu, 0);
}
OPTAUTOEDIT,
OPTAUTOTAG,
OPTBOUNCEDELIVERED,
- OPTBRAILLEFRIENDLY,
OPTCHECKNEW,
OPTCOLLAPSEUNREAD,
OPTCONFIRMAPPEND,
}
}
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
return (ret);
}
#define IsSendAttach(x) (x && (x)->bdy && !(x)->fp)
#define IsMsgAttach(x) (x && (x)->fp && (x)->bdy && (x)->bdy->hdr)
#define IsHeader(x) (x && (x)->hdr && !(x)->bdy)
-#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
/* hack to return to position when returning from index to same message */
static int TopLine = 0;
int search = 0, i, m;
if (!cnt)
- last_color = -1; /* force wattrset(stdscr) */
+ last_color = -1; /* force wattrset(main_w) */
if (lineInfo[n].continuation) {
if (!cnt && option (OPTMARKERS)) {
- SETCOLOR (MT_COLOR_MARKERS);
- waddch (stdscr, '+');
+ SETCOLOR(main_w, MT_COLOR_MARKERS);
+ waddch(main_w, '+');
last_color = ColorDefs[MT_COLOR_MARKERS];
}
m = (lineInfo[n].syntax)[0].first;
}
if (color != last_color) {
- wattrset (stdscr, color);
+ wattrset(main_w, color);
last_color = color;
}
}
return class;
}
-static int brailleLine = -1;
static int brailleCol = -1;
static int check_attachment_marker (char *);
if (n == 0 || ISHEADER (lineInfo[n - 1].type)) {
if (buf[0] == '\n') {
lineInfo[n].type = MT_COLOR_NORMAL;
- getyx(stdscr, brailleLine, brailleCol);
}
else if (n > 0 && (buf[0] == ' ' || buf[0] == '\t')) {
lineInfo[n].type = lineInfo[n - 1].type; /* wrapped line */
wchar_t wc;
mbstate_t mbstate;
- int wrap_cols = COLS;
+ int wrap_cols = getmaxx(main_w);
if (!(flags & (M_SHOWFLAT)))
wrap_cols -= WrapMargin;
- wrap_cols -= SW;
if (wrap_cols <= 0)
- wrap_cols = COLS;
+ wrap_cols = getmaxx(main_w);
/* FIXME: this should come from lineInfo */
p_clear(&mbstate, 1);
break;
col += 4;
if (pa)
- wprintw (stdscr, "\\%03o", buf[ch]);
+ wprintw(main_w, "\\%03o", buf[ch]);
k = 1;
continue;
}
break;
col += t;
if (pa)
- mutt_addwch (wc);
+ waddwch(main_w, wc);
}
else if (wc == '\n')
break;
break;
if (pa)
for (; col < t; col++)
- waddch (stdscr, ' ');
+ waddch(main_w, ' ');
else
col = t;
}
break;
col += 2;
if (pa)
- wprintw (stdscr, "^%c", ('@' + wc) & 0x7f);
+ wprintw(main_w, "^%c", ('@' + wc) & 0x7f);
}
else if (wc < 0x100) {
if (col + 4 > wrap_cols)
break;
col += 4;
if (pa)
- wprintw (stdscr, "\\%03o", wc);
+ wprintw(main_w, "\\%03o", wc);
} else {
if (col + 1 > wrap_cols)
break;
++col;
if (pa)
- waddch (stdscr, CharsetReplacement);
+ waddch(main_w, CharsetReplacement);
}
}
*pspace = space;
format_line (lineInfo, n, buf, flags, &a, cnt, &ch, &vch, &col, &special);
/* end the last color pattern (needed by S-Lang) */
- if (special || (col != COLS && (flags & (M_SHOWCOLOR | M_SEARCH))))
- resolve_color (*lineInfo, n, vch, flags, 0, &a);
+ if (special || (col != getmaxx(main_w) && (flags & (M_SHOWCOLOR | M_SEARCH))))
+ resolve_color(*lineInfo, n, vch, flags, 0, &a);
/*
* Fill the blank space at the end of the line with the prevailing color.
- * ncurses does an implicit wclrtoeol(stdscr) when you do waddch(stdscr,
+ * ncurses does an implicit wclrtoeol(main_w) when you do waddch(main_w,
* '\n') so we have to make sure to reset the color *after* that
*/
if (flags & M_SHOWCOLOR) {
else
def_color = ColorDefs[(*lineInfo)[m].type];
- wattrset (stdscr, def_color);
- wbkgdset (stdscr, def_color | ' ');
+ wattrset(main_w, def_color);
+ wbkgdset(main_w, def_color | ' ');
}
- waddch (stdscr, '\n');
+ waddch(main_w, '\n');
/*
* reset the color back to normal. This *must* come after the
- * waddch(stdscr, '\n'), otherwise the color for this line will not be
+ * waddch(main_w, '\n'), otherwise the color for this line will not be
* filled to the right margin.
*/
if (flags & M_SHOWCOLOR) {
- SETCOLOR (MT_COLOR_NORMAL);
- BKGDSET (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
}
/* build a return code */
imap_keepalive ();
if (redraw & REDRAW_FULL) {
- SETCOLOR (MT_COLOR_NORMAL);
- /* wclear(stdscr) doesn't optimize screen redraws */
- wmove (stdscr, 0, 0);
- wclrtobot (stdscr);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ /* wclear(main_w) doesn't optimize screen redraws */
+ wmove(main_w, 0, 0);
+ wclrtobot(main_w);
if (IsHeader (extra) && Context->vcount + 1 < PagerIndexLines)
indexlen = Context->vcount + 1;
bodylen = statusoffset - bodyoffset;
}
- SETCOLOR (MT_COLOR_STATUS);
- wmove (stdscr, helpoffset, SW);
- mutt_paddstr (COLS-SW, "");
- SETCOLOR (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_STATUS);
+ wmove(main_w, helpoffset, 0);
+ mutt_paddstr(main_w, getmaxx(main_w), "");
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
if (Resize != NULL) {
if ((SearchCompiled = Resize->SearchCompiled)) {
pager_index->current = extra->hdr->virtual;
}
- SETCOLOR (MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
pager_index->offset = indexoffset + (option (OPTSTATUSONTOP) ? 1 : 0);
pager_index->pagelen = indexlen - 1;
if ((redraw & REDRAW_BODY) || topline != oldtopline) {
do {
- wmove (stdscr, bodyoffset, SW);
+ wmove(main_w, bodyoffset, 0);
curline = oldtopline = topline;
lines = 0;
force_redraw = 0;
&SearchRE) > 0)
lines++;
curline++;
- wmove (stdscr, lines + bodyoffset, SW);
+ wmove(main_w, lines + bodyoffset, 0);
redraw |= REDRAW_SIDEBAR;
}
last_offset = lineInfo[curline].offset;
} while (force_redraw);
- SETCOLOR (MT_COLOR_TILDE);
- BKGDSET (MT_COLOR_TILDE);
+ SETCOLOR(main_w, MT_COLOR_TILDE);
+ BKGDSET(main_w, MT_COLOR_TILDE);
while (lines < bodylen) {
- wclrtoeol (stdscr);
+ wclrtoeol(main_w);
if (option (OPTTILDE))
- waddch (stdscr, '~');
- waddch (stdscr, '\n');
+ waddch(main_w, '~');
+ waddch(main_w, '\n');
lines++;
- wmove (stdscr, lines + bodyoffset, SW);
+ wmove(main_w, lines + bodyoffset, 0);
}
/* We are going to update the pager status bar, so it isn't
* necessary to reset to normal color now. */
if (redraw & REDRAW_STATUS) {
/* print out the pager status bar */
- SETCOLOR (MT_COLOR_STATUS);
- BKGDSET (MT_COLOR_STATUS);
- CLEARLINE_WIN (statusoffset);
+ SETCOLOR(main_w, MT_COLOR_STATUS);
+ BKGDSET(main_w, MT_COLOR_STATUS);
+ wmove(main_w, statusoffset, 0);
+ wclrtoeol(main_w);
if (IsHeader (extra)) {
- size_t l1 = (COLS - 9) * MB_LEN_MAX;
+ size_t l1 = (getmaxx(main_w) - 9) * MB_LEN_MAX;
size_t l2 = sizeof (buffer);
_mutt_make_string (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt),
Context, extra->hdr, M_FORMAT_MAKEPRINT);
}
else if (IsMsgAttach (extra)) {
- size_t l1 = (COLS - 9) * MB_LEN_MAX;
+ size_t l1 = (getmaxx(main_w) - 9) * MB_LEN_MAX;
size_t l2 = sizeof (buffer);
_mutt_make_string (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt),
Context, extra->bdy->hdr, M_FORMAT_MAKEPRINT);
}
- wmove(stdscr, statusoffset,SW);
- mutt_paddstr (COLS - 10 - SW, IsHeader (extra) ||
- IsMsgAttach (extra) ? buffer : banner);
+ wmove(main_w, statusoffset, 0);
+ mutt_paddstr(main_w, getmaxx(main_w) - 10,
+ IsHeader(extra) || IsMsgAttach(extra) ? buffer : banner);
- waddstr (stdscr, " -- (");
+ waddstr(main_w, " -- (");
if (last_pos < sb.st_size - 1)
- wprintw (stdscr, "%d%%)", (int) (100 * last_offset / sb.st_size));
+ wprintw(main_w, "%d%%)", (int) (100 * last_offset / sb.st_size));
else
- waddstr (stdscr, topline == 0 ? "all)" : "end)");
- BKGDSET (MT_COLOR_NORMAL);
- SETCOLOR (MT_COLOR_NORMAL);
+ waddstr(main_w, topline == 0 ? "all)" : "end)");
+ BKGDSET(main_w, MT_COLOR_NORMAL);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
}
if (redraw & REDRAW_SIDEBAR)
sidebar_draw ();
/* print out the pager_index status bar */
menu_status_line (buffer, sizeof (buffer), pager_index, NONULL (Status));
- wmove (stdscr, indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SW);
- SETCOLOR (MT_COLOR_STATUS);
- BKGDSET (MT_COLOR_STATUS);
- mutt_paddstr (COLS-SW, buffer);
- SETCOLOR (MT_COLOR_NORMAL);
- BKGDSET (MT_COLOR_NORMAL);
+ wmove(main_w, indexoffset + (option(OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
+ SETCOLOR(main_w, MT_COLOR_STATUS);
+ BKGDSET(main_w, MT_COLOR_STATUS);
+ mutt_paddstr(main_w, getmaxx(main_w), buffer);
+ SETCOLOR(main_w, MT_COLOR_NORMAL);
+ BKGDSET(main_w, MT_COLOR_NORMAL);
}
/* if we're not using the index, update every time */
if (index == 0)
sidebar_draw ();
redraw = 0;
-
- if (option(OPTBRAILLEFRIENDLY)) {
- if (brailleLine!=-1) {
- wmove(stdscr, brailleLine+1, 0);
- brailleLine = -1;
- }
- } else
- wmove (stdscr, statusoffset, COLS-1);
- mutt_refresh ();
+ mutt_refresh();
if (IsHeader (extra) && OldHdr == extra->hdr && TopLine != topline
&& lineInfo[curline].offset < sb.st_size-1) {
break;
case OP_REDRAW:
- clearok (stdscr, TRUE);
+ clearok(main_w, TRUE);
redraw = REDRAW_FULL;
break;
#include "attach.h"
#include "copy.h"
-#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
-
void mutt_update_tree (ATTACHPTR ** idx, short idxlen)
{
char buf[STRING];
static void attach_entry(char *b, ssize_t blen, MUTTMENU * menu, int num)
{
- m_strformat(b, blen, COLS - SW, AttachFormat, mutt_attach_fmt,
+ m_strformat(b, blen, getmaxx(main_w), AttachFormat, mutt_attach_fmt,
((ATTACHPTR **) menu->data)[num], 0);
}
_("WARNING! You are about to overwrite %s, continue?"),
body->filename);
if (mutt_yesorno (warning, M_NO) != M_YES) {
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
return;
}
tempfd = m_tempfd(tfile, sizeof(tfile), NONULL(mod_core.tmpdir), NULL);
buf);
#define extra_space (15+7+2)
- if (m_strwidth(prompt) > COLS - extra_space) {
- mutt_format_string (prompt, sizeof (prompt) - 4,
- 0, COLS - extra_space, 0, 0,
+ if (m_strwidth(prompt) > getmaxx(main_w) - extra_space) {
+ mutt_format_string (prompt, sizeof (prompt) - 4, 0,
+ getmaxx(main_w) - extra_space, 0, 0,
prompt, sizeof (prompt), 0);
m_strcat(prompt, sizeof(prompt), "...?");
} else {
if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) {
address_list_wipe(&adr);
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
mutt_message (p ? _("Message not bounced.") : _("Messages not bounced."));
return;
}
- CLEARLINE (LINES - 1);
+ CLEARLINE(main_w, LINES - 1);
if (cur)
ret = mutt_bounce_message (fp, cur->hdr, adr);