customize this is of course the Mutt way. */
void mutt_need_hard_redraw (void)
{
- if (!getenv ("DISPLAY"))
- {
- keypad (stdscr, TRUE);
- clearok (stdscr, TRUE);
- set_option (OPTNEEDREDRAW);
- }
+ keypad (stdscr, TRUE);
+ clearok (stdscr, TRUE);
+ set_option (OPTNEEDREDRAW);
}
event_t mutt_getch (void)
{
int ch;
event_t err = {-1, OP_NULL }, ret;
+ event_t timeout = {-2, OP_NULL};
if (!option(OPTUNBUFFEREDINPUT) && UngetCount)
return (KeyEvent[--UngetCount]);
mutt_allow_interrupt (0);
if (SigInt)
+ {
mutt_query_exit ();
+ return err;
+ }
if(ch == ERR)
{
endwin ();
exit (1);
}
- return err;
+ return timeout;
}
if ((ch & 0x80) && option (OPTMETAKEY))
mutt_error (_("Error running \"%s\"!"), cmd);
mutt_sleep (2);
}
+#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
+ /* the terminal may have been resized while the editor owned it */
+ mutt_resize_screen ();
+#endif
keypad (stdscr, TRUE);
clearok (stdscr, TRUE);
}
answer[1] = 0;
reyes_ok = (expr = nl_langinfo (YESEXPR)) && expr[0] == '^' &&
- !regcomp (&reyes, expr, REG_NOSUB|REG_EXTENDED);
+ !REGCOMP (&reyes, expr, REG_NOSUB);
reno_ok = (expr = nl_langinfo (NOEXPR)) && expr[0] == '^' &&
- !regcomp (&reno, expr, REG_NOSUB|REG_EXTENDED);
+ !REGCOMP (&reno, expr, REG_NOSUB);
#endif
CLEARLINE(LINES-1);
answer_string = safe_malloc (COLS + 1);
snprintf (answer_string, COLS + 1, " ([%s]/%s): ", def == M_YES ? yes : no, def == M_YES ? no : yes);
answer_string_len = strlen (answer_string);
- printw ("%.*s%s", COLS - answer_string_len, msg, answer_string);
+ mutt_message ("%.*s%s", COLS - answer_string_len, msg, answer_string);
FREE (&answer_string);
FOREVER
ch = mutt_getch ();
if (CI_is_return (ch.ch))
break;
- if (ch.ch == -1)
+ if (ch.ch < 0)
{
def = -1;
break;
addstr ((char *) (def == M_YES ? yes : no));
mutt_refresh ();
}
+ else
+ {
+ /* when the users cancels with ^G, clear the message stored with
+ * mutt_message() so it isn't displayed when the screen is refreshed. */
+ mutt_clear_error();
+ }
return (def);
}
SigInt = 0;
}
-void mutt_curses_error (const char *fmt, ...)
+static void curses_message (int error, const char *fmt, va_list ap)
{
- va_list ap;
char scratch[LONG_STRING];
- va_start (ap, fmt);
vsnprintf (scratch, sizeof (scratch), fmt, ap);
- va_end (ap);
-
+
dprint (1, (debugfile, "%s\n", scratch));
mutt_format_string (Errorbuf, sizeof (Errorbuf),
- 0, COLS-2, FMT_LEFT, 0, scratch, sizeof (scratch), 0);
+ 0, COLS, FMT_LEFT, 0, scratch, sizeof (scratch), 0);
if (!option (OPTKEEPQUIET))
{
- BEEP ();
- SETCOLOR (MT_COLOR_ERROR);
+ if (error)
+ BEEP ();
+ SETCOLOR (error ? MT_COLOR_ERROR : MT_COLOR_MESSAGE);
mvaddstr (LINES-1, 0, Errorbuf);
clrtoeol ();
SETCOLOR (MT_COLOR_NORMAL);
mutt_refresh ();
}
- set_option (OPTMSGERR);
+ if (error)
+ set_option (OPTMSGERR);
+ else
+ unset_option (OPTMSGERR);
}
-void mutt_curses_message (const char *fmt, ...)
+void mutt_curses_error (const char *fmt, ...)
{
va_list ap;
- char scratch[LONG_STRING];
va_start (ap, fmt);
- vsnprintf (scratch, sizeof (scratch), fmt, ap);
+ curses_message (1, fmt, ap);
va_end (ap);
+}
- mutt_format_string (Errorbuf, sizeof (Errorbuf),
- 0, COLS-2, FMT_LEFT, 0, scratch, sizeof (scratch), 0);
-
- if (!option (OPTKEEPQUIET))
- {
- SETCOLOR (MT_COLOR_MESSAGE);
- mvaddstr (LINES - 1, 0, Errorbuf);
- clrtoeol ();
- SETCOLOR (MT_COLOR_NORMAL);
- mutt_refresh ();
- }
+void mutt_curses_message (const char *fmt, ...)
+{
+ va_list ap;
- unset_option (OPTMSGERR);
+ va_start (ap, fmt);
+ curses_message (0, fmt, ap);
+ va_end (ap);
}
void mutt_progress_init (progress_t* progress, const char *msg,
if (!progress)
return;
+ if (option(OPTNOCURSES))
+ return;
+
memset (progress, 0, sizeof (progress_t));
progress->inc = inc;
progress->flags = flags;
dprint (1, (debugfile, "gettimeofday failed: %d\n", errno));
/* if timestamp is 0 no time-based suppression is done */
if (TimeInc)
- progress->timestamp = tv.tv_sec * 1000 + tv.tv_usec / 1000;
+ progress->timestamp = ((unsigned int) tv.tv_sec * 1000)
+ + (unsigned int) (tv.tv_usec / 1000);
mutt_progress_update (progress, 0, 0);
}
struct timeval tv = { 0, 0 };
unsigned int now = 0;
+ if (option(OPTNOCURSES))
+ return;
+
if (!progress->inc)
goto out;
/* skip refresh if not enough time has passed */
if (update && progress->timestamp && !gettimeofday (&tv, NULL)) {
- now = tv.tv_sec * 1000 + tv.tv_usec / 1000;
+ now = ((unsigned int) tv.tv_sec * 1000)
+ + (unsigned int) (tv.tv_usec / 1000);
if (now && now - progress->timestamp < TimeInc)
update = 0;
}
if (update)
{
- dprint (1, (debugfile, "Updating progress: %ld\n", pos));
if (progress->flags & M_PROGRESS_SIZE)
{
pos = pos / (progress->inc << 10) * (progress->inc << 10);
}
else
snprintf (posstr, sizeof (posstr), "%ld", pos);
-
+
+ dprint (5, (debugfile, "updating progress: %s\n", posstr));
+
progress->pos = pos;
if (now)
progress->timestamp = now;
mutt_refresh ();
ch = mutt_getch();
- if (ch.ch == -1)
+ if (ch.ch < 0)
{
CLEARLINE (LINES-1);
return (-1);
{
mutt_refresh ();
ch = mutt_getch ();
- if (ch.ch == -1 || CI_is_return (ch.ch))
+ if (ch.ch < 0 || CI_is_return (ch.ch))
{
choice = -1;
break;
w = 1; /* hack */
else
{
+#ifdef HAVE_ISWBLANK
+ if (iswblank (wc))
+ wc = ' ';
+ else
+#endif
if (!IsWPrint (wc))
wc = '?';
w = wcwidth (wc);
min_width -= w;
max_width -= w;
strncpy (p, scratch, k2);
- p += k2;
+ p += k2;
destlen -= k2;
}
}
{
wchar_t wc;
int w = 0, l = 0, cl;
- size_t cw, n;
+ int cw, n;
mbstate_t mbstate;
if (!src)
if (cl == (size_t)(-1) || cl == (size_t)(-2))
cw = cl = 1;
else
+ {
cw = wcwidth (wc);
+ /* hack because M_TREE symbols aren't turned into characters
+ * until rendered by print_enriched_string (#3364) */
+ if (cw < 0 && cl == 1 && src[0] && src[0] < M_TREE_MAX)
+ cw = 1;
+ }
if (cl + l > maxlen || cw + w > maxwid)
break;
l += cl;