NeoMutt  2023-05-17-16-g61469c
Teaching an old dog new tricks
DOXYGEN
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
93
94 // Common Windows
103};
104
105TAILQ_HEAD(MuttWindowList, MuttWindow);
106
107typedef uint8_t WindowActionFlags;
108#define WA_NO_FLAGS 0
109#define WA_REFLOW (1 << 0)
110#define WA_RECALC (1 << 1)
111#define WA_REPAINT (1 << 2)
112
123{
124 short req_cols;
125 short req_rows;
126
129
133
136 struct MuttWindowList children;
137
138 struct Notify *notify;
139
142 const struct Mapping *help_data;
143
145 void *wdata;
146
159 void (*wdata_free)(struct MuttWindow *win, void **ptr);
160
170 int (*recalc)(struct MuttWindow *win);
171
181 int (*repaint)(struct MuttWindow *win);
182};
183
184typedef uint8_t WindowNotifyFlags;
185#define WN_NO_FLAGS 0
186#define WN_TALLER (1 << 0)
187#define WN_SHORTER (1 << 1)
188#define WN_WIDER (1 << 2)
189#define WN_NARROWER (1 << 3)
190#define WN_MOVED (1 << 4)
191#define WN_VISIBLE (1 << 5)
192#define WN_HIDDEN (1 << 6)
193
203{
209};
210
215{
216 struct MuttWindow *win;
218};
219
220// Functions that deal with the Window
221void mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child);
222void mutt_window_free (struct MuttWindow **ptr);
223void mutt_window_get_coords (struct MuttWindow *win, int *col, int *row);
224struct MuttWindow *mutt_window_new (enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows);
225void mutt_window_reflow (struct MuttWindow *win);
226struct MuttWindow *mutt_window_remove_child (struct MuttWindow *parent, struct MuttWindow *child);
227int mutt_window_wrap_cols (int width, short wrap);
228
229// Functions for drawing on the Window
230int mutt_window_addch (struct MuttWindow *win, int ch);
231int mutt_window_addnstr (struct MuttWindow *win, const char *str, int num);
232int mutt_window_addstr (struct MuttWindow *win, const char *str);
233void mutt_window_clearline(struct MuttWindow *win, int row);
234void mutt_window_clear (struct MuttWindow *win);
235void mutt_window_clrtoeol (struct MuttWindow *win);
236int mutt_window_move (struct MuttWindow *win, int col, int row);
237int mutt_window_mvaddstr (struct MuttWindow *win, int col, int row, const char *str);
238int mutt_window_mvprintw (struct MuttWindow *win, int col, int row, const char *fmt, ...);
239int mutt_window_printf (struct MuttWindow *win, const char *format, ...);
240bool mutt_window_is_visible(struct MuttWindow *win);
241
242void mutt_winlist_free (struct MuttWindowList *head);
243struct MuttWindow *window_find_child (struct MuttWindow *win, enum WindowType type);
244struct MuttWindow *window_find_parent(struct MuttWindow *win, enum WindowType type);
245void window_notify_all (struct MuttWindow *win);
246void window_set_visible(struct MuttWindow *win, bool visible);
247struct MuttWindow *window_set_focus (struct MuttWindow *win);
248struct MuttWindow *window_get_focus (void);
249bool window_is_focused (const struct MuttWindow *win);
250
251void window_redraw(struct MuttWindow *win);
252void window_invalidate_all(void);
253const char *mutt_window_win_name(const struct MuttWindow *win);
254bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub);
255
256#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:696
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:502
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:605
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:341
struct MuttWindow * window_find_parent(struct MuttWindow *win, enum WindowType type)
Find a (grand-)parent of a Window by type.
Definition: mutt_window.c:548
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:143
bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub)
Organise windows according to config variable.
Definition: mutt_window.c:760
int mutt_window_printf(struct MuttWindow *win, const char *format,...)
Write a formatted string to a Window.
Definition: mutt_window.c:425
bool window_is_focused(const struct MuttWindow *win)
Does the given Window have the focus?
Definition: mutt_window.c:630
uint8_t WindowNotifyFlags
Flags for Changes to a MuttWindow, e.g. WN_TALLER.
Definition: mutt_window.h:184
WindowType
Type of Window.
Definition: mutt_window.h:70
@ WT_DLG_REMAILER
Remailer Dialog, dlg_mixmaster()
Definition: mutt_window.h:91
@ WT_CUSTOM
Window with a custom drawing function.
Definition: mutt_window.h:95
@ WT_ROOT
Parent of All Windows.
Definition: mutt_window.h:72
@ WT_DLG_ALIAS
Alias Dialog, dlg_select_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, buf_select_file()
Definition: mutt_window.h:80
@ WT_MESSAGE
Window for messages/errors and command entry.
Definition: mutt_window.h:99
@ WT_DLG_SMIME
Smime Dialog, dlg_select_smime_key()
Definition: mutt_window.h:92
@ WT_DLG_QUERY
Query Dialog, dlg_select_query()
Definition: mutt_window.h:90
@ WT_DLG_HISTORY
History Dialog, dlg_select_history()
Definition: mutt_window.h:85
@ WT_DLG_PGP
Pgp Dialog, dlg_select_pgp_key()
Definition: mutt_window.h:88
@ WT_CONTAINER
Invisible shaping container Window.
Definition: mutt_window.h:73
@ WT_DLG_CERTIFICATE
Certificate Dialog, dlg_verify_certificate()
Definition: mutt_window.h:81
@ WT_DLG_COMPOSE
Compose Dialog, mutt_compose_menu()
Definition: mutt_window.h:82
@ WT_DLG_INDEX
Index Dialog, index_pager_init()
Definition: mutt_window.h:86
@ WT_PAGER
A panel containing the Pager Window.
Definition: mutt_window.h:100
@ WT_DLG_CRYPT_GPGME
Crypt-GPGME Dialog, dlg_select_gpgme_key()
Definition: mutt_window.h:83
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
@ WT_HELP_BAR
Help Bar containing list of useful key bindings.
Definition: mutt_window.h:96
@ WT_DLG_POSTPONE
Postpone Dialog, dlg_select_postponed_email()
Definition: mutt_window.h:89
@ WT_INDEX
A panel containing the Index Window.
Definition: mutt_window.h:97
@ WT_DLG_ATTACH
Attach Dialog, dlg_select_attachment()
Definition: mutt_window.h:78
@ WT_SIDEBAR
Side panel containing Accounts or groups of data.
Definition: mutt_window.h:101
@ WT_DLG_DO_PAGER
Pager Dialog, mutt_do_pager()
Definition: mutt_window.h:84
@ WT_DLG_AUTOCRYPT
Autocrypt Dialog, dlg_select_autocrypt_account()
Definition: mutt_window.h:79
@ WT_MENU
An Window containing a Menu.
Definition: mutt_window.h:98
@ WT_DLG_PATTERN
Pattern Dialog, create_pattern_menu()
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:200
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:440
const char * mutt_window_win_name(const struct MuttWindow *win)
Get the name of a Window.
Definition: mutt_window.c:711
NotifyWindow
Window notification types.
Definition: mutt_window.h:203
@ NT_WINDOW_DIALOG
A new Dialog Window has been created, e.g. WT_DLG_INDEX.
Definition: mutt_window.h:207
@ NT_WINDOW_STATE
Window state has changed, e.g. WN_VISIBLE.
Definition: mutt_window.h:206
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:205
@ NT_WINDOW_FOCUS
Window focus has changed.
Definition: mutt_window.h:208
@ NT_WINDOW_ADD
New Window has been added.
Definition: mutt_window.h:204
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:180
struct MuttWindow * window_get_focus(void)
Get the currently focused Window.
Definition: mutt_window.c:644
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:294
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:660
TAILQ_HEAD(MuttWindowList, MuttWindow)
struct MuttWindow * mutt_window_remove_child(struct MuttWindow *parent, struct MuttWindow *child)
Remove a child from a Window.
Definition: mutt_window.c:461
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
Definition: mutt_window.c:163
void mutt_window_get_coords(struct MuttWindow *win, int *col, int *row)
Get the cursor position in the Window.
Definition: mutt_window.c:274
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:366
void mutt_winlist_free(struct MuttWindowList *head)
Free a tree of Windows.
Definition: mutt_window.c:479
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:523
uint8_t WindowActionFlags
Flags for Actions waiting to be performed on a MuttWindow, e.g. WA_REFLOW.
Definition: mutt_window.h:107
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:308
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:229
int mutt_window_addstr(struct MuttWindow *win, const char *str)
Write a string to a Window.
Definition: mutt_window.c:410
int mutt_window_addnstr(struct MuttWindow *win, const char *str, int num)
Write a partial string to a Window.
Definition: mutt_window.c:395
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:241
int mutt_window_mvprintw(struct MuttWindow *win, int col, int row, const char *fmt,...)
Move the cursor and write a formatted string to a Window.
Definition: mutt_window.c:323
void window_invalidate_all(void)
Mark all windows as in need of repaint.
Definition: mutt_window.c:743
int mutt_window_addch(struct MuttWindow *win, int ch)
Write one character to a Window.
Definition: mutt_window.c:382
A set of inherited config items.
Definition: subset.h:47
An Event that happened to a Window.
Definition: mutt_window.h:215
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:216
WindowNotifyFlags flags
Attributes of Window that changed.
Definition: mutt_window.h:217
Mapping between user-readable string and a constant.
Definition: mapping.h:32
struct WindowState old
Previous state of the Window.
Definition: mutt_window.h:128
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:142
int(* repaint)(struct MuttWindow *win)
Definition: mutt_window.h:181
short req_cols
Number of columns required.
Definition: mutt_window.h:124
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
struct MuttWindow * focus
Focused Window.
Definition: mutt_window.h:140
void * wdata
Private data.
Definition: mutt_window.h:145
enum MuttWindowOrientation orient
Which direction the Window will expand.
Definition: mutt_window.h:130
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
short req_rows
Number of rows required.
Definition: mutt_window.h:125
int(* recalc)(struct MuttWindow *win)
Definition: mutt_window.h:170
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:159
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:136
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:141
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Definition: mutt_window.h:131
TAILQ_ENTRY(MuttWindow) entries
Linked list.
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:144
Notification API.
Definition: notify.c:51
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