Window management. More...
Go to the source code of this file.
Data Structures | |
struct | WindowState |
The current, or old, state of a Window. More... | |
struct | MuttWindow |
struct | EventWindow |
An Event that happened to a Window. More... | |
Macros | |
#define | MUTT_WIN_SIZE_UNLIMITED -1 |
Use as much space as possible. | |
#define | WA_NO_FLAGS 0 |
No flags are set. | |
#define | WA_REFLOW (1 << 0) |
Reflow the Window and its children. | |
#define | WA_RECALC (1 << 1) |
Recalculate the contents of the Window. | |
#define | WA_REPAINT (1 << 2) |
Redraw the contents of the Window. | |
#define | WN_NO_FLAGS 0 |
No flags are set. | |
#define | WN_TALLER (1 << 0) |
Window became taller. | |
#define | WN_SHORTER (1 << 1) |
Window became shorter. | |
#define | WN_WIDER (1 << 2) |
Window became wider. | |
#define | WN_NARROWER (1 << 3) |
Window became narrower. | |
#define | WN_MOVED (1 << 4) |
Window moved. | |
#define | WN_VISIBLE (1 << 5) |
Window became visible. | |
#define | WN_HIDDEN (1 << 6) |
Window became hidden. | |
Typedefs | |
typedef uint8_t | WindowActionFlags |
Flags for Actions waiting to be performed on a MuttWindow, e.g. WA_REFLOW. | |
typedef uint8_t | WindowNotifyFlags |
Flags for Changes to a MuttWindow, e.g. WN_TALLER. | |
Enumerations | |
enum | MuttWindowOrientation { MUTT_WIN_ORIENT_VERTICAL = 1 , MUTT_WIN_ORIENT_HORIZONTAL } |
Which way does the Window expand? More... | |
enum | MuttWindowSize { MUTT_WIN_SIZE_FIXED = 1 , MUTT_WIN_SIZE_MAXIMISE , MUTT_WIN_SIZE_MINIMISE } |
Control the allocation of Window space. More... | |
enum | WindowType { WT_ROOT , WT_CONTAINER , WT_ALL_DIALOGS , WT_DLG_ALIAS , WT_DLG_ATTACHMENT , WT_DLG_AUTOCRYPT , WT_DLG_BROWSER , WT_DLG_CERTIFICATE , WT_DLG_COMPOSE , WT_DLG_GPGME , WT_DLG_PAGER , WT_DLG_HISTORY , WT_DLG_INDEX , WT_DLG_PATTERN , WT_DLG_PGP , WT_DLG_POSTPONED , WT_DLG_QUERY , WT_DLG_SMIME , WT_CUSTOM , WT_HELP_BAR , WT_INDEX , WT_MENU , WT_MESSAGE , WT_PAGER , WT_SIDEBAR , WT_STATUS_BAR } |
Type of Window. More... | |
enum | NotifyWindow { NT_WINDOW_ADD = 1 , NT_WINDOW_DELETE , NT_WINDOW_STATE , NT_WINDOW_DIALOG , NT_WINDOW_FOCUS } |
Window notification types. More... | |
Functions | |
TAILQ_HEAD (MuttWindowList, MuttWindow) | |
void | mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child) |
Add a child to Window. | |
void | mutt_window_free (struct MuttWindow **ptr) |
Free a Window and its children. | |
void | mutt_window_get_coords (struct MuttWindow *win, int *col, int *row) |
Get the cursor position in the Window. | |
struct MuttWindow * | mutt_window_new (enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows) |
Create a new Window. | |
void | mutt_window_reflow (struct MuttWindow *win) |
Resize a Window and its children. | |
struct MuttWindow * | mutt_window_remove_child (struct MuttWindow *parent, struct MuttWindow *child) |
Remove a child from a Window. | |
int | mutt_window_wrap_cols (int width, short wrap) |
Calculate the wrap column for a given screen width. | |
int | mutt_window_addch (struct MuttWindow *win, int ch) |
Write one character to a Window. | |
int | mutt_window_addnstr (struct MuttWindow *win, const char *str, int num) |
Write a partial string to a Window. | |
int | mutt_window_addstr (struct MuttWindow *win, const char *str) |
Write a string to a Window. | |
void | mutt_window_clearline (struct MuttWindow *win, int row) |
Clear a row of a Window. | |
void | mutt_window_clear (struct MuttWindow *win) |
Clear a Window. | |
void | mutt_window_clrtoeol (struct MuttWindow *win) |
Clear to the end of the line. | |
int | mutt_window_move (struct MuttWindow *win, int col, int row) |
Move the cursor in a Window. | |
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. | |
int | mutt_window_mvprintw (struct MuttWindow *win, int col, int row, const char *fmt,...) __attribute__((__format__(__printf__ |
int int | mutt_window_printf (struct MuttWindow *win, const char *format,...) __attribute__((__format__(__printf__ |
int int bool | mutt_window_is_visible (struct MuttWindow *win) |
Is the Window visible? | |
void | mutt_winlist_free (struct MuttWindowList *head) |
Free a tree of Windows. | |
struct MuttWindow * | window_find_child (struct MuttWindow *win, enum WindowType type) |
Recursively find a child Window of a given type. | |
struct MuttWindow * | window_find_parent (struct MuttWindow *win, enum WindowType type) |
Find a (grand-)parent of a Window by type. | |
void | window_notify_all (struct MuttWindow *win) |
Notify observers of changes to a Window and its children. | |
void | window_set_visible (struct MuttWindow *win, bool visible) |
Set a Window visible or hidden. | |
struct MuttWindow * | window_set_focus (struct MuttWindow *win) |
Set the Window focus. | |
struct MuttWindow * | window_get_focus (void) |
Get the currently focused Window. | |
bool | window_is_focused (const struct MuttWindow *win) |
Does the given Window have the focus? | |
void | window_redraw (struct MuttWindow *win) |
Reflow, recalc and repaint a tree of Windows. | |
void | window_invalidate_all (void) |
Mark all windows as in need of repaint. | |
const char * | mutt_window_win_name (const struct MuttWindow *win) |
Get the name of a Window. | |
bool | window_status_on_top (struct MuttWindow *panel, struct ConfigSubset *sub) |
Organise windows according to config variable. | |
bool | mutt_window_swap (struct MuttWindow *parent, struct MuttWindow *win1, struct MuttWindow *win2) |
Swap the position of two windows. | |
Window management.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file mutt_window.h.
#define MUTT_WIN_SIZE_UNLIMITED -1 |
Use as much space as possible.
Definition at line 53 of file mutt_window.h.
#define WA_NO_FLAGS 0 |
No flags are set.
Definition at line 108 of file mutt_window.h.
#define WA_REFLOW (1 << 0) |
Reflow the Window and its children.
Definition at line 109 of file mutt_window.h.
#define WA_RECALC (1 << 1) |
Recalculate the contents of the Window.
Definition at line 110 of file mutt_window.h.
#define WA_REPAINT (1 << 2) |
Redraw the contents of the Window.
Definition at line 111 of file mutt_window.h.
#define WN_NO_FLAGS 0 |
No flags are set.
Definition at line 209 of file mutt_window.h.
#define WN_TALLER (1 << 0) |
Window became taller.
Definition at line 210 of file mutt_window.h.
#define WN_SHORTER (1 << 1) |
Window became shorter.
Definition at line 211 of file mutt_window.h.
#define WN_WIDER (1 << 2) |
Window became wider.
Definition at line 212 of file mutt_window.h.
#define WN_NARROWER (1 << 3) |
Window became narrower.
Definition at line 213 of file mutt_window.h.
#define WN_MOVED (1 << 4) |
Window moved.
Definition at line 214 of file mutt_window.h.
#define WN_VISIBLE (1 << 5) |
Window became visible.
Definition at line 215 of file mutt_window.h.
#define WN_HIDDEN (1 << 6) |
Window became hidden.
Definition at line 216 of file mutt_window.h.
typedef uint8_t WindowActionFlags |
Flags for Actions waiting to be performed on a MuttWindow, e.g. WA_REFLOW.
Definition at line 107 of file mutt_window.h.
typedef uint8_t WindowNotifyFlags |
Flags for Changes to a MuttWindow, e.g. WN_TALLER.
Definition at line 208 of file mutt_window.h.
Which way does the Window expand?
Enumerator | |
---|---|
MUTT_WIN_ORIENT_VERTICAL | Window uses all available vertical space. |
MUTT_WIN_ORIENT_HORIZONTAL | Window uses all available horizontal space. |
Definition at line 37 of file mutt_window.h.
enum MuttWindowSize |
Control the allocation of Window space.
Enumerator | |
---|---|
MUTT_WIN_SIZE_FIXED | Window has a fixed size. |
MUTT_WIN_SIZE_MAXIMISE | Window wants as much space as possible. |
MUTT_WIN_SIZE_MINIMISE | Window size depends on its children. |
Definition at line 46 of file mutt_window.h.
enum WindowType |
Type of Window.
Enumerator | |
---|---|
WT_ROOT | Parent of All Windows. |
WT_CONTAINER | Invisible shaping container Window. |
WT_ALL_DIALOGS | Container for All Dialogs (nested Windows) |
WT_DLG_ALIAS | Alias Dialog, dlg_alias() |
WT_DLG_ATTACHMENT | Attachment Dialog, dlg_attachment() |
WT_DLG_AUTOCRYPT | Autocrypt Dialog, dlg_autocrypt() |
WT_DLG_BROWSER | Browser Dialog, dlg_browser() |
WT_DLG_CERTIFICATE | Certificate Dialog, dlg_certificate() |
WT_DLG_COMPOSE | Compose Dialog, dlg_compose() |
WT_DLG_GPGME | GPGME Dialog, dlg_gpgme() |
WT_DLG_PAGER | Pager Dialog, dlg_pager() |
WT_DLG_HISTORY | History Dialog, dlg_history() |
WT_DLG_INDEX | Index Dialog, dlg_index() |
WT_DLG_PATTERN | Pattern Dialog, dlg_pattern() |
WT_DLG_PGP | Pgp Dialog, dlg_pgp() |
WT_DLG_POSTPONED | Postponed Dialog, dlg_postponed() |
WT_DLG_QUERY | Query Dialog, dlg_query() |
WT_DLG_SMIME | Smime Dialog, dlg_smime() |
WT_CUSTOM | Window with a custom drawing function. |
WT_HELP_BAR | Help Bar containing list of useful key bindings. |
WT_INDEX | A panel containing the Index Window. |
WT_MENU | An Window containing a Menu. |
WT_MESSAGE | Window for messages/errors. |
WT_PAGER | A panel containing the Pager Window. |
WT_SIDEBAR | Side panel containing Accounts or groups of data. |
WT_STATUS_BAR | Status Bar containing extra info about the Index/Pager/etc. |
Definition at line 70 of file mutt_window.h.
enum NotifyWindow |
Window notification types.
Observers of NT_WINDOW will be passed an EventWindow.
Enumerator | |
---|---|
NT_WINDOW_ADD | New Window has been added. |
NT_WINDOW_DELETE | Window is about to be deleted. |
NT_WINDOW_STATE | Window state has changed, e.g. WN_VISIBLE. |
NT_WINDOW_DIALOG | A new Dialog Window has been created, e.g. WT_DLG_INDEX. |
NT_WINDOW_FOCUS | Window focus has changed. |
Definition at line 226 of file mutt_window.h.
TAILQ_HEAD | ( | MuttWindowList | , |
MuttWindow | |||
) |
void mutt_window_add_child | ( | struct MuttWindow * | parent, |
struct MuttWindow * | child | ||
) |
Add a child to Window.
parent | Window to add to |
child | Window to add |
Definition at line 446 of file mutt_window.c.
void mutt_window_free | ( | struct MuttWindow ** | ptr | ) |
Free a Window and its children.
ptr | Window to free |
Definition at line 202 of file mutt_window.c.
void mutt_window_get_coords | ( | struct MuttWindow * | win, |
int * | col, | ||
int * | row | ||
) |
Get the cursor position in the Window.
[in] | win | Window |
[out] | col | Column in Window |
[out] | row | Row in Window |
Assumes the current position is inside the window. Otherwise it will happily return negative or values outside the window boundaries
Definition at line 277 of file mutt_window.c.
struct MuttWindow * mutt_window_new | ( | enum WindowType | type, |
enum MuttWindowOrientation | orient, | ||
enum MuttWindowSize | size, | ||
int | cols, | ||
int | rows | ||
) |
Create a new Window.
type | Window type, e.g. WT_ROOT |
orient | Window orientation, e.g. MUTT_WIN_ORIENT_VERTICAL |
size | Window size, e.g. MUTT_WIN_SIZE_MAXIMISE |
cols | Initial number of columns to allocate, can be MUTT_WIN_SIZE_UNLIMITED |
rows | Initial number of rows to allocate, can be MUTT_WIN_SIZE_UNLIMITED |
ptr | New Window |
Definition at line 182 of file mutt_window.c.
void mutt_window_reflow | ( | struct MuttWindow * | win | ) |
Resize a Window and its children.
win | Window to resize |
Definition at line 344 of file mutt_window.c.
struct MuttWindow * mutt_window_remove_child | ( | struct MuttWindow * | parent, |
struct MuttWindow * | child | ||
) |
Remove a child from a Window.
parent | Window to remove from |
child | Window to remove |
ptr | Child Window |
Definition at line 468 of file mutt_window.c.
int mutt_window_wrap_cols | ( | int | width, |
short | wrap | ||
) |
Calculate the wrap column for a given screen width.
width | Screen width |
wrap | Wrap config |
num | Column that text should be wrapped at |
The wrap variable can be negative, meaning there should be a right margin.
Definition at line 372 of file mutt_window.c.
int mutt_window_addch | ( | struct MuttWindow * | win, |
int | ch | ||
) |
Write one character to a Window.
win | Window |
ch | Character to write |
0 | Success |
-1 | Error |
Definition at line 388 of file mutt_window.c.
int mutt_window_addnstr | ( | struct MuttWindow * | win, |
const char * | str, | ||
int | num | ||
) |
Write a partial string to a Window.
win | Window |
str | String |
num | Maximum number of characters to write |
0 | Success |
-1 | Error |
Definition at line 401 of file mutt_window.c.
int mutt_window_addstr | ( | struct MuttWindow * | win, |
const char * | str | ||
) |
Write a string to a Window.
win | Window |
str | String |
0 | Success |
-1 | Error |
Definition at line 416 of file mutt_window.c.
void mutt_window_clearline | ( | struct MuttWindow * | win, |
int | row | ||
) |
Clear a row of a Window.
win | Window |
row | Row to clear |
Definition at line 232 of file mutt_window.c.
void mutt_window_clear | ( | struct MuttWindow * | win | ) |
Clear a Window.
win | Window |
If the Window isn't visible, it won't be cleared.
Definition at line 720 of file mutt_window.c.
void mutt_window_clrtoeol | ( | struct MuttWindow * | win | ) |
Clear to the end of the line.
win | Window |
Definition at line 244 of file mutt_window.c.
int mutt_window_move | ( | struct MuttWindow * | win, |
int | col, | ||
int | row | ||
) |
Move the cursor in a Window.
win | Window |
col | Column to move to |
row | Row to move to |
OK | Success |
ERR | Error |
Definition at line 297 of file mutt_window.c.
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.
win | Window to write to |
col | Column to move to |
row | Row to move to |
str | String to write |
OK | Success |
ERR | Error |
Definition at line 311 of file mutt_window.c.
int mutt_window_mvprintw | ( | struct MuttWindow * | win, |
int | col, | ||
int | row, | ||
const char * | fmt, | ||
... | |||
) |
int int mutt_window_printf | ( | struct MuttWindow * | win, |
const char * | format, | ||
... | |||
) |
int int bool mutt_window_is_visible | ( | struct MuttWindow * | win | ) |
Is the Window visible?
win | Window |
true | The Window is visible |
For a Window to be visible, it must be visible and its parent and grandparent, etc.
Definition at line 512 of file mutt_window.c.
void mutt_winlist_free | ( | struct MuttWindowList * | head | ) |
Free a tree of Windows.
head | WindowList to free |
Definition at line 489 of file mutt_window.c.
struct MuttWindow * window_find_child | ( | struct MuttWindow * | win, |
enum WindowType | type | ||
) |
Recursively find a child Window of a given type.
win | Window to start searching |
type | Window type to find, e.g. WT_STATUS_BAR |
ptr | Matching Window |
NULL | No match |
Definition at line 533 of file mutt_window.c.
struct MuttWindow * window_find_parent | ( | struct MuttWindow * | win, |
enum WindowType | type | ||
) |
Find a (grand-)parent of a Window by type.
win | Window |
type | Window type, e.g. WT_DLG_INDEX |
ptr | Window |
Definition at line 558 of file mutt_window.c.
void window_notify_all | ( | struct MuttWindow * | win | ) |
Notify observers of changes to a Window and its children.
win | Window |
Definition at line 145 of file mutt_window.c.
void window_set_visible | ( | struct MuttWindow * | win, |
bool | visible | ||
) |
Set a Window visible or hidden.
win | Window |
visible | If true, make Window visible, otherwise hidden |
Definition at line 165 of file mutt_window.c.
struct MuttWindow * window_set_focus | ( | struct MuttWindow * | win | ) |
Set the Window focus.
win | Window to focus |
ptr | Old focused Window |
NULL | Error, or focus not changed |
Definition at line 684 of file mutt_window.c.
struct MuttWindow * window_get_focus | ( | void | ) |
Get the currently focused Window.
ptr | Window with focus |
Definition at line 668 of file mutt_window.c.
bool window_is_focused | ( | const struct MuttWindow * | win | ) |
Does the given Window have the focus?
win | Window to check |
true | Window has focus |
Definition at line 654 of file mutt_window.c.
void window_redraw | ( | struct MuttWindow * | win | ) |
Reflow, recalc and repaint a tree of Windows.
win | Window to start at |
Definition at line 634 of file mutt_window.c.
void window_invalidate_all | ( | void | ) |
Mark all windows as in need of repaint.
Definition at line 767 of file mutt_window.c.
const char * mutt_window_win_name | ( | const struct MuttWindow * | win | ) |
Get the name of a Window.
win | Window |
ptr | String describing Window |
NULL | Error, or unknown |
Definition at line 735 of file mutt_window.c.
bool window_status_on_top | ( | struct MuttWindow * | panel, |
struct ConfigSubset * | sub | ||
) |
Organise windows according to config variable.
panel | Window containing WT_MENU and WT_STATUS_BAR |
sub | Config Subset |
true | Window order was changed |
Set the positions of two Windows based on a config variable $status_on_top
.
Definition at line 784 of file mutt_window.c.
bool mutt_window_swap | ( | struct MuttWindow * | parent, |
struct MuttWindow * | win1, | ||
struct MuttWindow * | win2 | ||
) |
Swap the position of two windows.
parent | Parent Window |
win1 | Window |
win2 | Window |
true | Windows were switched |
Definition at line 820 of file mutt_window.c.