62 int repeat = (count > 0) ? count : 1;
65 if ((c_macro_repeat_max > 0) && (repeat > c_macro_repeat_max))
66 repeat = c_macro_repeat_max;
68 for (
int i = 0; i < repeat; i++)
89 if ((unget_count + macro_count) > 0)
92 unget_count + macro_count, unget_count, macro_count);
261 if (
ch == KEY_RESIZE)
264 while ((
ch = getch()) == KEY_RESIZE)
272 if (!isatty(STDIN_FILENO))
279 return event_repaint;
283 return event_timeout;
297 return (
struct KeyEvent) {
'\033', OP_NULL, 0 };
366 for (pp = p - 1; pp >= s && *pp !=
'<'; pp--)
428 int key_len,
struct KeymapMatchArray *kma)
430 if (!md || !keys || !kma)
442 if (key_len > km->
len)
447 for (
int i = 0; i < key_len; i++)
459 if (km->
len == key_len)
504 for (
int i = 0; i < ev_k.
key_len; i++)
520 struct KeyEvent event = { 0, OP_NULL, 0 };
523 int count_digits = 0;
525 struct Keymap *pending_exact = NULL;
526 bool feedback_active =
false;
537 const int timeout_ms = (state ==
DKS_START) ? c_key_timeout_idle : c_key_timeout_progress;
541 if (event.
op < OP_NULL)
547 if (pending_exact->
op != OP_MACRO)
551 return (
struct KeyEvent) { 0, pending_exact->
op, count };
557 return (
struct KeyEvent) { 0, OP_NULL, 0 };
565 pending_exact = NULL;
567 feedback_active =
false;
573 if (feedback_active || (state !=
DKS_START))
582 if (event.
op > OP_NULL)
584 if (feedback_active || (state !=
DKS_START))
591 if ((event.
count == 0) && (count_digits > 0))
600 (event.
ch >=
'0') && (event.
ch <=
'9'))
614 return (
struct KeyEvent) {
event.ch, OP_NULL, 0 };
617 const int digit =
event.ch -
'0';
618 if ((count > (INT_MAX / 10)) ||
619 ((count == (INT_MAX / 10)) && (
digit > (INT_MAX % 10))))
623 return (
struct KeyEvent) {
event.ch, OP_NULL, 0 };
626 count = (count * 10) +
digit;
629 feedback_active =
true;
639 return (
struct KeyEvent) {
event.ch, OP_NULL, 0 };
642 keys[key_len] =
event.ch;
650 bool has_exact =
false;
651 bool has_longer =
false;
652 pending_exact = NULL;
661 pending_exact = kmatch->
keymap;
669 if (!has_exact && !has_longer)
679 if (has_exact && has_longer)
682 feedback_active =
true;
688 if (!has_exact && has_longer)
691 feedback_active =
true;
697 if (has_exact && pending_exact)
699 struct Keymap *map = pending_exact;
701 if (map->
op != OP_MACRO)
708 return (
struct KeyEvent) {
event.ch, map->
op, count_digits > 0 ? count : 0 };
725 return (
struct KeyEvent) {
event.ch, OP_NULL, 0 };
733 pending_exact = NULL;
735 feedback_active =
false;
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
#define ARRAY_LAST(head)
Convenience method to get the last element.
#define ARRAY_EMPTY(head)
Check if an array is empty.
#define ARRAY_SIZE(head)
The number of elements stored.
#define ARRAY_FREE(head)
Release all memory.
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
#define ARRAY_SHRINK(head, n)
Mark a number of slots at the end of the array as unused.
size_t buf_strcpy_n(struct Buffer *buf, const char *s, size_t len)
Copy a string into a Buffer.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
void mutt_query_exit(void)
Ask the user if they want to leave NeoMutt.
void mutt_exit(int code)
Leave NeoMutt NOW.
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.
void mutt_push_macro_repeated(char *macro, int count)
Push a macro string into the input queue, optionally repeated.
void mutt_flushinp(void)
MacroEvents moved to KeyModuleData UngetKeyEvents moved to KeyModuleData.
static struct KeyEvent mutt_getch_timeout(GetChFlags flags, int timeout_ms)
Read a character from the input buffer with timeout.
static const int MaxKeyLoop
XXX.
void array_add(struct KeyEventArray *a, int ch, int op)
Add an event to the end of the array.
void array_to_endcond(struct KeyEventArray *a)
Clear the array until an OP_END_COND.
DokeyState
Internal state for km_dokey()
@ DKS_START
Initial state, no input received yet.
@ DKS_COUNTER
Reading count prefix digits.
@ DKS_NEED_MORE
Prefix matches an exact and/or longer keybinding.
static void key_progress_notify(const struct MenuDefinition *md, int count, const keycode_t *keys, int key_len, GetChFlags flags)
Send key matching progress notification.
void mutt_push_macro_event(int ch, int op)
Add the character/operation to the macro buffer.
struct KeyEvent mutt_getch(GetChFlags flags)
Read a character from the input buffer.
struct KeyEvent km_dokey(const struct MenuDefinition *md, GetChFlags flags)
Determine what a keypress should do.
void mutt_unget_op(int op)
Return an operation to the input buffer.
void km_error_key(const struct MenuDefinition *md)
Handle an unbound key sequence.
static int mutt_monitor_getch_timeout(int timeout_ms)
Get a character and poll the filesystem monitor.
void mutt_flush_macro_to_endcond(void)
Drop a macro from the input buffer.
struct KeyEvent * array_pop(struct KeyEventArray *a)
Remove an event from the array.
void mutt_unget_ch(int ch)
Return a keystroke to the input buffer.
@ GETCH_IGNORE_MACRO
Don't use MacroEvents.
@ GETCH_NO_FEEDBACK
km_dokey(): suppress key progress notifications
@ GETCH_NO_COUNTER
km_dokey(): disable numeric count prefix parsing
@ KEY_GATHER_NO_MATCH
No bindings match the search string.
@ KEY_GATHER_LONGER
No bindings match, but longer strings might.
@ KEY_GATHER_MATCH
Binding matches the search string.
#define KEY_COUNT_MAX_DIGITS
Maximum number of digits in a key count prefix, e.g. 123j
#define KEY_SEQ_MAX_LEN
Maximum number of keys in a key sequence, e.g. abc
struct KeyEvent * array_pop(struct KeyEventArray *a)
Remove an event from the array.
void mutt_unget_ch(int ch)
Return a keystroke to the input buffer.
bool OptGui
(pseudo) when the gui (and curses) are started
#define mutt_debug(LEVEL,...)
Convenience wrapper for the gui headers.
bool keymap_expand_key(struct Keymap *km, struct Buffer *buf)
Get the key string bound to a Keymap.
int parse_fkey(char *str)
Parse a function key string.
Key binding notifications.
@ NT_KEY_PROGRESS
Key state has changed.
short keycode_t
Type for key storage, the rest of neomutt works fine with int type.
@ LL_DEBUG3
Log at debug level 3.
@ LL_DEBUG1
Log at debug level 1.
#define MIN(a, b)
Return the minimum of two values.
#define MAX(a, b)
Return the maximum of two values.
@ MODULE_ID_KEY
ModuleKey, Key mappings
int mutt_monitor_poll(void)
Check for filesystem changes.
Monitor files for changes.
Convenience wrapper for the library headers.
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
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.
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
@ NT_TIMEOUT
Timeout has occurred.
@ NT_KEY
Runtime key handling changed, NotifyKey, EventKeyProgress.
@ NT_RESIZE
Window has been resized.
const char * opcodes_get_name(int op)
Get the name of an opcode.
#define OP_TIMEOUT
1 second with no events
#define OP_REPAINT
Repaint is needed.
#define OP_ABORT
$abort_key pressed (Ctrl-G)
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
#define STAILQ_FOREACH(var, head, field)
volatile sig_atomic_t SigWinch
true after SIGWINCH is received
volatile sig_atomic_t SigInt
true after SIGINT is received
void mutt_sig_allow_interrupt(bool allow)
Allow/disallow Ctrl-C (SIGINT)
String manipulation buffer.
Runtime key progress event.
short key_len
Number of keys entered.
keycode_t keys[KEY_SEQ_MAX_LEN]
Entered keys.
const struct MenuDefinition * md
Menu being matched.
int count
Parsed count prefix, if any.
An event such as a keypress.
int count
Optional count prefix, e.g. 3 for 3j
int op
Function opcode, e.g. OP_HELP.
struct KeyEventArray macro_events
Macro event buffer.
keycode_t abort_key
Key to abort prompts, normally Ctrl-G.
struct Mapping * key_names
Key name lookup table.
struct KeyEventArray unget_key_events
Unget key event buffer.
Result of Matching Keybinding.
KeyGatherFlags flags
Flags, e.g. KEY_GATHER_MATCH.
struct Keymap * keymap
Keymap defining bind or `macro.
keycode_t * keys
Key sequence.
char * macro
Macro expansion (op == OP_MACRO)
short len
Length of key sequence (unit: sizeof (keycode_t))
short op
Operation to perform.
const char * name
String value.
Container for Accounts, Notifications.
struct Notify * notify_timeout
Timeout notifications handler.
struct Notify * notify_resize
Window resize notifications handler.
struct Notify * notify
Notifications handler.
struct ConfigSubset * sub
Inherited config items.
MenuType
Types of GUI selections.