NeoMutt  2024-04-25-91-gb0e085
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
mutt_window.h
Go to the documentation of this file.
1
23#ifndef MUTT_GUI_MUTT_WINDOW_H
24#define MUTT_GUI_MUTT_WINDOW_H
25
26#include "config.h"
27#include <stdbool.h>
28#include <stdint.h>
29#include "mutt/lib.h"
30
31struct ConfigSubset;
32
37{
40};
41
46{
50};
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
70{
71 // Structural Windows
75
76 // Dialogs (nested Windows) displayed to the user
92
93 // Common Windows
102};
103
104TAILQ_HEAD(MuttWindowList, MuttWindow);
105
106typedef uint8_t WindowActionFlags;
107#define WA_NO_FLAGS 0
108#define WA_REFLOW (1 << 0)
109#define WA_RECALC (1 << 1)
110#define WA_REPAINT (1 << 2)
111
122{
123 short req_cols;
124 short req_rows;
125
128
132
135 struct MuttWindowList children;
136
137 struct Notify *notify;
138
141 const struct Mapping *help_data;
142
144 void *wdata;
145
158 void (*wdata_free)(struct MuttWindow *win, void **ptr);
159
172 int (*recalc)(struct MuttWindow *win);
173
186 int (*repaint)(struct MuttWindow *win);
187
204 bool (*recursor)(struct MuttWindow *win);
205};
206
207typedef uint8_t WindowNotifyFlags;
208#define WN_NO_FLAGS 0
209#define WN_TALLER (1 << 0)
210#define WN_SHORTER (1 << 1)
211#define WN_WIDER (1 << 2)
212#define WN_NARROWER (1 << 3)
213#define WN_MOVED (1 << 4)
214#define WN_VISIBLE (1 << 5)
215#define WN_HIDDEN (1 << 6)
216
226{
232};
233
238{
239 struct MuttWindow *win;
241};
242
243// Functions that deal with the Window
244void mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child);
245void mutt_window_free (struct MuttWindow **ptr);
246void mutt_window_get_coords (struct MuttWindow *win, int *col, int *row);
247struct MuttWindow *mutt_window_new (enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows);
248void mutt_window_reflow (struct MuttWindow *win);
249struct MuttWindow *mutt_window_remove_child (struct MuttWindow *parent, struct MuttWindow *child);
250int mutt_window_wrap_cols (int width, short wrap);
251
252// Functions for drawing on the Window
253int mutt_window_addch (struct MuttWindow *win, int ch);
254int mutt_window_addnstr (struct MuttWindow *win, const char *str, int num);
255int mutt_window_addstr (struct MuttWindow *win, const char *str);
256void mutt_window_clearline(struct MuttWindow *win, int row);
257void mutt_window_clear (struct MuttWindow *win);
258void mutt_window_clrtoeol (struct MuttWindow *win);
259int mutt_window_move (struct MuttWindow *win, int col, int row);
260int mutt_window_mvaddstr (struct MuttWindow *win, int col, int row, const char *str);
261int mutt_window_mvprintw (struct MuttWindow *win, int col, int row, const char *fmt, ...)
262 __attribute__((__format__(__printf__, 4, 5)));
263int mutt_window_printf (struct MuttWindow *win, const char *format, ...)
264 __attribute__((__format__(__printf__, 2, 3)));
265bool mutt_window_is_visible(struct MuttWindow *win);
266
267void mutt_winlist_free (struct MuttWindowList *head);
268struct MuttWindow *window_find_child (struct MuttWindow *win, enum WindowType type);
269struct MuttWindow *window_find_parent(struct MuttWindow *win, enum WindowType type);
270void window_notify_all (struct MuttWindow *win);
271void window_set_visible(struct MuttWindow *win, bool visible);
272struct MuttWindow *window_set_focus (struct MuttWindow *win);
273struct MuttWindow *window_get_focus (void);
274bool window_is_focused (const struct MuttWindow *win);
275
276void window_redraw(struct MuttWindow *win);
277void window_invalidate_all(void);
278const char *mutt_window_win_name(const struct MuttWindow *win);
279bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub);
280
281#endif /* MUTT_GUI_MUTT_WINDOW_H */
Convenience wrapper for the library headers.
void mutt_window_clear(struct MuttWindow *win)
Clear a Window.
Definition: mutt_window.c:719
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:633
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:343
int int bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:511
struct MuttWindow * window_find_parent(struct MuttWindow *win, enum WindowType type)
Find a (grand-)parent of a Window by type.
Definition: mutt_window.c:557
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:144
bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub)
Organise windows according to config variable.
Definition: mutt_window.c:783
bool window_is_focused(const struct MuttWindow *win)
Does the given Window have the focus?
Definition: mutt_window.c:653
uint8_t WindowNotifyFlags
Flags for Changes to a MuttWindow, e.g. WN_TALLER.
Definition: mutt_window.h:207
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.
Definition: mutt_window.h:101
@ WT_HELP_BAR
Help Bar containing list of useful key bindings.
Definition: mutt_window.h:95
@ WT_DLG_POSTPONED
Postponed Dialog, dlg_postponed()
Definition: mutt_window.h:89
@ WT_INDEX
A panel containing the Index Window.
Definition: mutt_window.h:96
@ WT_DLG_ATTACHMENT
Attachment Dialog, dlg_attachment()
Definition: mutt_window.h:78
@ WT_SIDEBAR
Side panel containing Accounts or groups of data.
Definition: mutt_window.h:100
@ 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
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:201
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:445
const char * mutt_window_win_name(const struct MuttWindow *win)
Get the name of a Window.
Definition: mutt_window.c:734
NotifyWindow
Window notification types.
Definition: mutt_window.h:226
@ NT_WINDOW_DIALOG
A new Dialog Window has been created, e.g. WT_DLG_INDEX.
Definition: mutt_window.h:230
@ NT_WINDOW_STATE
Window state has changed, e.g. WN_VISIBLE.
Definition: mutt_window.h:229
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:228
@ NT_WINDOW_FOCUS
Window focus has changed.
Definition: mutt_window.h:231
@ NT_WINDOW_ADD
New Window has been added.
Definition: mutt_window.h:227
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
Definition: mutt_window.c:181
struct MuttWindow * window_get_focus(void)
Get the currently focused Window.
Definition: mutt_window.c:667
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:296
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:683
int int mutt_window_printf(struct MuttWindow *win, const char *format,...) __attribute__((__format__(__printf__
struct MuttWindow * mutt_window_remove_child(struct MuttWindow *parent, struct MuttWindow *child)
Remove a child from a Window.
Definition: mutt_window.c:467
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
Definition: mutt_window.c:164
void mutt_window_get_coords(struct MuttWindow *win, int *col, int *row)
Get the cursor position in the Window.
Definition: mutt_window.c:276
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.
Definition: mutt_window.c:371
void mutt_winlist_free(struct MuttWindowList *head)
Free a tree of Windows.
Definition: mutt_window.c:488
int mutt_window_mvprintw(struct MuttWindow *win, int col, int row, const char *fmt,...) __attribute__((__format__(__printf__
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:532
uint8_t WindowActionFlags
Flags for Actions waiting to be performed on a MuttWindow, e.g. WA_REFLOW.
Definition: mutt_window.h:106
int mutt_window_mvaddstr(struct MuttWindow *win, int col, int row, const char *str)
Move the cursor and write a fixed string to a Window.
Definition: mutt_window.c:310
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:231
int mutt_window_addstr(struct MuttWindow *win, const char *str)
Write a string to a Window.
Definition: mutt_window.c:415
int mutt_window_addnstr(struct MuttWindow *win, const char *str, int num)
Write a partial string to a Window.
Definition: mutt_window.c:400
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:243
void window_invalidate_all(void)
Mark all windows as in need of repaint.
Definition: mutt_window.c:766
int mutt_window_addch(struct MuttWindow *win, int ch)
Write one character to a Window.
Definition: mutt_window.c:387
#define TAILQ_HEAD(name, type)
Definition: queue.h:623
A set of inherited config items.
Definition: subset.h:47
An Event that happened to a Window.
Definition: mutt_window.h:238
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:239
WindowNotifyFlags flags
Attributes of Window that changed.
Definition: mutt_window.h:240
Mapping between user-readable string and a constant.
Definition: mapping.h:33
struct WindowState old
Previous state of the Window.
Definition: mutt_window.h:127
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:141
int(* repaint)(struct MuttWindow *win)
Definition: mutt_window.h:186
short req_cols
Number of columns required.
Definition: mutt_window.h:123
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:126
struct MuttWindow * focus
Focused Window.
Definition: mutt_window.h:139
void * wdata
Private data.
Definition: mutt_window.h:144
enum MuttWindowOrientation orient
Which direction the Window will expand.
Definition: mutt_window.h:129
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:137
short req_rows
Number of rows required.
Definition: mutt_window.h:124
int(* recalc)(struct MuttWindow *win)
Definition: mutt_window.h:172
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:158
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:135
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:140
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:134
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:131
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Definition: mutt_window.h:130
bool(* recursor)(struct MuttWindow *win)
Definition: mutt_window.h:204
TAILQ_ENTRY(MuttWindow) entries
Linked list.
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:143
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