From f6aab6b0c36b70826d4b66ac2454d219ed04eb6e Mon Sep 17 00:00:00 2001 From: pdmef Date: Sun, 27 Feb 2005 00:53:18 +0000 Subject: [PATCH] Rocco Rutte: added coloring for flagged msg in sidebar + fixed flagging git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@92 e385b8ad-14ed-0310-8656-cc95a2468c6d --- buffy.c | 1 - color.c | 1 + mutt_curses.h | 1 + sidebar.c | 15 ++++++++++++--- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/buffy.c b/buffy.c index 6b91745..208eaac 100644 --- a/buffy.c +++ b/buffy.c @@ -404,7 +404,6 @@ int mutt_buffy_check (int force) } tmp->msgcount = 0; tmp->msg_unread = 0; - tmp->msg_flagged = 0; while ((de = readdir (dirp)) != NULL) { char *p; diff --git a/color.c b/color.c index 24afbd4..f913611 100644 --- a/color.c +++ b/color.c @@ -94,6 +94,7 @@ static struct mapping_t Fields[] = { "underline", MT_COLOR_UNDERLINE }, { "index", MT_COLOR_INDEX }, { "sidebar_new", MT_COLOR_NEW }, + { "sidebar_flagged", MT_COLOR_FLAGGED }, { NULL, 0 } }; diff --git a/mutt_curses.h b/mutt_curses.h index 87c837f..3908e9b 100644 --- a/mutt_curses.h +++ b/mutt_curses.h @@ -123,6 +123,7 @@ enum MT_COLOR_UNDERLINE, MT_COLOR_INDEX, MT_COLOR_NEW, + MT_COLOR_FLAGGED, MT_COLOR_MAX }; diff --git a/sidebar.c b/sidebar.c index 8699196..c71090e 100644 --- a/sidebar.c +++ b/sidebar.c @@ -136,7 +136,8 @@ static char * shortened_hierarchy(char * box) { char *make_sidebar_entry(char *box, int size, int new, int flagged) { char *c; - int i = 0, dlen = mutt_strlen (SidebarDelim); + int i = 0, dlen = mutt_strlen (SidebarDelim), max = SidebarWidth-dlen-1, + shortened = 0; c = realloc(entry, SidebarWidth + 1); if ( c ) entry = c; @@ -149,8 +150,14 @@ char *make_sidebar_entry(char *box, int size, int new, int flagged) } } #endif - if (option(OPTSHORTENHIERARCHY)) { + max -= quick_log10(size); + if (new) + max -= quick_log10(new) + 2; + if (flagged > 0) + max -= quick_log10(flagged) + 2; + if (option(OPTSHORTENHIERARCHY) && mutt_strlen(box) > max) { box = shortened_hierarchy(box); + shortened = 1; } i = strlen(box); strncpy( entry, box, i < SidebarWidth - dlen ? i :SidebarWidth - dlen); @@ -171,7 +178,7 @@ char *make_sidebar_entry(char *box, int size, int new, int flagged) } } - if (option(OPTSHORTENHIERARCHY)) { + if (option(OPTSHORTENHIERARCHY) && shortened) { free(box); } return entry; @@ -264,6 +271,8 @@ int draw_sidebar(int menu) { for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option (OPTSTATUSONTOP)); tmp = tmp->next ) { if ( tmp == CurBuffy ) SETCOLOR(MT_COLOR_INDICATOR); + else if ( tmp->msg_flagged > 0 ) + SETCOLOR(MT_COLOR_FLAGGED); else if ( tmp->msg_unread > 0 ) SETCOLOR(MT_COLOR_NEW); else -- 2.20.1