NeoMutt  2021-02-05-89-gabe350
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 
121  struct WindowState old;
122 
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 
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);
207 struct MuttWindow *mutt_window_new (enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows);
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 */
WT_DLG_POSTPONE
@ WT_DLG_POSTPONE
Postpone Dialog, dlg_select_postponed_email()
Definition: mutt_window.h:86
WT_CUSTOM
@ WT_CUSTOM
Window with a custom drawing function.
Definition: mutt_window.h:92
WT_PAGER
@ WT_PAGER
Window containing paged free-form text.
Definition: mutt_window.h:97
NT_WINDOW_STATE
@ NT_WINDOW_STATE
Window state has changed, e.g. WN_VISIBLE.
Definition: mutt_window.h:183
WT_DLG_ATTACH
@ WT_DLG_ATTACH
Attach Dialog, dlg_select_attachment()
Definition: mutt_window.h:75
WT_PAGER_BAR
@ WT_PAGER_BAR
Pager Bar containing status info about the Pager.
Definition: mutt_window.h:98
WT_ROOT
@ WT_ROOT
Parent of All Windows.
Definition: mutt_window.h:69
MuttWindowSize
MuttWindowSize
Control the allocation of Window space.
Definition: mutt_window.h:42
EventWindow::flags
WindowNotifyFlags flags
Attributes of Window that changed.
Definition: mutt_window.h:194
MUTT_WIN_ORIENT_HORIZONTAL
@ MUTT_WIN_ORIENT_HORIZONTAL
Window uses all available horizontal space.
Definition: mutt_window.h:36
WT_DLG_CERTIFICATE
@ WT_DLG_CERTIFICATE
Certificate Dialog, dlg_verify_certificate()
Definition: mutt_window.h:78
mutt_window_remove_child
struct MuttWindow * mutt_window_remove_child(struct MuttWindow *parent, struct MuttWindow *child)
Remove a child from a Window.
Definition: mutt_window.c:584
mutt_window_mvaddstr
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
WindowType
WindowType
Type of Window.
Definition: mutt_window.h:66
MuttWindow::req_cols
short req_cols
Number of columns required.
Definition: mutt_window.h:117
WT_DLG_AUTOCRYPT
@ WT_DLG_AUTOCRYPT
Autocrypt Dialog, dlg_select_autocrypt_account()
Definition: mutt_window.h:76
AllDialogsWindow
struct MuttWindow * AllDialogsWindow
Parent of all Dialogs.
Definition: mutt_window.c:46
window_set_visible
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
Definition: mutt_window.c:149
EventWindow::win
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:193
MuttWindow
A division of the screen.
Definition: mutt_window.h:115
MuttWindow::wdata_free
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Free the private data attached to the MuttWindow.
Definition: mutt_window.h:145
WindowState::row_offset
short row_offset
Absolute on-screen row.
Definition: mutt_window.h:60
WindowState::visible
bool visible
Window is visible.
Definition: mutt_window.h:56
WT_DLG_CRYPT_GPGME
@ WT_DLG_CRYPT_GPGME
Crypt-GPGME Dialog, dlg_select_gpgme_key()
Definition: mutt_window.h:80
NT_WINDOW_DIALOG
@ NT_WINDOW_DIALOG
A new Dialog Window has been created, e.g. WT_DLG_INDEX.
Definition: mutt_window.h:184
MuttWindow::help_menu
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:134
WindowActionFlags
uint8_t WindowActionFlags
Actions waiting to be performed on a MuttWindow.
Definition: mutt_window.h:104
mutt_winlist_free
void mutt_winlist_free(struct MuttWindowList *head)
Free a tree of Windows.
Definition: mutt_window.c:604
MuttWindowOrientation
MuttWindowOrientation
Which way does the Window expand?
Definition: mutt_window.h:33
MUTT_WIN_SIZE_MAXIMISE
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition: mutt_window.h:45
WT_DLG_COMPOSE
@ WT_DLG_COMPOSE
Compose Dialog, mutt_compose_menu()
Definition: mutt_window.h:79
WT_DLG_PGP
@ WT_DLG_PGP
Pgp Dialog, dlg_select_pgp_key()
Definition: mutt_window.h:85
WT_SIDEBAR
@ WT_SIDEBAR
Side panel containing Accounts or groups of data.
Definition: mutt_window.h:99
mutt_window_add_child
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:565
Mapping
Mapping between user-readable string and a constant.
Definition: mapping.h:31
TAILQ_HEAD
TAILQ_HEAD(MuttWindowList, MuttWindow)
NT_WINDOW_DELETE
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:182
window_get_focus
struct MuttWindow * window_get_focus(void)
Get the currently focussed Window.
Definition: mutt_window.c:790
mutt_window_new
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
mutt_window_move_abs
void mutt_window_move_abs(int col, int row)
Move the cursor to an absolute screen position.
Definition: mutt_window.c:539
WindowState::col_offset
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:59
WT_MESSAGE
@ WT_MESSAGE
Window for messages/errors and command entry.
Definition: mutt_window.h:96
MuttWindow::focus
struct MuttWindow * focus
Focussed Window.
Definition: mutt_window.h:133
MuttWindow::notify
struct Notify * notify
Notifications system.
Definition: mutt_window.h:131
window_redraw
void window_redraw(struct MuttWindow *win, bool force)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:747
mutt_window_printf
int mutt_window_printf(const char *format,...)
Write a formatted string to a Window.
Definition: mutt_window.c:550
mutt_window_get_coords
void mutt_window_get_coords(struct MuttWindow *win, int *col, int *row)
Get the cursor position in the Window.
Definition: mutt_window.c:322
MUTT_WIN_ORIENT_VERTICAL
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition: mutt_window.h:35
mutt_window_addnstr
int mutt_window_addnstr(const char *str, int num)
Write a partial string to a Window.
Definition: mutt_window.c:504
lib.h
MuttWindow::old
struct WindowState old
Previous state of the Window.
Definition: mutt_window.h:121
WT_DLG_QUERY
@ WT_DLG_QUERY
Query Dialog, dlg_select_query()
Definition: mutt_window.h:87
mutt_window_wrap_cols
int mutt_window_wrap_cols(int width, short wrap)
Calculate the wrap column for a given screen width.
Definition: mutt_window.c:477
MuttWindow::actions
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:125
WindowState
The current, or old, state of a Window.
Definition: mutt_window.h:54
WT_DLG_INDEX
@ WT_DLG_INDEX
Index Dialog, index_pager_init()
Definition: mutt_window.h:83
NT_WINDOW_NEW
@ NT_WINDOW_NEW
New Window has been added.
Definition: mutt_window.h:181
mutt_window_addstr
int mutt_window_addstr(const char *str)
Write a string to a Window.
Definition: mutt_window.c:522
mutt_window_find
struct MuttWindow * mutt_window_find(struct MuttWindow *root, enum WindowType type)
Find a Window of a given type.
Definition: mutt_window.c:678
mutt_window_move
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:382
MessageWindow
struct MuttWindow * MessageWindow
Message Window, ":set", etc.
Definition: mutt_window.c:47
WT_DLG_DO_PAGER
@ WT_DLG_DO_PAGER
Pager Dialog, mutt_do_pager()
Definition: mutt_window.h:81
mutt_window_mvprintw
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
WindowState::rows
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:58
MuttWindow::parent
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:128
WT_DLG_BROWSER
@ WT_DLG_BROWSER
Browser Dialog, mutt_buffer_select_file()
Definition: mutt_window.h:77
mutt_window_set_root
void mutt_window_set_root(int cols, int rows)
Set the dimensions of the Root Window.
Definition: mutt_window.c:624
MuttWindow::help_data
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:135
MuttWindow::repaint
int(* repaint)(struct MuttWindow *win)
Repaint the Window.
Definition: mutt_window.h:161
NT_WINDOW_FOCUS
@ NT_WINDOW_FOCUS
Window focus has changed.
Definition: mutt_window.h:185
WT_DLG_PATTERN
@ WT_DLG_PATTERN
Pattern Dialog, create_pattern_menu()
Definition: mutt_window.h:84
MuttWindow::state
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:120
WT_INDEX
@ WT_INDEX
An Index Window containing a selection list.
Definition: mutt_window.h:94
WT_DLG_ALIAS
@ WT_DLG_ALIAS
Alias Dialog, dlg_select_alias()
Definition: mutt_window.h:74
MuttWindow::req_rows
short req_rows
Number of rows required.
Definition: mutt_window.h:118
WT_DLG_SMIME
@ WT_DLG_SMIME
Smime Dialog, dlg_select_smime_key()
Definition: mutt_window.h:89
Notify
Notification API.
Definition: notify.c:39
mutt_window_clearline
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:232
WT_ALL_DIALOGS
@ WT_ALL_DIALOGS
Container for All Dialogs (nested Windows)
Definition: mutt_window.h:71
WT_CONTAINER
@ WT_CONTAINER
Invisible shaping container Window.
Definition: mutt_window.h:70
mutt_window_addch
int mutt_window_addch(int ch)
Write one character to a Window.
Definition: mutt_window.c:492
MuttWindow::size
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Definition: mutt_window.h:124
WindowNotifyFlags
uint8_t WindowNotifyFlags
Changes to a MuttWindow.
Definition: mutt_window.h:164
MUTT_WIN_SIZE_MINIMISE
@ MUTT_WIN_SIZE_MINIMISE
Window size depends on its children.
Definition: mutt_window.h:46
WT_INDEX_BAR
@ WT_INDEX_BAR
Index Bar containing status info about the Index.
Definition: mutt_window.h:95
window_notify_all
void window_notify_all(struct MuttWindow *win)
Notify observers of changes to a Window and its children.
Definition: mutt_window.c:129
WT_HELP_BAR
@ WT_HELP_BAR
Help Bar containing list of useful key bindings.
Definition: mutt_window.h:93
RootWindow
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: mutt_window.c:45
MuttWindow::TAILQ_ENTRY
TAILQ_ENTRY(MuttWindow) entries
Linked list.
MuttWindow::type
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:137
mutt_window_init
void mutt_window_init(void)
Create the default Windows.
Definition: mutt_window.c:339
MUTT_WIN_SIZE_FIXED
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
Definition: mutt_window.h:44
window_set_focus
void window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:763
NotifyWindow
NotifyWindow
Window notification types.
Definition: mutt_window.h:179
WindowState::cols
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:57
mutt_window_free
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:186
mutt_window_reflow
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:433
WT_DLG_HISTORY
@ WT_DLG_HISTORY
History Dialog, dlg_select_history()
Definition: mutt_window.h:82
MuttWindow::children
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:129
mutt_window_free_all
void mutt_window_free_all(void)
Free all the default Windows.
Definition: mutt_window.c:304
MuttWindow::recalc
int(* recalc)(struct MuttWindow *win)
Recalculate the Window data.
Definition: mutt_window.h:153
WT_DLG_REMAILER
@ WT_DLG_REMAILER
Remailer Dialog, dlg_select_mixmaster_chain()
Definition: mutt_window.h:88
MuttWindow::orient
enum MuttWindowOrientation orient
Which direction the Window will expand.
Definition: mutt_window.h:123
EventWindow
An Event that happened to a Window.
Definition: mutt_window.h:191
mutt_window_reflow_message_rows
void mutt_window_reflow_message_rows(int mw_rows)
Resize the Message Window.
Definition: mutt_window.c:459
mutt_window_is_visible
bool mutt_window_is_visible(struct MuttWindow *win)
Is the Window visible?
Definition: mutt_window.c:657
mutt_window_clear
void mutt_window_clear(struct MuttWindow *win)
Clear a Window.
Definition: mutt_window.c:806
MuttWindow::wdata
void * wdata
Private data.
Definition: mutt_window.h:138
mutt_window_clrtoeol
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:244