X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=sidebar.c;h=a1a3b5b077039dd1c2d44948b58ceb7b406b53a3;hb=adc81e1c9e43c57bf03f51f12b8d38a9aea5905d;hp=c352913b345261e7b73b2970f400bee29b671507;hpb=0d23a37d51884266b694d3a94300ddb5c3faf4fa;p=apps%2Fmadmutt.git diff --git a/sidebar.c b/sidebar.c index c352913..a1a3b5b 100644 --- a/sidebar.c +++ b/sidebar.c @@ -67,7 +67,7 @@ static char *shortened_hierarchy (char *box) int i, j; char *new_box; - for (i = 0; i < mutt_strlen (box); ++i) { + for (i = 0; i < safe_strlen (box); ++i) { if (box[i] == '.') ++dots; else if (isupper (box[i])) @@ -76,9 +76,9 @@ static char *shortened_hierarchy (char *box) last_dot = strrchr (box, '.'); if (last_dot) { ++last_dot; - new_box = safe_malloc (mutt_strlen (last_dot) + 2 * dots + 1); + new_box = safe_malloc (safe_strlen (last_dot) + 2 * dots + 1); new_box[0] = box[0]; - for (i = 1, j = 1; i < mutt_strlen (box); ++i) { + for (i = 1, j = 1; i < safe_strlen (box); ++i) { if (box[i] == '.') { new_box[j++] = '.'; new_box[j] = 0; @@ -108,17 +108,17 @@ char *make_sidebar_entry (char *box, int size, int new, int flagged) if (SidebarWidth > COLS) SidebarWidth = COLS; - dlen = mutt_strlen (SidebarDelim); + dlen = safe_strlen (SidebarDelim); max = SidebarWidth - dlen - 1; safe_realloc (&entry, SidebarWidth + 1); entry[SidebarWidth] = 0; for (; i < SidebarWidth; entry[i++] = ' '); #if USE_IMAP - if (ImapHomeNamespace && mutt_strlen (ImapHomeNamespace) > 0) { - if (strncmp (box, ImapHomeNamespace, mutt_strlen (ImapHomeNamespace)) == 0 - && mutt_strcmp (box, ImapHomeNamespace) != 0) { - box += mutt_strlen (ImapHomeNamespace) + 1; + if (ImapHomeNamespace && safe_strlen (ImapHomeNamespace) > 0) { + if (strncmp (box, ImapHomeNamespace, safe_strlen (ImapHomeNamespace)) == 0 + && safe_strcmp (box, ImapHomeNamespace) != 0) { + box += safe_strlen (ImapHomeNamespace) + 1; } } #endif @@ -127,11 +127,11 @@ char *make_sidebar_entry (char *box, int size, int new, int flagged) max -= quick_log10 (new) + 2; if (flagged > 0) max -= quick_log10 (flagged) + 2; - if (option (OPTSHORTENHIERARCHY) && mutt_strlen (box) > max) { + if (option (OPTSHORTENHIERARCHY) && safe_strlen (box) > max) { box = shortened_hierarchy (box); shortened = 1; } - i = mutt_strlen (box); + i = safe_strlen (box); strncpy (entry, box, i < SidebarWidth - dlen ? i : SidebarWidth - dlen); if (new) { @@ -216,16 +216,19 @@ int sidebar_draw (int menu) { int lines = option (OPTHELP) ? 1 : 0; + int draw_devider=1; BUFFY *tmp; int i = 0; - short delim_len = mutt_strlen (SidebarDelim); + short delim_len = safe_strlen (SidebarDelim); /* initialize first time */ if (!initialized) { prev_show_value = option (OPTMBOXPANE); saveSidebarWidth = SidebarWidth; - if (!option (OPTMBOXPANE)) + if (!option (OPTMBOXPANE)){ SidebarWidth = 0; + draw_devider = 1; + } initialized = 1; } @@ -244,7 +247,7 @@ int sidebar_draw (int menu) } if (SidebarWidth > 0 && option (OPTMBOXPANE) - && mutt_strlen (SidebarDelim) >= SidebarWidth) { + && safe_strlen (SidebarDelim) >= SidebarWidth) { mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar.")); sleep (2); unset_option (OPTMBOXPANE); @@ -253,21 +256,23 @@ int sidebar_draw (int menu) if (SidebarWidth == 0 || !option (OPTMBOXPANE)) return 0; - - /* draw the divider */ - SETCOLOR (MT_COLOR_SIDEBAR); - for (lines = 1; - lines < LINES - 1 - (menu != MENU_PAGER || option (OPTSTATUSONTOP)); - lines++) { - move (lines, SidebarWidth - delim_len); - if (option (OPTASCIICHARS)) - addstr (NONULL (SidebarDelim)); - else if (!option (OPTASCIICHARS) && !mutt_strcmp (SidebarDelim, "|")) - addch (ACS_VLINE); - else if ((Charset_is_utf8) && !mutt_strcmp (SidebarDelim, "|")) - addstr ("\342\224\202"); - else - addstr (NONULL (SidebarDelim)); + /* draw devider only if necessary (if the sidebar becomes visible e.g.)*/ + if (draw_devider == 1){ + /* draw the divider */ + SETCOLOR (MT_COLOR_SIDEBAR); + for (lines = 1; + lines < LINES - 1 - (menu != MENU_PAGER || option (OPTSTATUSONTOP)); + lines++) { + move (lines, SidebarWidth - delim_len); + if (option (OPTASCIICHARS)) + addstr (NONULL (SidebarDelim)); + else if (!option (OPTASCIICHARS) && !safe_strcmp (SidebarDelim, "|")) + addch (ACS_VLINE); + else if ((Charset_is_utf8) && !safe_strcmp (SidebarDelim, "|")) + addstr ("\342\224\202"); + else + addstr (NONULL (SidebarDelim)); + } } SETCOLOR (MT_COLOR_NORMAL); @@ -293,7 +298,7 @@ int sidebar_draw (int menu) move (lines, 0); if (option (OPTSIDEBARNEWMAILONLY)) { if (tmp->msg_unread > 0) { - if (Context && !mutt_strcmp (tmp->path, Context->path)) { + if (Context && !safe_strcmp (tmp->path, Context->path)) { printw ("%.*s", SidebarWidth - delim_len, make_sidebar_entry (basename (tmp->path), Context->msgcount, Context->unread, @@ -311,7 +316,7 @@ int sidebar_draw (int menu) } } else { - if (Context && !mutt_strcmp (tmp->path, Context->path)) { + if (Context && !safe_strcmp (tmp->path, Context->path)) { printw ("%.*s", SidebarWidth - delim_len, make_sidebar_entry (basename (tmp->path), Context->msgcount, Context->unread,