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

Get a key from the user. More...

#include <stdint.h>
#include "mutt/lib.h"
#include "menu/lib.h"
#include "keymap.h"
+ Include dependency graph for get.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  KeyEvent
 An event such as a keypress. More...
 
struct  KeymapMatch
 Result of Matching Keybinding. More...
 

Macros

#define GETCH_NO_FLAGS   0
 No flags are set.
 
#define GETCH_IGNORE_MACRO   (1 << 0)
 Don't use MacroEvents.
 
#define KEY_GATHER_NO_MATCH   0
 No bindings match the search string.
 
#define KEY_GATHER_MATCH   (1 << 0)
 Binding matches the search string.
 
#define KEY_GATHER_LONGER   (1 << 1)
 No bindings match, but longer strings might.
 
#define MFF_NO_FLAGS   0
 No flags are set.
 
#define MFF_DEPRECATED   (1 << 1)
 Redraw the pager.
 

Typedefs

typedef uint8_t GetChFlags
 Flags for mutt_getch(), e.g. GETCH_NO_FLAGS.
 
typedef uint8_t KeyGatherFlags
 Flags for gather_functions(), e.g. KEY_GATHER_NO_MATCH.
 
typedef uint8_t MenuFuncFlags
 Flags, e.g. MFF_DEPRECATED.
 

Functions

 ARRAY_HEAD (KeyEventArray, struct KeyEvent)
 
 ARRAY_HEAD (KeymapMatchArray, struct KeymapMatch)
 
void array_add (struct KeyEventArray *a, int ch, int op)
 Add an event to the end of the array.
 
struct KeyEventarray_pop (struct KeyEventArray *a)
 Remove an event from the array.
 
void array_to_endcond (struct KeyEventArray *a)
 Clear the array until an OP_END_COND.
 
KeyGatherFlags gather_functions (const struct MenuDefinition *md, const keycode_t *keys, int key_len, struct KeymapMatchArray *kma)
 Find functions whose keybindings match.
 
void generic_tokenize_push_string (char *s)
 Parse and queue a 'push' command.
 
struct KeyEvent km_dokey (const struct MenuDefinition *md, GetChFlags flags)
 Determine what a keypress should do.
 
void km_error_key (const struct MenuDefinition *md)
 Handle an unbound key sequence.
 
void mutt_flushinp (void)
 Empty all the keyboard buffers.
 
void mutt_flush_macro_to_endcond (void)
 Drop a macro from the input buffer.
 
struct KeyEvent mutt_getch (GetChFlags flags)
 Read a character from the input buffer.
 
int mutt_monitor_getch (void)
 Get a character and poll the filesystem monitor.
 
void mutt_push_macro_event (int ch, int op)
 Add the character/operation to the macro buffer.
 
void mutt_unget_ch (int ch)
 Return a keystroke to the input buffer.
 
void mutt_unget_op (int op)
 Return an operation to the input buffer.
 

Variables

struct KeyEventArray MacroEvents
 These are used for macros and exec/push commands.
 
struct KeyEventArray UngetKeyEvents
 These are used in all other "normal" situations, and are not ignored when passing GETCH_IGNORE_MACRO.
 

Detailed Description

Get a key from the user.

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 get.h.

Macro Definition Documentation

◆ GETCH_NO_FLAGS

#define GETCH_NO_FLAGS   0

No flags are set.

Definition at line 34 of file get.h.

◆ GETCH_IGNORE_MACRO

#define GETCH_IGNORE_MACRO   (1 << 0)

Don't use MacroEvents.

Definition at line 35 of file get.h.

◆ KEY_GATHER_NO_MATCH

#define KEY_GATHER_NO_MATCH   0

No bindings match the search string.

Definition at line 38 of file get.h.

◆ KEY_GATHER_MATCH

#define KEY_GATHER_MATCH   (1 << 0)

Binding matches the search string.

Definition at line 39 of file get.h.

◆ KEY_GATHER_LONGER

#define KEY_GATHER_LONGER   (1 << 1)

No bindings match, but longer strings might.

Definition at line 40 of file get.h.

◆ MFF_NO_FLAGS

#define MFF_NO_FLAGS   0

No flags are set.

Definition at line 43 of file get.h.

◆ MFF_DEPRECATED

#define MFF_DEPRECATED   (1 << 1)

Redraw the pager.

Definition at line 44 of file get.h.

Typedef Documentation

◆ GetChFlags

typedef uint8_t GetChFlags

Flags for mutt_getch(), e.g. GETCH_NO_FLAGS.

Definition at line 33 of file get.h.

◆ KeyGatherFlags

typedef uint8_t KeyGatherFlags

Flags for gather_functions(), e.g. KEY_GATHER_NO_MATCH.

Definition at line 37 of file get.h.

◆ MenuFuncFlags

typedef uint8_t MenuFuncFlags

Flags, e.g. MFF_DEPRECATED.

Definition at line 42 of file get.h.

Function Documentation

◆ ARRAY_HEAD() [1/2]

ARRAY_HEAD ( KeyEventArray ,
struct KeyEvent  )

◆ ARRAY_HEAD() [2/2]

ARRAY_HEAD ( KeymapMatchArray ,
struct KeymapMatch  )
+ Here is the call graph for this function:

◆ array_add()

void array_add ( struct KeyEventArray * a,
int ch,
int op )

Add an event to the end of the array.

Parameters
aArray
chCharacter
opOperation, e.g. OP_DELETE

Definition at line 95 of file get.c.

96{
97 struct KeyEvent event = { ch, op };
98 ARRAY_ADD(a, event);
99}
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition array.h:157
An event such as a keypress.
Definition get.h:50
int op
Function opcode, e.g. OP_HELP.
Definition get.h:52
int ch
Raw key pressed.
Definition get.h:51
+ Here is the caller graph for this function:

◆ array_pop()

struct KeyEvent * array_pop ( struct KeyEventArray * a)

Remove an event from the array.

Parameters
aArray
Return values
ptrEvent

Definition at line 77 of file get.c.

78{
79 if (ARRAY_EMPTY(a))
80 {
81 return NULL;
82 }
83
84 struct KeyEvent *event = ARRAY_LAST(a);
85 ARRAY_SHRINK(a, 1);
86 return event;
87}
#define ARRAY_LAST(head)
Convenience method to get the last element.
Definition array.h:145
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition array.h:74
#define ARRAY_SHRINK(head, n)
Mark a number of slots at the end of the array as unused.
Definition array.h:174
+ Here is the caller graph for this function:

◆ array_to_endcond()

void array_to_endcond ( struct KeyEventArray * a)

Clear the array until an OP_END_COND.

Parameters
aArray

Definition at line 105 of file get.c.

106{
107 while (!ARRAY_EMPTY(a))
108 {
109 if (array_pop(a)->op == OP_END_COND)
110 {
111 return;
112 }
113 }
114}
struct KeyEvent * array_pop(struct KeyEventArray *a)
Remove an event from the array.
Definition get.c:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gather_functions()

KeyGatherFlags gather_functions ( const struct MenuDefinition * md,
const keycode_t * keys,
int key_len,
struct KeymapMatchArray * kma )

Find functions whose keybindings match.

Parameters
[in]mdMenu Definition of all valid functions
[in]keysUser-entered key string to match
[in]key_lenLength of key string
[out]kmaArray for the results
Return values
flagsResults, e.g. KEY_GATHER_MATCH

Definition at line 383 of file get.c.

385{
386 if (!md || !keys || !kma)
387 return 0;
388
389 struct SubMenu **smp = NULL;
391
392 ARRAY_FOREACH(smp, &md->submenus)
393 {
394 struct Keymap *km = NULL;
395
396 STAILQ_FOREACH(km, &(*smp)->keymaps, entries)
397 {
398 bool match = true;
399
400 for (int i = 0; i < key_len; i++)
401 {
402 if (keys[i] != km->keys[i])
403 {
404 match = false;
405 break;
406 }
407 }
408
409 if (match)
410 {
412 if (km->len == key_len)
413 fmatch = KEY_GATHER_MATCH;
414 else
415 fmatch = KEY_GATHER_LONGER;
416
417 flags |= fmatch;
418
419 struct KeymapMatch kmatch = { md->id, fmatch, km };
420 ARRAY_ADD(kma, kmatch);
421 }
422 }
423 }
424
425 return flags;
426}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define KEY_GATHER_LONGER
No bindings match, but longer strings might.
Definition get.h:40
#define KEY_GATHER_NO_MATCH
No bindings match the search string.
Definition get.h:38
uint8_t KeyGatherFlags
Flags for gather_functions(), e.g. KEY_GATHER_NO_MATCH.
Definition get.h:37
#define KEY_GATHER_MATCH
Binding matches the search string.
Definition get.h:39
#define STAILQ_FOREACH(var, head, field)
Definition queue.h:390
Result of Matching Keybinding.
Definition get.h:65
KeyGatherFlags flags
Flags, e.g. KEY_GATHER_MATCH.
Definition get.h:67
A keyboard mapping.
Definition keymap.h:43
keycode_t * keys
Key sequence.
Definition keymap.h:49
short len
Length of key sequence (unit: sizeof (keycode_t))
Definition keymap.h:48
int id
Menu ID, e.g. MENU_ALIAS.
Definition menu.h:81
struct SubMenuPArray submenus
Parts making up the Menu.
Definition menu.h:83
Collection of related functions.
Definition menu.h:68
+ Here is the caller graph for this function:

◆ generic_tokenize_push_string()

void generic_tokenize_push_string ( char * s)

Parse and queue a 'push' command.

Parameters
sString to push into the key queue

Parses s for <function> syntax and adds the whole sequence the macro buffer.

Definition at line 309 of file get.c.

310{
311 char *pp = NULL;
312 char *p = s + mutt_str_len(s) - 1;
313 size_t l;
314 int i, op = OP_NULL;
315
316 while (p >= s)
317 {
318 /* if we see something like "<PageUp>", look to see if it is a real
319 * function name and return the corresponding value */
320 if (*p == '>')
321 {
322 for (pp = p - 1; pp >= s && *pp != '<'; pp--)
323 ; // do nothing
324
325 if (pp >= s)
326 {
327 i = parse_fkey(pp);
328 if (i > 0)
329 {
330 mutt_push_macro_event(KEY_F(i), 0);
331 p = pp - 1;
332 continue;
333 }
334
335 l = p - pp + 1;
336 for (i = 0; KeyNames[i].name; i++)
337 {
338 if (mutt_istrn_equal(pp, KeyNames[i].name, l))
339 break;
340 }
341 if (KeyNames[i].name)
342 {
343 /* found a match */
344 mutt_push_macro_event(KeyNames[i].value, 0);
345 p = pp - 1;
346 continue;
347 }
348
349 /* See if it is a valid command
350 * skip the '<' and the '>' when comparing */
351 struct Buffer *buf = buf_pool_get();
352 buf_strcpy_n(buf, pp + 1, l - 2);
353
354 for (enum MenuType j = 0; j < MENU_MAX; j++)
355 {
356 op = km_get_op_menu(j, buf_string(buf));
357 if (op != OP_NULL)
358 break;
359 }
360
361 buf_pool_release(&buf);
362
363 if (op != OP_NULL)
364 {
366 p = pp - 1;
367 continue;
368 }
369 }
370 }
371 mutt_push_macro_event((unsigned char) *p--, 0); /* independent 8 bits chars */
372 }
373}
size_t buf_strcpy_n(struct Buffer *buf, const char *s, size_t len)
Copy a string into a Buffer.
Definition buffer.c:416
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
void mutt_push_macro_event(int ch, int op)
Add the character/operation to the macro buffer.
Definition get.c:146
int parse_fkey(char *str)
Parse a function key string.
Definition keymap.c:266
struct Mapping KeyNames[]
Key name lookup table.
Definition keymap.c:42
int km_get_op_menu(int mtype, const char *func)
Get the OpCode for a Function from a Menu.
Definition menu.c:213
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition string.c:500
bool mutt_istrn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings ignoring case (to a maximum), safely.
Definition string.c:457
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
String manipulation buffer.
Definition buffer.h:36
MenuType
Types of GUI selections.
Definition type.h:33
@ MENU_MAX
Definition type.h:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ km_dokey()

struct KeyEvent km_dokey ( const struct MenuDefinition * md,
GetChFlags flags )

Determine what a keypress should do.

Parameters
mdMenu Definition
flagsFlags, e.g. GETCH_IGNORE_MACRO
Return values
ptrEvent

Definition at line 434 of file get.c.

435{
436 struct KeyEvent event = { 0, OP_NULL };
437 int pos = 0;
438 keycode_t keys[MAX_SEQ] = { 0 };
439
440 if (!md)
441 return event;
442
443 for (int n = 0; n < MaxKeyLoop; n++)
444 {
445 event = mutt_getch(flags);
446 mutt_debug(LL_DEBUG1, "KEY: \n");
447
448 // abort, timeout, repaint
449 if (event.op < OP_NULL)
450 {
451 mutt_debug(LL_DEBUG1, "KEY: getch() %s\n", opcodes_get_name(event.op));
452 return event;
453 }
454
455 mutt_debug(LL_DEBUG1, "KEY: getch() '%c'\n", isprint(event.ch) ? event.ch : '?');
456
457 keys[pos] = event.ch;
458 struct KeymapMatchArray kma = ARRAY_HEAD_INITIALIZER;
459 KeyGatherFlags kfg = gather_functions(md, keys, pos + 1, &kma);
460
461 mutt_debug(LL_DEBUG1, "KEY: flags = %x\n", kfg);
462
463 if (kfg == KEY_GATHER_NO_MATCH)
464 {
465 mutt_debug(LL_DEBUG1, "KEY: \033[1;31mFAIL1: ('%c', %s)\033[0m\n",
466 isprint(event.ch) ? event.ch : '?', opcodes_get_name(event.op));
467 return event;
468 }
469
470 if ((kfg & KEY_GATHER_MATCH) == KEY_GATHER_MATCH)
471 {
472 struct KeymapMatch *kmatch = NULL;
473
474 ARRAY_FOREACH(kmatch, &kma)
475 {
476 if (kmatch->flags == KEY_GATHER_MATCH)
477 {
478 struct Keymap *map = kmatch->keymap;
479
480 if (map->op != OP_MACRO)
481 {
482 mutt_debug(LL_DEBUG1, "KEY: \033[1;32mSUCCESS: ('%c', %s)\033[0m\n",
483 isprint(event.ch) ? event.ch : '?', opcodes_get_name(map->op));
484 ARRAY_FREE(&kma);
485 return (struct KeyEvent) { event.ch, map->op };
486 }
487
488 /* #GETCH_IGNORE_MACRO turns off processing the MacroEvents buffer
489 * in mutt_getch(). Generating new macro events during that time would
490 * result in undesired behavior once the option is turned off.
491 *
492 * Originally this returned -1, however that results in an unbuffered
493 * username or password prompt being aborted. Returning OP_NULL allows
494 * mw_get_field() to display the keybinding pressed instead.
495 *
496 * It may be unexpected for a macro's keybinding to be returned,
497 * but less so than aborting the prompt. */
498 if (flags & GETCH_IGNORE_MACRO)
499 {
500 ARRAY_FREE(&kma);
501 return (struct KeyEvent) { event.ch, OP_NULL };
502 }
503
505 pos = 0;
506 ARRAY_FREE(&kma);
507 break;
508 }
509 }
510 }
511 else
512 {
513 mutt_debug(LL_DEBUG1, "KEY: \033[1;33mLONGER: getch() '%c'\033[0m\n",
514 isprint(event.ch) ? event.ch : '?');
515 pos++;
516 }
517
518 ARRAY_FREE(&kma);
519 }
520
522 mutt_error(_("Macro loop detected"));
523 return (struct KeyEvent) { '\0', OP_ABORT };
524}
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition array.h:58
KeyGatherFlags gather_functions(const struct MenuDefinition *md, const keycode_t *keys, int key_len, struct KeymapMatchArray *kma)
Find functions whose keybindings match.
Definition get.c:383
void generic_tokenize_push_string(char *s)
Parse and queue a 'push' command.
Definition get.c:309
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition get.c:65
static const int MaxKeyLoop
XXX.
Definition get.c:49
struct KeyEvent mutt_getch(GetChFlags flags)
Read a character from the input buffer.
Definition get.c:201
#define GETCH_IGNORE_MACRO
Don't use MacroEvents.
Definition get.h:35
#define mutt_error(...)
Definition logging2.h:94
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
short keycode_t
Type for key storage, the rest of neomutt works fine with int type.
Definition keymap.h:31
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
#define MAX_SEQ
Maximum length of a key binding sequence used for buffer in km_bind.
Definition menu.h:32
#define _(a)
Definition message.h:28
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition opcodes.c:48
#define OP_ABORT
$abort_key pressed (Ctrl-G)
Definition opcodes.h:36
struct Keymap * keymap
Keymap defining bind or `macro.
Definition get.h:68
char * macro
Macro expansion (op == OP_MACRO)
Definition keymap.h:44
short op
Operation to perform.
Definition keymap.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ km_error_key()

void km_error_key ( const struct MenuDefinition * md)

Handle an unbound key sequence.

Parameters
mdMenu Definition

Definition at line 285 of file get.c.

286{
287 if (!md)
288 return;
289
290 struct Keymap *key = km_find_func(md, OP_HELP);
291 if (!key)
292 {
293 mutt_error(_("Key is not bound"));
294 return;
295 }
296
297 struct Buffer *buf = buf_pool_get();
298 keymap_expand_key(key, buf);
299 mutt_error(_("Key is not bound. Press '%s' for help."), buf_string(buf));
300 buf_pool_release(&buf);
301}
bool keymap_expand_key(struct Keymap *km, struct Buffer *buf)
Get the key string bound to a Keymap.
Definition keymap.c:229
struct Keymap * km_find_func(const struct MenuDefinition *md, int func)
Find a function's mapping in a Menu.
Definition menu.c:157
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_flushinp()

void mutt_flushinp ( void )

Empty all the keyboard buffers.

Definition at line 65 of file get.c.

66{
69 flushinp();
70}
#define ARRAY_SIZE(head)
The number of elements stored.
Definition array.h:87
struct KeyEventArray MacroEvents
These are used for macros and exec/push commands.
Definition get.c:56
struct KeyEventArray UngetKeyEvents
These are used in all other "normal" situations, and are not ignored when passing GETCH_IGNORE_MACRO.
Definition get.c:60
+ Here is the caller graph for this function:

◆ mutt_flush_macro_to_endcond()

void mutt_flush_macro_to_endcond ( void )

Drop a macro from the input buffer.

All the macro text is deleted until an OP_END_COND command, or the buffer is empty.

Definition at line 157 of file get.c.

158{
160}
void array_to_endcond(struct KeyEventArray *a)
Clear the array until an OP_END_COND.
Definition get.c:105
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_getch()

struct KeyEvent mutt_getch ( GetChFlags flags)

Read a character from the input buffer.

Parameters
flagsFlags, e.g. GETCH_IGNORE_MACRO
Return values
objKeyEvent to process

The priority for reading events is:

  1. UngetKeyEvents buffer
  2. MacroEvents buffer
  3. Keyboard

This function can return:

  • Abort { 0, OP_ABORT }
  • Repaint { 0, OP_REPAINT }
  • Timeout { 0, OP_TIMEOUT }

Definition at line 201 of file get.c.

202{
203 static const struct KeyEvent event_abort = { 0, OP_ABORT };
204 static const struct KeyEvent event_repaint = { 0, OP_REPAINT };
205 static const struct KeyEvent event_timeout = { 0, OP_TIMEOUT };
206
207 if (!OptGui)
208 return event_abort;
209
210 struct KeyEvent *event_key = array_pop(&UngetKeyEvents);
211 if (event_key)
212 return *event_key;
213
214 if (!(flags & GETCH_IGNORE_MACRO))
215 {
216 event_key = array_pop(&MacroEvents);
217 if (event_key)
218 return *event_key;
219 }
220
221 int ch;
222 SigInt = false;
224 timeout(1000); // 1 second
225#ifdef USE_INOTIFY
227#else
228 ch = getch();
229#endif
231
232 if (SigInt)
233 {
235 return event_abort;
236 }
237
238 if (ch == KEY_RESIZE)
239 {
240 timeout(0);
241 while ((ch = getch()) == KEY_RESIZE)
242 {
243 // do nothing
244 }
245 }
246
247 if (ch == ERR)
248 {
249 if (!isatty(STDIN_FILENO)) // terminal was lost
250 mutt_exit(1);
251
252 if (SigWinch)
253 {
254 SigWinch = false;
256 return event_repaint;
257 }
258
260 return event_timeout;
261 }
262
263 if (ch == AbortKey)
264 return event_abort;
265
266 if (ch & 0x80)
267 {
268 const bool c_meta_key = cs_subset_bool(NeoMutt->sub, "meta_key");
269 if (c_meta_key)
270 {
271 /* send ALT-x as ESC-x */
272 ch &= ~0x80;
274 return (struct KeyEvent) { '\033', OP_NULL }; // Escape
275 }
276 }
277
278 return (struct KeyEvent) { ch, OP_NULL };
279}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
void mutt_query_exit(void)
Ask the user if they want to leave NeoMutt.
Definition curs_lib.c:137
void mutt_exit(int code)
Leave NeoMutt NOW.
Definition exit.c:41
int mutt_monitor_getch(void)
Get a character and poll the filesystem monitor.
Definition get.c:168
void mutt_unget_ch(int ch)
Return a keystroke to the input buffer.
Definition get.c:122
bool OptGui
(pseudo) when the gui (and curses) are started
Definition globals.c:48
keycode_t AbortKey
code of key to abort prompts, normally Ctrl-G
Definition init.c:47
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition notify.c:173
@ NT_TIMEOUT
Timeout has occurred.
Definition notify_type.h:56
@ NT_RESIZE
Window has been resized.
Definition notify_type.h:52
#define OP_TIMEOUT
1 second with no events
Definition opcodes.h:35
#define OP_REPAINT
Repaint is needed.
Definition opcodes.h:34
volatile sig_atomic_t SigWinch
true after SIGWINCH is received
Definition signal.c:69
volatile sig_atomic_t SigInt
true after SIGINT is received
Definition signal.c:68
void mutt_sig_allow_interrupt(bool allow)
Allow/disallow Ctrl-C (SIGINT)
Definition signal.c:315
Container for Accounts, Notifications.
Definition neomutt.h:41
struct Notify * notify_timeout
Timeout notifications handler.
Definition neomutt.h:47
struct Notify * notify_resize
Window resize notifications handler.
Definition neomutt.h:46
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_monitor_getch()

int mutt_monitor_getch ( void )

Get a character and poll the filesystem monitor.

Return values
numCharacter pressed
ERRTimeout

Definition at line 168 of file get.c.

169{
170 /* ncurses has its own internal buffer, so before we perform a poll,
171 * we need to make sure there isn't a character waiting */
172 timeout(0);
173 int ch = getch();
174 timeout(1000); // 1 second
175 if (ch == ERR)
176 {
177 if (mutt_monitor_poll() != 0)
178 ch = ERR;
179 else
180 ch = getch();
181 }
182 return ch;
183}
int mutt_monitor_poll(void)
Check for filesystem changes.
Definition monitor.c:401
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_push_macro_event()

void mutt_push_macro_event ( int ch,
int op )

Add the character/operation to the macro buffer.

Parameters
chCharacter to add
opOperation to add

Adds the ch/op to the macro buffer. This should be used for macros, push, and exec commands only.

Definition at line 146 of file get.c.

147{
148 array_add(&MacroEvents, ch, op);
149}
void array_add(struct KeyEventArray *a, int ch, int op)
Add an event to the end of the array.
Definition get.c:95
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_unget_ch()

void mutt_unget_ch ( int ch)

Return a keystroke to the input buffer.

Parameters
chKey press

This puts events into the UngetKeyEvents buffer

Definition at line 122 of file get.c.

123{
124 array_add(&UngetKeyEvents, ch, OP_NULL);
125}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_unget_op()

void mutt_unget_op ( int op)

Return an operation to the input buffer.

Parameters
opOperation, e.g. OP_DELETE

This puts events into the UngetKeyEvents buffer

Definition at line 133 of file get.c.

134{
135 array_add(&UngetKeyEvents, 0, op);
136}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ MacroEvents

struct KeyEventArray MacroEvents
extern

These are used for macros and exec/push commands.

They can be temporarily ignored by passing GETCH_IGNORE_MACRO

Definition at line 56 of file get.c.

◆ UngetKeyEvents

struct KeyEventArray UngetKeyEvents
extern

These are used in all other "normal" situations, and are not ignored when passing GETCH_IGNORE_MACRO.

Definition at line 60 of file get.c.