X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=sidebar.c;h=ebc1a64d63309b9c280de575501fc6ea151f35b7;hp=c71090e7d8b941babd0864e86b3ee37df0db5dca;hb=643be053e447a35cccc37550ac0087bb5bb5c5ad;hpb=f6aab6b0c36b70826d4b66ac2454d219ed04eb6e diff --git a/sidebar.c b/sidebar.c index c71090e..ebc1a64 100644 --- a/sidebar.c +++ b/sidebar.c @@ -207,6 +207,8 @@ void set_curbuffy(char buf[LONG_STRING]) void set_buffystats (CONTEXT* Context) { BUFFY* tmp = Incoming; + if (!Context) + return; while (tmp) { if (strcmp (tmp->path, Context->path) == 0) @@ -303,24 +305,58 @@ 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) + return; + else CurBuffy = tmp; + break; case OP_SIDEBAR_PREV: - if ( CurBuffy == Incoming ) return; - { - 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; + break; + case OP_SIDEBAR_PREV_NEW: + if ( (tmp = exist_prev_new()) == NULL) + return; + else CurBuffy = tmp; break; + case OP_SIDEBAR_SCROLL_UP: CurBuffy = TopBuffy; if ( CurBuffy != Incoming ) {