NeoMutt  2020-11-20
Teaching an old dog new tricks
DOXYGEN
mutt_window.h
Go to the documentation of this file.
1 
23 #ifndef MUTT_MUTT_WINDOW_H
24 #define MUTT_MUTT_WINDOW_H
25 
26 #include "config.h"
27 #include <stdbool.h>
28 #include "mutt/lib.h"
29 
34 {
37 };
38 
43 {
47 };
48 
49 #define MUTT_WIN_SIZE_UNLIMITED -1
50 
51 
55 {
56  bool visible;
57  short cols;
58  short rows;
59  short col_offset;
60  short row_offset;
61 };
62 
67 {
68  // Structural Windows
72 
73  // Dialogs (nested Windows) displayed to the user
90 
91  // Common Windows
100 };
101 
102 TAILQ_HEAD(MuttWindowList, MuttWindow);
103 
104 typedef uint8_t WindowActionFlags;
105 #define WA_NO_FLAGS 0
106 #define WA_REFLOW (1 << 0)
107 #define WA_RECALC (1 << 1)
108 #define WA_REPAINT (1 << 2)
109 
110 
116 {
117  short req_cols;
118  short req_rows;
119 
120  struct WindowState state;
121  struct WindowState old;
122 
123  enum MuttWindowOrientation orient;
124  enum MuttWindowSize size;
126 
127  TAILQ_ENTRY(MuttWindow) entries;
128  struct MuttWindow *parent;
129  struct MuttWindowList children;
130 
131  struct Notify *notify;
132 
133  struct MuttWindow *focus;
134  int help_menu;
135  const struct Mapping *help_data;
136 
137  enum WindowType type;
138  void *wdata;
139 
145  void (*wdata_free)(struct MuttWindow *win, void **ptr);
146 
153  int (*recalc)(struct MuttWindow *win);
154 
161  int (*repaint)(struct MuttWindow *win);
162 };
163 
164 typedef uint8_t WindowNotifyFlags;
165 #define WN_NO_FLAGS 0
166 #define WN_TALLER (1 << 0)
167 #define WN_SHORTER (1 << 1)
168 #define WN_WIDER (1 << 2)
169 #define WN_NARROWER (1 << 3)
170 #define WN_MOVED (1 << 4)
171 #define WN_VISIBLE (1 << 5)
172 #define WN_HIDDEN (1 << 6)
173 
174 
180 {
186 };
187 
192 {
193  struct MuttWindow *win;
195 };
196 
197 extern struct MuttWindow *RootWindow;
198 extern struct MuttWindow *AllDialogsWindow;
199 extern struct MuttWindow *MessageWindow;
200 
201 // Functions that deal with the Window
202 void mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child);
203 void mutt_window_free (struct MuttWindow **ptr);
204 void mutt_window_free_all (void);
205 void mutt_window_get_coords (struct MuttWindow *win, int *col, int *row);
206 void mutt_window_init (void);
208 void mutt_window_reflow (struct MuttWindow *win);
209 void mutt_window_reflow_message_rows(int mw_rows);
210 struct MuttWindow *mutt_window_remove_child (struct MuttWindow *parent, struct MuttWindow *child);
211 void mutt_window_set_root (int cols, int rows);
212 int mutt_window_wrap_cols (int width, short wrap);
213 
214 // Functions for drawing on the Window
215 int mutt_window_addch (int ch);
216 int mutt_window_addnstr (const char *str, int num);
217 int mutt_window_addstr (const char *str);
218 void mutt_window_clearline(struct MuttWindow *win, int row);
219 void mutt_window_clear (struct MuttWindow *win);
220 void mutt_window_clrtoeol (struct MuttWindow *win);
221 int mutt_window_move (struct MuttWindow *win, int col, int row);
222 void mutt_window_move_abs (int col, int row);
223 int mutt_window_mvaddstr (struct MuttWindow *win, int col, int row, const char *str);
224 int mutt_window_mvprintw (struct MuttWindow *win, int col, int row, const char *fmt, ...);
225 int mutt_window_printf (const char *format, ...);
226 bool mutt_window_is_visible(struct MuttWindow *win);
227 
228 void mutt_winlist_free (struct MuttWindowList *head);
229 struct MuttWindow *mutt_window_find (struct MuttWindow *root, enum WindowType type);
230 void window_notify_all (struct MuttWindow *win);
231 void window_set_visible(struct MuttWindow *win, bool visible);
232 void window_set_focus (struct MuttWindow *win);
233 struct MuttWindow *window_get_focus (void);
234 
235 void window_redraw(struct MuttWindow *win, bool force);
236 
237 #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:322
struct MuttWindow * MessageWindow
Message Window, ":set", etc.
Definition: mutt_window.c:47
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: mutt_window.c:45
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:657
A new Dialog Window has been created, e.g. WT_DLG_INDEX.
Definition: mutt_window.h:184
enum MuttWindowOrientation orient
Which direction the Window will expand.
Definition: mutt_window.h:123
History Dialog, dlg_select_history()
Definition: mutt_window.h:82
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:193
An Event that happened to a Window.
Definition: mutt_window.h:191
Pager Bar containing status info about the Pager.
Definition: mutt_window.h:98
Crypt-GPGME Dialog, dlg_select_gpgme_key()
Definition: mutt_window.h:80
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:244
Window for messages/errors and command entry.
Definition: mutt_window.h:96
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:134
Attach Dialog, dlg_select_attachment()
Definition: mutt_window.h:75
Window uses all available vertical space.
Definition: mutt_window.h:35
void mutt_window_reflow_message_rows(int mw_rows)
Resize the Message Window.
Definition: mutt_window.c:459
Pgp Dialog, dlg_select_pgp_key()
Definition: mutt_window.h:85
int mutt_window_printf(const char *format,...)
Write a formatted string to a Window.
Definition: mutt_window.c:550
Query Dialog, dlg_select_query()
Definition: mutt_window.h:87
WindowType
Type of Window.
Definition: mutt_window.h:66
MuttWindowOrientation
Which way does the Window expand?
Definition: mutt_window.h:33
struct MuttWindow * mutt_window_remove_child(struct MuttWindow *parent, struct MuttWindow *child)
Remove a child from a Window.
Definition: mutt_window.c:584
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:565
Invisible shaping container Window.
Definition: mutt_window.h:70
Parent of All Windows.
Definition: mutt_window.h:69
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:186
struct MuttWindow * mutt_window_find(struct MuttWindow *root, enum WindowType type)
Find a Window of a given type.
Definition: mutt_window.c:678
Window is about to be deleted.
Definition: mutt_window.h:182
void mutt_window_clear(struct MuttWindow *win)
Clear a Window.
Definition: mutt_window.c:806
Window focus has changed.
Definition: mutt_window.h:185
A division of the screen.
Definition: mutt_window.h:115
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:59
TAILQ_HEAD(MuttWindowList, MuttWindow)
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
Definition: mutt_window.c:149
WindowNotifyFlags flags
Attributes of Window that changed.
Definition: mutt_window.h:194
uint8_t WindowActionFlags
Actions waiting to be performed on a MuttWindow.
Definition: mutt_window.h:104
An Index Window containing a selection list.
Definition: mutt_window.h:94
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:415
struct MuttWindow * focus
Focussed Window.
Definition: mutt_window.h:133
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:125
struct Notify * notify
Notifications system.
Definition: mutt_window.h:131
void mutt_window_move_abs(int col, int row)
Move the cursor to an absolute screen position.
Definition: mutt_window.c:539
New Window has been added.
Definition: mutt_window.h:181
Window with a custom drawing function.
Definition: mutt_window.h:92
struct MuttWindow * window_get_focus(void)
Get the currently focussed Window.
Definition: mutt_window.c:790
Browser Dialog, mutt_buffer_select_file()
Definition: mutt_window.h:77
Window has a fixed size.
Definition: mutt_window.h:44
Window state has changed, e.g. WN_VISIBLE.
Definition: mutt_window.h:183
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:57
Autocrypt Dialog, dlg_select_autocrypt_account()
Definition: mutt_window.h:76
Side panel containing Accounts or groups of data.
Definition: mutt_window.h:99
Window size depends on its children.
Definition: mutt_window.h:46
int mutt_window_addstr(const char *str)
Write a string to a Window.
Definition: mutt_window.c:522
bool visible
Window is visible.
Definition: mutt_window.h:56
short row_offset
Absolute on-screen row.
Definition: mutt_window.h:60
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:58
void mutt_window_set_root(int cols, int rows)
Set the dimensions of the Root Window.
Definition: mutt_window.c:624
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:129
uint8_t WindowNotifyFlags
Changes to a MuttWindow.
Definition: mutt_window.h:164
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:135
void mutt_window_init(void)
Create the default Windows.
Definition: mutt_window.c:339
Help Bar containing list of useful key bindings.
Definition: mutt_window.h:93
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:396
Pager Dialog, mutt_do_pager()
Definition: mutt_window.h:81
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:433
Notification API.
Definition: notify.c:39
NotifyWindow
Window notification types.
Definition: mutt_window.h:179
struct MuttWindow * AllDialogsWindow
Parent of all Dialogs.
Definition: mutt_window.c:46
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Definition: mutt_window.h:124
Container for All Dialogs (nested Windows)
Definition: mutt_window.h:71
int mutt_window_addnstr(const char *str, int num)
Write a partial string to a Window.
Definition: mutt_window.c:504
The current, or old, state of a Window.
Definition: mutt_window.h:54
#define TAILQ_ENTRY(type)
Definition: queue.h:633
Window containing paged free-form text.
Definition: mutt_window.h:97
Smime Dialog, dlg_select_smime_key()
Definition: mutt_window.h:89
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:166
void mutt_winlist_free(struct MuttWindowList *head)
Free a tree of Windows.
Definition: mutt_window.c:604
Window uses all available horizontal space.
Definition: mutt_window.h:36
Compose Dialog, mutt_compose_menu()
Definition: mutt_window.h:79
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:128
Pattern Dialog, create_pattern_menu()
Definition: mutt_window.h:84
void window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:763
void window_redraw(struct MuttWindow *win, bool force)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:747
Postpone Dialog, dlg_select_postponed_email()
Definition: mutt_window.h:86
int(* repaint)(struct MuttWindow *win)
Repaint the Window.
Definition: mutt_window.h:161
Mapping between user-readable string and a constant.
Definition: mapping.h:31
MuttWindowSize
Control the allocation of Window space.
Definition: mutt_window.h:42
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:382
void mutt_window_free_all(void)
Free all the default Windows.
Definition: mutt_window.c:304
short req_rows
Number of rows required.
Definition: mutt_window.h:118
int(* recalc)(struct MuttWindow *win)
Recalculate the Window data.
Definition: mutt_window.h:153
int mutt_window_addch(int ch)
Write one character to a Window.
Definition: mutt_window.c:492
Index Dialog, index_pager_init()
Definition: mutt_window.h:83
Convenience wrapper for the library headers.
Window wants as much space as possible.
Definition: mutt_window.h:45
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:232
Certificate Dialog, dlg_verify_certificate()
Definition: mutt_window.h:78
void * wdata
Private data.
Definition: mutt_window.h:138
Index Bar containing status info about the Index.
Definition: mutt_window.h:95
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:137
int mutt_window_wrap_cols(int width, short wrap)
Calculate the wrap column for a given screen width.
Definition: mutt_window.c:477
Alias Dialog, dlg_select_alias()
Definition: mutt_window.h:74
Remailer Dialog, dlg_select_mixmaster_chain()
Definition: mutt_window.h:88
short req_cols
Number of columns required.
Definition: mutt_window.h:117