Encapsulate a curses function to reduce dependencies.
mutt_window_move(MuttMessageWindow, 0, 0);
mutt_curses_set_color(MT_COLOR_PROMPT);
- addnstr(msg, trunc_msg_len);
+ mutt_window_addnstr(msg, trunc_msg_len);
addstr(answer_string);
mutt_curses_set_color(MT_COLOR_NORMAL);
mutt_window_clrtoeol(MuttMessageWindow);
{
// write the part between prompt and cur using MT_COLOR_PROMPT
mutt_curses_set_color(MT_COLOR_PROMPT);
- addnstr(prompt, cur - prompt);
+ mutt_window_addnstr(prompt, cur - prompt);
if (isalnum(cur[1]) && (cur[2] == ')'))
{
{
if (w > n)
break;
- addnstr((char *) s, k);
+ mutt_window_addnstr((char *) s, k);
n -= w;
}
}
if ((chunks > 0) && (syntax[0].first > 0))
{
/* Text before the first highlight */
- addnstr(buf, MIN(len, syntax[0].first));
+ mutt_window_addnstr(buf, MIN(len, syntax[0].first));
attrset(ColorDefs[MT_COLOR_STATUS]);
if (len <= syntax[0].first)
goto dsl_finish; /* no more room */
{
/* Highlighted text */
attrset(syntax[i].color);
- addnstr(buf + offset, MIN(len, syntax[i].last) - offset);
+ mutt_window_addnstr(buf + offset, MIN(len, syntax[i].last) - offset);
if (len <= syntax[i].last)
goto dsl_finish; /* no more room */
attrset(ColorDefs[MT_COLOR_STATUS]);
offset = syntax[i].last;
- addnstr(buf + offset, next - offset);
+ mutt_window_addnstr(buf + offset, next - offset);
offset = next;
if (offset >= len)
if (offset < len)
{
/* Text after the last highlight */
- addnstr(buf + offset, len - offset);
+ mutt_window_addnstr(buf + offset, len - offset);
}
int width = mutt_strwidth(buf);
}
else if ((k = mbrtowc(&wc, (char *) s, n, &mbstate)) > 0)
{
- addnstr((char *) s, k);
+ mutt_window_addnstr((char *) s, k);
s += k;
n -= k;
}
/* The prototypes for these four functions use "(char*)",
* whereas the ncurses versions use "(const char*)" */
-#undef addnstr
#undef addstr
#undef mvaddnstr
#undef mvaddstr
/* We redefine the helper macros to hide the compiler warnings */
-#define addnstr(str, n) waddnstr(stdscr, ((char *) str), (n))
#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 addch(ch);
}
+
+/**
+ * mutt_window_addnstr - Write a partial string to a Window
+ * @param str String
+ * @param num Maximum number of characters to write
+ * @retval 0 Success
+ * @retval -1 Error
+ */
+int mutt_window_addnstr(const char *str, int num)
+{
+ if (!str)
+ return -1;
+
+#ifdef USE_SLANG_CURSES
+ return addnstr((char *) str, num);
+#else
+ return addnstr(str, num);
+#endif
+}
// Functions for drawing on the Window
int mutt_window_addch (int ch);
+int mutt_window_addnstr (const char *str, int num);
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);