NeoMutt  2025-12-11-872-g385a04
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
mutt_window.h
Go to the documentation of this file.
1
23
24#ifndef MUTT_GUI_MUTT_WINDOW_H
25#define MUTT_GUI_MUTT_WINDOW_H
26
27#include <stdbool.h>
28#include <stdint.h>
29#include "mutt/lib.h"
30
31struct ConfigSubset;
32
41
51
52#define MUTT_WIN_SIZE_UNLIMITED -1
53
58{
59 bool visible;
60 short cols;
61 short rows;
62 short col_offset;
63 short row_offset;
64};
65
103
104ARRAY_HEAD(MuttWindowArray, struct MuttWindow *);
105
110{
112 WA_REFLOW = 1U << 0,
113 WA_RECALC = 1U << 1,
114 WA_REPAINT = 1U << 2,
115};
116typedef uint8_t WindowActionFlags;
117
128{
129 short req_cols;
130 short req_rows;
131
134
138
140 struct MuttWindowArray children;
141
142 struct Notify *notify;
143
145 const struct MenuDefinition *help_md;
146 const struct Mapping *help_data;
147
149 void *wdata;
150
163 void (*wdata_free)(struct MuttWindow *win, void **ptr);
164
177 int (*recalc)(struct MuttWindow *win);
178
191 int (*repaint)(struct MuttWindow *win);
192
209 bool (*recursor)(struct MuttWindow *win);
210};
211
216{
218 WN_TALLER = 1U << 0,
219 WN_SHORTER = 1U << 1,
220 WN_WIDER = 1U << 2,
221 WN_NARROWER = 1U << 3,
222 WN_MOVED = 1U << 4,
223 WN_VISIBLE = 1U << 5,
224 WN_HIDDEN = 1U << 6,
225};
226typedef uint8_t WindowNotifyFlags;
227
244
253
254// Functions that deal with the Window
255void mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child);
256void mutt_window_free (struct MuttWindow **ptr);
257void mutt_window_get_coords (struct MuttWindow *win, int *row, int *col);
258struct MuttWindow *mutt_window_new (enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows);
259void mutt_window_reflow (struct MuttWindow *win);
260struct MuttWindow *mutt_window_remove_child (struct MuttWindow *parent, struct MuttWindow *child);
261int mutt_window_wrap_cols (int width, short wrap);
262
263// Functions for drawing on the Window
264int mutt_window_addch (struct MuttWindow *win, int ch);
265int mutt_window_addnstr (struct MuttWindow *win, const char *str, int num);
266int mutt_window_addstr (struct MuttWindow *win, const char *str);
267void mutt_window_clearline(struct MuttWindow *win, int row);
268void mutt_window_clear (struct MuttWindow *win);
269void mutt_window_clrtoeol (struct MuttWindow *win);
270int mutt_window_move (struct MuttWindow *win, int row, int col);
271int mutt_window_printf (struct MuttWindow *win, const char *format, ...)
272 __attribute__((__format__(__printf__, 2, 3)));
273bool mutt_window_is_visible(struct MuttWindow *win);
274
275void mutt_winlist_free (struct MuttWindowArray *wa);
276struct MuttWindow *window_find_child (struct MuttWindow *win, enum WindowType type);
277struct MuttWindow *window_find_parent(struct MuttWindow *win, enum WindowType type);
278void window_notify_all (struct MuttWindow *win);
279void window_set_visible(struct MuttWindow *win, bool visible);
280struct MuttWindow *window_set_focus (struct MuttWindow *win);
281struct MuttWindow *window_get_focus (void);
282bool window_is_focused (const struct MuttWindow *win);
283
284void window_redraw(struct MuttWindow *win);
285void window_invalidate_all(void);
286const char *mutt_window_win_name(const struct MuttWindow *win);
287bool window_status_on_top(struct MuttWindow *panel, const struct ConfigSubset *sub);
288bool mutt_window_swap(struct MuttWindow *parent, struct MuttWindow *win1, struct MuttWindow *win2);
289
290#endif /* MUTT_GUI_MUTT_WINDOW_H */
#define ARRAY_HEAD(name, T)
Define a named struct for arrays of elements of a certain type.
Definition array.h:47
Convenience wrapper for the library headers.
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
struct MuttWindow * window_find_parent(struct MuttWindow *win, enum WindowType type)
Find a (grand-)parent of a Window by type.
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
bool window_is_focused(const struct MuttWindow *win)
Does the given Window have the focus?
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.
void mutt_winlist_free(struct MuttWindowArray *wa)
Free a tree of Windows.
bool mutt_window_swap(struct MuttWindow *parent, struct MuttWindow *win1, struct MuttWindow *win2)
Swap the position of two windows.
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
void window_invalidate_all(void)
Mark all windows as in need of repaint.
bool window_status_on_top(struct MuttWindow *panel, const struct ConfigSubset *sub)
Organise windows according to config variable.
void mutt_window_clear(struct MuttWindow *win)
Clear a Window.
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
uint8_t WindowNotifyFlags
WindowType
Type of Window.
Definition mutt_window.h:70
@ WT_CUSTOM
Window with a custom drawing function.
Definition mutt_window.h:94
@ WT_ROOT
Parent of All Windows.
Definition mutt_window.h:72
@ WT_DLG_ALIAS
Alias Dialog, dlg_alias()
Definition mutt_window.h:77
@ WT_ALL_DIALOGS
Container for All Dialogs (nested Windows)
Definition mutt_window.h:74
@ WT_DLG_BROWSER
Browser Dialog, dlg_browser()
Definition mutt_window.h:80
@ WT_MESSAGE
Window for messages/errors.
Definition mutt_window.h:98
@ WT_DLG_SMIME
Smime Dialog, dlg_smime()
Definition mutt_window.h:91
@ WT_DLG_QUERY
Query Dialog, dlg_query()
Definition mutt_window.h:90
@ WT_DLG_HISTORY
History Dialog, dlg_history()
Definition mutt_window.h:85
@ WT_DLG_PGP
Pgp Dialog, dlg_pgp()
Definition mutt_window.h:88
@ WT_CONTAINER
Invisible shaping container Window.
Definition mutt_window.h:73
@ WT_DLG_CERTIFICATE
Certificate Dialog, dlg_certificate()
Definition mutt_window.h:81
@ WT_DLG_COMPOSE
Compose Dialog, dlg_compose()
Definition mutt_window.h:82
@ WT_DLG_INDEX
Index Dialog, dlg_index()
Definition mutt_window.h:86
@ WT_PAGER
A panel containing the Pager Window.
Definition mutt_window.h:99
@ WT_DLG_GPGME
GPGME Dialog, dlg_gpgme()
Definition mutt_window.h:83
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
@ WT_HELP_BAR
Help Bar containing list of useful key bindings.
Definition mutt_window.h:95
@ WT_DLG_POSTPONE
Postpone Dialog, dlg_postpone()
Definition mutt_window.h:89
@ WT_INDEX
A panel containing the Index Window.
Definition mutt_window.h:96
@ WT_DLG_ATTACH
Attach Dialog, dlg_attach()
Definition mutt_window.h:78
@ WT_SIDEBAR
Side panel containing Accounts or groups of data.
@ WT_DLG_PAGER
Pager Dialog, dlg_pager()
Definition mutt_window.h:84
@ WT_DLG_AUTOCRYPT
Autocrypt Dialog, dlg_autocrypt()
Definition mutt_window.h:79
@ WT_MENU
An Window containing a Menu.
Definition mutt_window.h:97
@ WT_DLG_PATTERN
Pattern Dialog, dlg_pattern()
Definition mutt_window.h:87
MuttWindowOrientation
Which way does the Window expand?
Definition mutt_window.h:37
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition mutt_window.h:38
@ MUTT_WIN_ORIENT_HORIZONTAL
Window uses all available horizontal space.
Definition mutt_window.h:39
int mutt_window_printf(struct MuttWindow *win, const char *format,...) __attribute__((__format__(__printf__
WindowActionFlag
Flags for Actions waiting to be performed on a MuttWindow.
@ WA_REPAINT
Redraw the contents of the Window.
@ WA_NONE
No flags are set.
@ WA_RECALC
Recalculate the contents of the Window.
@ WA_REFLOW
Reflow the Window and its children.
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
NotifyWindow
Window notification types.
@ NT_WINDOW_DIALOG
A new Dialog Window has been created, e.g. WT_DLG_INDEX.
@ NT_WINDOW_STATE
Window state has changed, e.g. WN_VISIBLE.
@ NT_WINDOW_DELETE
Window is about to be deleted.
@ NT_WINDOW_FOCUS
Window focus has changed.
@ NT_WINDOW_ADD
New Window has been added.
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
WindowNotifyFlag
Flags for Changes to a MuttWindow.
@ WN_WIDER
Window became wider.
@ WN_HIDDEN
Window became hidden.
@ WN_NARROWER
Window became narrower.
@ WN_VISIBLE
Window became visible.
@ WN_TALLER
Window became taller.
@ WN_MOVED
Window moved.
@ WN_SHORTER
Window became shorter.
@ WN_NONE
No flags are set.
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
struct MuttWindow * mutt_window_remove_child(struct MuttWindow *parent, struct MuttWindow *child)
Remove a child from a Window.
void mutt_window_get_coords(struct MuttWindow *win, int *row, int *col)
Get the cursor position in the Window.
MuttWindowSize
Control the allocation of Window space.
Definition mutt_window.h:46
@ 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
int mutt_window_wrap_cols(int width, short wrap)
Calculate the wrap column for a given screen width.
uint8_t WindowActionFlags
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
int mutt_window_addstr(struct MuttWindow *win, const char *str)
Write a string to a Window.
int mutt_window_addnstr(struct MuttWindow *win, const char *str, int num)
Write a partial string to a Window.
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
int mutt_window_addch(struct MuttWindow *win, int ch)
Write one character to a Window.
A set of inherited config items.
Definition subset.h:46
An Event that happened to a Window.
struct MuttWindow * win
Window that changed.
WindowNotifyFlags flags
Attributes of Window that changed.
Mapping between user-readable string and a constant.
Definition mapping.h:33
Functions for a Dialog or Window.
Definition menu.h:77
struct WindowState old
Previous state of the Window.
const struct Mapping * help_data
Data for the Help Bar.
const struct MenuDefinition * help_md
Menu Definition for key bindings.
struct MuttWindowArray children
Children Windows.
int(* repaint)(struct MuttWindow *win)
short req_cols
Number of columns required.
struct WindowState state
Current state of the Window.
struct MuttWindow * focus
Focused Window.
void * wdata
Private data.
enum MuttWindowOrientation orient
Which direction the Window will expand.
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
short req_rows
Number of rows required.
int(* recalc)(struct MuttWindow *win)
void(* wdata_free)(struct MuttWindow *win, void **ptr)
struct MuttWindow * parent
Parent Window.
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
bool(* recursor)(struct MuttWindow *win)
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Notification API.
Definition notify.c:53
The current, or old, state of a Window.
Definition mutt_window.h:58
bool visible
Window is visible.
Definition mutt_window.h:59
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