NeoMutt  2022-04-29-249-gaae397
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
160 void (*wdata_free)(struct MuttWindow *win, void **ptr);
161
171 int (*recalc)(struct MuttWindow *win);
172
182 int (*repaint)(struct MuttWindow *win);
183};
184
185typedef uint8_t WindowNotifyFlags;
186#define WN_NO_FLAGS 0
187#define WN_TALLER (1 << 0)
188#define WN_SHORTER (1 << 1)
189#define WN_WIDER (1 << 2)
190#define WN_NARROWER (1 << 3)
191#define WN_MOVED (1 << 4)
192#define WN_VISIBLE (1 << 5)
193#define WN_HIDDEN (1 << 6)
194
204{
210};
211
216{
217 struct MuttWindow *win;
219};
220
221// Functions that deal with the Window
222void mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child);
223void mutt_window_free (struct MuttWindow **ptr);
224void mutt_window_get_coords (struct MuttWindow *win, int *col, int *row);
225struct MuttWindow *mutt_window_new (enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows);
226void mutt_window_reflow (struct MuttWindow *win);
227struct MuttWindow *mutt_window_remove_child (struct MuttWindow *parent, struct MuttWindow *child);
228int mutt_window_wrap_cols (int width, short wrap);
229
230// Functions for drawing on the Window
231int mutt_window_addch (struct MuttWindow *win, int ch);
232int mutt_window_addnstr (struct MuttWindow *win, const char *str, int num);
233int mutt_window_addstr (struct MuttWindow *win, const char *str);
234void mutt_window_clearline(struct MuttWindow *win, int row);
235void mutt_window_clear (struct MuttWindow *win);
236void mutt_window_clrtoeol (struct MuttWindow *win);
237int mutt_window_move (struct MuttWindow *win, int col, int row);
238int mutt_window_mvaddstr (struct MuttWindow *win, int col, int row, const char *str);
239int mutt_window_mvprintw (struct MuttWindow *win, int col, int row, const char *fmt, ...);
240int mutt_window_printf (struct MuttWindow *win, const char *format, ...);
241bool mutt_window_is_visible(struct MuttWindow *win);
242
243void mutt_winlist_free (struct MuttWindowList *head);
244struct MuttWindow *window_find_child (struct MuttWindow *win, enum WindowType type);
245struct MuttWindow *window_find_parent(struct MuttWindow *win, enum WindowType type);
246void window_notify_all (struct MuttWindow *win);
247void window_set_visible(struct MuttWindow *win, bool visible);
248struct MuttWindow *window_set_focus (struct MuttWindow *win);
249struct MuttWindow *window_get_focus (void);
250bool window_is_focused (const struct MuttWindow *win);
251
252void window_redraw(struct MuttWindow *win);
253void window_invalidate_all(void);
254const char *mutt_window_win_name(const struct MuttWindow *win);
255bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub);
256
257#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:695
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:501
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:604
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:340
struct MuttWindow * window_find_parent(struct MuttWindow *win, enum WindowType type)
Find a (grand-)parent of a Window by type.
Definition: mutt_window.c:547
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:759
int mutt_window_printf(struct MuttWindow *win, const char *format,...)
Write a formatted string to a Window.
Definition: mutt_window.c:424
bool window_is_focused(const struct MuttWindow *win)
Does the given Window have the focus?
Definition: mutt_window.c:629
uint8_t WindowNotifyFlags
Flags for Changes to a MuttWindow, e.g. WN_TALLER.
Definition: mutt_window.h:185
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, mutt_buffer_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:201
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:439
const char * mutt_window_win_name(const struct MuttWindow *win)
Get the name of a Window.
Definition: mutt_window.c:710
NotifyWindow
Window notification types.
Definition: mutt_window.h:204
@ NT_WINDOW_DIALOG
A new Dialog Window has been created, e.g. WT_DLG_INDEX.
Definition: mutt_window.h:208
@ NT_WINDOW_STATE
Window state has changed, e.g. WN_VISIBLE.
Definition: mutt_window.h:207
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:206
@ NT_WINDOW_FOCUS
Window focus has changed.
Definition: mutt_window.h:209
@ NT_WINDOW_ADD
New Window has been added.
Definition: mutt_window.h:205
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:643
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:293
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:659
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:460
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:273
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:365
void mutt_winlist_free(struct MuttWindowList *head)
Free a tree of Windows.
Definition: mutt_window.c:478
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:522
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:307
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:230
int mutt_window_addstr(struct MuttWindow *win, const char *str)
Write a string to a Window.
Definition: mutt_window.c:409
int mutt_window_addnstr(struct MuttWindow *win, const char *str, int num)
Write a partial string to a Window.
Definition: mutt_window.c:394
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:242
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:322
void window_invalidate_all(void)
Mark all windows as in need of repaint.
Definition: mutt_window.c:742
int mutt_window_addch(struct MuttWindow *win, int ch)
Write one character to a Window.
Definition: mutt_window.c:381
A set of inherited config items.
Definition: subset.h:47
An Event that happened to a Window.
Definition: mutt_window.h:216
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:217
WindowNotifyFlags flags
Attributes of Window that changed.
Definition: mutt_window.h:218
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:182
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:171
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:160
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