X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=status.c;h=95ad3ffc9ee3e4932a623610cb9479ff80062ca5;hp=212b007ba6f7eeee4b2d06dd226cdee22353ef82;hb=d4483b5add8d25008c305b51729f4a53bccfaab8;hpb=364bf52ada05bf7d7158dba9d2391f63b71258f6 diff --git a/status.c b/status.c index 212b007..95ad3ff 100644 --- a/status.c +++ b/status.c @@ -11,6 +11,10 @@ # include "config.h" #endif +#include +#include +#include + #include "mutt.h" #include "mutt_menu.h" #include "mutt_curses.h" @@ -19,14 +23,13 @@ #include "mx.h" #include "buffy.h" -#include "lib/mem.h" -#include "lib/intl.h" -#include "lib/str.h" #include #include #include +#define SW (option(OPTMBOXPANE)?SidebarWidth:0) + static char *get_sort_str (char *buf, size_t buflen, int method) { snprintf (buf, buflen, "%s%s%s", @@ -60,7 +63,8 @@ static const char *status_format_str (char *buf, size_t buflen, char op, const char *elsestring, unsigned long data, format_flag flags) { - char fmt[SHORT_STRING], tmp[SHORT_STRING], *cp, *p; + char fmt[SHORT_STRING], tmp[SHORT_STRING]; + const char *cp, *p; int count, optional = (flags & M_FORMAT_OPTIONAL); MUTTMENU *menu = (MUTTMENU *) data; @@ -241,7 +245,7 @@ static const char *status_format_str (char *buf, size_t buflen, char op, if (!StChars) buf[0] = 0; - else if (i >= str_len (StChars)) + else if (i >= m_strlen(StChars)) buf[0] = StChars[0]; else buf[0] = StChars[i]; @@ -309,9 +313,13 @@ static const char *status_format_str (char *buf, size_t buflen, char op, return (src); } -void menu_status_line (char *buf, size_t buflen, MUTTMENU * menu, - const char *p) -{ - mutt_FormatString (buf, buflen, p, status_format_str, (unsigned long) menu, - 0); +void menu_status_line (char* buf, size_t len, MUTTMENU* menu, const char* p) { + /* + * if we have enough space for buffer, format lines to $COLS-$SidebarWidth + * only to not wrap past end of screen + */ + int width = COLS - SW; + mutt_FormatString (buf, (width >= len ? len : (width + 1)), + p, status_format_str, + (unsigned long) menu, 0); }