NeoMutt  2025-12-11-769-g906513
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
msgcont.c
Go to the documentation of this file.
1
22
28
29#include "config.h"
30#include <stdbool.h>
31#include <stddef.h>
32#include "mutt/lib.h"
33#include "core/lib.h"
34#include "msgcont.h"
35#include "module_data.h"
36#include "mutt_window.h"
37#ifdef USE_DEBUG_WINDOW
38#include "debug/lib.h"
39#endif
40
46{
51 if (mod_data)
52 mod_data->message_container = win;
53 return win;
54}
55
61{
63 if (!mod_data || !mod_data->message_container)
64 return NULL;
65
66 struct MuttWindow *mc = mod_data->message_container;
67
68 struct MuttWindow **wp_pop = ARRAY_LAST(&mc->children);
69 if (!wp_pop)
70 return NULL;
71
72 struct MuttWindow *win_pop = *wp_pop;
73
74 // Don't pop the last entry (check if there's a previous one)
75 if (ARRAY_SIZE(&mc->children) <= 1)
76 return NULL;
77
78 // Hide the old window
79 window_set_visible(win_pop, false);
80
81 // Get the window that will become top of stack
82 struct MuttWindow **wp_top = ARRAY_GET(&mc->children, ARRAY_SIZE(&mc->children) - 2);
83 struct MuttWindow *win_top = wp_top ? *wp_top : NULL;
84
85 ARRAY_REMOVE(&mc->children, wp_pop);
86
87 if (win_top)
88 {
89 window_set_visible(win_top, true);
90 win_top->actions |= WA_RECALC;
91 }
92
94 window_redraw(NULL);
95#ifdef USE_DEBUG_WINDOW
97#endif
98 return win_pop;
99}
100
106{
108 if (!mod_data || !mod_data->message_container || !win)
109 return;
110
111 struct MuttWindow *mc = mod_data->message_container;
112
113 // Hide the current top window
114 struct MuttWindow **wp_top = ARRAY_LAST(&mc->children);
115 if (wp_top)
116 window_set_visible(*wp_top, false);
117
118 mutt_window_add_child(mc, win);
119 mutt_window_reflow(NULL);
120 window_redraw(NULL);
121#ifdef USE_DEBUG_WINDOW
123#endif
124}
125
134{
136 if (!mod_data || !mod_data->message_container)
137 return NULL;
138
139 struct MuttWindow **wp = ARRAY_FIRST(&mod_data->message_container->children);
140 if (!wp)
141 return NULL;
142
143 struct MuttWindow *win = *wp;
144 if (win->type != WT_MESSAGE)
145 return NULL;
146
147 return win;
148}
#define ARRAY_FIRST(head)
Convenience method to get the first element.
Definition array.h:136
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition array.h:355
#define ARRAY_LAST(head)
Convenience method to get the last element.
Definition array.h:145
#define ARRAY_SIZE(head)
The number of elements stored.
Definition array.h:87
#define ARRAY_GET(head, idx)
Return the element at index.
Definition array.h:109
Convenience wrapper for the core headers.
Convenience wrapper for the debug headers.
void debug_win_dump(void)
Dump all windows to debug output.
Definition window.c:116
Gui private Module data.
@ MODULE_ID_GUI
ModuleGui, Graphical code
Definition module_api.h:45
struct MuttWindow * msgcont_new(void)
Create a new Message Container.
Definition msgcont.c:45
void msgcont_push_window(struct MuttWindow *win)
Add a window to the Container Stack.
Definition msgcont.c:105
struct MuttWindow * msgcont_pop_window(void)
Remove the last Window from the Container Stack.
Definition msgcont.c:60
struct MuttWindow * msgcont_get_msgwin(void)
Get the Message Window.
Definition msgcont.c:133
Message Window.
Convenience wrapper for the library headers.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
Window management.
#define WA_RECALC
Recalculate the contents of the Window.
@ WT_MESSAGE
Window for messages/errors.
Definition mutt_window.h:98
@ WT_CONTAINER
Invisible shaping container Window.
Definition mutt_window.h:73
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition mutt_window.h:38
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition mutt_window.h:52
@ MUTT_WIN_SIZE_MINIMISE
Window size depends on its children.
Definition mutt_window.h:49
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:665
Gui private Module data.
Definition module_data.h:32
struct MuttWindow * message_container
Message Container Window.
Definition module_data.h:39
struct MuttWindowArray children
Children Windows.
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Container for Accounts, Notifications.
Definition neomutt.h:41