Encapsulate a curses function to reduce dependencies.
if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
{
- addstr(_("Not supported"));
+ mutt_window_addstr(_("Not supported"));
return;
}
if ((e->security & (SEC_ENCRYPT | SEC_SIGN)) == (SEC_ENCRYPT | SEC_SIGN))
{
mutt_curses_set_color(MT_COLOR_COMPOSE_SECURITY_BOTH);
- addstr(_("Sign, Encrypt"));
+ mutt_window_addstr(_("Sign, Encrypt"));
}
else if (e->security & SEC_ENCRYPT)
{
mutt_curses_set_color(MT_COLOR_COMPOSE_SECURITY_ENCRYPT);
- addstr(_("Encrypt"));
+ mutt_window_addstr(_("Encrypt"));
}
else if (e->security & SEC_SIGN)
{
mutt_curses_set_color(MT_COLOR_COMPOSE_SECURITY_SIGN);
- addstr(_("Sign"));
+ mutt_window_addstr(_("Sign"));
}
else
{
/* L10N: This refers to the encryption of the email, e.g. "Security: None" */
mutt_curses_set_color(MT_COLOR_COMPOSE_SECURITY_NONE);
- addstr(_("None"));
+ mutt_window_addstr(_("None"));
}
mutt_curses_set_color(MT_COLOR_NORMAL);
if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & APPLICATION_PGP))
{
if ((e->security & SEC_INLINE))
- addstr(_(" (inline PGP)"));
+ mutt_window_addstr(_(" (inline PGP)"));
else
- addstr(_(" (PGP/MIME)"));
+ mutt_window_addstr(_(" (PGP/MIME)"));
}
else if (((WithCrypto & APPLICATION_SMIME) != 0) && (e->security & APPLICATION_SMIME))
- addstr(_(" (S/MIME)"));
+ mutt_window_addstr(_(" (S/MIME)"));
}
if (C_CryptOpportunisticEncrypt && (e->security & SEC_OPPENCRYPT))
- addstr(_(" (OppEnc mode)"));
+ mutt_window_addstr(_(" (OppEnc mode)"));
mutt_window_clrtoeol(rd->win);
mutt_window_move(rd->win, HDR_CRYPTINFO, 0);
if (e->security & SEC_AUTOCRYPT)
{
mutt_curses_set_color(MT_COLOR_COMPOSE_SECURITY_ENCRYPT);
- addstr(_("Encrypt"));
+ mutt_window_addstr(_("Encrypt"));
}
else
{
mutt_curses_set_color(MT_COLOR_COMPOSE_SECURITY_NONE);
- addstr(_("Off"));
+ mutt_window_addstr(_("Off"));
}
mutt_curses_set_color(MT_COLOR_COMPOSE_HEADER);
if (STAILQ_EMPTY(chain))
{
- addstr(_("<no chain defined>"));
+ mutt_window_addstr(_("<no chain defined>"));
mutt_window_clrtoeol(rd->win);
return;
}
if (c + mutt_str_strlen(t) + 2 >= rd->win->cols)
break;
- addstr(NONULL(t));
+ mutt_window_addstr(NONULL(t));
if (STAILQ_NEXT(np, entries))
- addstr(", ");
+ mutt_window_addstr(", ");
c += mutt_str_strlen(t) + 2;
}
}
mutt_window_clearline(MuttMessageWindow, 0);
mutt_curses_set_color(MT_COLOR_PROMPT);
- addstr(field);
+ mutt_window_addstr(field);
mutt_curses_set_color(MT_COLOR_NORMAL);
mutt_refresh();
mutt_window_getxy(MuttMessageWindow, &x, NULL);
mutt_window_move(MuttMessageWindow, 0, 0);
mutt_curses_set_color(MT_COLOR_PROMPT);
mutt_window_addnstr(msg, trunc_msg_len);
- addstr(answer_string);
+ mutt_window_addstr(answer_string);
mutt_curses_set_color(MT_COLOR_NORMAL);
mutt_window_clrtoeol(MuttMessageWindow);
}
if (def != MUTT_ABORT)
{
- addstr((char *) ((def == MUTT_YES) ? yes : no));
+ mutt_window_addstr((char *) ((def == MUTT_YES) ? yes : no));
mutt_refresh();
}
else
mutt_curses_set_color(MT_COLOR_PROMPT);
mutt_window_mvaddstr(MuttMessageWindow, 0, 0, prompt);
- addstr(_(" ('?' for list): "));
+ mutt_window_addstr(_(" ('?' for list): "));
mutt_curses_set_color(MT_COLOR_NORMAL);
if (!mutt_buffer_is_empty(fname))
- addstr(mutt_b2s(fname));
+ mutt_window_addstr(mutt_b2s(fname));
mutt_window_clrtoeol(MuttMessageWindow);
mutt_refresh();
}
mutt_curses_set_color(MT_COLOR_PROMPT);
- addstr(prompt);
+ mutt_window_addstr(prompt);
mutt_curses_set_color(MT_COLOR_NORMAL);
mutt_window_addch(' ');
}
else
{
- return addstr(buf);
+ return mutt_window_addstr(buf);
}
}
if (verbose)
{
snprintf(tmp, sizeof(tmp), "\"%s\" %lu bytes\n", path, (unsigned long) sb.st_size);
- addstr(tmp);
+ mutt_window_addstr(tmp);
}
mutt_file_fclose(&fp);
}
else
{
snprintf(tmp, sizeof(tmp), "%s: %s\n", path, strerror(errno));
- addstr(tmp);
+ mutt_window_addstr(tmp);
}
return buf;
}
FILE *fp = fopen(path, "w");
if (!fp)
{
- addstr(strerror(errno));
+ mutt_window_addstr(strerror(errno));
mutt_window_addch('\n');
return -1;
}
if (!TAILQ_EMPTY(&env->to))
{
- addstr("To: ");
+ mutt_window_addstr("To: ");
tmp[0] = '\0';
mutt_addrlist_write(tmp, sizeof(tmp), &env->to, true);
- addstr(tmp);
+ mutt_window_addstr(tmp);
mutt_window_addch('\n');
}
if (!TAILQ_EMPTY(&env->cc))
{
- addstr("Cc: ");
+ mutt_window_addstr("Cc: ");
tmp[0] = '\0';
mutt_addrlist_write(tmp, sizeof(tmp), &env->cc, true);
- addstr(tmp);
+ mutt_window_addstr(tmp);
mutt_window_addch('\n');
}
if (!TAILQ_EMPTY(&env->bcc))
{
- addstr("Bcc: ");
+ mutt_window_addstr("Bcc: ");
tmp[0] = '\0';
mutt_addrlist_write(tmp, sizeof(tmp), &env->bcc, true);
- addstr(tmp);
+ mutt_window_addstr(tmp);
mutt_window_addch('\n');
}
if (env->subject)
{
- addstr("Subject: ");
- addstr(env->subject);
+ mutt_window_addstr("Subject: ");
+ mutt_window_addstr(env->subject);
mutt_window_addch('\n');
}
mutt_window_addch('\n');
mutt_window_move(MuttMessageWindow, 0, 0);
- addstr("To: ");
+ mutt_window_addstr("To: ");
tmp[0] = '\0';
mutt_addrlist_to_local(&e->to);
mutt_addrlist_write(tmp, sizeof(tmp), &e->to, false);
else
{
mutt_addrlist_to_intl(&e->to, NULL); /* XXX - IDNA error reporting? */
- addstr(tmp);
+ mutt_window_addstr(tmp);
}
mutt_window_addch('\n');
if (!e->subject || force)
{
- addstr("Subject: ");
+ mutt_window_addstr("Subject: ");
mutt_str_strfcpy(tmp, e->subject ? e->subject : "", sizeof(tmp));
if (mutt_enter_string(tmp, sizeof(tmp), 9, MUTT_COMP_NO_FLAGS) == 0)
mutt_str_replace(&e->subject, tmp);
if ((TAILQ_EMPTY(&e->cc) && C_Askcc) || force)
{
- addstr("Cc: ");
+ mutt_window_addstr("Cc: ");
tmp[0] = '\0';
mutt_addrlist_to_local(&e->cc);
mutt_addrlist_write(tmp, sizeof(tmp), &e->cc, false);
if (C_Askbcc || force)
{
- addstr("Bcc: ");
+ mutt_window_addstr("Bcc: ");
tmp[0] = '\0';
mutt_addrlist_to_local(&e->bcc);
mutt_addrlist_write(tmp, sizeof(tmp), &e->bcc, false);
be_edit_header(e_new->env, false);
- addstr(_("(End message with a . on a line by itself)\n"));
+ mutt_window_addstr(_("(End message with a . on a line by itself)\n"));
buf = be_snarf_file(path, buf, &bufmax, &buflen, false);
switch (tmp[1])
{
case '?':
- addstr(_(EditorHelp1));
- addstr(_(EditorHelp2));
+ mutt_window_addstr(_(EditorHelp1));
+ mutt_window_addstr(_(EditorHelp2));
break;
case 'b':
mutt_addrlist_parse2(&e_new->env->bcc, p);
(isupper((unsigned char) tmp[1])));
}
else
- addstr(_("No mailbox.\n"));
+ mutt_window_addstr(_("No mailbox.\n"));
break;
case 'p':
- addstr("-----\n");
- addstr(_("Message contains:\n"));
+ mutt_window_addstr("-----\n");
+ mutt_window_addstr(_("Message contains:\n"));
be_print_header(e_new->env);
for (int i = 0; i < buflen; i++)
- addstr(buf[i]);
+ mutt_window_addstr(buf[i]);
/* L10N: This entry is shown AFTER the message content,
not IN the middle of the content.
So it doesn't mean "(message will continue)"
but means "(press any key to continue using neomutt)". */
- addstr(_("(continue)\n"));
+ mutt_window_addstr(_("(continue)\n"));
break;
case 'q':
done = true;
buf = be_snarf_file(tmp, buf, &bufmax, &buflen, true);
}
else
- addstr(_("missing filename.\n"));
+ mutt_window_addstr(_("missing filename.\n"));
break;
case 's':
mutt_str_replace(&e_new->env->subject, p);
continue;
}
else
- addstr(_("No lines in message.\n"));
+ mutt_window_addstr(_("No lines in message.\n"));
break;
case 'e':
buf = be_snarf_file(path, buf, &bufmax, &buflen, false);
- addstr(_("(continue)\n"));
+ mutt_window_addstr(_("(continue)\n"));
}
break;
case 'w':
add_wch(WACS_LLCORNER);
#else
else if (CharsetIsUtf8)
- addstr("\342\224\224"); /* WACS_LLCORNER */
+ mutt_window_addstr("\342\224\224"); /* WACS_LLCORNER */
else
mutt_window_addch(ACS_LLCORNER);
#endif
add_wch(WACS_ULCORNER);
#else
else if (CharsetIsUtf8)
- addstr("\342\224\214"); /* WACS_ULCORNER */
+ mutt_window_addstr("\342\224\214"); /* WACS_ULCORNER */
else
mutt_window_addch(ACS_ULCORNER);
#endif
add_wch(WACS_LTEE);
#else
else if (CharsetIsUtf8)
- addstr("\342\224\234"); /* WACS_LTEE */
+ mutt_window_addstr("\342\224\234"); /* WACS_LTEE */
else
mutt_window_addch(ACS_LTEE);
#endif
add_wch(WACS_HLINE);
#else
else if (CharsetIsUtf8)
- addstr("\342\224\200"); /* WACS_HLINE */
+ mutt_window_addstr("\342\224\200"); /* WACS_HLINE */
else
mutt_window_addch(ACS_HLINE);
#endif
add_wch(WACS_VLINE);
#else
else if (CharsetIsUtf8)
- addstr("\342\224\202"); /* WACS_VLINE */
+ mutt_window_addstr("\342\224\202"); /* WACS_VLINE */
else
mutt_window_addch(ACS_VLINE);
#endif
add_wch(WACS_TTEE);
#else
else if (CharsetIsUtf8)
- addstr("\342\224\254"); /* WACS_TTEE */
+ mutt_window_addstr("\342\224\254"); /* WACS_TTEE */
else
mutt_window_addch(ACS_TTEE);
#endif
add_wch(WACS_BTEE);
#else
else if (CharsetIsUtf8)
- addstr("\342\224\264"); /* WACS_BTEE */
+ mutt_window_addstr("\342\224\264"); /* WACS_BTEE */
else
mutt_window_addch(ACS_BTEE);
#endif
mutt_curses_set_color(MT_COLOR_INDICATOR);
if (C_ArrowCursor)
{
- addstr("->");
+ mutt_window_addstr("->");
mutt_curses_set_attr(attr);
mutt_window_addch(' ');
}
do_color = false;
}
else if (C_ArrowCursor)
- addstr(" ");
+ mutt_window_addstr(" ");
print_enriched_string(i, attr, (unsigned char *) buf, do_color);
}
if (C_ArrowCursor)
{
/* clear the pointer */
- addstr(" ");
+ mutt_window_addstr(" ");
if (menu->redraw & REDRAW_MOTION_RESYNC)
{
mutt_curses_set_color(MT_COLOR_INDICATOR);
if (C_ArrowCursor)
{
- addstr("->");
+ mutt_window_addstr("->");
mutt_curses_set_attr(attr);
mutt_window_addch(' ');
menu_pad_string(menu, buf, sizeof(buf));
/* The prototypes for these four functions use "(char*)",
* whereas the ncurses versions use "(const char*)" */
-#undef addstr
#undef mvaddnstr
#undef mvaddstr
/* We redefine the helper macros to hide the compiler warnings */
-#define addstr(x) waddstr(stdscr, ((char *) x))
#define mvaddnstr(y, x, str, n) mvwaddnstr(stdscr, (y), (x), ((char *) str), (n))
#define mvaddstr(y, x, str) mvwaddstr(stdscr, (y), (x), ((char *) str))
return addnstr(str, num);
#endif
}
+
+/**
+ * mutt_window_addstr - Write a string to a Window
+ * @param str String
+ * @retval 0 Success
+ * @retval -1 Error
+ */
+int mutt_window_addstr(const char *str)
+{
+ if (!str)
+ return -1;
+
+#ifdef USE_SLANG_CURSES
+ return addstr((char *) str);
+#else
+ return addstr(str);
+#endif
+}
// Functions for drawing on the Window
int mutt_window_addch (int ch);
int mutt_window_addnstr (const char *str, int num);
+int mutt_window_addstr (const char *str);
void mutt_window_clearline(struct MuttWindow *win, int row);
void mutt_window_clrtoeol (struct MuttWindow *win);
int mutt_window_move (struct MuttWindow *win, int row, int col);
if (ColorDefs[MT_COLOR_PROGRESS] == 0)
{
- addstr(buf2);
+ mutt_window_addstr(buf2);
}
else
{
{
/* The string fits within the colour bar */
mutt_curses_set_color(MT_COLOR_PROGRESS);
- addstr(buf2);
+ mutt_window_addstr(buf2);
w -= l;
while (w-- > 0)
{
char ch = buf2[off];
buf2[off] = '\0';
mutt_curses_set_color(MT_COLOR_PROGRESS);
- addstr(buf2);
+ mutt_window_addstr(buf2);
buf2[off] = ch;
mutt_curses_set_color(MT_COLOR_NORMAL);
- addstr(&buf2[off]);
+ mutt_window_addstr(&buf2[off]);
}
}
mutt_curses_set_color(MT_COLOR_NORMAL);
if (i + 1 < chain->cl)
- addstr(", ");
+ mutt_window_addstr(", ");
}
}
switch (altchar)
{
case SB_DIV_USER:
- addstr(NONULL(C_SidebarDividerChar));
+ mutt_window_addstr(NONULL(C_SidebarDividerChar));
break;
case SB_DIV_ASCII:
mutt_window_addch('|');