NeoMutt  2023-11-03-85-g512e01
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Sidebar Function API

Prototype for a Sidebar Function. More...

+ Collaboration diagram for Sidebar Function API:

Functions

static int op_sidebar_first (struct SidebarWindowData *wdata, int op)
 Selects the first unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_last (struct SidebarWindowData *wdata, int op)
 Selects the last unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_next (struct SidebarWindowData *wdata, int op)
 Selects the next unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_next_new (struct SidebarWindowData *wdata, int op)
 Selects the next new mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_open (struct SidebarWindowData *wdata, int op)
 Open highlighted mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_page_down (struct SidebarWindowData *wdata, int op)
 Selects the first entry in the next page of mailboxes - Implements sidebar_function_t -.
 
static int op_sidebar_page_up (struct SidebarWindowData *wdata, int op)
 Selects the last entry in the previous page of mailboxes - Implements sidebar_function_t -.
 
static int op_sidebar_prev (struct SidebarWindowData *wdata, int op)
 Selects the previous unhidden mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_prev_new (struct SidebarWindowData *wdata, int op)
 Selects the previous new mailbox - Implements sidebar_function_t -.
 
static int op_sidebar_toggle_visible (struct SidebarWindowData *wdata, int op)
 Make the sidebar (in)visible - Implements sidebar_function_t -.
 
static int op_sidebar_toggle_virtual (struct SidebarWindowData *wdata, int op)
 Deprecated - Implements sidebar_function_t -.
 

Detailed Description

Prototype for a Sidebar Function.

Parameters
wdataSidebar Window data
opOperation to perform, e.g. OP_SIDEBAR_NEXT
Return values
enumFunctionRetval

Function Documentation

◆ op_sidebar_first()

static int op_sidebar_first ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the first unhidden mailbox - Implements sidebar_function_t -.

Definition at line 128 of file functions.c.

129{
130 if (!mutt_window_is_visible(wdata->win))
131 return FR_NO_ACTION;
132
133 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
134 return FR_NO_ACTION;
135
136 int orig_hil_index = wdata->hil_index;
137
138 wdata->hil_index = 0;
139 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
140 if (!sb_next(wdata))
141 wdata->hil_index = orig_hil_index;
142
143 if (orig_hil_index == wdata->hil_index)
144 return FR_NO_ACTION;
145
146 wdata->win->actions |= WA_RECALC;
147 return FR_SUCCESS;
148}
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:73
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:108
@ FR_SUCCESS
Valid function - successfully performed.
Definition: dispatcher.h:39
@ FR_NO_ACTION
Valid function - no action performed.
Definition: dispatcher.h:37
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:512
#define WA_RECALC
Recalculate the contents of the Window.
Definition: mutt_window.h:110
bool sb_next(struct SidebarWindowData *wdata)
Find the next unhidden Mailbox.
Definition: functions.c:46
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
int hil_index
Highlighted mailbox.
Definition: private.h:71
struct MuttWindow * win
Sidebar Window.
Definition: private.h:65
struct SbEntryArray entries
Items to display in the sidebar.
Definition: private.h:67
+ Here is the call graph for this function:

◆ op_sidebar_last()

static int op_sidebar_last ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the last unhidden mailbox - Implements sidebar_function_t -.

Definition at line 153 of file functions.c.

154{
155 if (!mutt_window_is_visible(wdata->win))
156 return FR_NO_ACTION;
157
158 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
159 return FR_NO_ACTION;
160
161 int orig_hil_index = wdata->hil_index;
162
163 wdata->hil_index = ARRAY_SIZE(&wdata->entries);
164 if (!sb_prev(wdata))
165 wdata->hil_index = orig_hil_index;
166
167 if (orig_hil_index == wdata->hil_index)
168 return FR_NO_ACTION;
169
170 wdata->win->actions |= WA_RECALC;
171 return FR_SUCCESS;
172}
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:86
bool sb_prev(struct SidebarWindowData *wdata)
Find the previous unhidden Mailbox.
Definition: functions.c:85
+ Here is the call graph for this function:

◆ op_sidebar_next()

static int op_sidebar_next ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the next unhidden mailbox - Implements sidebar_function_t -.

Definition at line 177 of file functions.c.

178{
179 if (!mutt_window_is_visible(wdata->win))
180 return FR_NO_ACTION;
181
182 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
183 return FR_NO_ACTION;
184
185 if (!sb_next(wdata))
186 return FR_NO_ACTION;
187
188 wdata->win->actions |= WA_RECALC;
189 return FR_SUCCESS;
190}
+ Here is the call graph for this function:

◆ op_sidebar_next_new()

static int op_sidebar_next_new ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the next new mailbox - Implements sidebar_function_t -.

Search down the list of mail folders for one containing new mail.

Definition at line 197 of file functions.c.

198{
199 if (!mutt_window_is_visible(wdata->win))
200 return FR_NO_ACTION;
201
202 const size_t max_entries = ARRAY_SIZE(&wdata->entries);
203 if ((max_entries == 0) || (wdata->hil_index < 0))
204 return FR_NO_ACTION;
205
206 const bool c_sidebar_next_new_wrap = cs_subset_bool(NeoMutt->sub, "sidebar_next_new_wrap");
207 struct SbEntry **sbep = NULL;
208 if ((sbep = sb_next_new(wdata, wdata->hil_index + 1, max_entries)) ||
209 (c_sidebar_next_new_wrap && (sbep = sb_next_new(wdata, 0, wdata->hil_index))))
210 {
211 wdata->hil_index = ARRAY_IDX(&wdata->entries, sbep);
212 wdata->win->actions |= WA_RECALC;
213 return FR_SUCCESS;
214 }
215
216 return FR_NO_ACTION;
217}
#define ARRAY_IDX(head, elem)
Return the index of an element of the array.
Definition: array.h:258
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
static struct SbEntry ** sb_next_new(struct SidebarWindowData *wdata, size_t begin, size_t end)
Return the next mailbox with new messages.
Definition: functions.c:69
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
Info about folders in the sidebar.
Definition: private.h:41
+ Here is the call graph for this function:

◆ op_sidebar_open()

static int op_sidebar_open ( struct SidebarWindowData wdata,
int  op 
)
static

Open highlighted mailbox - Implements sidebar_function_t -.

Definition at line 222 of file functions.c.

223{
224 struct MuttWindow *win_sidebar = wdata->win;
225 if (!mutt_window_is_visible(win_sidebar))
226 return FR_NO_ACTION;
227
228 struct MuttWindow *dlg = dialog_find(win_sidebar);
229 index_change_folder(dlg, sb_get_highlight(win_sidebar));
230 return FR_SUCCESS;
231}
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: dialog.c:89
void index_change_folder(struct MuttWindow *dlg, struct Mailbox *m)
Change the current folder, cautiously.
Definition: dlg_index.c:1419
struct Mailbox * sb_get_highlight(struct MuttWindow *win)
Get the Mailbox that's highlighted in the sidebar.
Definition: sidebar.c:63
void * wdata
Private data.
Definition: mutt_window.h:145
+ Here is the call graph for this function:

◆ op_sidebar_page_down()

static int op_sidebar_page_down ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the first entry in the next page of mailboxes - Implements sidebar_function_t -.

Definition at line 236 of file functions.c.

237{
238 if (!mutt_window_is_visible(wdata->win))
239 return FR_NO_ACTION;
240
241 if (ARRAY_EMPTY(&wdata->entries) || (wdata->bot_index < 0))
242 return FR_NO_ACTION;
243
244 int orig_hil_index = wdata->hil_index;
245
246 wdata->hil_index = wdata->bot_index;
247 sb_next(wdata);
248 /* If the rest of the entries are hidden, go up to the last unhidden one */
249 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
250 sb_prev(wdata);
251
252 if (orig_hil_index == wdata->hil_index)
253 return FR_NO_ACTION;
254
255 wdata->win->actions |= WA_RECALC;
256 return FR_SUCCESS;
257}
int bot_index
Last mailbox visible in sidebar.
Definition: private.h:72
+ Here is the call graph for this function:

◆ op_sidebar_page_up()

static int op_sidebar_page_up ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the last entry in the previous page of mailboxes - Implements sidebar_function_t -.

Definition at line 262 of file functions.c.

263{
264 if (!mutt_window_is_visible(wdata->win))
265 return FR_NO_ACTION;
266
267 if (ARRAY_EMPTY(&wdata->entries) || (wdata->top_index < 0))
268 return FR_NO_ACTION;
269
270 int orig_hil_index = wdata->hil_index;
271
272 wdata->hil_index = wdata->top_index;
273 sb_prev(wdata);
274 /* If the rest of the entries are hidden, go down to the last unhidden one */
275 if ((*ARRAY_GET(&wdata->entries, wdata->hil_index))->is_hidden)
276 sb_next(wdata);
277
278 if (orig_hil_index == wdata->hil_index)
279 return FR_NO_ACTION;
280
281 wdata->win->actions |= WA_RECALC;
282 return FR_SUCCESS;
283}
int top_index
First mailbox visible in sidebar.
Definition: private.h:69
+ Here is the call graph for this function:

◆ op_sidebar_prev()

static int op_sidebar_prev ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the previous unhidden mailbox - Implements sidebar_function_t -.

Definition at line 288 of file functions.c.

289{
290 if (!mutt_window_is_visible(wdata->win))
291 return FR_NO_ACTION;
292
293 if (ARRAY_EMPTY(&wdata->entries) || (wdata->hil_index < 0))
294 return FR_NO_ACTION;
295
296 if (!sb_prev(wdata))
297 return FR_NO_ACTION;
298
299 wdata->win->actions |= WA_RECALC;
300 return FR_SUCCESS;
301}
+ Here is the call graph for this function:

◆ op_sidebar_prev_new()

static int op_sidebar_prev_new ( struct SidebarWindowData wdata,
int  op 
)
static

Selects the previous new mailbox - Implements sidebar_function_t -.

Search up the list of mail folders for one containing new mail.

Definition at line 308 of file functions.c.

309{
310 if (!mutt_window_is_visible(wdata->win))
311 return FR_NO_ACTION;
312
313 const size_t max_entries = ARRAY_SIZE(&wdata->entries);
314 if ((max_entries == 0) || (wdata->hil_index < 0))
315 return FR_NO_ACTION;
316
317 const bool c_sidebar_next_new_wrap = cs_subset_bool(NeoMutt->sub, "sidebar_next_new_wrap");
318 struct SbEntry **sbep = NULL;
319 if ((sbep = sb_prev_new(wdata, 0, wdata->hil_index)) ||
320 (c_sidebar_next_new_wrap &&
321 (sbep = sb_prev_new(wdata, wdata->hil_index + 1, max_entries))))
322 {
323 wdata->hil_index = ARRAY_IDX(&wdata->entries, sbep);
324 wdata->win->actions |= WA_RECALC;
325 return FR_SUCCESS;
326 }
327
328 return FR_NO_ACTION;
329}
static struct SbEntry ** sb_prev_new(struct SidebarWindowData *wdata, size_t begin, size_t end)
Return the previous mailbox with new messages.
Definition: functions.c:111
+ Here is the call graph for this function:

◆ op_sidebar_toggle_visible()

static int op_sidebar_toggle_visible ( struct SidebarWindowData wdata,
int  op 
)
static

Make the sidebar (in)visible - Implements sidebar_function_t -.

Definition at line 334 of file functions.c.

335{
336 bool_str_toggle(NeoMutt->sub, "sidebar_visible", NULL);
337 mutt_window_reflow(NULL);
338 return FR_SUCCESS;
339}
int bool_str_toggle(struct ConfigSubset *sub, const char *name, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:223
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:344
+ Here is the call graph for this function:

◆ op_sidebar_toggle_virtual()

static int op_sidebar_toggle_virtual ( struct SidebarWindowData wdata,
int  op 
)
static

Deprecated - Implements sidebar_function_t -.

Definition at line 344 of file functions.c.

345{
346 return FR_SUCCESS;
347}