NeoMutt  2025-12-11-769-g906513
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
msgcont.c File Reference

Message Container. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "mutt/lib.h"
#include "core/lib.h"
#include "msgcont.h"
#include "module_data.h"
#include "mutt_window.h"
+ Include dependency graph for msgcont.c:

Go to the source code of this file.

Functions

struct MuttWindowmsgcont_new (void)
 Create a new Message Container.
 
struct MuttWindowmsgcont_pop_window (void)
 Remove the last Window from the Container Stack.
 
void msgcont_push_window (struct MuttWindow *win)
 Add a window to the Container Stack.
 
struct MuttWindowmsgcont_get_msgwin (void)
 Get the Message Window.
 

Detailed Description

Message Container.

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 msgcont.c.

Function Documentation

◆ msgcont_new()

struct MuttWindow * msgcont_new ( void )

Create a new Message Container.

Return values
ptrNew Container Window

Definition at line 45 of file msgcont.c.

46{
51 if (mod_data)
52 mod_data->message_container = win;
53 return win;
54}
@ MODULE_ID_GUI
ModuleGui, Graphical code
Definition module_api.h:45
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
@ 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
Container for Accounts, Notifications.
Definition neomutt.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msgcont_pop_window()

struct MuttWindow * msgcont_pop_window ( void )

Remove the last Window from the Container Stack.

Return values
ptrWindow removed from the stack

Definition at line 60 of file msgcont.c.

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}
#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
void debug_win_dump(void)
Dump all windows to debug output.
Definition window.c:116
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 window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
#define WA_RECALC
Recalculate the contents of the Window.
struct MuttWindowArray children
Children Windows.
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msgcont_push_window()

void msgcont_push_window ( struct MuttWindow * win)

Add a window to the Container Stack.

Parameters
winWindow to add

Definition at line 105 of file msgcont.c.

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}
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msgcont_get_msgwin()

struct MuttWindow * msgcont_get_msgwin ( void )

Get the Message Window.

Return values
ptrMessage Window

The Message Window is the first child of the MessageContainer and will have type WT_MESSAGE.

Definition at line 133 of file msgcont.c.

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
@ WT_MESSAGE
Window for messages/errors.
Definition mutt_window.h:98
enum WindowType type
Window type, e.g. WT_SIDEBAR.
+ Here is the call graph for this function:
+ Here is the caller graph for this function: