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

NeoMutt  2025-12-11-219-g274730
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 "msgcont.h"
34#include "mutt_window.h"
35#ifdef USE_DEBUG_WINDOW
36#include "debug/lib.h"
37#endif
38
41
52
58{
60 return NULL;
61
62 struct MuttWindow **wp_pop = ARRAY_LAST(&MessageContainer->children);
63 if (!wp_pop)
64 return NULL;
65
66 struct MuttWindow *win_pop = *wp_pop;
67
68 // Don't pop the last entry (check if there's a previous one)
69 if (ARRAY_SIZE(&MessageContainer->children) <= 1)
70 return NULL;
71
72 // Hide the old window
73 window_set_visible(win_pop, false);
74
75 // Get the window that will become top of stack
76 struct MuttWindow **wp_top = ARRAY_GET(&MessageContainer->children,
77 ARRAY_SIZE(&MessageContainer->children) - 2);
78 struct MuttWindow *win_top = wp_top ? *wp_top : NULL;
79
80 ARRAY_REMOVE(&MessageContainer->children, wp_pop);
81
82 if (win_top)
83 {
84 window_set_visible(win_top, true);
85 win_top->actions |= WA_RECALC;
86 }
87
89 window_redraw(NULL);
90#ifdef USE_DEBUG_WINDOW
92#endif
93 return win_pop;
94}
95
101{
102 if (!MessageContainer || !win)
103 return;
104
105 // Hide the current top window
106 struct MuttWindow **wp_top = ARRAY_LAST(&MessageContainer->children);
107 if (wp_top)
108 window_set_visible(*wp_top, false);
109
111 mutt_window_reflow(NULL);
112 window_redraw(NULL);
113#ifdef USE_DEBUG_WINDOW
115#endif
116}
117
126{
127 if (!MessageContainer)
128 return NULL;
129
130 struct MuttWindow **wp = ARRAY_FIRST(&MessageContainer->children);
131 if (!wp)
132 return NULL;
133
134 struct MuttWindow *win = *wp;
135 if (win->type != WT_MESSAGE)
136 return NULL;
137
138 return win;
139}
#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 debug headers.
void debug_win_dump(void)
Dump all windows to debug output.
Definition window.c:114
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
void msgcont_push_window(struct MuttWindow *win)
Add a window to the Container Stack.
Definition msgcont.c:100
struct MuttWindow * msgcont_pop_window(void)
Remove the last Window from the Container Stack.
Definition msgcont.c:57
struct MuttWindow * msgcont_get_msgwin(void)
Get the Message Window.
Definition msgcont.c:125
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:99
@ WT_CONTAINER
Invisible shaping container Window.
Definition mutt_window.h:74
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition mutt_window.h:39
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition mutt_window.h:53
@ MUTT_WIN_SIZE_MINIMISE
Window size depends on its children.
Definition mutt_window.h:50
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
enum WindowType type
Window type, e.g. WT_SIDEBAR.