NeoMutt  2019-12-07-60-g0cfa53
Teaching an old dog new tricks
DOXYGEN
mutt_window.h File Reference

Window management. More...

#include "config.h"
+ Include dependency graph for mutt_window.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  WindowState
 The current, or old, state of a Window. More...
 
struct  MuttWindow
 A division of the screen. More...
 

Macros

#define MUTT_WIN_SIZE_UNLIMITED   -1
 Use as much space as possible. More...
 

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_ALL_DIALOGS, WT_DIALOG, WT_CONTAINER,
  WT_HELP_BAR, WT_MESSAGE, WT_INDEX, WT_INDEX_BAR,
  WT_PAGER, WT_PAGER_BAR, WT_SIDEBAR
}
 Type of Window. More...
 

Functions

 TAILQ_HEAD (MuttWindowList, MuttWindow)
 
void mutt_window_add_child (struct MuttWindow *parent, struct MuttWindow *child)
 Add a child to Window. More...
 
void mutt_window_copy_size (const struct MuttWindow *win_src, struct MuttWindow *win_dst)
 Copy the size of one Window to another. More...
 
void mutt_window_free (struct MuttWindow **ptr)
 Free a Window and its children. 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...
 
struct MuttWindowmutt_window_new (enum MuttWindowOrientation orient, enum MuttWindowSize size, int rows, int cols)
 Create a new 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...
 
void mutt_window_set_root (int rows, int cols)
 Set the dimensions of the Root 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_clearline (struct MuttWindow *win, int row)
 Clear a row of a Window. More...
 
void mutt_window_clrtobot (void)
 Clear to the bottom of the Window. More...
 
void mutt_window_clrtoeol (struct MuttWindow *win)
 Clear to the end of the line. More...
 
int mutt_window_move (struct MuttWindow *win, int row, int col)
 Move the cursor in a Window. More...
 
void mutt_window_move_abs (int row, int col)
 Move the cursor to an absolute screen position. More...
 
int mutt_window_mvaddstr (struct MuttWindow *win, int row, int col, const char *str)
 Move the cursor and write a fixed string to a Window. More...
 
int mutt_window_mvprintw (struct MuttWindow *win, int row, int col, const char *fmt,...)
 Move the cursor and write a formatted string to a Window. More...
 
int mutt_window_printf (const char *format,...)
 Write a formatted string to a Window. More...
 
bool mutt_window_is_visible (struct MuttWindow *win)
 Is the Window visible? More...
 
void mutt_winlist_free (struct MuttWindowList *head)
 Free a tree of Windows. More...
 
struct MuttWindowmutt_window_find (struct MuttWindow *root, enum WindowType type)
 Find a Window of a given type. More...
 
struct MuttWindowmutt_window_dialog (struct MuttWindow *win)
 Find the parent Dialog of a Window. More...
 
void dialog_pop (void)
 Hide a Window from the user. More...
 
void dialog_push (struct MuttWindow *dlg)
 Display a Window to the user. More...
 

Variables

struct MuttWindowMuttDialogWindow
 Parent of all Dialogs. More...
 
struct MuttWindowMuttHelpWindow
 Help Window. More...
 
struct MuttWindowMuttMessageWindow
 Message Window. More...
 

Detailed Description

Window management.

Authors
  • Richard Russon

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.

Macro Definition Documentation

◆ MUTT_WIN_SIZE_UNLIMITED

#define MUTT_WIN_SIZE_UNLIMITED   -1

Use as much space as possible.

Definition at line 47 of file mutt_window.h.

Enumeration Type Documentation

◆ MuttWindowOrientation

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 31 of file mutt_window.h.

32 {
35 };
Window uses all available vertical space.
Definition: mutt_window.h:33
Window uses all available horizontal space.
Definition: mutt_window.h:34

◆ 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 40 of file mutt_window.h.

41 {
45 };
Window has a fixed size.
Definition: mutt_window.h:42
Window size depends on its children.
Definition: mutt_window.h:44
Window wants as much space as possible.
Definition: mutt_window.h:43

◆ WindowType

enum WindowType

Type of Window.

Enumerator
WT_ROOT 

Parent of All Windows.

WT_ALL_DIALOGS 

Container for All Dialogs (nested Windows)

WT_DIALOG 

Dialog (nested Windows) displayed to the user.

WT_CONTAINER 

Invisible shaping container Window.

WT_HELP_BAR 

Help Bar containing list of useful key bindings.

WT_MESSAGE 

Window for messages/errors and command entry.

WT_INDEX 

An Index Window containing a selection list.

WT_INDEX_BAR 

Index Bar containing status info about the Index.

WT_PAGER 

Window containing paged free-form text.

WT_PAGER_BAR 

Pager Bar containing status info about the Pager.

WT_SIDEBAR 

Side panel containing Accounts or groups of data.

Definition at line 64 of file mutt_window.h.

65 {
66  WT_ROOT,
68  WT_DIALOG,
69  WT_CONTAINER,
70  WT_HELP_BAR,
71  WT_MESSAGE,
72  WT_INDEX,
73  WT_INDEX_BAR,
74  WT_PAGER,
75  WT_PAGER_BAR,
76  WT_SIDEBAR,
77 };
Pager Bar containing status info about the Pager.
Definition: mutt_window.h:75
Dialog (nested Windows) displayed to the user.
Definition: mutt_window.h:68
Window for messages/errors and command entry.
Definition: mutt_window.h:71
Invisible shaping container Window.
Definition: mutt_window.h:69
Parent of All Windows.
Definition: mutt_window.h:66
An Index Window containing a selection list.
Definition: mutt_window.h:72
Side panel containing Accounts or groups of data.
Definition: mutt_window.h:76
Help Bar containing list of useful key bindings.
Definition: mutt_window.h:70
Container for All Dialogs (nested Windows)
Definition: mutt_window.h:67
Window containing paged free-form text.
Definition: mutt_window.h:74
Index Bar containing status info about the Index.
Definition: mutt_window.h:73

Function Documentation

◆ TAILQ_HEAD()

TAILQ_HEAD ( MuttWindowList  ,
MuttWindow   
)

◆ mutt_window_add_child()

void mutt_window_add_child ( struct MuttWindow parent,
struct MuttWindow child 
)

Add a child to Window.

Parameters
parentWindow to add to
childWindow to add

Definition at line 471 of file mutt_window.c.

472 {
473  if (!parent || !child)
474  return;
475 
476  TAILQ_INSERT_TAIL(&parent->children, child, entries);
477  child->parent = parent;
478 }
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:802
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:98
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:99
+ Here is the caller graph for this function:

◆ mutt_window_copy_size()

void mutt_window_copy_size ( const struct MuttWindow win_src,
struct MuttWindow win_dst 
)

Copy the size of one Window to another.

Parameters
win_srcWindow to copy
win_dstWindow to resize

Definition at line 331 of file mutt_window.c.

332 {
333  if (!win_src || !win_dst)
334  return;
335 
336  win_dst->state.rows = win_src->state.rows;
337  win_dst->state.cols = win_src->state.cols;
338  win_dst->state.row_offset = win_src->state.row_offset;
339  win_dst->state.col_offset = win_src->state.col_offset;
340 }
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:58
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:56
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:91
short row_offset
Absolute on-screen row.
Definition: mutt_window.h:57
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:55

◆ mutt_window_free()

void mutt_window_free ( struct MuttWindow **  ptr)

Free a Window and its children.

Parameters
ptrWindow to free

Definition at line 75 of file mutt_window.c.

76 {
77  if (!ptr || !*ptr)
78  return;
79 
80  struct MuttWindow *win = *ptr;
81 
82  if (win->wdata && win->free_wdata)
83  win->free_wdata(win, &win->wdata); // Custom function to free private data
84 
86 
87  FREE(ptr);
88 }
A division of the screen.
Definition: mutt_window.h:86
void mutt_winlist_free(struct MuttWindowList *head)
Free a tree of Windows.
Definition: mutt_window.c:484
void(* free_wdata)(struct MuttWindow *win, void **)
Callback function to free private data.
Definition: mutt_window.h:103
#define FREE(x)
Definition: memory.h:40
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:99
void * wdata
Private data.
Definition: mutt_window.h:102
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_window_free_all()

void mutt_window_free_all ( void  )

Free all the default Windows.

Definition at line 202 of file mutt_window.c.

203 {
204  if (NeoMutt)
206  MuttDialogWindow = NULL;
207  MuttHelpWindow = NULL;
208  MuttMessageWindow = NULL;
210 }
struct MuttWindow * MuttHelpWindow
Help Window.
Definition: mutt_window.c:46
Container for Accounts, Notifications.
Definition: neomutt.h:35
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
Definition: mutt_window.c:75
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: mutt_window.c:44
bool notify_observer_remove(struct Notify *notify, observer_t callback, void *global_data)
Remove an observer from an object.
Definition: notify.c:186
int mutt_dlg_rootwin_observer(struct NotifyCallback *nc)
Listen for config changes affecting the Root Window - Implements observer_t()
Definition: mutt_window.c:160
struct Notify * notify
Notifications handler.
Definition: neomutt.h:37
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:47
struct MuttWindow * MuttDialogWindow
Parent of all Dialogs.
Definition: mutt_window.c:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_window_get_coords()

void mutt_window_get_coords ( struct MuttWindow win,
int *  row,
int *  col 
)

Get the cursor position in the Window.

Parameters
[in]winWindow
[out]rowRow in Window
[out]colColumn 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 221 of file mutt_window.c.

222 {
223  int x = 0;
224  int y = 0;
225 
226  getyx(stdscr, y, x);
227  if (col)
228  *col = x - win->state.col_offset;
229  if (row)
230  *row = y - win->state.row_offset;
231 }
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:58
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:91
short row_offset
Absolute on-screen row.
Definition: mutt_window.h:57
+ Here is the caller graph for this function:

◆ mutt_window_init()

void mutt_window_init ( void  )

Create the default Windows.

Create the Help, Index, Status, Message and Sidebar Windows.

Definition at line 238 of file mutt_window.c.

239 {
240  if (RootWindow)
241  return;
242 
255 
256  if (C_StatusOnTop)
257  {
260  }
261  else
262  {
265  }
266 
269 }
WHERE bool C_StatusOnTop
Config: Display the status bar at the top.
Definition: globals.h:255
Window for messages/errors and command entry.
Definition: mutt_window.h:71
Window uses all available vertical space.
Definition: mutt_window.h:33
WHERE bool C_Help
Config: Display a help line with common key bindings.
Definition: globals.h:220
Parent of All Windows.
Definition: mutt_window.h:66
struct MuttWindow * MuttHelpWindow
Help Window.
Definition: mutt_window.c:46
Container for Accounts, Notifications.
Definition: neomutt.h:35
bool notify_observer_add(struct Notify *notify, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:154
Window has a fixed size.
Definition: mutt_window.h:42
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:91
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: mutt_window.c:44
bool visible
Window is visible.
Definition: mutt_window.h:54
struct MuttWindow * mutt_window_new(enum MuttWindowOrientation orient, enum MuttWindowSize size, int rows, int cols)
Create a new Window.
Definition: mutt_window.c:57
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:47
int mutt_dlg_rootwin_observer(struct NotifyCallback *nc)
Listen for config changes affecting the Root Window - Implements observer_t()
Definition: mutt_window.c:160
Help Bar containing list of useful key bindings.
Definition: mutt_window.h:70
struct Notify * notify
Notifications handler.
Definition: neomutt.h:37
Container for All Dialogs (nested Windows)
Definition: mutt_window.h:67
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
Definition: mutt_window.c:471
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:47
Window wants as much space as possible.
Definition: mutt_window.h:43
struct MuttWindow * MuttDialogWindow
Parent of all Dialogs.
Definition: mutt_window.c:45
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:101
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_window_new()

struct MuttWindow* mutt_window_new ( enum MuttWindowOrientation  orient,
enum MuttWindowSize  size,
int  rows,
int  cols 
)

Create a new Window.

Parameters
orientWindow orientation, e.g. MUTT_WIN_ORIENT_VERTICAL
sizeWindow size, e.g. MUTT_WIN_SIZE_MAXIMISE
rowsInitial number of rows to allocate, can be MUTT_WIN_SIZE_UNLIMITED
colsInitial number of columns to allocate, can be MUTT_WIN_SIZE_UNLIMITED
Return values
ptrNew Window

Definition at line 57 of file mutt_window.c.

59 {
60  struct MuttWindow *win = mutt_mem_calloc(1, sizeof(struct MuttWindow));
61 
62  win->orient = orient;
63  win->size = size;
64  win->req_rows = rows;
65  win->req_cols = cols;
66  win->state.visible = true;
67  TAILQ_INIT(&win->children);
68  return win;
69 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
enum MuttWindowOrientation orient
Which direction the Window will expand.
Definition: mutt_window.h:94
A division of the screen.
Definition: mutt_window.h:86
#define TAILQ_INIT(head)
Definition: queue.h:758
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:91
bool visible
Window is visible.
Definition: mutt_window.h:54
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Definition: mutt_window.h:95
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:99
short req_rows
Number of rows required.
Definition: mutt_window.h:88
short req_cols
Number of columns required.
Definition: mutt_window.h:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_window_reflow()

void mutt_window_reflow ( struct MuttWindow win)

Resize a Window and its children.

Parameters
winWindow to resize

Definition at line 346 of file mutt_window.c.

347 {
348  if (OptNoCurses)
349  return;
350 
351  mutt_debug(LL_DEBUG2, "entering\n");
352  window_reflow(win ? win : RootWindow);
353 
355  /* the pager menu needs this flag set to recalc line_info */
357 }
#define REDRAW_FLOW
Used by pager to reflow text.
Definition: mutt_menu.h:49
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:46
void window_reflow(struct MuttWindow *win)
Reflow Windows.
Definition: reflow.c:226
Log at debug level 2.
Definition: logging.h:41
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: mutt_window.c:44
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_window_reflow_message_rows()

void mutt_window_reflow_message_rows ( int  mw_rows)

Resize the Message Window.

Parameters
mw_rowsNumber of rows required

Resize the other Windows to allow a multi-line message to be displayed.

Definition at line 365 of file mutt_window.c.

366 {
367  MuttMessageWindow->req_rows = mw_rows;
369 
370  /* We don't also set REDRAW_FLOW because this function only
371  * changes rows and is a temporary adjustment. */
373 }
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:346
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:98
short req_rows
Number of rows required.
Definition: mutt_window.h:88
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_window_set_root()

void mutt_window_set_root ( int  rows,
int  cols 
)

Set the dimensions of the Root Window.

Parameters
rows
cols

Definition at line 504 of file mutt_window.c.

505 {
506  if (!RootWindow)
507  return;
508 
509  bool changed = false;
510 
511  if (RootWindow->state.rows != rows)
512  {
513  RootWindow->state.rows = rows;
514  changed = true;
515  }
516 
517  if (RootWindow->state.cols != cols)
518  {
519  RootWindow->state.cols = cols;
520  changed = true;
521  }
522 
523  if (changed)
524  {
526  }
527 }
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:56
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:91
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: mutt_window.c:44
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:55
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:346
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_window_wrap_cols()

int mutt_window_wrap_cols ( int  width,
short  wrap 
)

Calculate the wrap column for a given screen width.

Parameters
widthScreen width
wrapWrap config
Return values
numColumn that text should be wrapped at

The wrap variable can be negative, meaning there should be a right margin.

Definition at line 383 of file mutt_window.c.

384 {
385  if (wrap < 0)
386  return (width > -wrap) ? (width + wrap) : width;
387  if (wrap)
388  return (wrap < width) ? wrap : width;
389  return width;
390 }
+ Here is the caller graph for this function:

◆ mutt_window_addch()

int mutt_window_addch ( int  ch)

Write one character to a Window.

Parameters
chCharacter to write
Return values
0Success
-1Error

Definition at line 398 of file mutt_window.c.

399 {
400  return addch(ch);
401 }
+ Here is the caller graph for this function:

◆ mutt_window_addnstr()

int mutt_window_addnstr ( const char *  str,
int  num 
)

Write a partial string to a Window.

Parameters
strString
numMaximum number of characters to write
Return values
0Success
-1Error

Definition at line 410 of file mutt_window.c.

411 {
412  if (!str)
413  return -1;
414 
415 #ifdef USE_SLANG_CURSES
416  return addnstr((char *) str, num);
417 #else
418  return addnstr(str, num);
419 #endif
420 }
+ Here is the caller graph for this function:

◆ mutt_window_addstr()

int mutt_window_addstr ( const char *  str)

Write a string to a Window.

Parameters
strString
Return values
0Success
-1Error

Definition at line 428 of file mutt_window.c.

429 {
430  if (!str)
431  return -1;
432 
433 #ifdef USE_SLANG_CURSES
434  return addstr((char *) str);
435 #else
436  return addstr(str);
437 #endif
438 }
+ Here is the caller graph for this function:

◆ mutt_window_clearline()

void mutt_window_clearline ( struct MuttWindow win,
int  row 
)

Clear a row of a Window.

Parameters
winWindow
rowRow to clear

Definition at line 113 of file mutt_window.c.

114 {
115  mutt_window_move(win, row, 0);
117 }
void mutt_window_clrtoeol(struct MuttWindow *win)
Clear to the end of the line.
Definition: mutt_window.c:135
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:279
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_window_clrtobot()

void mutt_window_clrtobot ( void  )

Clear to the bottom of the Window.

Note
Assumes the cursor has already been positioned within the Window.

Definition at line 124 of file mutt_window.c.

125 {
126  clrtobot();
127 }
+ Here is the caller graph for this function:

◆ mutt_window_clrtoeol()

void mutt_window_clrtoeol ( struct MuttWindow win)

Clear to the end of the line.

Parameters
winWindow
Note
Assumes the cursor has already been positioned within the window.

Definition at line 135 of file mutt_window.c.

136 {
137  if (!win || !stdscr)
138  return;
139 
140  if (win->state.col_offset + win->state.cols == COLS)
141  clrtoeol();
142  else
143  {
144  int row = 0;
145  int col = 0;
146  getyx(stdscr, row, col);
147  int curcol = col;
148  while (curcol < (win->state.col_offset + win->state.cols))
149  {
150  addch(' ');
151  curcol++;
152  }
153  move(row, col);
154  }
155 }
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:58
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:56
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:91
+ Here is the caller graph for this function:

◆ mutt_window_move()

int mutt_window_move ( struct MuttWindow win,
int  row,
int  col 
)

Move the cursor in a Window.

Parameters
winWindow
rowRow to move to
colColumn to move to
Return values
OKSuccess
ERRError

Definition at line 279 of file mutt_window.c.

280 {
281  return move(win->state.row_offset + row, win->state.col_offset + col);
282 }
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:58
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:91
short row_offset
Absolute on-screen row.
Definition: mutt_window.h:57
+ Here is the caller graph for this function:

◆ mutt_window_move_abs()

void mutt_window_move_abs ( int  row,
int  col 
)

Move the cursor to an absolute screen position.

Parameters
rowScreen row (0-based)
colScreen column (0-based)

Definition at line 445 of file mutt_window.c.

446 {
447  move(row, col);
448 }
+ Here is the caller graph for this function:

◆ mutt_window_mvaddstr()

int mutt_window_mvaddstr ( struct MuttWindow win,
int  row,
int  col,
const char *  str 
)

Move the cursor and write a fixed string to a Window.

Parameters
winWindow to write to
rowRow to move to
colColumn to move to
strString to write
Return values
OKSuccess
ERRError

Definition at line 293 of file mutt_window.c.

294 {
295 #ifdef USE_SLANG_CURSES
296  return mvaddstr(win->state.row_offset + row, win->state.col_offset + col, (char *) str);
297 #else
298  return mvaddstr(win->state.row_offset + row, win->state.col_offset + col, str);
299 #endif
300 }
short col_offset
Absolute on-screen column.
Definition: mutt_window.h:58
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:91
short row_offset
Absolute on-screen row.
Definition: mutt_window.h:57
+ Here is the caller graph for this function:

◆ mutt_window_mvprintw()

int mutt_window_mvprintw ( struct MuttWindow win,
int  row,
int  col,
const char *  fmt,
  ... 
)

Move the cursor and write a formatted string to a Window.

Parameters
winWindow to write to
rowRow to move to
colColumn to move to
fmtprintf format string
...printf arguments
Return values
numSuccess, characters written
ERRError, move failed

Definition at line 312 of file mutt_window.c.

313 {
314  int rc = mutt_window_move(win, row, col);
315  if (rc == ERR)
316  return rc;
317 
318  va_list ap;
319  va_start(ap, fmt);
320  rc = vw_printw(stdscr, fmt, ap);
321  va_end(ap);
322 
323  return rc;
324 }
int mutt_window_move(struct MuttWindow *win, int row, int col)
Move the cursor in a Window.
Definition: mutt_window.c:279
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_window_printf()

int mutt_window_printf ( const char *  fmt,
  ... 
)

Write a formatted string to a Window.

Parameters
fmtFormat string
...Arguments
Return values
numNumber of characters written

Definition at line 456 of file mutt_window.c.

457 {
458  va_list ap;
459  va_start(ap, fmt);
460  int rc = vw_printw(stdscr, fmt, ap);
461  va_end(ap);
462 
463  return rc;
464 }
+ Here is the caller graph for this function:

◆ mutt_window_is_visible()

bool mutt_window_is_visible ( struct MuttWindow win)

Is the Window visible?

Parameters
winWindow
Return values
trueIf the Window is visible

For a Window to be visible, it must be visible and it's parent and grandparent, etc.

Definition at line 537 of file mutt_window.c.

538 {
539  if (!win)
540  return false;
541 
542  for (; win; win = win->parent)
543  {
544  if (!win->state.visible)
545  return false;
546  }
547 
548  return true;
549 }
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:91
bool visible
Window is visible.
Definition: mutt_window.h:54
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:98
+ Here is the caller graph for this function:

◆ mutt_winlist_free()

void mutt_winlist_free ( struct MuttWindowList *  head)

Free a tree of Windows.

Parameters
headWindowList to free

Definition at line 484 of file mutt_window.c.

485 {
486  if (!head)
487  return;
488 
489  struct MuttWindow *np = NULL;
490  struct MuttWindow *tmp = NULL;
491  TAILQ_FOREACH_SAFE(np, head, entries, tmp)
492  {
493  TAILQ_REMOVE(head, np, entries);
495  FREE(&np);
496  }
497 }
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:728
A division of the screen.
Definition: mutt_window.h:86
void mutt_winlist_free(struct MuttWindowList *head)
Free a tree of Windows.
Definition: mutt_window.c:484
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:834
#define FREE(x)
Definition: memory.h:40
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:99
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_window_find()

struct MuttWindow* mutt_window_find ( struct MuttWindow root,
enum WindowType  type 
)

Find a Window of a given type.

Parameters
rootWindow to start searching
typeWindow type to find, e.g. WT_INDEX_BAR
Return values
ptrMatching Window
NULLNo match

Definition at line 575 of file mutt_window.c.

576 {
577  if (!root)
578  return NULL;
579  if (root->type == type)
580  return root;
581 
582  struct MuttWindow *np = NULL;
583  struct MuttWindow *match = NULL;
584  TAILQ_FOREACH(np, &root->children, entries)
585  {
586  match = mutt_window_find(np, type);
587  if (match)
588  return match;
589  }
590 
591  return NULL;
592 }
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
struct MuttWindow * mutt_window_find(struct MuttWindow *root, enum WindowType type)
Find a Window of a given type.
Definition: mutt_window.c:575
A division of the screen.
Definition: mutt_window.h:86
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:99
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:101
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_window_dialog()

struct MuttWindow* mutt_window_dialog ( struct MuttWindow win)

Find the parent Dialog of a Window.

Parameters
winWindow
Return values
ptrDialog

Windows may be nested under a MuttWindow of type WT_DIALOG.

Definition at line 558 of file mutt_window.c.

559 {
560  if (!win)
561  return NULL;
562  if (win->type == WT_DIALOG)
563  return win;
564 
565  return mutt_window_dialog(win->parent);
566 }
Dialog (nested Windows) displayed to the user.
Definition: mutt_window.h:68
struct MuttWindow * mutt_window_dialog(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: mutt_window.c:558
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:98
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:101
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dialog_pop()

void dialog_pop ( void  )

Hide a Window from the user.

The topmost (visible) Window is removed from the stack and the next Window is marked as visible.

Definition at line 623 of file mutt_window.c.

624 {
625  if (!MuttDialogWindow)
626  return;
627 
628  struct MuttWindow *last = TAILQ_LAST(&MuttDialogWindow->children, MuttWindowList);
629  if (!last)
630  return;
631 
632  last->state.visible = false;
633  TAILQ_REMOVE(&MuttDialogWindow->children, last, entries);
634 
635  last = TAILQ_LAST(&MuttDialogWindow->children, MuttWindowList);
636  if (last)
637  {
638  last->state.visible = true;
640  }
641 }
#define TAILQ_LAST(head, headname)
Definition: queue.h:812
A division of the screen.
Definition: mutt_window.h:86
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:834
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:91
bool visible
Window is visible.
Definition: mutt_window.h:54
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:346
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:99
struct MuttWindow * MuttDialogWindow
Parent of all Dialogs.
Definition: mutt_window.c:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dialog_push()

void dialog_push ( struct MuttWindow dlg)

Display a Window to the user.

Parameters
dlgWindow to display

The Dialog Windows are kept in a stack. The topmost is visible to the user, whilst the others are hidden.

When a Window is pushed, the old Window is marked as not visible.

Definition at line 603 of file mutt_window.c.

604 {
605  if (!dlg || !MuttDialogWindow)
606  return;
607 
608  struct MuttWindow *last = TAILQ_LAST(&MuttDialogWindow->children, MuttWindowList);
609  if (last)
610  last->state.visible = false;
611 
613  dlg->state.visible = true;
615 }
#define TAILQ_LAST(head, headname)
Definition: queue.h:812
A division of the screen.
Definition: mutt_window.h:86
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:91
bool visible
Window is visible.
Definition: mutt_window.h:54
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:802
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:346
struct MuttWindowList children
Children Windows.
Definition: mutt_window.h:99
struct MuttWindow * MuttDialogWindow
Parent of all Dialogs.
Definition: mutt_window.c:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ MuttDialogWindow

struct MuttWindow* MuttDialogWindow

Parent of all Dialogs.

Definition at line 45 of file mutt_window.c.

◆ MuttHelpWindow

struct MuttWindow* MuttHelpWindow

Help Window.

Definition at line 46 of file mutt_window.c.

◆ MuttMessageWindow

struct MuttWindow* MuttMessageWindow

Message Window.

Definition at line 47 of file mutt_window.c.