NeoMutt  2024-11-14-138-ge5ca67
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
mutt_window.h
Go to the documentation of this file.
1
24#ifndef MUTT_GUI_MUTT_WINDOW_H
25#define MUTT_GUI_MUTT_WINDOW_H
26
27#include "config.h"
28#include <stdbool.h>
29#include <stdint.h>
30#include "mutt/lib.h"
31
32struct ConfigSubset;
33
38{
41};
42
47{
51};
52
53#define MUTT_WIN_SIZE_UNLIMITED -1
54
59{
60 bool visible;
61 short cols;
62 short rows;
63 short col_offset;
64 short row_offset;
65};
66
71{
72 // Structural Windows
76
77 // 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
173 int (*recalc)(struct MuttWindow *win);
174
187 int (*repaint)(struct MuttWindow *win);
188
205 bool (*recursor)(struct MuttWindow *win);
206};
207
208typedef uint8_t WindowNotifyFlags;
209#define WN_NO_FLAGS 0
210#define WN_TALLER (1 << 0)
211#define WN_SHORTER (1 << 1)
212#define WN_WIDER (1 << 2)
213#define WN_NARROWER (1 << 3)
214#define WN_MOVED (1 << 4)
215#define WN_VISIBLE (1 << 5)
216#define WN_HIDDEN (1 << 6)
217
227{
233};
234
239{
240 struct MuttWindow *win;
242};
243
244// Functions that deal with the Window
245void mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child);
246void mutt_window_free (struct MuttWindow **ptr);
247void mutt_window_get_coords (struct MuttWindow *win, int *col, int *row);
248struct MuttWindow *mutt_window_new (enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows);
249void mutt_window_reflow (struct MuttWindow *win);
250struct MuttWindow *mutt_window_remove_child (struct MuttWindow *parent, struct MuttWindow *child);
251int mutt_window_wrap_cols (int width, short wrap);
252
253// Functions for drawing on the Window
254int mutt_window_addch (struct MuttWindow *win, int ch);
255int mutt_window_addnstr (struct MuttWindow *win, const char *str, int num);
256int mutt_window_addstr (struct MuttWindow *win, const char *str);
257void mutt_window_clearline(struct MuttWindow *win, int row);
258void mutt_window_clear (struct MuttWindow *win);
259void mutt_window_clrtoeol (struct MuttWindow *win);
260int mutt_window_move (struct MuttWindow *win, int col, int row);
261int mutt_window_mvaddstr (struct MuttWindow *win, int col, int row, const char *str);
262int mutt_window_mvprintw (struct MuttWindow *win, int col, int row, const char *fmt, ...)
263 __attribute__((__format__(__printf__, 4, 5)));
264int mutt_window_printf (struct MuttWindow *win, const char *format, ...)
265 __attribute__((__format__(__printf__, 2, 3)));
266bool mutt_window_is_visible(struct MuttWindow *win);
267
268void mutt_winlist_free (struct MuttWindowList *head);
269struct MuttWindow *window_find_child (struct MuttWindow *win, enum WindowType type);
270struct MuttWindow *window_find_parent(struct MuttWindow *win, enum WindowType type);
271void window_notify_all (struct MuttWindow *win);
272void window_set_visible(struct MuttWindow *win, bool visible);
273struct MuttWindow *window_set_focus (struct MuttWindow *win);
274struct MuttWindow *window_get_focus (void);
275bool window_is_focused (const struct MuttWindow *win);
276
277void window_redraw(struct MuttWindow *win);
278void window_invalidate_all(void);
279const char *mutt_window_win_name(const struct MuttWindow *win);
280bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub);
281bool mutt_window_swap(struct MuttWindow *parent, struct MuttWindow *win1,
282 struct MuttWindow *win2);
283
284#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:720
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:634
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:344
int int bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:512
struct MuttWindow * window_find_parent(struct MuttWindow *win, enum WindowType type)
Find a (grand-)parent of a Window by type.
Definition: mutt_window.c:558
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:145
bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub)
Organise windows according to config variable.
Definition: mutt_window.c:784
bool window_is_focused(const struct MuttWindow *win)
Does the given Window have the focus?
Definition: mutt_window.c:654
uint8_t WindowNotifyFlags
Flags for Changes to a MuttWindow, e.g. WN_TALLER.
Definition: mutt_window.h:208
WindowType
Type of Window.
Definition: mutt_window.h:71
@ WT_CUSTOM
Window with a custom drawing function.
Definition: mutt_window.h:95
@ WT_ROOT
Parent of All Windows.
Definition: mutt_window.h:73
@ WT_DLG_ALIAS
Alias Dialog, dlg_alias()
Definition: mutt_window.h:78
@ WT_ALL_DIALOGS
Container for All Dialogs (nested Windows)
Definition: mutt_window.h:75
@ WT_DLG_BROWSER
Browser Dialog, dlg_browser()
Definition: mutt_window.h:81
@ WT_MESSAGE
Window for messages/errors.
Definition: mutt_window.h:99
@ WT_DLG_SMIME
Smime Dialog, dlg_smime()
Definition: mutt_window.h:92
@ WT_DLG_QUERY
Query Dialog, dlg_query()
Definition: mutt_window.h:91
@ WT_DLG_HISTORY
History Dialog, dlg_history()
Definition: mutt_window.h:86
@ WT_DLG_PGP
Pgp Dialog, dlg_pgp()
Definition: mutt_window.h:89
@ WT_CONTAINER
Invisible shaping container Window.
Definition: mutt_window.h:74
@ WT_DLG_CERTIFICATE
Certificate Dialog, dlg_certificate()
Definition: mutt_window.h:82
@ WT_DLG_COMPOSE
Compose Dialog, dlg_compose()
Definition: mutt_window.h:83
@ WT_DLG_INDEX
Index Dialog, dlg_index()
Definition: mutt_window.h:87
@ WT_PAGER
A panel containing the Pager Window.
Definition: mutt_window.h:100
@ WT_DLG_GPGME
GPGME Dialog, dlg_gpgme()
Definition: mutt_window.h:84
@ 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_POSTPONED
Postponed Dialog, dlg_postponed()
Definition: mutt_window.h:90
@ WT_INDEX
A panel containing the Index Window.
Definition: mutt_window.h:97
@ WT_DLG_ATTACHMENT
Attachment Dialog, dlg_attachment()
Definition: mutt_window.h:79
@ WT_SIDEBAR
Side panel containing Accounts or groups of data.
Definition: mutt_window.h:101
@ WT_DLG_PAGER
Pager Dialog, dlg_pager()
Definition: mutt_window.h:85
@ WT_DLG_AUTOCRYPT
Autocrypt Dialog, dlg_autocrypt()
Definition: mutt_window.h:80
@ WT_MENU
An Window containing a Menu.
Definition: mutt_window.h:98
@ WT_DLG_PATTERN
Pattern Dialog, dlg_pattern()
Definition: mutt_window.h:88
MuttWindowOrientation
Which way does the Window expand?
Definition: mutt_window.h:38
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition: mutt_window.h:39
@ MUTT_WIN_ORIENT_HORIZONTAL
Window uses all available horizontal space.
Definition: mutt_window.h:40
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:202
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:446
const char * mutt_window_win_name(const struct MuttWindow *win)
Get the name of a Window.
Definition: mutt_window.c:735
NotifyWindow
Window notification types.
Definition: mutt_window.h:227
@ NT_WINDOW_DIALOG
A new Dialog Window has been created, e.g. WT_DLG_INDEX.
Definition: mutt_window.h:231
@ NT_WINDOW_STATE
Window state has changed, e.g. WN_VISIBLE.
Definition: mutt_window.h:230
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:229
@ NT_WINDOW_FOCUS
Window focus has changed.
Definition: mutt_window.h:232
@ NT_WINDOW_ADD
New Window has been added.
Definition: mutt_window.h:228
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:182
struct MuttWindow * window_get_focus(void)
Get the currently focused Window.
Definition: mutt_window.c:668
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:297
bool mutt_window_swap(struct MuttWindow *parent, struct MuttWindow *win1, struct MuttWindow *win2)
Swap the position of two windows.
Definition: mutt_window.c:820
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:684
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:468
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
Definition: mutt_window.c:165
void mutt_window_get_coords(struct MuttWindow *win, int *col, int *row)
Get the cursor position in the Window.
Definition: mutt_window.c:277
MuttWindowSize
Control the allocation of Window space.
Definition: mutt_window.h:47
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
Definition: mutt_window.h:48
@ MUTT_WIN_SIZE_MINIMISE
Window size depends on its children.
Definition: mutt_window.h:50
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition: mutt_window.h:49
int mutt_window_wrap_cols(int width, short wrap)
Calculate the wrap column for a given screen width.
Definition: mutt_window.c:372
void mutt_winlist_free(struct MuttWindowList *head)
Free a tree of Windows.
Definition: mutt_window.c:489
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:533
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:311
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:232
int mutt_window_addstr(struct MuttWindow *win, const char *str)
Write a string to a Window.
Definition: mutt_window.c:416
int mutt_window_addnstr(struct MuttWindow *win, const char *str, int num)
Write a partial string to a Window.
Definition: mutt_window.c:401
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:244
void window_invalidate_all(void)
Mark all windows as in need of repaint.
Definition: mutt_window.c:767
int mutt_window_addch(struct MuttWindow *win, int ch)
Write one character to a Window.
Definition: mutt_window.c:388
#define TAILQ_HEAD(name, type)
Definition: queue.h:641
A set of inherited config items.
Definition: subset.h:47
An Event that happened to a Window.
Definition: mutt_window.h:239
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:240
WindowNotifyFlags flags
Attributes of Window that changed.
Definition: mutt_window.h:241
Mapping between user-readable string and a constant.
Definition: mapping.h:33
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:187
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:173
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
bool(* recursor)(struct MuttWindow *win)
Definition: mutt_window.h:205
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:53
The current, or old, state of a Window.
Definition: mutt_window.h:59
bool visible
Window is visible.
Definition: mutt_window.h:60
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:61
short row_offset
Absolute on-screen row.
Definition: mutt_window.h:64
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:63
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:62