Window management. More...
#include "config.h"
#include <stdarg.h>
#include <string.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "debug/lib.h"
#include "mutt_window.h"
#include "helpbar/lib.h"
#include "mutt_curses.h"
#include "mutt_globals.h"
#include "mutt_menu.h"
#include "opcodes.h"
#include "options.h"
#include "reflow.h"
Go to the source code of this file.
Functions | |
static bool | window_was_visible (struct MuttWindow *win) |
Was the Window visible? More... | |
static void | window_notify (struct MuttWindow *win) |
Notify observers of changes to a Window. More... | |
void | window_notify_all (struct MuttWindow *win) |
Notify observers of changes to a Window and its children. More... | |
void | window_set_visible (struct MuttWindow *win, bool visible) |
Set a Window visible or hidden. More... | |
struct MuttWindow * | mutt_window_new (enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows) |
Create a new Window. More... | |
void | mutt_window_free (struct MuttWindow **ptr) |
Free a Window and its children. More... | |
void | mutt_window_clearline (struct MuttWindow *win, int row) |
Clear a row of a Window. More... | |
void | mutt_window_clrtoeol (struct MuttWindow *win) |
Clear to the end of the line. More... | |
static int | mutt_dlg_rootwin_observer (struct NotifyCallback *nc) |
Listen for config changes affecting the Root Window - Implements observer_t. More... | |
void | mutt_window_free_all (void) |
Free all the default Windows. More... | |
void | mutt_window_get_coords (struct MuttWindow *win, int *col, int *row) |
Get the cursor position in the Window. More... | |
void | mutt_window_init (void) |
Create the default Windows. More... | |
int | mutt_window_move (struct MuttWindow *win, int col, int row) |
Move the cursor in a Window. More... | |
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. More... | |
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. More... | |
void | mutt_window_reflow (struct MuttWindow *win) |
Resize a Window and its children. More... | |
void | mutt_window_reflow_message_rows (int mw_rows) |
Resize the Message Window. More... | |
int | mutt_window_wrap_cols (int width, short wrap) |
Calculate the wrap column for a given screen width. More... | |
int | mutt_window_addch (int ch) |
Write one character to a Window. More... | |
int | mutt_window_addnstr (const char *str, int num) |
Write a partial string to a Window. More... | |
int | mutt_window_addstr (const char *str) |
Write a string to a Window. More... | |
void | mutt_window_move_abs (int col, int row) |
Move the cursor to an absolute screen position. More... | |
int | mutt_window_printf (const char *fmt,...) |
Write a formatted string to a Window. More... | |
void | mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child) |
Add a child to Window. More... | |
struct MuttWindow * | mutt_window_remove_child (struct MuttWindow *parent, struct MuttWindow *child) |
Remove a child from a Window. More... | |
void | mutt_winlist_free (struct MuttWindowList *head) |
Free a tree of Windows. More... | |
void | mutt_window_set_root (int cols, int rows) |
Set the dimensions of the Root Window. More... | |
bool | mutt_window_is_visible (struct MuttWindow *win) |
Is the Window visible? More... | |
struct MuttWindow * | mutt_window_find (struct MuttWindow *root, enum WindowType type) |
Find a Window of a given type. More... | |
static void | window_recalc (struct MuttWindow *win) |
Recalculate a tree of Windows. More... | |
static void | window_repaint (struct MuttWindow *win, bool force) |
Repaint a tree of Windows. More... | |
void | window_redraw (struct MuttWindow *win, bool force) |
Reflow, recalc and repaint a tree of Windows. More... | |
void | window_set_focus (struct MuttWindow *win) |
Set the Window focus. More... | |
struct MuttWindow * | window_get_focus (void) |
Get the currently focussed Window. More... | |
void | mutt_window_clear (struct MuttWindow *win) |
Clear a Window. More... | |
Variables | |
struct MuttWindow * | RootWindow = NULL |
Parent of all Windows. More... | |
struct MuttWindow * | AllDialogsWindow = NULL |
Parent of all Dialogs. More... | |
struct MuttWindow * | MessageWindow = NULL |
Message Window, ":set", etc. More... | |
static const struct Mapping | EditorHelp [] |
Help Bar for the Command Line Editor. More... | |
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 | If 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 it's parent and grandparent, etc.
Definition at line 73 of file mutt_window.c.
|
static |
Notify observers of changes to a Window.
win | Window |
Definition at line 91 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 129 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 149 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 166 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 186 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.
|
static |
Listen for config changes affecting the Root Window - Implements observer_t.
Definition at line 269 of file mutt_window.c.
void mutt_window_free_all | ( | void | ) |
Free all the default Windows.
Definition at line 304 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 322 of file mutt_window.c.
void mutt_window_init | ( | void | ) |
Create the default Windows.
Create the Help, Index, Status, Message and Sidebar Windows.
Definition at line 339 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 382 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 396 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 415 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 433 of file mutt_window.c.
void mutt_window_reflow_message_rows | ( | int | mw_rows | ) |
mw_rows | Number of rows required |
Resize the other Windows to allow a multi-line message to be displayed.
Definition at line 459 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 477 of file mutt_window.c.
int mutt_window_addch | ( | int | ch | ) |
Write one character to a Window.
ch | Character to write |
0 | Success |
-1 | Error |
Definition at line 492 of file mutt_window.c.
int mutt_window_addnstr | ( | const char * | str, |
int | num | ||
) |
Write a partial string to a Window.
str | String |
num | Maximum number of characters to write |
0 | Success |
-1 | Error |
Definition at line 504 of file mutt_window.c.
int mutt_window_addstr | ( | const char * | str | ) |
Write a string to a Window.
str | String |
0 | Success |
-1 | Error |
Definition at line 522 of file mutt_window.c.
void mutt_window_move_abs | ( | int | col, |
int | row | ||
) |
Move the cursor to an absolute screen position.
col | Screen column (0-based) |
row | Screen row (0-based) |
Definition at line 539 of file mutt_window.c.
int mutt_window_printf | ( | const char * | fmt, |
... | |||
) |
Write a formatted string to a Window.
fmt | Format string |
... | Arguments |
num | Number of characters written |
Definition at line 550 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 565 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 |
Definition at line 584 of file mutt_window.c.
void mutt_winlist_free | ( | struct MuttWindowList * | head | ) |
Free a tree of Windows.
head | WindowList to free |
Definition at line 604 of file mutt_window.c.
void mutt_window_set_root | ( | int | cols, |
int | rows | ||
) |
Set the dimensions of the Root Window.
rows | |
cols |
Definition at line 624 of file mutt_window.c.
bool mutt_window_is_visible | ( | struct MuttWindow * | win | ) |
Is the Window visible?
win | Window |
true | If the Window is visible |
For a Window to be visible, it must be visible and it's parent and grandparent, etc.
Definition at line 657 of file mutt_window.c.
struct MuttWindow* mutt_window_find | ( | struct MuttWindow * | root, |
enum WindowType | type | ||
) |
Find a Window of a given type.
root | Window to start searching |
type | Window type to find, e.g. WT_INDEX_BAR |
ptr | Matching Window |
NULL | No match |
Definition at line 678 of file mutt_window.c.
|
static |
Recalculate a tree of Windows.
win | Window to start at |
Definition at line 701 of file mutt_window.c.
|
static |
Repaint a tree of Windows.
win | Window to start at |
force | Repaint everything |
Definition at line 724 of file mutt_window.c.
void window_redraw | ( | struct MuttWindow * | win, |
bool | force | ||
) |
Reflow, recalc and repaint a tree of Windows.
win | Window to start at |
force | Repaint everything |
Definition at line 747 of file mutt_window.c.
void window_set_focus | ( | struct MuttWindow * | win | ) |
Set the Window focus.
win | Window to focus |
Definition at line 763 of file mutt_window.c.
struct MuttWindow* window_get_focus | ( | void | ) |
Get the currently focussed Window.
ptr | Window with focus |
Definition at line 790 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 806 of file mutt_window.c.
struct MuttWindow* RootWindow = NULL |
Parent of all Windows.
Definition at line 45 of file mutt_window.c.
struct MuttWindow* AllDialogsWindow = NULL |
Parent of all Dialogs.
Definition at line 46 of file mutt_window.c.
struct MuttWindow* MessageWindow = NULL |
Message Window, ":set", etc.
Definition at line 47 of file mutt_window.c.
|
static |
Help Bar for the Command Line Editor.
Definition at line 50 of file mutt_window.c.