NeoMutt  2024-12-12-19-ge4b57e
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
window.c
Go to the documentation of this file.
1
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
42static void win_dump(struct MuttWindow *win, int indent)
43{
44 bool visible = mutt_window_is_visible(win);
45
46 mutt_debug(LL_DEBUG1, "%*s%s[%d,%d] %s-%c \033[1;33m%s\033[0m (%d,%d)%s%s\n",
47 indent, "", visible ? "✓" : "✗\033[1;30m", win->state.col_offset,
49 (win->orient == MUTT_WIN_ORIENT_VERTICAL) ? 'V' : 'H',
50 mutt_window_win_name(win), win->state.cols, win->state.rows,
51 visible ? "" : "\033[0m",
52 (win == WinFocus) ? " <-- \033[1;31mFOCUS\033[0m" : "");
53
54 struct MuttWindow *np = NULL;
55 TAILQ_FOREACH(np, &win->children, entries)
56 {
57 win_dump(np, indent + 4);
58 }
59}
60
61#ifdef DEBUG_SHOW_SERIALISE
62static const char *win_size(struct MuttWindow *win)
63{
64 if (!win)
65 return "???";
66
67 switch (win->size)
68 {
70 return "FIX";
72 return "MAX";
74 return "MIN";
75 }
76
77 return "???";
78}
79
80static void win_serialise(struct MuttWindow *win, struct Buffer *buf)
81{
82 if (!mutt_window_is_visible(win))
83 return;
84
85 buf_add_printf(buf, "<%s {%dx,%dy} [%dC,%dR]", win_size(win), win->state.col_offset,
86 win->state.row_offset, win->state.cols, win->state.rows);
87 struct MuttWindow *np = NULL;
88 TAILQ_FOREACH(np, &win->children, entries)
89 {
90 win_serialise(np, buf);
91 }
92 buf_addstr(buf, ">");
93}
94#endif
95
97{
99 mutt_debug(LL_DEBUG1, "\n");
101 mutt_debug(LL_DEBUG1, "\n");
102#ifdef DEBUG_SHOW_SERIALISE
103 struct Buffer buf = buf_pool_get();
104 win_serialise(RootWindow, buf);
105 mutt_debug(LL_DEBUG1, "%s\n", buf_string(buf));
106 buf_pool_release(&buf);
107#endif
108 WinFocus = NULL;
109}
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
const char * name_window_size(const struct MuttWindow *win)
Definition: names.c:257
static void win_dump(struct MuttWindow *win, int indent)
Definition: window.c:42
void debug_win_dump(void)
Definition: window.c:96
static struct MuttWindow * WinFocus
The Window that is currently focussed.
Definition: window.c:40
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
Convenience wrapper for the gui headers.
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
Convenience wrapper for the library headers.
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:512
const char * mutt_window_win_name(const struct MuttWindow *win)
Get the name of a Window.
Definition: mutt_window.c:735
struct MuttWindow * window_get_focus(void)
Get the currently focused Window.
Definition: mutt_window.c:668
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition: mutt_window.h:39
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
Definition: mutt_window.h:48
@ MUTT_WIN_SIZE_MINIMISE
Window size depends on its children.
Definition: mutt_window.h:50
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition: mutt_window.h:49
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:96
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:743
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: rootwin.c:106
Key value store.
String manipulation buffer.
Definition: buffer.h:36
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
enum MuttWindowOrientation orient
Which direction the Window will expand.
Definition: mutt_window.h:130
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:136
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Definition: mutt_window.h:131
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:61
short row_offset
Absolute on-screen row.
Definition: mutt_window.h:64
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:63
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:62