X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=sidebar.c;h=bbc2c60a0dc1ea323feaf24995ace7a7bebcb441;hp=869919618a4daa02ea588982300a63397464f677;hb=0b94e5518f3859ba10697f34978122d8e3adb334;hpb=2709e0121568c93bd012a57dedb15456271ef025 diff --git a/sidebar.c b/sidebar.c index 8699196..bbc2c60 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 @@ -294,24 +303,64 @@ int draw_sidebar(int menu) { return 0; } +BUFFY * exist_next_new() +{ + BUFFY *tmp = CurBuffy; + if(tmp == NULL) return NULL; + while (tmp->next != NULL) + { + tmp = tmp->next; + if(tmp->msg_unread) return tmp; + } + return NULL; +} + +BUFFY * exist_prev_new() +{ + BUFFY *tmp = CurBuffy; + if(tmp == NULL) return NULL; + while (tmp->prev != NULL) + { + tmp = tmp->prev; + if(tmp->msg_unread) return tmp; + } + return NULL; +} + + void scroll_sidebar(int op, int menu) { - if(!SidebarWidth) return; - if(!CurBuffy) return; + BUFFY *tmp; + + if(!SidebarWidth) return; + if(!CurBuffy) return; switch (op) { case OP_SIDEBAR_NEXT: if ( CurBuffy->next == NULL ) return; CurBuffy = CurBuffy->next; break; + case OP_SIDEBAR_NEXT_NEW: + if ( (tmp = exist_next_new()) == NULL) + { + if (CurBuffy->next == NULL) return; + CurBuffy = CurBuffy->next; + } + else CurBuffy = tmp; + break; case OP_SIDEBAR_PREV: - if ( CurBuffy == Incoming ) return; + if ( CurBuffy->prev == NULL ) return; + CurBuffy = CurBuffy->prev; + break; + case OP_SIDEBAR_PREV_NEW: + if ( (tmp = exist_prev_new()) == NULL) { - BUFFY *tmp = Incoming; - while ( tmp->next && strcmp(tmp->next->path, CurBuffy->path) ) tmp = tmp->next; - CurBuffy = tmp; + if(CurBuffy->prev == NULL) return; + CurBuffy = CurBuffy->prev; } + else CurBuffy = tmp; break; + case OP_SIDEBAR_SCROLL_UP: CurBuffy = TopBuffy; if ( CurBuffy != Incoming ) {