X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-ui%2Fsidebar.c;h=238a5dd1b34e12532b1af5b8db0fd650a960b060;hp=e55537f76b730d0760b68f84f549e960879422fe;hb=f435868132e200bfa71ac155f037cf64bf5414ba;hpb=27c3007f2cfb52db5a357eaa2a8313a5ab03c93d diff --git a/lib-ui/sidebar.c b/lib-ui/sidebar.c index e55537f..238a5dd 100644 --- a/lib-ui/sidebar.c +++ b/lib-ui/sidebar.c @@ -12,10 +12,9 @@ * please see the file GPL in the top level source directory. */ -#include +#include #include -#include #include #include @@ -92,12 +91,14 @@ static char *shortened_hierarchy (char *hbox, int maxlen) return m_strdup(hbox); } -static const char* sidebar_number_format (char* dest, ssize_t destlen, char op, - const char* src, const char* fmt, - const char* ifstr, const char* elstr, - unsigned long data, format_flag flags) { +static const char * +sidebar_number_format(char* dest, ssize_t destlen, + char op, const char* src, const char* fmt, + const char* ifstr, const char* elstr, + anytype data, format_flag flags) +{ char tmp[STRING]; - BUFFY* b = Incoming.arr[data]; + BUFFY* b = Incoming.arr[data.i]; int opt = flags & M_FORMAT_OPTIONAL; int c = Context && !m_strcmp(Context->path, b->path); @@ -163,8 +164,8 @@ static const char* sidebar_number_format (char* dest, ssize_t destlen, char op, } if (flags & M_FORMAT_OPTIONAL) - m_strformat(dest, destlen, opt ? ifstr : elstr, sidebar_number_format, - data, flags); + m_strformat(dest, destlen, 0, opt ? ifstr : elstr, + sidebar_number_format, data, flags); return src; } @@ -184,7 +185,6 @@ static int make_sidebar_entry (char* sbox, int idx, ssize_t len) { int shortened = 0, lencnt = 0; char no[STRING], entry[STRING]; - int l = m_strlen(ImapHomeNamespace); int l_m = m_strlen(Maildir); if (SidebarWidth > COLS) @@ -197,14 +197,9 @@ static int make_sidebar_entry (char* sbox, int idx, ssize_t len) * (i.e. always display the currently opened) */ return 0; - m_strformat(no, len, NONULL(SidebarNumberFormat), sidebar_number_format, - idx, 0); + m_strformat(no, len, SidebarWidth, SidebarNumberFormat, sidebar_number_format, idx, 0); lencnt = m_strlen(no); - if (l > 0 && m_strncmp(sbox, ImapHomeNamespace, l) == 0 && - m_strlen(sbox) > l) - sbox += l + 1; /* we're trimming the ImapHomeNamespace, the "+ 1" is for the separator */ - else if (l_m > 0 && m_strncmp(sbox, Maildir, l_m) == 0 && m_strlen(sbox) > l_m) { sbox += l_m; @@ -221,7 +216,7 @@ static int make_sidebar_entry (char* sbox, int idx, ssize_t len) snprintf(entry, sizeof(entry), "%*s", (int)len, no); memcpy(entry, sbox, MIN(len - 1, m_strlen(sbox))); - addnstr(entry, len); + waddnstr(stdscr, entry, len); if (shortened) p_delete(&sbox); @@ -273,15 +268,11 @@ void sidebar_draw_frames (void) { /* draw vertical delimiter */ SETCOLOR (MT_COLOR_SIDEBAR); for (i = 0; i < LINES-1; i++) { - move (i, SidebarWidth - delim_len); - if (option (OPTASCIICHARS)) - addstr (NONULL (SidebarDelim)); - else if (!option (OPTASCIICHARS) && !m_strcmp(SidebarDelim, "|")) - addch (ACS_VLINE); - else if ((Charset_is_utf8) && !m_strcmp(SidebarDelim, "|")) - addstr ("\342\224\202"); + wmove (stdscr, i, SidebarWidth - delim_len); + if (!m_strcmp(SidebarDelim, "|")) + waddch (stdscr, ACS_VLINE); else - addstr (NONULL (SidebarDelim)); + waddstr (stdscr, NONULL (SidebarDelim)); } /* fill "gaps" at top+bottom */ @@ -292,16 +283,16 @@ void sidebar_draw_frames (void) { * gap with spaces to get bg color */ if (option(OPTSTATUSONTOP) || option(OPTHELP)) { - move(0,i); - addch(' '); + wmove(stdscr, 0,i); + waddch(stdscr, ' '); } /* * if we don't have $status_on_top or we have $help, fill bottom * gap with spaces to get bg color */ if (!option(OPTSTATUSONTOP) || option(OPTHELP)) { - move(LINES-2,i); - addch(' '); + wmove(stdscr, LINES-2,i); + waddch(stdscr, ' '); } } SETCOLOR (MT_COLOR_NORMAL); @@ -367,7 +358,7 @@ int sidebar_draw (void) { else SETCOLOR (MT_COLOR_NORMAL); - move (line, 0); + wmove (stdscr, line, 0); line += make_sidebar_entry (tmp->path, i, SidebarWidth-delim_len); } @@ -376,8 +367,8 @@ int sidebar_draw (void) { /* fill with blanks to bottom */ memset(&blank, ' ', sizeof(blank)); for (; line < last_line; line++) { - move (line, 0); - addnstr (blank, SidebarWidth-delim_len); + wmove (stdscr, line, 0); + waddnstr (stdscr, blank, SidebarWidth-delim_len); } return 0; }