Thanks to visit codestin.com
Credit goes to code.neomutt.org

NeoMutt  2025-12-11-189-gceedb6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
rootwin.c
Go to the documentation of this file.
1
22
91
92#include "config.h"
93#include <stdbool.h>
94#include <string.h>
95#include "mutt/lib.h"
96#include "config/lib.h"
97#include "core/lib.h"
98#include "helpbar/lib.h"
99#include "dialog.h"
100#include "msgcont.h"
101#include "msgwin.h"
102#include "mutt_window.h"
103
104void mutt_resize_screen(void);
105
106struct MuttWindow *RootWindow = NULL;
107
114{
115 if (nc->event_type != NT_CONFIG)
116 return 0;
117 if (!nc->global_data || !nc->event_data)
118 return -1;
119
120 struct EventConfig *ev_c = nc->event_data;
121 struct MuttWindow *win_root = nc->global_data;
122
123 if (!mutt_str_equal(ev_c->name, "status_on_top"))
124 return 0;
125
126 struct MuttWindow **wp_first = ARRAY_FIRST(&win_root->children);
127 if (!wp_first)
128 return 0;
129
130 struct MuttWindow *first = *wp_first;
131
132 const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
133 if ((c_status_on_top && (first->type == WT_HELP_BAR)) ||
134 (!c_status_on_top && (first->type != WT_HELP_BAR)))
135 {
136 // Swap the HelpBar and the AllDialogsWindow
137 if (ARRAY_SIZE(&win_root->children) < 2)
138 return 0;
139
140 struct MuttWindow **wp_next = ARRAY_GET(&win_root->children, 1);
141 if (!wp_next)
142 return 0;
143
144 struct MuttWindow *next = *wp_next;
145 ARRAY_REMOVE(&win_root->children, wp_next);
146 ARRAY_INSERT(&win_root->children, 0, next);
147
148 mutt_window_reflow(win_root);
149 mutt_debug(LL_DEBUG5, "config done, request WA_REFLOW\n");
150 }
151
152 return 0;
153}
154
161{
162 if (nc->event_type != NT_RESIZE)
163 return 0;
164 if (!nc->global_data)
165 return -1;
166
169
170 mutt_debug(LL_DEBUG5, "window resize done\n");
171 return 0;
172}
173
182{
183 if (nc->event_type != NT_WINDOW)
184 return 0;
185 if (!nc->global_data || !nc->event_data)
186 return -1;
188 return 0;
189
190 struct MuttWindow *win_root = nc->global_data;
191 struct EventWindow *ev_w = nc->event_data;
192 if (ev_w->win != win_root)
193 return 0;
194
196 if (NeoMutt)
197 {
200 }
201
202 mutt_debug(LL_DEBUG5, "window delete done\n");
203 return 0;
204}
205
210{
211 AllDialogsWindow = NULL;
212 MessageContainer = NULL;
214}
215
221void rootwin_new(void)
222{
224 MUTT_WIN_SIZE_FIXED, 0, 0);
226 RootWindow = win_root;
227
228 struct MuttWindow *win_helpbar = helpbar_new();
229 struct MuttWindow *win_alldlgs = alldialogs_new();
230
231 const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
232 if (c_status_on_top)
233 {
234 mutt_window_add_child(win_root, win_alldlgs);
235 mutt_window_add_child(win_root, win_helpbar);
236 }
237 else
238 {
239 mutt_window_add_child(win_root, win_helpbar);
240 mutt_window_add_child(win_root, win_alldlgs);
241 }
242
243 struct MuttWindow *win_cont = msgcont_new();
244 struct MuttWindow *win_msg = msgwin_new(false);
245 mutt_window_add_child(win_cont, win_msg);
246 mutt_window_add_child(win_root, win_cont);
247
251}
252
260void rootwin_set_size(int cols, int rows)
261{
262 if (!RootWindow)
263 return;
264
265 bool changed = false;
266
267 if (RootWindow->state.rows != rows)
268 {
269 RootWindow->state.rows = rows;
270 changed = true;
271 }
272
273 if (RootWindow->state.cols != cols)
274 {
275 RootWindow->state.cols = cols;
276 changed = true;
277 }
278
279 if (changed)
280 {
282 }
283}
#define ARRAY_FIRST(head)
Convenience method to get the first element.
Definition array.h:136
#define ARRAY_INSERT(head, idx, elem)
Insert an element into the, shifting up the subsequent entries.
Definition array.h:338
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition array.h:355
#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
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
struct MuttWindow * AllDialogsWindow
Parent of all Dialogs.
Definition dialog.c:80
struct MuttWindow * alldialogs_new(void)
Create the AllDialogs Window.
Definition dialog.c:212
Dialog Windows.
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
static int rootwin_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition rootwin.c:113
static int rootwin_resize_observer(struct NotifyCallback *nc)
Notification that the terminal has been resized - Implements observer_t -.
Definition rootwin.c:160
static int rootwin_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition rootwin.c:181
Help Bar Convenience wrapper for the Help Bar headers.
struct MuttWindow * helpbar_new(void)
Create the Help Bar Window.
Definition helpbar.c:316
@ LL_DEBUG5
Log at debug level 5.
Definition logging2.h:49
struct MuttWindow * msgcont_new(void)
Create a new Message Container.
Definition msgcont.c:46
struct MuttWindow * MessageContainer
Window acting as a stack for the message windows.
Definition msgcont.c:40
Message Window.
struct MuttWindow * msgwin_new(bool interactive)
Create the Message Window.
Definition msgwin.c:370
Message Window.
Convenience wrapper for the library headers.
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition notify.c:230
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition notify.c:191
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:662
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
void mutt_window_free(struct MuttWindow **ptr)
Free 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_invalidate_all(void)
Mark all windows as in need of repaint.
Window management.
@ WT_ROOT
Parent of All Windows.
Definition mutt_window.h:73
@ WT_HELP_BAR
Help Bar containing list of useful key bindings.
Definition mutt_window.h:96
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition mutt_window.h:39
@ NT_WINDOW_DELETE
Window is about to be deleted.
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
Definition mutt_window.h:48
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition notify_type.h:57
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition notify_type.h:43
@ NT_RESIZE
Window has been resized.
Definition notify_type.h:52
void mutt_resize_screen(void)
Update NeoMutt's opinion about the window size.
Definition resize.c:76
void rootwin_set_size(int cols, int rows)
Set the dimensions of the Root Window.
Definition rootwin.c:260
void rootwin_cleanup(void)
Free all the default Windows.
Definition rootwin.c:209
struct MuttWindow * RootWindow
Parent of all Windows.
Definition rootwin.c:106
void rootwin_new(void)
Create the default Windows.
Definition rootwin.c:221
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition subset.h:51
A config-change event.
Definition subset.h:70
const char * name
Name of config item that changed.
Definition subset.h:72
An Event that happened to a Window.
struct MuttWindow * win
Window that changed.
struct MuttWindowArray children
Children Windows.
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Container for Accounts, Notifications.
Definition neomutt.h:128
struct Notify * notify_resize
Window resize notifications handler.
Definition neomutt.h:131
struct Notify * notify
Notifications handler.
Definition neomutt.h:130
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:134
Data passed to a notification function.
Definition observer.h:34
void * event_data
Data from notify_send()
Definition observer.h:38
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition observer.h:36
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition observer.h:37
void * global_data
Data from notify_observer_add()
Definition observer.h:39