NeoMutt  2024-11-14-138-ge5ca67
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
window.c
Go to the documentation of this file.
1
68#include "config.h"
69#include <stdbool.h>
70#include "private.h"
71#include "mutt/lib.h"
72#include "config/lib.h"
73#include "gui/lib.h"
74#include "lib.h"
75#include "type.h"
76
80static int menu_recalc(struct MuttWindow *win)
81{
82 if (win->type != WT_MENU)
83 return 0;
84
86 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
87 return 0;
88}
89
93static int menu_repaint(struct MuttWindow *win)
94{
95 if (win->type != WT_MENU)
96 return 0;
97
98 struct Menu *menu = win->wdata;
99 menu->redraw |= MENU_REDRAW_FULL;
100 menu_redraw(menu);
102
103 const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
104 const bool c_braille_friendly = cs_subset_bool(menu->sub, "braille_friendly");
105
106 /* move the cursor out of the way */
107 if (c_arrow_cursor)
108 {
109 const char *const c_arrow_string = cs_subset_string(menu->sub, "arrow_string");
110 const int arrow_width = mutt_strwidth(c_arrow_string);
111 mutt_window_move(menu->win, arrow_width, menu->current - menu->top);
112 }
113 else if (c_braille_friendly)
114 {
115 mutt_window_move(menu->win, 0, menu->current - menu->top);
116 }
117 else
118 {
119 mutt_window_move(menu->win, menu->win->state.cols - 1, menu->current - menu->top);
120 }
121
122 mutt_debug(LL_DEBUG5, "repaint done\n");
123 return 0;
124}
125
129static void menu_wdata_free(struct MuttWindow *win, void **ptr)
130{
131 menu_free((struct Menu **) ptr);
132}
133
141{
145
146 struct Menu *menu = menu_new(type, win, sub);
147
150 win->wdata = menu;
153
154 return win;
155}
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:291
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
Convenience wrapper for the config headers.
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
Definition: curs_lib.c:443
int menu_redraw(struct Menu *menu)
Redraw the parts of the screen that have been flagged to be redrawn.
Definition: draw.c:480
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static int menu_recalc(struct MuttWindow *win)
Recalculate the Window data - Implements MuttWindow::recalc() -.
Definition: window.c:80
static int menu_repaint(struct MuttWindow *win)
Repaint the Window - Implements MuttWindow::repaint() -.
Definition: window.c:93
static void menu_wdata_free(struct MuttWindow *win, void **ptr)
Free the Menu - Implements MuttWindow::wdata_free() -.
Definition: window.c:129
Convenience wrapper for the gui headers.
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
#define MENU_REDRAW_FULL
Redraw everything.
Definition: lib.h:59
#define MENU_REDRAW_NO_FLAGS
No flags are set.
Definition: lib.h:55
struct MuttWindow * menu_window_new(enum MenuType type, struct ConfigSubset *sub)
Create a new Menu Window.
Definition: window.c:140
void menu_free(struct Menu **ptr)
Free a Menu.
Definition: menu.c:114
struct Menu * menu_new(enum MenuType type, struct MuttWindow *win, struct ConfigSubset *sub)
Create a new Menu.
Definition: menu.c:136
Convenience wrapper for the library headers.
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:182
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:297
#define WA_RECALC
Recalculate the contents of the Window.
Definition: mutt_window.h:110
@ WT_MENU
An Window containing a Menu.
Definition: mutt_window.h:98
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition: mutt_window.h:39
#define WA_REPAINT
Redraw the contents of the Window.
Definition: mutt_window.h:111
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:53
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition: mutt_window.h:49
GUI display the mailboxes in a side panel.
Key value store.
A set of inherited config items.
Definition: subset.h:47
Definition: lib.h:79
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:86
int current
Current entry.
Definition: lib.h:80
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:82
int top
Entry that is the top of the current page.
Definition: lib.h:90
enum MenuType type
Menu definition for keymap entries.
Definition: lib.h:83
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:87
int(* repaint)(struct MuttWindow *win)
Definition: mutt_window.h:187
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
void * wdata
Private data.
Definition: mutt_window.h:145
int(* recalc)(struct MuttWindow *win)
Definition: mutt_window.h:173
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:159
WindowActionFlags actions
Actions to be performed, e.g. WA_RECALC.
Definition: mutt_window.h:132
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:144
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:61
Menu types.
MenuType
Types of GUI selections.
Definition: type.h:36