NeoMutt  2025-12-11-949-g4870ee
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
msgcont.h File Reference

Message Window. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct MuttWindowmsgcont_get_msgwin (void)
 Get the Message Window.
 
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.
 
void msgcont_recalc_rows (void)
 Recalculate the Bottom Bar height.
 
int msgcont_num_windows (void)
 Count the Windows in the Message Container.
 

Detailed Description

Message 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 msgcont.h.

Function Documentation

◆ 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 190 of file msgcont.c.

191{
193 if (!mod_data || !mod_data->message_container)
194 return NULL;
195
196 struct MuttWindow **wp = ARRAY_FIRST(&mod_data->message_container->children);
197 if (!wp)
198 return NULL;
199
200 struct MuttWindow *win = *wp;
201 if (win->type != WT_MESSAGE)
202 return NULL;
203
204 return win;
205}
#define ARRAY_FIRST(head)
Convenience method to get the first element.
Definition array.h:136
@ MODULE_ID_GUI
ModuleGui, Graphical code
Definition module_api.h:45
@ WT_MESSAGE
Window for messages/errors.
Definition mutt_window.h:99
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:666
Gui private Module data.
Definition module_data.h:32
struct MuttWindow * message_container
Message Container Window.
Definition module_data.h:38
struct MuttWindowArray children
Children Windows.
enum WindowType type
Window type, e.g. WT_SIDEBAR.
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_new()

struct MuttWindow * msgcont_new ( void )

Create a new Message Container.

Return values
ptrNew Container Window

Definition at line 46 of file msgcont.c.

47{
52 if (mod_data)
53 mod_data->message_container = win;
54 return win;
55}
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_MAXIMISE
Window wants as much space as possible.
Definition mutt_window.h:48
+ 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 103 of file msgcont.c.

104{
106 if (!mod_data || !mod_data->message_container)
107 return NULL;
108
109 struct MuttWindow *mc = mod_data->message_container;
110
111 struct MuttWindow **wp_pop = ARRAY_LAST(&mc->children);
112 if (!wp_pop)
113 return NULL;
114
115 struct MuttWindow *win_pop = *wp_pop;
116
117 // Don't pop the last entry (check if there's a previous one)
118 if (ARRAY_SIZE(&mc->children) <= 1)
119 return NULL;
120
121 // Hide the old window
122 window_set_visible(win_pop, false);
123
124 // Get the window that will become top of stack
125 struct MuttWindow **wp_top = ARRAY_GET(&mc->children, ARRAY_SIZE(&mc->children) - 2);
126 struct MuttWindow *win_top = wp_top ? *wp_top : NULL;
127
128 ARRAY_REMOVE(&mc->children, wp_pop);
129
130 if (win_top)
131 {
132 window_set_visible(win_top, true);
133 win_top->actions |= WA_RECALC;
134 }
135
137
138 mutt_window_reflow(NULL);
139 window_redraw(NULL);
140#ifdef USE_DEBUG_WINDOW
142#endif
143 return win_pop;
144}
#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 msgcont_recalc_rows(void)
Recalculate the Bottom Bar height.
Definition msgcont.c:64
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.
@ WA_RECALC
Recalculate the contents of the Window.
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 150 of file msgcont.c.

151{
153 if (!mod_data || !mod_data->message_container || !win)
154 return;
155
156 struct MuttWindow *mc = mod_data->message_container;
157 const bool keep_msgwin = msgwin_has_text();
158
159 // Hide all currently visible children: the new window will take over the
160 // space. If the Message Window currently holds any text, it should remain
161 // visible so the user still sees the message.
162 struct MuttWindow **wp = NULL;
163 ARRAY_FOREACH(wp, &mc->children)
164 {
165 if (!(*wp)->state.visible)
166 continue;
167 if (keep_msgwin && ((*wp)->type == WT_MESSAGE))
168 continue;
169 window_set_visible(*wp, false);
170 }
171
172 mutt_window_add_child(mc, win);
173
175
176 mutt_window_reflow(NULL);
177 window_redraw(NULL);
178#ifdef USE_DEBUG_WINDOW
180#endif
181}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
bool msgwin_has_text(void)
Does the Message Window currently hold any text?
Definition msgwin.c:609
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_recalc_rows()

void msgcont_recalc_rows ( void )

Recalculate the Bottom Bar height.

Sum the req_rows of all visible children of the Message Container and apply the result to the Bottom Bar's req_rows. The caller is responsible for triggering a reflow if needed.

Definition at line 64 of file msgcont.c.

65{
67 if (!mod_data || !mod_data->message_container || !mod_data->bottom_bar)
68 return;
69
70 struct MuttWindow *mc = mod_data->message_container;
71 int rows = 0;
72 struct MuttWindow **wp = NULL;
73 ARRAY_FOREACH(wp, &mc->children)
74 {
75 if (!(*wp)->state.visible)
76 continue;
77 rows += MAX(0, (*wp)->req_rows);
78 }
79
80 if (rows < 1)
81 rows = 1;
82
83 mod_data->bottom_bar->req_rows = rows;
84}
#define MAX(a, b)
Return the maximum of two values.
Definition memory.h:38
struct MuttWindow * bottom_bar
Bottom Bar Container Window.
Definition module_data.h:37
short req_rows
Number of rows required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msgcont_num_windows()

int msgcont_num_windows ( void )

Count the Windows in the Message Container.

Return values
numNumber of children windows

Definition at line 90 of file msgcont.c.

91{
93 if (!mod_data || !mod_data->message_container)
94 return 0;
95
96 return ARRAY_SIZE(&mod_data->message_container->children);
97}
+ Here is the call graph for this function:
+ Here is the caller graph for this function: