NeoMutt  2025-12-11-276-g10b23b
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 (enum MenuType mtype, GetChFlags flags)
 Determine what a keypress should do.
 
void km_error_key (enum MenuType mtype)
 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 380 of file get.c.

382{
383 if (!md || !keys || !kma)
384 return 0;
385
386 struct SubMenu **smp = NULL;
388
389 ARRAY_FOREACH(smp, &md->submenus)
390 {
391 struct Keymap *km = NULL;
392
393 STAILQ_FOREACH(km, &(*smp)->keymaps, entries)
394 {
395 bool match = true;
396
397 for (int i = 0; i < key_len; i++)
398 {
399 if (keys[i] != km->keys[i])
400 {
401 match = false;
402 break;
403 }
404 }
405
406 if (match)
407 {
409 if (km->len == key_len)
410 fmatch = KEY_GATHER_MATCH;
411 else
412 fmatch = KEY_GATHER_LONGER;
413
414 flags |= fmatch;
415
416 struct KeymapMatch kmatch = { md->id, fmatch, km };
417 ARRAY_ADD(kma, kmatch);
418 }
419 }
420 }
421
422 return flags;
423}
#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:82
struct SubMenuPArray submenus
Parts making up the Menu.
Definition menu.h:84
Collection of related functions.
Definition menu.h:69
+ 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 306 of file get.c.

307{
308 char *pp = NULL;
309 char *p = s + mutt_str_len(s) - 1;
310 size_t l;
311 int i, op = OP_NULL;
312
313 while (p >= s)
314 {
315 /* if we see something like "<PageUp>", look to see if it is a real
316 * function name and return the corresponding value */
317 if (*p == '>')
318 {
319 for (pp = p - 1; pp >= s && *pp != '<'; pp--)
320 ; // do nothing
321
322 if (pp >= s)
323 {
324 i = parse_fkey(pp);
325 if (i > 0)
326 {
327 mutt_push_macro_event(KEY_F(i), 0);
328 p = pp - 1;
329 continue;
330 }
331
332 l = p - pp + 1;
333 for (i = 0; KeyNames[i].name; i++)
334 {
335 if (mutt_istrn_equal(pp, KeyNames[i].name, l))
336 break;
337 }
338 if (KeyNames[i].name)
339 {
340 /* found a match */
341 mutt_push_macro_event(KeyNames[i].value, 0);
342 p = pp - 1;
343 continue;
344 }
345
346 /* See if it is a valid command
347 * skip the '<' and the '>' when comparing */
348 struct Buffer *buf = buf_pool_get();
349 buf_strcpy_n(buf, pp + 1, l - 2);
350
351 for (enum MenuType j = 0; j < MENU_MAX; j++)
352 {
353 op = km_get_op_menu(j, buf_string(buf));
354 if (op != OP_NULL)
355 break;
356 }
357
358 buf_pool_release(&buf);
359
360 if (op != OP_NULL)
361 {
363 p = pp - 1;
364 continue;
365 }
366 }
367 }
368 mutt_push_macro_event((unsigned char) *p--, 0); /* independent 8 bits chars */
369 }
370}
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:257
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 ( enum MenuType mtype,
GetChFlags flags )

Determine what a keypress should do.

Parameters
mtypeMenu type, e.g. MENU_EDITOR
flagsFlags, e.g. GETCH_IGNORE_MACRO
Return values
ptrEvent

Definition at line 431 of file get.c.

432{
433 struct KeyEvent event = { 0, OP_NULL };
434 int pos = 0;
435 const struct MenuDefinition *md = NULL;
436 keycode_t keys[MAX_SEQ] = { 0 };
437
439 {
440 if (md->id == mtype)
441 break;
442 }
443
444 for (int n = 0; n < MaxKeyLoop; n++)
445 {
446 event = mutt_getch(flags);
447 mutt_debug(LL_DEBUG1, "KEY: \n");
448
449 // abort, timeout, repaint
450 if (event.op < OP_NULL)
451 {
452 mutt_debug(LL_DEBUG1, "KEY: getch() %s\n", opcodes_get_name(event.op));
453 return event;
454 }
455
456 mutt_debug(LL_DEBUG1, "KEY: getch() '%c'\n", isprint(event.ch) ? event.ch : '?');
457
458 keys[pos] = event.ch;
459 struct KeymapMatchArray kma = ARRAY_HEAD_INITIALIZER;
460 KeyGatherFlags kfg = gather_functions(md, keys, pos + 1, &kma);
461
462 mutt_debug(LL_DEBUG1, "KEY: flags = %x\n", kfg);
463
464 if (kfg == KEY_GATHER_NO_MATCH)
465 {
466 mutt_debug(LL_DEBUG1, "KEY: \033[1;31mFAIL1: ('%c', %s)\033[0m\n",
467 isprint(event.ch) ? event.ch : '?', opcodes_get_name(event.op));
468 return event;
469 }
470
471 if ((kfg & KEY_GATHER_MATCH) == KEY_GATHER_MATCH)
472 {
473 struct KeymapMatch *kmatch = NULL;
474
475 ARRAY_FOREACH(kmatch, &kma)
476 {
477 if (kmatch->flags == KEY_GATHER_MATCH)
478 {
479 struct Keymap *map = kmatch->keymap;
480
481 if (map->op != OP_MACRO)
482 {
483 mutt_debug(LL_DEBUG1, "KEY: \033[1;32mSUCCESS: ('%c', %s)\033[0m\n",
484 isprint(event.ch) ? event.ch : '?', opcodes_get_name(map->op));
485 ARRAY_FREE(&kma);
486 return (struct KeyEvent) { event.ch, map->op };
487 }
488
489 /* #GETCH_IGNORE_MACRO turns off processing the MacroEvents buffer
490 * in mutt_getch(). Generating new macro events during that time would
491 * result in undesired behavior once the option is turned off.
492 *
493 * Originally this returned -1, however that results in an unbuffered
494 * username or password prompt being aborted. Returning OP_NULL allows
495 * mw_get_field() to display the keybinding pressed instead.
496 *
497 * It may be unexpected for a macro's keybinding to be returned,
498 * but less so than aborting the prompt. */
499 if (flags & GETCH_IGNORE_MACRO)
500 {
501 ARRAY_FREE(&kma);
502 return (struct KeyEvent) { event.ch, OP_NULL };
503 }
504
506 pos = 0;
507 ARRAY_FREE(&kma);
508 break;
509 }
510 }
511 }
512 else
513 {
514 mutt_debug(LL_DEBUG1, "KEY: \033[1;33mLONGER: getch() '%c'\033[0m\n",
515 isprint(event.ch) ? event.ch : '?');
516 pos++;
517 }
518
519 ARRAY_FREE(&kma);
520 }
521
523 mutt_error(_("Macro loop detected"));
524 return (struct KeyEvent) { '\0', OP_ABORT };
525}
#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:380
void generic_tokenize_push_string(char *s)
Parse and queue a 'push' command.
Definition get.c:306
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
struct MenuDefinitionArray MenuDefs
All the registered Menus.
Definition init.c:42
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:33
#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
Functions for a Dialog or Window.
Definition menu.h:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ km_error_key()

void km_error_key ( enum MenuType mtype)

Handle an unbound key sequence.

Parameters
mtypeMenu type, e.g. MENU_PAGER

Definition at line 285 of file get.c.

286{
287 struct Keymap *key = km_find_func(mtype, OP_HELP);
288 if (!key)
289 {
290 mutt_error(_("Key is not bound"));
291 return;
292 }
293
294 struct Buffer *buf = buf_pool_get();
295 keymap_expand_key(key, buf);
296 mutt_error(_("Key is not bound. Press '%s' for help."), buf_string(buf));
297 buf_pool_release(&buf);
298}
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(enum MenuType mtype, int func)
Find a function's mapping in a Menu.
Definition menu.c:164
+ 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.