NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
Go to the documentation of this file.
26 #include "config.h"
27 #include <stdbool.h>
28 #include <stdint.h>
29 #include "mutt/lib.h"
31 struct ConfigSubset;
37 {
40 };
46 {
50 };
58 {
59  bool visible;
60  short cols;
61  short rows;
62  short col_offset;
63  short row_offset;
64 };
70 {
71  // Structural Windows
76  // Dialogs (nested Windows) displayed to the user
94  // Common Windows
103 };
105 TAILQ_HEAD(MuttWindowList, MuttWindow);
107 typedef 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)
123 {
124  short req_cols;
125  short req_rows;
127  struct WindowState state;
128  struct WindowState old;
130  enum MuttWindowOrientation orient;
131  enum MuttWindowSize size;
134  TAILQ_ENTRY(MuttWindow) entries;
135  struct MuttWindow *parent;
136  struct MuttWindowList children;
138  struct Notify *notify;
140  struct MuttWindow *focus;
141  int help_menu;
142  const struct Mapping *help_data;
144  enum WindowType type;
145  void *wdata;
160  void (*wdata_free)(struct MuttWindow *win, void **ptr);
171  int (*recalc)(struct MuttWindow *win);
182  int (*repaint)(struct MuttWindow *win);
183 };
185 typedef 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)
204 {
210 };
216 {
217  struct MuttWindow *win;
219 };
221 // Functions that deal with the Window
222 void mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child);
223 void mutt_window_free (struct MuttWindow **ptr);
224 void mutt_window_get_coords (struct MuttWindow *win, int *col, int *row);
226 void mutt_window_reflow (struct MuttWindow *win);
227 struct MuttWindow *mutt_window_remove_child (struct MuttWindow *parent, struct MuttWindow *child);
228 int mutt_window_wrap_cols (int width, short wrap);
230 // Functions for drawing on the Window
231 int mutt_window_addch (struct MuttWindow *win, int ch);
232 int mutt_window_addnstr (struct MuttWindow *win, const char *str, int num);
233 int mutt_window_addstr (struct MuttWindow *win, const char *str);
234 void mutt_window_clearline(struct MuttWindow *win, int row);
235 void mutt_window_clear (struct MuttWindow *win);
236 void mutt_window_clrtoeol (struct MuttWindow *win);
237 int mutt_window_move (struct MuttWindow *win, int col, int row);
238 int mutt_window_mvaddstr (struct MuttWindow *win, int col, int row, const char *str);
239 int mutt_window_mvprintw (struct MuttWindow *win, int col, int row, const char *fmt, ...);
240 int mutt_window_printf (struct MuttWindow *win, const char *format, ...);
241 bool mutt_window_is_visible(struct MuttWindow *win);
243 void mutt_winlist_free (struct MuttWindowList *head);
244 struct MuttWindow *window_find_child (struct MuttWindow *win, enum WindowType type);
245 struct MuttWindow *window_find_parent(struct MuttWindow *win, enum WindowType type);
246 void window_notify_all (struct MuttWindow *win);
247 void window_set_visible(struct MuttWindow *win, bool visible);
248 struct MuttWindow *window_set_focus (struct MuttWindow *win);
249 struct MuttWindow *window_get_focus (void);
250 bool window_is_focused (struct MuttWindow *win);
252 void window_redraw(struct MuttWindow *win);
253 void window_invalidate_all(void);
254 const char *mutt_window_win_name(const struct MuttWindow *win);
255 bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub);
257 #endif /* MUTT_MUTT_WINDOW_H */
void mutt_window_get_coords(struct MuttWindow *win, int *col, int *row)
Get the cursor position in the Window.
Definition: mutt_window.c:290
New Window has been added.
Definition: mutt_window.h:205
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:529
A new Dialog Window has been created, e.g. WT_DLG_INDEX.
Definition: mutt_window.h:208
enum MuttWindowOrientation orient
Which direction the Window will expand.
Definition: mutt_window.h:130
History Dialog, dlg_select_history()
Definition: mutt_window.h:85
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:217
bool window_status_on_top(struct MuttWindow *panel, struct ConfigSubset *sub)
Organise windows according to config variable.
Definition: mutt_window.c:780
An Event that happened to a Window.
Definition: mutt_window.h:215
Crypt-GPGME Dialog, dlg_select_gpgme_key()
Definition: mutt_window.h:83
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:259
Window for messages/errors and command entry.
Definition: mutt_window.h:99
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:141
Attach Dialog, dlg_select_attachment()
Definition: mutt_window.h:78
Window uses all available vertical space.
Definition: mutt_window.h:38
Pgp Dialog, dlg_select_pgp_key()
Definition: mutt_window.h:88
Query Dialog, dlg_select_query()
Definition: mutt_window.h:90
Type of Window.
Definition: mutt_window.h:69
Which way does the Window expand?
Definition: mutt_window.h:36
struct MuttWindow * mutt_window_remove_child(struct MuttWindow *parent, struct MuttWindow *child)
Remove a child from a Window.
Definition: mutt_window.c:488
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:468
Invisible shaping container Window.
Definition: mutt_window.h:73
Parent of All Windows.
Definition: mutt_window.h:72
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:200
const char * mutt_window_win_name(const struct MuttWindow *win)
Get the name of a Window.
Definition: mutt_window.c:731
Window is about to be deleted.
Definition: mutt_window.h:206
void mutt_window_clear(struct MuttWindow *win)
Clear a Window.
Definition: mutt_window.c:716
Window focus has changed.
Definition: mutt_window.h:209
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:62
TAILQ_HEAD(MuttWindowList, MuttWindow)
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
Definition: mutt_window.c:163
int mutt_window_addch(struct MuttWindow *win, int ch)
Write one character to a Window.
Definition: mutt_window.c:402
struct MuttWindow * window_find_parent(struct MuttWindow *win, enum WindowType type)
Find a (grand-)parent of a Window by type.
Definition: mutt_window.c:575
WindowNotifyFlags flags
Attributes of Window that changed.
Definition: mutt_window.h:218
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
uint8_t WindowActionFlags
Actions waiting to be performed on a MuttWindow.
Definition: mutt_window.h:107
A panel containing the Index Window.
Definition: mutt_window.h:97
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:343
struct MuttWindow * focus
Focussed Window.
Definition: mutt_window.h:140
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
void window_invalidate_all(void)
Mark all windows as in need of repaint.
Definition: mutt_window.c:763
Window with a custom drawing function.
Definition: mutt_window.h:95
struct MuttWindow * window_get_focus(void)
Get the currently focussed Window.
Definition: mutt_window.c:664
Browser Dialog, mutt_buffer_select_file()
Definition: mutt_window.h:80
Window has a fixed size.
Definition: mutt_window.h:47
Window state has changed, e.g. WN_VISIBLE.
Definition: mutt_window.h:207
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
Autocrypt Dialog, dlg_select_autocrypt_account()
Definition: mutt_window.h:79
Side panel containing Accounts or groups of data.
Definition: mutt_window.h:101
Window size depends on its children.
Definition: mutt_window.h:49
A set of inherited config items.
Definition: subset.h:46
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:680
bool visible
Window is visible.
Definition: mutt_window.h:59
short row_offset
Absolute on-screen row.
Definition: mutt_window.h:63
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:61
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:143
uint8_t WindowNotifyFlags
Changes to a MuttWindow.
Definition: mutt_window.h:185
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:142
Help Bar containing list of useful key bindings.
Definition: mutt_window.h:96
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:324
Pager Dialog, mutt_do_pager()
Definition: mutt_window.h:84
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:361
Notification API.
Definition: notify.c:50
Window notification types.
Definition: mutt_window.h:203
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Definition: mutt_window.h:131
Container for All Dialogs (nested Windows)
Definition: mutt_window.h:74
The current, or old, state of a Window.
Definition: mutt_window.h:57
#define TAILQ_ENTRY(type)
Definition: queue.h:640
A panel containing the Pager Window.
Definition: mutt_window.h:100
Smime Dialog, dlg_select_smime_key()
Definition: mutt_window.h:92
int mutt_window_addstr(struct MuttWindow *win, const char *str)
Write a string to a Window.
Definition: mutt_window.c:434
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:632
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
void mutt_winlist_free(struct MuttWindowList *head)
Free a tree of Windows.
Definition: mutt_window.c:506
Window uses all available horizontal space.
Definition: mutt_window.h:39
Compose Dialog, mutt_compose_menu()
Definition: mutt_window.h:82
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
Pattern Dialog, create_pattern_menu()
Definition: mutt_window.h:87
int mutt_window_addnstr(struct MuttWindow *win, const char *str, int num)
Write a partial string to a Window.
Definition: mutt_window.c:415
int mutt_window_printf(struct MuttWindow *win, const char *format,...)
Write a formatted string to a Window.
Definition: mutt_window.c:453
Postpone Dialog, dlg_select_postponed_email()
Definition: mutt_window.h:89
bool window_is_focused(struct MuttWindow *win)
Does the given Window have the focus?
Definition: mutt_window.c:650
int(* repaint)(struct MuttWindow *win)
Definition: mutt_window.h:182
Mapping between user-readable string and a constant.
Definition: mapping.h:31
Control the allocation of Window space.
Definition: mutt_window.h:45
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:310
short req_rows
Number of rows required.
Definition: mutt_window.h:125
int(* recalc)(struct MuttWindow *win)
Definition: mutt_window.h:171
Index Dialog, index_pager_init()
Definition: mutt_window.h:86
Convenience wrapper for the library headers.
Window wants as much space as possible.
Definition: mutt_window.h:48
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:247
Certificate Dialog, dlg_verify_certificate()
Definition: mutt_window.h:81
void * wdata
Private data.
Definition: mutt_window.h:145
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:144
int mutt_window_wrap_cols(int width, short wrap)
Calculate the wrap column for a given screen width.
Definition: mutt_window.c:386
An Window containing a Menu.
Definition: mutt_window.h:98
Alias Dialog, dlg_select_alias()
Definition: mutt_window.h:77
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:550
Remailer Dialog, dlg_select_mixmaster_chain()
Definition: mutt_window.h:91
short req_cols
Number of columns required.
Definition: mutt_window.h:124