1 /**
2  * @file
3  * GUI display the mailboxes in a side panel
4  *
5  * @authors
6  * Copyright (C) 2020 Richard Russon <rich@flatcap.org>
7  *
8  * @copyright
9  * This program is free software: you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License as published by the Free Software
11  * Foundation, either version 2 of the License, or (at your option) any later
12  * version.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU General Public License along with
20  * this program.  If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef MUTT_SIDEBAR_PRIVATE_H
24 #define MUTT_SIDEBAR_PRIVATE_H
25 
26 #include <stdbool.h>
27 #include "mutt/lib.h"
28 #include "config/lib.h"
29 #include "color/lib.h"
30 
31 struct IndexSharedData;
32 struct Mailbox;
33 struct MuttWindow;
34 
35 extern struct ListHead SidebarWhitelist;
36 
37 /**
38  * struct SbEntry - Info about folders in the sidebar
39  */
40 struct SbEntry
41 {
42   char box[256];           ///< Mailbox path (possibly abbreviated)
43   char display[256];       ///< Formatted string to display
44   int depth;               ///< Indentation depth
45   struct Mailbox *mailbox; ///< Mailbox this represents
46   bool is_hidden;          ///< Don't show, e.g. $sidebar_new_mail_only
47   enum ColorId color;      ///< Colour to use
48 };
49 
50 /**
51  * enum DivType - Source of the sidebar divider character
52  */
53 enum DivType
54 {
55   SB_DIV_USER,  ///< User configured using $sidebar_divider_char
56   SB_DIV_ASCII, ///< An ASCII vertical bar (pipe)
57   SB_DIV_UTF8,  ///< A unicode line-drawing character
58 };
59 
60 /**
61  * struct SidebarWindowData - Sidebar private Window data - @extends MuttWindow
62  */
63 struct SidebarWindowData
64 {
65   struct IndexSharedData *shared;         ///< Shared Index Data
66   ARRAY_HEAD(, struct SbEntry *) entries; ///< Items to display in the sidebar
67 
68   int top_index;             ///< First mailbox visible in sidebar
69   int opn_index;             ///< Current (open) mailbox
70   int hil_index;             ///< Highlighted mailbox
71   int bot_index;             ///< Last mailbox visible in sidebar
72 
73   short previous_sort;       ///< Old `$sidebar_sort_method`
74   enum DivType divider_type; ///< Type of divider to use, e.g. #SB_DIV_ASCII
75   short divider_width;       ///< Width of the divider in screen columns
76 };
77 
78 // sidebar.c
79 void sb_add_mailbox        (struct SidebarWindowData *wdata, struct Mailbox *m);
80 void sb_remove_mailbox     (struct SidebarWindowData *wdata, struct Mailbox *m);
81 void sb_set_current_mailbox(struct SidebarWindowData *wdata, struct Mailbox *m);
82 
83 // functions.c
84 bool select_next(struct SidebarWindowData *wdata);
85 bool select_prev(struct SidebarWindowData *wdata);
86 
87 // observer.c
88 int sb_insertion_window_observer(struct NotifyCallback *nc);
89 void sb_win_add_observers(struct MuttWindow *win);
90 
91 // sort.c
92 void sb_sort_entries(struct SidebarWindowData *wdata, enum SortType sort);
93 
94 // wdata.c
95 void                      sb_wdata_free(struct MuttWindow *win, void **ptr);
96 struct SidebarWindowData *sb_wdata_get(struct MuttWindow *win);
97 struct SidebarWindowData *sb_wdata_new(struct IndexSharedData *shared);
98 
99 // window.c
100 int sb_recalc(struct MuttWindow *win);
101 int sb_repaint(struct MuttWindow *win);
102 
103 #endif /* MUTT_SIDEBAR_PRIVATE_H */
104