Get a key from the user. More...
#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "globals.h"
#include "monitor.h"
Go to the source code of this file.
Functions | |
void | mutt_flushinp (void) |
Empty all the keyboard buffers. | |
static struct KeyEvent * | array_pop (struct KeyEventArray *a) |
Remove an event from the array. | |
static void | array_add (struct KeyEventArray *a, int ch, int op) |
Add an event to the end of the array. | |
static void | array_to_endcond (struct KeyEventArray *a) |
Clear the array until an OP_END_COND. | |
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. | |
void | mutt_unget_string (const char *s) |
Return a string to the input buffer. | |
void | mutt_push_macro_event (int ch, int op) |
Add the character/operation to the macro buffer. | |
void | mutt_flush_macro_to_endcond (void) |
Drop a macro from the input buffer. | |
static int | mutt_monitor_getch (void) |
Get a character and poll the filesystem monitor. | |
struct KeyEvent | mutt_getch (GetChFlags flags) |
Read a character from the input buffer. | |
void | km_error_key (enum MenuType mtype) |
Handle an unbound key sequence. | |
static struct KeyEvent | retry_generic (enum MenuType mtype, keycode_t *keys, int keyslen, int lastkey, GetChFlags flags) |
Try to find the key in the generic menu bindings. | |
struct KeyEvent | km_dokey_event (enum MenuType mtype, GetChFlags flags) |
Determine what a keypress should do. | |
int | km_dokey (enum MenuType mtype, GetChFlags flags) |
Determine what a keypress should do. | |
Variables | |
struct KeyEventArray | MacroEvents = ARRAY_HEAD_INITIALIZER |
These are used for macros and exec/push commands. | |
static struct KeyEventArray | UngetKeyEvents = ARRAY_HEAD_INITIALIZER |
These are used in all other "normal" situations, and are not ignored when passing GETCH_IGNORE_MACRO. | |
Get a key from the user.
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.c.
void mutt_flushinp | ( | void | ) |
Empty all the keyboard buffers.
Definition at line 58 of file get.c.
|
static |
Remove an event from the array.
a | Array |
ptr | Event |
Definition at line 70 of file get.c.
|
static |
Add an event to the end of the array.
a | Array |
ch | Character |
op | Operation, e.g. OP_DELETE |
Definition at line 88 of file get.c.
|
static |
void mutt_unget_ch | ( | int | ch | ) |
void mutt_unget_op | ( | int | op | ) |
void mutt_unget_string | ( | const char * | s | ) |
Return a string to the input buffer.
s | String to return |
This puts events into the UngetKeyEvents
buffer
Definition at line 137 of file get.c.
void mutt_push_macro_event | ( | int | ch, |
int | op | ||
) |
Add the character/operation to the macro buffer.
ch | Character to add |
op | Operation to add |
Adds the ch/op to the macro buffer. This should be used for macros, push, and exec commands only.
Definition at line 155 of file get.c.
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 166 of file get.c.
|
static |
Get a character and poll the filesystem monitor.
num | Character pressed |
ERR | Timeout |
Definition at line 177 of file get.c.
struct KeyEvent mutt_getch | ( | GetChFlags | flags | ) |
Read a character from the input buffer.
flags | Flags, e.g. GETCH_IGNORE_MACRO |
obj | KeyEvent to process |
The priority for reading events is:
This function can return:
{ 0, OP_ABORT }
{ 0, OP_REPAINT }
{ 0, OP_TIMEOUT }
Definition at line 210 of file get.c.
void km_error_key | ( | enum MenuType | mtype | ) |
Handle an unbound key sequence.
mtype | Menu type, e.g. MENU_PAGER |
Definition at line 294 of file get.c.
|
static |
Try to find the key in the generic menu bindings.
mtype | Menu type, e.g. MENU_PAGER |
keys | Array of keys to return to the input queue |
keyslen | Number of keys in the array |
lastkey | Last key pressed (to return to input queue) |
flags | Flags, e.g. GETCH_IGNORE_MACRO |
num | Operation, e.g. OP_DELETE |
Definition at line 319 of file get.c.
struct KeyEvent km_dokey_event | ( | enum MenuType | mtype, |
GetChFlags | flags | ||
) |
Determine what a keypress should do.
mtype | Menu type, e.g. MENU_EDITOR |
flags | Flags, e.g. GETCH_IGNORE_MACRO |
ptr | Event |
Definition at line 346 of file get.c.
int km_dokey | ( | enum MenuType | mtype, |
GetChFlags | flags | ||
) |
Determine what a keypress should do.
mtype | Menu type, e.g. MENU_EDITOR |
flags | Flags, e.g. GETCH_IGNORE_MACRO |
>0 | Function to execute |
OP_NULL | No function bound to key sequence |
-1 | Error occurred while reading input |
-2 | A timeout or sigwinch occurred |
Definition at line 464 of file get.c.
struct KeyEventArray MacroEvents = ARRAY_HEAD_INITIALIZER |
These are used for macros and exec/push commands.
They can be temporarily ignored by passing GETCH_IGNORE_MACRO
|
static |
These are used in all other "normal" situations, and are not ignored when passing GETCH_IGNORE_MACRO.