NeoMutt  2021-02-05-329-g9e03b7
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"
35 {
38 };
44 {
48 };
56 {
57  bool visible;
58  short cols;
59  short rows;
60  short col_offset;
61  short row_offset;
62 };
68 {
69  // Structural Windows
74  // Dialogs (nested Windows) displayed to the user
92  // Common Windows
102 };
104 TAILQ_HEAD(MuttWindowList, MuttWindow);
106 typedef uint8_t WindowActionFlags;
107 #define WA_NO_FLAGS 0
108 #define WA_REFLOW (1 << 0)
109 #define WA_RECALC (1 << 1)
110 #define WA_REPAINT (1 << 2)
118 {
119  short req_cols;
120  short req_rows;
122  struct WindowState state;
123  struct WindowState old;
125  enum MuttWindowOrientation orient;
126  enum MuttWindowSize size;
129  TAILQ_ENTRY(MuttWindow) entries;
130  struct MuttWindow *parent;
131  struct MuttWindowList children;
133  struct Notify *notify;
135  struct MuttWindow *focus;
136  int help_menu;
137  const struct Mapping *help_data;
139  enum WindowType type;
140  void *wdata;
147  void (*wdata_free)(struct MuttWindow *win, void **ptr);
155  int (*recalc)(struct MuttWindow *win);
163  int (*repaint)(struct MuttWindow *win);
164 };
166 typedef uint8_t WindowNotifyFlags;
167 #define WN_NO_FLAGS 0
168 #define WN_TALLER (1 << 0)
169 #define WN_SHORTER (1 << 1)
170 #define WN_WIDER (1 << 2)
171 #define WN_NARROWER (1 << 3)
172 #define WN_MOVED (1 << 4)
173 #define WN_VISIBLE (1 << 5)
174 #define WN_HIDDEN (1 << 6)
182 {
188 };
194 {
195  struct MuttWindow *win;
197 };
199 extern struct MuttWindow *RootWindow;
200 extern struct MuttWindow *AllDialogsWindow;
201 extern struct MuttWindow *MessageWindow;
203 // Functions that deal with the Window
204 void mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child);
205 void mutt_window_free (struct MuttWindow **ptr);
206 void mutt_window_free_all (void);
207 void mutt_window_get_coords (struct MuttWindow *win, int *col, int *row);
208 void mutt_window_init (void);
210 void mutt_window_reflow (struct MuttWindow *win);
211 void mutt_window_reflow_message_rows(int mw_rows);
212 struct MuttWindow *mutt_window_remove_child (struct MuttWindow *parent, struct MuttWindow *child);
213 void mutt_window_set_root (int cols, int rows);
214 int mutt_window_wrap_cols (int width, short wrap);
216 // Functions for drawing on the Window
217 int mutt_window_addch (int ch);
218 int mutt_window_addnstr (const char *str, int num);
219 int mutt_window_addstr (const char *str);
220 void mutt_window_clearline(struct MuttWindow *win, int row);
221 void mutt_window_clear (struct MuttWindow *win);
222 void mutt_window_clrtoeol (struct MuttWindow *win);
223 int mutt_window_move (struct MuttWindow *win, int col, int row);
224 void mutt_window_move_abs (int col, int row);
225 int mutt_window_mvaddstr (struct MuttWindow *win, int col, int row, const char *str);
226 int mutt_window_mvprintw (struct MuttWindow *win, int col, int row, const char *fmt, ...);
227 int mutt_window_printf (const char *format, ...);
228 bool mutt_window_is_visible(struct MuttWindow *win);
230 void mutt_winlist_free (struct MuttWindowList *head);
231 struct MuttWindow *mutt_window_find (struct MuttWindow *root, enum WindowType type);
232 void window_notify_all (struct MuttWindow *win);
233 void window_set_visible(struct MuttWindow *win, bool visible);
234 void window_set_focus (struct MuttWindow *win);
235 struct MuttWindow *window_get_focus (void);
236 struct MuttWindow *window_get_dialog (void);
238 void window_redraw(struct MuttWindow *win, bool force);
240 #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:321
struct MuttWindow * MessageWindow
Message Window, ":set", etc.
Definition: mutt_window.c:45
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: mutt_window.c:43
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:654
A new Dialog Window has been created, e.g. WT_DLG_INDEX.
Definition: mutt_window.h:186
enum MuttWindowOrientation orient
Which direction the Window will expand.
Definition: mutt_window.h:125
History Dialog, dlg_select_history()
Definition: mutt_window.h:83
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:195
An Event that happened to a Window.
Definition: mutt_window.h:193
Pager Bar containing status info about the Pager.
Definition: mutt_window.h:100
Crypt-GPGME Dialog, dlg_select_gpgme_key()
Definition: mutt_window.h:81
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:242
Window for messages/errors and command entry.
Definition: mutt_window.h:98
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:136
Attach Dialog, dlg_select_attachment()
Definition: mutt_window.h:76
Window uses all available vertical space.
Definition: mutt_window.h:36
struct MuttWindow * window_get_dialog(void)
Get the currently active Dialog.
Definition: mutt_window.c:801
void mutt_window_reflow_message_rows(int mw_rows)
Resize the Message Window.
Definition: mutt_window.c:456
Pgp Dialog, dlg_select_pgp_key()
Definition: mutt_window.h:86
int mutt_window_printf(const char *format,...)
Write a formatted string to a Window.
Definition: mutt_window.c:547
Query Dialog, dlg_select_query()
Definition: mutt_window.h:88
Type of Window.
Definition: mutt_window.h:67
Which way does the Window expand?
Definition: mutt_window.h:34
struct MuttWindow * mutt_window_remove_child(struct MuttWindow *parent, struct MuttWindow *child)
Remove a child from a Window.
Definition: mutt_window.c:581
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:562
Invisible shaping container Window.
Definition: mutt_window.h:71
Parent of All Windows.
Definition: mutt_window.h:70
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:184
struct MuttWindow * mutt_window_find(struct MuttWindow *root, enum WindowType type)
Find a Window of a given type.
Definition: mutt_window.c:675
Window is about to be deleted.
Definition: mutt_window.h:184
void mutt_window_clear(struct MuttWindow *win)
Clear a Window.
Definition: mutt_window.c:822
Window focus has changed.
Definition: mutt_window.h:187
A division of the screen.
Definition: mutt_window.h:117
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:60
TAILQ_HEAD(MuttWindowList, MuttWindow)
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
Definition: mutt_window.c:147
WindowNotifyFlags flags
Attributes of Window that changed.
Definition: mutt_window.h:196
uint8_t WindowActionFlags
Actions waiting to be performed on a MuttWindow.
Definition: mutt_window.h:106
A panel containing the Index Window.
Definition: mutt_window.h:95
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:135
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:127
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:133
void mutt_window_move_abs(int col, int row)
Move the cursor to an absolute screen position.
Definition: mutt_window.c:536
New Window has been added.
Definition: mutt_window.h:183
Window with a custom drawing function.
Definition: mutt_window.h:93
struct MuttWindow * window_get_focus(void)
Get the currently focussed Window.
Definition: mutt_window.c:787
Browser Dialog, mutt_buffer_select_file()
Definition: mutt_window.h:78
Window has a fixed size.
Definition: mutt_window.h:45
Window state has changed, e.g. WN_VISIBLE.
Definition: mutt_window.h:185
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:58
Autocrypt Dialog, dlg_select_autocrypt_account()
Definition: mutt_window.h:77
Side panel containing Accounts or groups of data.
Definition: mutt_window.h:101
Window size depends on its children.
Definition: mutt_window.h:47
int mutt_window_addstr(const char *str)
Write a string to a Window.
Definition: mutt_window.c:519
bool visible
Window is visible.
Definition: mutt_window.h:57
short row_offset
Absolute on-screen row.
Definition: mutt_window.h:61
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:59
void mutt_window_set_root(int cols, int rows)
Set the dimensions of the Root Window.
Definition: mutt_window.c:621
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:127
uint8_t WindowNotifyFlags
Changes to a MuttWindow.
Definition: mutt_window.h:166
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:137
void mutt_window_init(void)
Create the default Windows.
Definition: mutt_window.c:338
Help Bar containing list of useful key bindings.
Definition: mutt_window.h:94
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:82
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:433
Notification API.
Definition: notify.c:39
Window notification types.
Definition: mutt_window.h:181
struct MuttWindow * AllDialogsWindow
Parent of all Dialogs.
Definition: mutt_window.c:44
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Definition: mutt_window.h:126
Container for All Dialogs (nested Windows)
Definition: mutt_window.h:72
int mutt_window_addnstr(const char *str, int num)
Write a partial string to a Window.
Definition: mutt_window.c:501
The current, or old, state of a Window.
Definition: mutt_window.h:55
#define TAILQ_ENTRY(type)
Definition: queue.h:633
A panel containing the Pager Window.
Definition: mutt_window.h:99
Smime Dialog, dlg_select_smime_key()
Definition: mutt_window.h:90
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:164
void mutt_winlist_free(struct MuttWindowList *head)
Free a tree of Windows.
Definition: mutt_window.c:601
Window uses all available horizontal space.
Definition: mutt_window.h:37
Compose Dialog, mutt_compose_menu()
Definition: mutt_window.h:80
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:130
Pattern Dialog, create_pattern_menu()
Definition: mutt_window.h:85
void window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:760
void window_redraw(struct MuttWindow *win, bool force)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:744
Postpone Dialog, dlg_select_postponed_email()
Definition: mutt_window.h:87
int(* repaint)(struct MuttWindow *win)
Repaint the Window.
Definition: mutt_window.h:163
Mapping between user-readable string and a constant.
Definition: mapping.h:31
Control the allocation of Window space.
Definition: mutt_window.h:43
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:303
short req_rows
Number of rows required.
Definition: mutt_window.h:120
int(* recalc)(struct MuttWindow *win)
Recalculate the Window data.
Definition: mutt_window.h:155
int mutt_window_addch(int ch)
Write one character to a Window.
Definition: mutt_window.c:489
Index Dialog, index_pager_init()
Definition: mutt_window.h:84
Convenience wrapper for the library headers.
Window wants as much space as possible.
Definition: mutt_window.h:46
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:230
Certificate Dialog, dlg_verify_certificate()
Definition: mutt_window.h:79
void * wdata
Private data.
Definition: mutt_window.h:140
Index Bar containing status info about the Index.
Definition: mutt_window.h:96
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:139
int mutt_window_wrap_cols(int width, short wrap)
Calculate the wrap column for a given screen width.
Definition: mutt_window.c:474
An Window containing a Menu.
Definition: mutt_window.h:97
Alias Dialog, dlg_select_alias()
Definition: mutt_window.h:75
Remailer Dialog, dlg_select_mixmaster_chain()
Definition: mutt_window.h:89
short req_cols
Number of columns required.
Definition: mutt_window.h:119