NeoMutt  2020-06-26-89-g172cd3
Teaching an old dog new tricks
Go to the documentation of this file.
26 #include "config.h"
27 #include <stdbool.h>
28 #include "mutt/lib.h"
34 {
37 };
43 {
47 };
55 {
56  bool visible;
57  short cols;
58  short rows;
59  short col_offset;
60  short row_offset;
61 };
67 {
68  // Structural Windows
73  // Dialogs (nested Windows) displayed to the user
90  // Common Windows
99 };
101 TAILQ_HEAD(MuttWindowList, MuttWindow);
103 typedef uint8_t WindowActionFlags;
104 #define WA_NO_FLAGS 0
105 #define WA_REFLOW (1 << 0)
106 #define WA_RECALC (1 << 1)
107 #define WA_REPAINT (1 << 2)
115 {
116  short req_cols;
117  short req_rows;
119  struct WindowState state;
120  struct WindowState old;
122  enum MuttWindowOrientation orient;
123  enum MuttWindowSize size;
126  TAILQ_ENTRY(MuttWindow) entries;
127  struct MuttWindow *parent;
128  struct MuttWindowList children;
130  struct Notify *notify;
132  enum WindowType type;
133  void *wdata;
134  void (*wdata_free)(struct MuttWindow *win, void **ptr);
141  int (*recalc)(struct MuttWindow *win, bool all);
148  int (*repaint)(struct MuttWindow *win, bool all);
149 };
151 typedef uint8_t WindowNotifyFlags;
152 #define WN_NO_FLAGS 0
153 #define WN_TALLER (1 << 0)
154 #define WN_SHORTER (1 << 1)
155 #define WN_WIDER (1 << 2)
156 #define WN_NARROWER (1 << 3)
157 #define WN_MOVED (1 << 4)
158 #define WN_VISIBLE (1 << 5)
159 #define WN_HIDDEN (1 << 6)
167 {
172 };
178 {
179  struct MuttWindow *win;
181 };
183 extern struct MuttWindow *MuttDialogWindow;
184 extern struct MuttWindow *MuttHelpWindow;
185 extern struct MuttWindow *MuttMessageWindow;
187 // Functions that deal with the Window
188 void mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child);
189 void mutt_window_copy_size (const struct MuttWindow *win_src, struct MuttWindow *win_dst);
190 void mutt_window_free (struct MuttWindow **ptr);
191 void mutt_window_free_all (void);
192 void mutt_window_get_coords (struct MuttWindow *win, int *col, int *row);
193 void mutt_window_init (void);
195 void mutt_window_reflow (struct MuttWindow *win);
196 void mutt_window_reflow_message_rows(int mw_rows);
197 struct MuttWindow *mutt_window_remove_child (struct MuttWindow *parent, struct MuttWindow *child);
198 void mutt_window_set_root (int cols, int rows);
199 int mutt_window_wrap_cols (int width, short wrap);
201 // Functions for drawing on the Window
202 int mutt_window_addch (int ch);
203 int mutt_window_addnstr (const char *str, int num);
204 int mutt_window_addstr (const char *str);
205 void mutt_window_clearline(struct MuttWindow *win, int row);
206 void mutt_window_clrtobot (void);
207 void mutt_window_clrtoeol (struct MuttWindow *win);
208 int mutt_window_move (struct MuttWindow *win, int col, int row);
209 void mutt_window_move_abs (int col, int row);
210 int mutt_window_mvaddstr (struct MuttWindow *win, int col, int row, const char *str);
211 int mutt_window_mvprintw (struct MuttWindow *win, int col, int row, const char *fmt, ...);
212 int mutt_window_printf (const char *format, ...);
213 bool mutt_window_is_visible(struct MuttWindow *win);
215 void mutt_winlist_free (struct MuttWindowList *head);
216 struct MuttWindow *mutt_window_find (struct MuttWindow *root, enum WindowType type);
217 struct MuttWindow *mutt_window_dialog(struct MuttWindow *win);
218 void window_notify_all (struct MuttWindow *win);
219 void window_set_visible(struct MuttWindow *win, bool visible);
221 void dialog_pop(void);
222 void dialog_push(struct MuttWindow *dlg);
224 void window_redraw(struct MuttWindow *win);
226 #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:302
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:653
A new Dialog Window has been created, e.g. WT_DLG_INDEX.
Definition: mutt_window.h:171
enum MuttWindowOrientation orient
Which direction the Window will expand.
Definition: mutt_window.h:122
History Dialog, history_menu()
Definition: mutt_window.h:82
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:179
An Event that happened to a Window.
Definition: mutt_window.h:177
Pager Bar containing status info about the Pager.
Definition: mutt_window.h:97
Crypt-GPGME Dialog, crypt_select_key()
Definition: mutt_window.h:80
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:216
Window for messages/errors and command entry.
Definition: mutt_window.h:95
Attach Dialog, mutt_view_attachments()
Definition: mutt_window.h:75
Window uses all available vertical space.
Definition: mutt_window.h:35
static int const char * fmt
Definition: acutest.h:488
void mutt_window_reflow_message_rows(int mw_rows)
Resize the Message Window.
Definition: mutt_window.c:455
Pgp Dialog, pgp_select_key()
Definition: mutt_window.h:84
int mutt_window_printf(const char *format,...)
Write a formatted string to a Window.
Definition: mutt_window.c:546
Query Dialog, query_menu()
Definition: mutt_window.h:86
Type of Window.
Definition: mutt_window.h:66
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:580
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:561
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:151
struct MuttWindow * mutt_window_find(struct MuttWindow *root, enum WindowType type)
Find a Window of a given type.
Definition: mutt_window.c:692
void dialog_push(struct MuttWindow *dlg)
Display a Window to the user.
Definition: mutt_window.c:720
Window is about to be deleted.
Definition: mutt_window.h:169
A division of the screen.
Definition: mutt_window.h:114
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 (and its children) visible or hidden.
Definition: mutt_window.c:108
WindowNotifyFlags flags
Attributes of Window that changed.
Definition: mutt_window.h:180
uint8_t WindowActionFlags
Actions waiting to be performed on a MuttWindow.
Definition: mutt_window.h:103
An Index Window containing a selection list.
Definition: mutt_window.h:93
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:395
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:124
struct Notify * notify
Notifications system.
Definition: mutt_window.h:130
void mutt_window_move_abs(int col, int row)
Move the cursor to an absolute screen position.
Definition: mutt_window.c:535
New Window has been added.
Definition: mutt_window.h:168
Window with a custom drawing function.
Definition: mutt_window.h:91
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:170
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:57
Autocrypt Dialog, mutt_autocrypt_account_menu()
Definition: mutt_window.h:76
Side panel containing Accounts or groups of data.
Definition: mutt_window.h:98
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:518
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:620
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:89
uint8_t WindowNotifyFlags
Changes to a MuttWindow.
Definition: mutt_window.h:151
void mutt_window_init(void)
Create the default Windows.
Definition: mutt_window.c:319
Help Bar containing list of useful key bindings.
Definition: mutt_window.h:92
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:376
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:429
Notification API.
Definition: notify.c:39
Window notification types.
Definition: mutt_window.h:166
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Definition: mutt_window.h:123
struct MuttWindow * mutt_window_dialog(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: mutt_window.c:674
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:500
The current, or old, state of a Window.
Definition: mutt_window.h:54
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:46
#define TAILQ_ENTRY(type)
Definition: queue.h:633
Window containing paged free-form text.
Definition: mutt_window.h:96
Smime Dialog, smime_select_key()
Definition: mutt_window.h:88
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:823
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:131
void mutt_winlist_free(struct MuttWindowList *head)
Free a tree of Windows.
Definition: mutt_window.c:600
struct MuttWindow * MuttHelpWindow
Help Window.
Definition: mutt_window.c:45
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:127
Postpone Dialog, select_msg()
Definition: mutt_window.h:85
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:362
void dialog_pop(void)
Hide a Window from the user.
Definition: mutt_window.c:750
void mutt_window_free_all(void)
Free all the default Windows.
Definition: mutt_window.c:283
short req_rows
Number of rows required.
Definition: mutt_window.h:117
int mutt_window_addch(int ch)
Write one character to a Window.
Definition: mutt_window.c:488
int(* repaint)(struct MuttWindow *win, bool all)
Repaint the Window.
Definition: mutt_window.h:148
Index Dialog, index_pager_init()
Definition: mutt_window.h:83
void mutt_window_copy_size(const struct MuttWindow *win_src, struct MuttWindow *win_dst)
Copy the size of one Window to another.
Definition: mutt_window.c:414
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:194
Certificate Dialog, dlg_verify_cert()
Definition: mutt_window.h:78
void * wdata
Private data.
Definition: mutt_window.h:133
Index Bar containing status info about the Index.
Definition: mutt_window.h:94
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:132
int mutt_window_wrap_cols(int width, short wrap)
Calculate the wrap column for a given screen width.
Definition: mutt_window.c:473
void mutt_window_clrtobot(void)
Clear to the bottom of the Window.
Definition: mutt_window.c:205
struct MuttWindow * MuttDialogWindow
Parent of all Dialogs.
Definition: mutt_window.c:44
int(* recalc)(struct MuttWindow *win, bool all)
Recalculate the Window data.
Definition: mutt_window.h:141
Alias Dialog, alias_menu()
Definition: mutt_window.h:74
Remailer Dialog, mix_make_chain()
Definition: mutt_window.h:87
short req_cols
Number of columns required.
Definition: mutt_window.h:116