NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
rootwin.c File Reference

Root Window. More...

#include "config.h"
#include <stdbool.h>
#include <string.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "helpbar/lib.h"
#include "bottombar.h"
#include "dialog.h"
#include "module_data.h"
#include "msgcont.h"
#include "msgwin.h"
#include "mutt_window.h"
#include "utilwin.h"
+ Include dependency graph for rootwin.c:

Go to the source code of this file.

Functions

void mutt_resize_screen (void)
 Update NeoMutt's opinion about the window size.
 
static int rootwin_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -.
 
static int rootwin_resize_observer (struct NotifyCallback *nc)
 Notification that the terminal has been resized - Implements observer_t -.
 
static int rootwin_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
 
void rootwin_cleanup (struct GuiModuleData *mod_data)
 Free all the default Windows.
 
void rootwin_new (struct GuiModuleData *mod_data)
 Create the default Windows.
 
void rootwin_set_size (int cols, int rows)
 Set the dimensions of the Root Window.
 

Detailed Description

Root Window.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file rootwin.c.

Function Documentation

◆ mutt_resize_screen()

void mutt_resize_screen ( void )

Update NeoMutt's opinion about the window size.

Definition at line 76 of file resize.c.

77{
78 struct winsize w = mutt_get_winsize();
79
80 int screenrows = w.ws_row;
81 int screencols = w.ws_col;
82
83 if (screenrows <= 0)
84 {
85 const char *cp = mutt_str_getenv("LINES");
86 if (cp && !mutt_str_atoi_full(cp, &screenrows))
87 screenrows = 24;
88 }
89
90 if (screencols <= 0)
91 {
92 const char *cp = mutt_str_getenv("COLUMNS");
93 if (cp && !mutt_str_atoi_full(cp, &screencols))
94 screencols = 80;
95 }
96
97 resizeterm(screenrows, screencols);
98 rootwin_set_size(screencols, screenrows);
100}
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition string.c:731
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
static struct winsize mutt_get_winsize(void)
Get the window size.
Definition resize.c:56
void rootwin_set_size(int cols, int rows)
Set the dimensions of the Root Window.
Definition rootwin.c:273
+ Here is the caller graph for this function:

◆ rootwin_cleanup()

void rootwin_cleanup ( struct GuiModuleData * mod_data)

Free all the default Windows.

Parameters
mod_dataGUI module data

Definition at line 211 of file rootwin.c.

212{
213 if (mod_data)
214 {
215 mod_data->all_dialogs_window = NULL;
216 mod_data->bottom_bar = NULL;
217 mod_data->message_container = NULL;
218 mod_data->utility_window = NULL;
219 mutt_window_free(&mod_data->root_window);
220 }
221}
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
struct MuttWindow * root_window
Parent of all Windows.
Definition module_data.h:41
struct MuttWindow * all_dialogs_window
Parent of all Dialogs.
Definition module_data.h:38
struct MuttWindow * utility_window
Utility Window.
Definition module_data.h:42
struct MuttWindow * message_container
Message Container Window.
Definition module_data.h:40
struct MuttWindow * bottom_bar
Bottom Bar Container Window.
Definition module_data.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rootwin_new()

void rootwin_new ( struct GuiModuleData * mod_data)

Create the default Windows.

Parameters
mod_dataGUI module data

Create the Help, Index, Status, Message and Sidebar Windows.

Definition at line 229 of file rootwin.c.

230{
232 MUTT_WIN_SIZE_FIXED, 0, 0);
234 if (mod_data)
235 mod_data->root_window = win_root;
236
237 struct MuttWindow *win_helpbar = helpbar_new();
238 struct MuttWindow *win_alldlgs = alldialogs_new();
239
240 const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
241 if (c_status_on_top)
242 {
243 mutt_window_add_child(win_root, win_alldlgs);
244 mutt_window_add_child(win_root, win_helpbar);
245 }
246 else
247 {
248 mutt_window_add_child(win_root, win_helpbar);
249 mutt_window_add_child(win_root, win_alldlgs);
250 }
251
252 struct MuttWindow *win_bbar = bottombar_new();
253 struct MuttWindow *win_cont = msgcont_new();
254 struct MuttWindow *win_msg = msgwin_new(false);
255 struct MuttWindow *win_util = utilwin_new();
256 mutt_window_add_child(win_cont, win_msg);
257 mutt_window_add_child(win_bbar, win_cont);
258 mutt_window_add_child(win_bbar, win_util);
259 mutt_window_add_child(win_root, win_bbar);
260
264}
struct MuttWindow * bottombar_new(void)
Create the Bottom Bar Container.
Definition bottombar.c:67
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
struct MuttWindow * alldialogs_new(void)
Create the AllDialogs Window.
Definition dialog.c:223
static int rootwin_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition rootwin.c:114
static int rootwin_resize_observer(struct NotifyCallback *nc)
Notification that the terminal has been resized - Implements observer_t -.
Definition rootwin.c:161
static int rootwin_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition rootwin.c:182
struct MuttWindow * helpbar_new(void)
Create the Help Bar Window.
Definition helpbar.c:321
struct MuttWindow * msgcont_new(void)
Create a new Message Container.
Definition msgcont.c:46
struct MuttWindow * msgwin_new(bool interactive)
Create the Message Window.
Definition msgwin.c:381
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
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.
@ WT_ROOT
Parent of All Windows.
Definition mutt_window.h:72
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition mutt_window.h:38
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
Definition mutt_window.h:47
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition notify_type.h:58
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition notify_type.h:43
@ NT_RESIZE
Window has been resized.
Definition notify_type.h:53
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition subset.h:51
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Container for Accounts, Notifications.
Definition neomutt.h:41
struct Notify * notify_resize
Window resize notifications handler.
Definition neomutt.h:46
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
struct MuttWindow * utilwin_new(void)
Create the Utility Window.
Definition utilwin.c:215
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rootwin_set_size()

void rootwin_set_size ( int cols,
int rows )

Set the dimensions of the Root Window.

Parameters
rowsNumber of rows on the screen
colsNumber of columns on the screen

This function is called after NeoMutt receives a SIGWINCH signal.

Definition at line 273 of file rootwin.c.

274{
276 if (!mod_data || !mod_data->root_window)
277 return;
278
279 struct MuttWindow *win_root = mod_data->root_window;
280 bool changed = false;
281
282 if (win_root->state.rows != rows)
283 {
284 win_root->state.rows = rows;
285 changed = true;
286 }
287
288 if (win_root->state.cols != cols)
289 {
290 win_root->state.cols = cols;
291 changed = true;
292 }
293
294 if (changed)
295 {
296 mutt_window_reflow(win_root);
297 }
298}
@ MODULE_ID_GUI
ModuleGui, Graphical code
Definition module_api.h:45
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
Gui private Module data.
Definition module_data.h:32
struct WindowState state
Current state of the Window.
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:60
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function: