55 const struct Binding *map = NULL;
68 for (
int i = 0; map[i].
name; i++)
85 static int print_macro(FILE *fp,
int maxwidth,
const char **macro)
91 mbstate_t mbstate1, mbstate2;
93 memset(&mbstate1, 0,
sizeof(mbstate1));
94 memset(&mbstate2, 0,
sizeof(mbstate2));
95 for (; len && (k = mbrtowc(&wc, *macro, len, &mbstate1)); *macro += k, len -= k)
97 if ((k == (
size_t)(-1)) || (k == (size_t)(-2)))
99 if (k == (
size_t)(-1))
100 memset(&mbstate1, 0,
sizeof(mbstate1));
101 k = (k == (size_t)(-1)) ? 1 : len;
105 const int w = wcwidth(wc);
112 char buf[MB_LEN_MAX * 2];
114 if (((n1 = wcrtomb(buf, wc, &mbstate2)) != (
size_t)(-1)) &&
115 ((n2 = wcrtomb(buf + n1, 0, &mbstate2)) != (
size_t)(-1)))
121 else if ((wc < 0x20) || (wc == 0x7f))
135 fprintf(fp,
"^%c", (
char) ((wc +
'@') & 0x7f));
165 memset(&mbstate, 0,
sizeof(mbstate));
166 for (m = wid, n = 0; len && (k = mbrtowc(&wc, s, len, &mbstate)) && (n <= wid);
171 if ((k == (
size_t)(-1)) || (k == (size_t)(-2)))
173 if (k == (
size_t)(-1))
174 memset(&mbstate, 0,
sizeof(mbstate));
175 k = (k == (size_t)(-1)) ? 1 : len;
198 static int pad(FILE *fp,
int col,
int i)
202 char fmt[32] = { 0 };
203 snprintf(fmt,
sizeof(fmt),
"%%-%ds", i - col);
204 fprintf(fp, fmt,
"");
227 static void format_line(FILE *fp,
int ismacro,
const char *t1,
const char *t2,
228 const char *t3,
int wraplen)
236 bool split = (wraplen < 40);
245 const int col_a = (wraplen > 83) ? (wraplen - 32) >> 2 : 12;
246 col_b = (wraplen > 49) ? (wraplen - 10) >> 1 : 19;
269 col =
pad(fp, col, col_b);
280 int n = wraplen - col;
303 col =
pad(fp, n, col_b);
319 struct Keymap *map = NULL;
320 const struct Binding *b = NULL;
325 if (map->
op != OP_NULL)
329 if (map->
op == OP_MACRO)
340 b ?
_(
OpStrings[b->
op][1]) :
_(
"ERROR: please report this bug"), wraplen);
354 struct Keymap *map = NULL;
372 struct KeymapList *km_list,
struct KeymapList *aux,
int wraplen)
374 for (
int i = 0; funcs[i].
name; i++)
398 desc =
_(
"<UNKNOWN>");
412 fprintf(fp,
"\n%s\n\n",
_(
"Generic bindings:"));
416 fprintf(fp,
"\n%s\n\n",
_(
"Unbound functions:"));
424 snprintf(buf,
sizeof(buf),
_(
"Help for %s"), desc);
427 NULL) == OP_REFORMAT_WINCH);
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Convenience wrapper for the gui headers.
#define mutt_buffer_mktemp(buf)
static void dump_unbound(FILE *fp, const struct Binding *funcs, struct KeymapList *km_list, struct KeymapList *aux, int wraplen)
Write out all the operations with no key bindings.
struct KeymapList Keymaps[MENU_MAX]
Array of Keymap keybindings, one for each Menu.
MenuType
Types of GUI selections.
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
static int print_macro(FILE *fp, int maxwidth, const char **macro)
Print a macro string to a file.
String manipulation buffer.
static const struct Binding * help_lookup_function(int op, enum MenuType menu)
Find a keybinding for an operation.
All user-callable functions.
static void format_line(FILE *fp, int ismacro, const char *t1, const char *t2, const char *t3, int wraplen)
Write a formatted line to a file.
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Some miscellaneous functions.
static int get_wrapped_width(const char *t, size_t wid)
Wrap a string at a sensible place.
Pager pager (email viewer)
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
const struct Binding OpGeneric[]
Key bindings for the generic menu.
const char * name
name of the function
short op
operation to perform
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
const char * OpStrings[][2]
Prototypes for many functions.
const struct Mapping Menus[]
Menu name lookup table.
int mutt_strwidth(const char *s)
Measure a string's width in screen cells.
int km_expand_key(char *s, size_t len, struct Keymap *map)
Get the key string bound to a Keymap.
char * macro
macro expansion (op == OP_MACRO)
static void dump_menu(FILE *fp, enum MenuType menu, int wraplen)
Write all the key bindings to a file.
wchar_t ReplacementChar
When a Unicode character can't be displayed, use this instead.
WHERE bool C_Markers
Config: Display a '+' at the beginning of wrapped lines in the pager.
static bool is_bound(struct KeymapList *km_list, int op)
Does a function have a keybinding?
#define STAILQ_FOREACH(var, head, field)
char * desc
description of a macro for the help menu
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definitions of user functions.
WHERE char * C_Pager
Config: External command for viewing messages, or 'builtin' to use NeoMutt's.
int mutt_do_pager(const char *banner, const char *tempfile, PagerFlags do_color, struct Pager *info)
Display some page-able text to the user.
void mutt_help(enum MenuType menu, int wraplen)
Display the help menu.
const struct Binding * km_get_table(enum MenuType menu)
Lookup a menu's keybindings.
Hundreds of global variables to back the user variables.
Convenience wrapper for the library headers.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
static int pad(FILE *fp, int col, int i)
Write some padding to a file.
Mapping between a user key and a function.