Window management. More...
#include "config.h"
#include <stdarg.h>
#include <string.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "mutt_window.h"
#include "curs_lib.h"
#include "globals.h"
#include "mutt_curses.h"
#include "reflow.h"
#include "rootwin.h"
Go to the source code of this file.
Functions | |
static bool | window_was_visible (struct MuttWindow *win) |
Was the Window visible? | |
static void | window_notify (struct MuttWindow *win) |
Notify observers of changes to a Window. | |
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 * | mutt_window_new (enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows) |
Create a new Window. | |
void | mutt_window_free (struct MuttWindow **ptr) |
Free a Window and its children. | |
void | mutt_window_clearline (struct MuttWindow *win, int row) |
Clear a row of a Window. | |
void | mutt_window_clrtoeol (struct MuttWindow *win) |
Clear to the end of the line. | |
void | mutt_window_get_coords (struct MuttWindow *win, int *col, int *row) |
Get the cursor position in the Window. | |
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,...) |
Move the cursor and write a formatted string to a Window. | |
void | mutt_window_reflow (struct MuttWindow *win) |
Resize a Window and its children. | |
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. | |
int | mutt_window_printf (struct MuttWindow *win, const char *fmt,...) |
Write a formatted string to a Window. | |
void | mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child) |
Add a child to Window. | |
struct MuttWindow * | mutt_window_remove_child (struct MuttWindow *parent, struct MuttWindow *child) |
Remove a child from a Window. | |
void | mutt_winlist_free (struct MuttWindowList *head) |
Free a tree of Windows. | |
bool | mutt_window_is_visible (struct MuttWindow *win) |
Is the Window visible? | |
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. | |
static void | window_recalc (struct MuttWindow *win) |
Recalculate a tree of Windows. | |
static void | window_repaint (struct MuttWindow *win) |
Repaint a tree of Windows. | |
static void | window_recursor (void) |
Recursor the focussed Window. | |
void | window_redraw (struct MuttWindow *win) |
Reflow, recalc and repaint a tree of Windows. | |
bool | window_is_focused (const struct MuttWindow *win) |
Does the given Window have the focus? | |
struct MuttWindow * | window_get_focus (void) |
Get the currently focused Window. | |
struct MuttWindow * | window_set_focus (struct MuttWindow *win) |
Set the Window focus. | |
void | mutt_window_clear (struct MuttWindow *win) |
Clear a Window. | |
const char * | mutt_window_win_name (const struct MuttWindow *win) |
Get the name of a Window. | |
static void | window_invalidate (struct MuttWindow *win) |
Mark a window as in need of repaint. | |
void | window_invalidate_all (void) |
Mark all windows as in need of repaint. | |
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. | |
Variables | |
static const struct Mapping | WindowNames [] |
Lookups for Window Names. | |
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.c.
|
static |
Was the Window visible?
win | Window |
true | The Window was visible |
Using the WindowState old
, check if a Window used to be visible. For a Window to be visible, it must have been visible and its parent and grandparent, etc.
Definition at line 87 of file mutt_window.c.
|
static |
Notify observers of changes to a Window.
win | Window |
Definition at line 105 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 * 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_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_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_clrtoeol | ( | struct MuttWindow * | win | ) |
Clear to the end of the line.
win | Window |
Definition at line 244 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.
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, | ||
... | |||
) |
Move the cursor and write a formatted string to a Window.
win | Window to write to |
col | Column to move to |
row | Row to move to |
fmt | printf format string |
... | printf arguments |
num | Success, characters written |
ERR | Error, move failed |
Definition at line 326 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.
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.
int mutt_window_printf | ( | struct MuttWindow * | win, |
const char * | fmt, | ||
... | |||
) |
Write a formatted string to a Window.
win | Window |
fmt | Format string |
... | Arguments |
num | Number of characters written |
Definition at line 431 of file mutt_window.c.
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.
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.
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.
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.
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.
|
static |
Recalculate a tree of Windows.
win | Window to start at |
Definition at line 573 of file mutt_window.c.
|
static |
Repaint a tree of Windows.
win | Window to start at |
Definition at line 593 of file mutt_window.c.
|
static |
Recursor the focussed Window.
Give the focussed Window an opportunity to set the position and visibility of its cursor.
Definition at line 615 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.
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.
struct MuttWindow * window_get_focus | ( | void | ) |
Get the currently focused Window.
ptr | Window with focus |
Definition at line 668 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.
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.
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.
|
static |
Mark a window as in need of repaint.
win | Window to start at |
Definition at line 750 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.
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.
|
static |
Lookups for Window Names.
Definition at line 46 of file mutt_window.c.