NeoMutt  2022-04-29-249-gaae397
Teaching an old dog new tricks
DOXYGEN
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
85 // struct Menu *menu = win->wdata;
86
88 mutt_debug(LL_DEBUG5, "recalc done, request WA_REPAINT\n");
89 return 0;
90}
91
95static int menu_repaint(struct MuttWindow *win)
96{
97 if (win->type != WT_MENU)
98 return 0;
99
100 struct Menu *menu = win->wdata;
101 menu->redraw |= MENU_REDRAW_FULL;
102 menu_redraw(menu);
104
105 const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
106 const bool c_braille_friendly = cs_subset_bool(menu->sub, "braille_friendly");
107
108 /* move the cursor out of the way */
109 if (c_arrow_cursor)
110 mutt_window_move(menu->win, 2, menu->current - menu->top);
111 else if (c_braille_friendly)
112 mutt_window_move(menu->win, 0, menu->current - menu->top);
113 else
114 {
115 mutt_window_move(menu->win, menu->win->state.cols - 1, menu->current - menu->top);
116 }
117
118 mutt_debug(LL_DEBUG5, "repaint done\n");
119 return 0;
120}
121
125static void menu_wdata_free(struct MuttWindow *win, void **ptr)
126{
127 menu_free((struct Menu **) ptr);
128}
129
137{
141
142 struct Menu *menu = menu_new(type, win, sub);
143
146 win->wdata = menu;
149
150 return win;
151}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
Convenience wrapper for the config headers.
int menu_redraw(struct Menu *menu)
Redraw the parts of the screen that have been flagged to be redrawn.
Definition: draw.c:472
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
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:95
static void menu_wdata_free(struct MuttWindow *win, void **ptr)
Destroy a Menu Window - Implements MuttWindow::wdata_free() -.
Definition: window.c:125
Convenience wrapper for the gui headers.
@ LL_DEBUG5
Log at debug level 5.
Definition: logging.h:44
#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:136
void menu_free(struct Menu **ptr)
Free a Menu.
Definition: menu.c:111
struct Menu * menu_new(enum MenuType type, struct MuttWindow *win, struct ConfigSubset *sub)
Create a new Menu.
Definition: menu.c:130
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:181
int mutt_window_move(struct MuttWindow *win, int col, int row)
Move the cursor in a Window.
Definition: mutt_window.c:293
#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:38
#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:52
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition: mutt_window.h:48
GUI display the mailboxes in a side panel.
Key value store.
A set of inherited config items.
Definition: subset.h:47
Definition: lib.h:69
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
int current
Current entry.
Definition: lib.h:70
MenuRedrawFlags redraw
When to redraw the screen.
Definition: lib.h:72
int top
Entry that is the top of the current page.
Definition: lib.h:80
enum MenuType type
Menu definition for keymap entries.
Definition: lib.h:73
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:77
int(* repaint)(struct MuttWindow *win)
Definition: mutt_window.h:182
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:171
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:160
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:60
Menu types.
MenuType
Types of GUI selections.
Definition: type.h:36