NeoMutt  2025-01-09-41-g086358
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
helpbar.c File Reference

Help Bar. More...

#include "config.h"
#include <stdbool.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "color/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
+ Include dependency graph for helpbar.c:

Go to the source code of this file.

Functions

static bool make_help (enum MenuType menu, int op, const char *txt, struct Buffer *buf)
 Create one entry for the Help Bar.
 
static void compile_help (enum MenuType menu, const struct Mapping *items, struct Buffer *buf)
 Create the text for the help menu.
 
static int helpbar_recalc (struct MuttWindow *win)
 Recalculate the display of the Help Bar - Implements MuttWindow::recalc() -.
 
static int helpbar_repaint (struct MuttWindow *win)
 Redraw the Help Bar - Implements MuttWindow::repaint() -.
 
static int helpbar_binding_observer (struct NotifyCallback *nc)
 Notification that a Key Binding has changed - Implements observer_t -.
 
static int helpbar_color_observer (struct NotifyCallback *nc)
 Notification that a Color has changed - Implements observer_t -.
 
static int helpbar_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -.
 
static int helpbar_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
 
struct MuttWindowhelpbar_new (void)
 Create the Help Bar Window.
 

Detailed Description

Help Bar.

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 helpbar.c.

Function Documentation

◆ make_help()

static bool make_help ( enum MenuType  menu,
int  op,
const char *  txt,
struct Buffer buf 
)
static

Create one entry for the Help Bar.

Parameters
[in]menuCurrent Menu, e.g. MENU_PAGER
[in]opOperation, e.g. OP_DELETE
[in]txtText part, e.g. "delete"
[out]bufBuffer for the result
Return values
trueKeybinding exists

This will return something like: "d:delete"

Definition at line 89 of file helpbar.c.

90{
91 if (km_expand_key(km_find_func(menu, op), buf) ||
93 {
94 buf_addch(buf, ':');
95 buf_addstr(buf, txt);
96 return true;
97 }
98
99 return false;
100}
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:241
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:226
struct Keymap * km_find_func(enum MenuType mtype, int func)
Find a function's mapping in a Menu.
Definition: lib.c:483
bool km_expand_key(struct Keymap *map, struct Buffer *buf)
Get the key string bound to a Keymap.
Definition: lib.c:451
@ MENU_GENERIC
Generic selection list.
Definition: type.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compile_help()

static void compile_help ( enum MenuType  menu,
const struct Mapping items,
struct Buffer buf 
)
static

Create the text for the help menu.

Parameters
[in]menuCurrent Menu, e.g. MENU_PAGER
[in]itemsMap of functions to display in the Help Bar
[out]bufBuffer for the result

Definition at line 108 of file helpbar.c.

109{
110 for (int i = 0; items[i].name; i++)
111 {
112 if (!make_help(menu, items[i].value, _(items[i].name), buf))
113 continue;
114
115 buf_addstr(buf, " ");
116 }
117}
static bool make_help(enum MenuType menu, int op, const char *txt, struct Buffer *buf)
Create one entry for the Help Bar.
Definition: helpbar.c:89
#define _(a)
Definition: message.h:28
const char * name
String value.
Definition: mapping.h:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ helpbar_new()

struct MuttWindow * helpbar_new ( void  )

Create the Help Bar Window.

Return values
ptrNew Window
Note
The Window can be freed with mutt_window_free().

Definition at line 317 of file helpbar.c.

318{
322 win->state.visible = cs_subset_bool(NeoMutt->sub, "help");
323
324 win->recalc = helpbar_recalc;
326
327 win->wdata = helpbar_wdata_new();
329
334 return win;
335}
void mutt_color_observer_add(observer_t callback, void *global_data)
Add an observer.
Definition: notify.c:61
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
static int helpbar_color_observer(struct NotifyCallback *nc)
Notification that a Color has changed - Implements observer_t -.
Definition: helpbar.c:213
static int helpbar_binding_observer(struct NotifyCallback *nc)
Notification that a Key Binding has changed - Implements observer_t -.
Definition: helpbar.c:184
static int helpbar_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: helpbar.c:270
static int helpbar_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: helpbar.c:242
static int helpbar_recalc(struct MuttWindow *win)
Recalculate the display of the Help Bar - Implements MuttWindow::recalc() -.
Definition: helpbar.c:125
static int helpbar_repaint(struct MuttWindow *win)
Redraw the Help Bar - Implements MuttWindow::repaint() -.
Definition: helpbar.c:163
void helpbar_wdata_free(struct MuttWindow *win, void **ptr)
Free Helpbar Window data - Implements MuttWindow::wdata_free() -.
Definition: wdata.c:47
struct HelpbarWindowData * helpbar_wdata_new(void)
Create new Window data for the Helpbar.
Definition: wdata.c:39
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:191
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
@ WT_HELP_BAR
Help Bar containing list of useful key bindings.
Definition: mutt_window.h:96
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition: mutt_window.h:39
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:53
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
Definition: mutt_window.h:48
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:57
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
@ NT_BINDING
Key binding has changed, NotifyBinding, EventBinding.
Definition: notify_type.h:40
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: rootwin.c:106
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition: subset.h:52
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
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
int(* recalc)(struct MuttWindow *win)
Definition: mutt_window.h:173
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Definition: mutt_window.h:159
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct Notify * notify
Notifications handler.
Definition: neomutt.h:43
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
bool visible
Window is visible.
Definition: mutt_window.h:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function: