Rocco Rutte:
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sun, 27 Feb 2005 00:53:18 +0000 (00:53 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sun, 27 Feb 2005 00:53:18 +0000 (00:53 +0000)
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
color.c
mutt_curses.h
sidebar.c

diff --git a/buffy.c b/buffy.c
index 6b91745..208eaac 100644 (file)
--- 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 (file)
--- 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 }
 };
 
index 87c837f..3908e9b 100644 (file)
@@ -123,6 +123,7 @@ enum
   MT_COLOR_UNDERLINE,
   MT_COLOR_INDEX,
   MT_COLOR_NEW,
+  MT_COLOR_FLAGGED,
   MT_COLOR_MAX
 };
 
index 8699196..c71090e 100644 (file)
--- 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