NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
help.c File Reference

Generate the help-page and GUI display it. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "index/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "pager/lib.h"
+ Include dependency graph for help.c:

Go to the source code of this file.

Functions

static void dump_message_flags (const struct MenuDefinition *md, FILE *fp)
 Write out all the message flags.
 
void mutt_help (const struct MenuDefinition *md)
 Display the Help Page.
 

Variables

static const char * FlagCharsDesc []
 Descriptions of the $flag_chars flags.
 
static const char * CryptCharsDesc []
 Descriptions of the $crypt_chars flags.
 
static const char * ToCharsDesc []
 Descriptions of the $to_chars flags.
 

Detailed Description

Generate the help-page and GUI display it.

Authors
  • Michael R. Elkins
  • Richard Russon
  • Pietro Cerutti
  • Yousef Akbar
  • Ihor Antonov
  • Tóth János

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

Function Documentation

◆ dump_message_flags()

static void dump_message_flags ( const struct MenuDefinition * md,
FILE * fp )
static

Write out all the message flags.

Parameters
mdMenu Definition
fpFile to write to

Display a quick reminder of all the flags in the config options:

  • $crypt_chars
  • $flag_chars
  • $to_chars

Definition at line 103 of file help.c.

104{
105 if (md != MdIndex)
106 return;
107
108 const char *flag = NULL;
109 int cols;
110
111 fprintf(fp, "\n%s\n\n", _("Message flags:"));
112
113 const struct MbTable *c_flag_chars = cs_subset_mbtable(NeoMutt->sub, "flag_chars");
114 fprintf(fp, "$flag_chars:\n");
115 for (int i = FLAG_CHAR_TAGGED; i <= FLAG_CHAR_ZEMPTY; i++)
116 {
117 flag = mbtable_get_nth_wchar(c_flag_chars, i);
118 cols = mutt_strwidth(flag);
119 fprintf(fp, " '%s'%*s %s\n", flag, 4 - cols, "", _(FlagCharsDesc[i]));
120 }
121
122 const struct MbTable *c_crypt_chars = cs_subset_mbtable(NeoMutt->sub, "crypt_chars");
123 fprintf(fp, "\n$crypt_chars:\n");
125 {
126 flag = mbtable_get_nth_wchar(c_crypt_chars, i);
127 cols = mutt_strwidth(flag);
128 fprintf(fp, " '%s'%*s %s\n", flag, 4 - cols, "", _(CryptCharsDesc[i]));
129 }
130
131 const struct MbTable *c_to_chars = cs_subset_mbtable(NeoMutt->sub, "to_chars");
132 fprintf(fp, "\n$to_chars:\n");
134 {
135 flag = mbtable_get_nth_wchar(c_to_chars, i);
136 cols = mutt_strwidth(flag);
137 fprintf(fp, " '%s'%*s %s\n", flag, 4 - cols, "", _(ToCharsDesc[i]));
138 }
139
140 fprintf(fp, "\n");
141}
struct MbTable * cs_subset_mbtable(const struct ConfigSubset *sub, const char *name)
Get a Multibyte table config item by name.
Definition helpers.c:119
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
Definition curs_lib.c:444
@ FLAG_CHAR_TO_NOT_IN_THE_LIST
Character denoting that the user is not in list.
@ FLAG_CHAR_TO_REPLY_TO
Character denoting that the user is in the Reply-To list.
@ FLAG_CHAR_CRYPT_NO_CRYPTO
Character denoting a message has no cryptography information.
@ FLAG_CHAR_CRYPT_GOOD_SIGN
Character denoting a message signed with a verified key.
@ FLAG_CHAR_ZEMPTY
Character denoting a read email, $index_format Z expando.
@ FLAG_CHAR_TAGGED
Character denoting a tagged email.
static const char * ToCharsDesc[]
Descriptions of the $to_chars flags.
Definition help.c:83
static const char * CryptCharsDesc[]
Descriptions of the $crypt_chars flags.
Definition help.c:70
static const char * FlagCharsDesc[]
Descriptions of the $flag_chars flags.
Definition help.c:51
struct MenuDefinition * MdIndex
Index Menu Definition.
Definition functions.c:80
const char * mbtable_get_nth_wchar(const struct MbTable *table, int index)
Extract one char from a multi-byte table.
Definition mbtable.c:340
#define _(a)
Definition message.h:28
Multibyte character table.
Definition mbtable.h:36
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_help()

void mutt_help ( const struct MenuDefinition * md)

Display the Help Page.

Parameters
mdMenu Definition

Definition at line 147 of file help.c.

148{
149 struct BindingInfoArray bia_bind = ARRAY_HEAD_INITIALIZER;
150 struct BindingInfoArray bia_macro = ARRAY_HEAD_INITIALIZER;
151 struct BindingInfoArray bia_unbound = ARRAY_HEAD_INITIALIZER;
152 struct Buffer *banner = NULL;
153 struct Buffer *tempfile = NULL;
154 struct BindingInfo *bi = NULL;
155
156 // ---------------------------------------------------------------------------
157 // Gather the data
158
159 gather_menu(md, &bia_bind, &bia_macro, false);
160
161 ARRAY_SORT(&bia_bind, binding_sort, NULL);
162 ARRAY_SORT(&bia_macro, binding_sort, NULL);
163
164 int wb0 = measure_column(&bia_bind, 0);
165 int wb1 = measure_column(&bia_bind, 1);
166
167 const int wm0 = measure_column(&bia_macro, 0);
168
169 gather_unbound(md, &bia_unbound);
170
171 ARRAY_SORT(&bia_unbound, binding_sort, NULL);
172 const int wu1 = measure_column(&bia_unbound, 1);
173
174 // ---------------------------------------------------------------------------
175 // Save the data to a file
176
177 tempfile = buf_pool_get();
178 buf_mktemp(tempfile);
179 FILE *fp = mutt_file_fopen(buf_string(tempfile), "w");
180 if (!fp)
181 {
182 mutt_perror("%s", buf_string(tempfile));
183 goto cleanup;
184 }
185
186 const char *menu_name = NULL;
187 ARRAY_FOREACH(bi, &bia_bind)
188 {
189 if (!bi->a[0])
190 {
191 menu_name = bi->a[2];
192 continue;
193 }
194
195 if (menu_name)
196 {
197 if (ARRAY_FOREACH_IDX_bi > 0)
198 fprintf(fp, "\n");
199
200 fprintf(fp, "%s bindings\n", menu_name);
201 fprintf(fp, "\n");
202 menu_name = NULL;
203 }
204
205 // key text description
206 fprintf(fp, "%*s %*s %s\n", -wb0, bi->a[0], -wb1, bi->a[1], bi->a[2]);
207 }
208
209 ARRAY_FOREACH(bi, &bia_macro)
210 {
211 if (!bi->a[0])
212 {
213 menu_name = bi->a[2];
214 continue;
215 }
216
217 if (menu_name)
218 {
219 if (ARRAY_FOREACH_IDX_bi > 0)
220 fprintf(fp, "\n");
221
222 fprintf(fp, "%s macros\n", menu_name);
223 fprintf(fp, "\n");
224 menu_name = NULL;
225 }
226
227 if (bi->a[2]) // description
228 {
229 // key description, macro-text, blank line
230 fprintf(fp, "%*s %s\n", -wm0, bi->a[0], bi->a[2]);
231 fprintf(fp, "%s\n", bi->a[1]);
232 fprintf(fp, "\n");
233 }
234 else
235 {
236 // key macro-text
237 fprintf(fp, "%*s %s\n", -wm0, bi->a[0], bi->a[1]);
238 }
239 }
240 fprintf(fp, "\n");
241
242 fprintf(fp, "unbound functions\n");
243 fprintf(fp, "\n");
244 ARRAY_FOREACH(bi, &bia_unbound)
245 {
246 // function description
247 fprintf(fp, "%*s %s\n", -wu1, bi->a[1], bi->a[2]);
248 }
249
250 dump_message_flags(md, fp);
251 mutt_file_fclose(&fp);
252
253 // ---------------------------------------------------------------------------
254 // Display data
255
256 struct PagerData pdata = { 0 };
257 struct PagerView pview = { &pdata };
258
259 pview.mode = PAGER_MODE_HELP;
261
263 buf_printf(banner, _("Help for %s"), md->name);
264 pdata.fname = buf_string(tempfile);
265 pview.banner = buf_string(banner);
266 mutt_do_pager(&pview, NULL);
267
268cleanup:
269
270 ARRAY_FOREACH(bi, &bia_bind)
271 {
272 FREE(&bi->a[0]);
273 }
274
275 ARRAY_FOREACH(bi, &bia_macro)
276 {
277 FREE(&bi->a[0]);
278 FREE(&bi->a[1]);
279 }
280
282 buf_pool_release(&tempfile);
283 ARRAY_FREE(&bia_bind);
284 ARRAY_FREE(&bia_macro);
285 ARRAY_FREE(&bia_unbound);
286}
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition array.h:373
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition array.h:58
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
int mutt_do_pager(struct PagerView *pview, struct Email *e)
Display some page-able text to the user (help or attachment)
Definition do_pager.c:122
#define mutt_file_fclose(FP)
Definition file.h:139
#define mutt_file_fopen(PATH, MODE)
Definition file.h:138
#define mutt_perror(...)
Definition logging2.h:95
int binding_sort(const void *a, const void *b, void *sdata)
Compare two BindingInfo by their keybinding - Implements sort_t -.
Definition dump.c:205
static void dump_message_flags(const struct MenuDefinition *md, FILE *fp)
Write out all the message flags.
Definition help.c:103
int measure_column(struct BindingInfoArray *bia, int col)
Measure one column of a table.
Definition dump.c:229
void gather_menu(const struct MenuDefinition *md, struct BindingInfoArray *bia_bind, struct BindingInfoArray *bia_macro, bool one_submenu)
Gather info about one menu.
Definition dump.c:134
int gather_unbound(const struct MenuDefinition *md, struct BindingInfoArray *bia_unbound)
Gather info about unbound functions for one menu.
Definition dump.c:439
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
#define MUTT_PAGER_NOWRAP
Format for term width, ignore $wrap.
Definition lib.h:73
#define MUTT_PAGER_STRIPES
Striped highlighting.
Definition lib.h:76
#define MUTT_PAGER_MARKER
Use markers if option is set.
Definition lib.h:71
@ PAGER_MODE_HELP
Pager is invoked via 3rd path to show help.
Definition lib.h:141
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
Info about one keybinding.
Definition dump.h:40
const char * a[3]
Array of info.
Definition dump.h:42
String manipulation buffer.
Definition buffer.h:36
const char * name
Menu name, e.g. "alias".
Definition menu.h:82
Data to be displayed by PagerView.
Definition lib.h:161
const char * fname
Name of the file to read.
Definition lib.h:165
Paged view into some data.
Definition lib.h:172
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition lib.h:173
enum PagerMode mode
Pager mode.
Definition lib.h:174
PagerFlags flags
Additional settings to tweak pager's function.
Definition lib.h:175
const char * banner
Title to display in status bar.
Definition lib.h:176
#define buf_mktemp(buf)
Definition tmp.h:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ FlagCharsDesc

const char* FlagCharsDesc[]
static
Initial value:
= {
N_("message is tagged"),
N_("message is flagged"),
N_("message is deleted"),
N_("attachment is deleted"),
N_("message has been replied to"),
N_("message has been read"),
N_("message is new"),
N_("thread has been read"),
N_("thread has at least one new message"),
N_("message has been read (%S expando)"),
N_("message has been read (%Z expando)"),
}
#define N_(a)
Definition message.h:32

Descriptions of the $flag_chars flags.

This must be in the same order as FlagChars

Definition at line 51 of file help.c.

51 {
52 N_("message is tagged"),
53 N_("message is flagged"),
54 N_("message is deleted"),
55 N_("attachment is deleted"),
56 N_("message has been replied to"),
57 N_("message has been read"),
58 N_("message is new"),
59 N_("thread has been read"),
60 N_("thread has at least one new message"),
61 N_("message has been read (%S expando)"),
62 N_("message has been read (%Z expando)"),
63};

◆ CryptCharsDesc

const char* CryptCharsDesc[]
static
Initial value:
= {
N_("message signed with a verified key"),
N_("message is PGP-encrypted"),
N_("message is signed"),
N_("message contains a PGP key"),
N_("message has no cryptography information"),
}

Descriptions of the $crypt_chars flags.

This must be in the same order as CryptChars

Definition at line 70 of file help.c.

70 {
71 N_("message signed with a verified key"),
72 N_("message is PGP-encrypted"),
73 N_("message is signed"),
74 N_("message contains a PGP key"),
75 N_("message has no cryptography information"),
76};

◆ ToCharsDesc

const char* ToCharsDesc[]
static
Initial value:
= {
N_("message is not To: you"),
N_("message is To: you and only you"),
N_("message is To: you"),
N_("message is Cc: to you"),
N_("message is From: you"),
N_("message is sent to a subscribed mailing list"),
N_("you are in the Reply-To: list"),
}

Descriptions of the $to_chars flags.

This must be in the same order as ToChars

Definition at line 83 of file help.c.

83 {
84 N_("message is not To: you"),
85 N_("message is To: you and only you"),
86 N_("message is To: you"),
87 N_("message is Cc: to you"),
88 N_("message is From: you"),
89 N_("message is sent to a subscribed mailing list"),
90 N_("you are in the Reply-To: list"),
91};