NeoMutt  2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
window.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 "gui/lib.h"
34#include "lib.h"
35
36// #define DEBUG_SHOW_SERIALISE
37
40static struct MuttWindow *WinFocus = NULL;
41
47static void win_dump(struct MuttWindow *win, int indent)
48{
49 bool visible = mutt_window_is_visible(win);
50
51 mutt_debug(LL_DEBUG1, "%*s%s[%d,%d] %s-%c \033[1;33m%s\033[0m (%d,%d)%s%s\n",
52 indent, "", visible ? "✓" : "✗\033[1;30m", win->state.col_offset,
54 (win->orient == MUTT_WIN_ORIENT_VERTICAL) ? 'V' : 'H',
55 mutt_window_win_name(win), win->state.cols, win->state.rows,
56 visible ? "" : "\033[0m",
57 (win == WinFocus) ? " <-- \033[1;31mFOCUS\033[0m" : "");
58
59 struct MuttWindow **wp = NULL;
60 ARRAY_FOREACH(wp, &win->children)
61 {
62 win_dump(*wp, indent + 4);
63 }
64}
65
66#ifdef DEBUG_SHOW_SERIALISE
72static const char *win_size(struct MuttWindow *win)
73{
74 if (!win)
75 return "???";
76
77 switch (win->size)
78 {
80 return "FIX";
82 return "MAX";
84 return "MIN";
85 }
86
87 return "???";
88}
89
95static void win_serialise(struct MuttWindow *win, struct Buffer *buf)
96{
97 if (!mutt_window_is_visible(win))
98 return;
99
100 buf_add_printf(buf, "<%s {%dx,%dy} [%dC,%dR]", win_size(win), win->state.col_offset,
101 win->state.row_offset, win->state.cols, win->state.rows);
102 struct MuttWindow *np = NULL;
103 TAILQ_FOREACH(np, &win->children, entries)
104 {
105 win_serialise(np, buf);
106 }
107 buf_addstr(buf, ">");
108}
109#endif
110
115{
117 mutt_debug(LL_DEBUG1, "\n");
119 mutt_debug(LL_DEBUG1, "\n");
120#ifdef DEBUG_SHOW_SERIALISE
121 struct Buffer buf = buf_pool_get();
122 win_serialise(RootWindow, buf);
123 mutt_debug(LL_DEBUG1, "%s\n", buf_string(buf));
124 buf_pool_release(&buf);
125#endif
126 WinFocus = NULL;
127}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition buffer.c:204
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition buffer.c:226
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
Convenience wrapper for the debug headers.
const char * name_window_size(const struct MuttWindow *win)
Get the name of a window size.
Definition names.c:416
static void win_dump(struct MuttWindow *win, int indent)
Recursively dump window structure.
Definition window.c:47
void debug_win_dump(void)
Dump all windows to debug output.
Definition window.c:114
static struct MuttWindow * WinFocus
The Window that is currently focused.
Definition window.c:40
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
Convenience wrapper for the gui headers.
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
Convenience wrapper for the library headers.
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
const char * mutt_window_win_name(const struct MuttWindow *win)
Get the name of a Window.
struct MuttWindow * window_get_focus(void)
Get the currently focused Window.
@ 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
@ MUTT_WIN_SIZE_MINIMISE
Window size depends on its children.
Definition mutt_window.h:49
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition mutt_window.h:48
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
#define TAILQ_FOREACH(var, head, field)
Definition queue.h:782
struct MuttWindow * RootWindow
Parent of all Windows.
Definition rootwin.c:106
String manipulation buffer.
Definition buffer.h:36
struct MuttWindowArray children
Children Windows.
struct WindowState state
Current state of the Window.
enum MuttWindowOrientation orient
Which direction the Window will expand.
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:60
short row_offset
Absolute on-screen row.
Definition mutt_window.h:63
short col_offset
Absolute on-screen column.
Definition mutt_window.h:62
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:61