NeoMutt  2023-11-03-107-g582dc1
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 <stddef.h>
31#include <stdbool.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 void win_serialise(struct MuttWindow *win, struct Buffer *buf)
63{
64 if (!mutt_window_is_visible(win))
65 return;
66
67 buf_add_printf(buf, "<%s {%dx,%dy} [%dC,%dR]", win_size(win), win->state.col_offset,
68 win->state.row_offset, win->state.cols, win->state.rows);
69 struct MuttWindow *np = NULL;
70 TAILQ_FOREACH(np, &win->children, entries)
71 {
72 win_serialise(np, buf);
73 }
74 buf_addstr(buf, ">");
75}
76#endif
77
79{
81 mutt_debug(LL_DEBUG1, "\n");
83 mutt_debug(LL_DEBUG1, "\n");
84#ifdef DEBUG_SHOW_SERIALISE
85 struct Buffer buf = buf_make(1024);
86 win_serialise(RootWindow, &buf);
87 mutt_debug(LL_DEBUG1, "%s\n", buf_string(&buf));
88 buf_dealloc(&buf);
89#endif
90 WinFocus = NULL;
91}
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition: buffer.c:216
void buf_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:389
struct Buffer buf_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:70
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:238
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:93
const char * name_window_size(const struct MuttWindow *win)
Definition: names.c:261
static void win_dump(struct MuttWindow *win, int indent)
Definition: window.c:42
void debug_win_dump(void)
Definition: window.c:78
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:38
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:725
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: rootwin.c:106
Key value store.
String manipulation buffer.
Definition: buffer.h:34
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
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