2
* Copyright 2009 Alexandros Frantzis
4
* This file is part of bless.
6
* bless is free software: you can redistribute it and/or modify it under the
7
* terms of the GNU Lesser General Public License as published by the Free
8
* Software Foundation, either version 3 of the License, or (at your option)
11
* bless is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16
* You should have received a copy of the GNU General Public License along with
17
* bless. If not, see <http://www.gnu.org/licenses/>.
25
#ifndef _BLESS_APP_INPUT_H
26
#define _BLESS_APP_INPUT_H
32
#include <bless-ui/pos.h>
33
#include "app_action.h"
36
* @defgroup app_input Input handling
42
* Input handler modes.
45
BLESS_APP_INPUT_MODE_NORMAL = 0,
46
BLESS_APP_INPUT_MODE_INSERT
50
* Domains in which to apply keymaps in the input handler.
53
BLESS_APP_INPUT_DOMAIN_NORMAL = 0,
54
BLESS_APP_INPUT_DOMAIN_INSERT,
55
BLESS_APP_INPUT_DOMAIN_OBJECT
59
* Argument types for input handler actions
62
BLESS_APP_INPUT_ARG_TYPE_INFO = 1,
63
BLESS_APP_INPUT_ARG_TYPE_OBJECT,
64
BLESS_APP_INPUT_ARG_TYPE_STRING
68
* The result of key processing.
71
BLESS_APP_INPUT_RESULT_HANDLED = 0,
72
BLESS_APP_INPUT_RESULT_NOT_HANDLED,
73
BLESS_APP_INPUT_RESULT_PENDING,
74
BLESS_APP_INPUT_RESULT_FAILED
78
* Flags indicating whether an action can be used as a regular action,
79
* a data object or both.
82
BLESS_APP_INPUT_ACTION_FLAG_ACTION = 1,
83
BLESS_APP_INPUT_ACTION_FLAG_OBJECT = 2
86
typedef struct bless_app_input bless_app_input_t;
89
* Data associated with key processing result.
91
struct bless_app_input_result {
92
/** The actual result (BLESS_APP_INPUT_RESULT_*) */
94
/** Pointer the key sequence */
96
/** Pointer the next key to process */
101
* Structure used to pass information to set a keymap.
103
struct bless_app_input_keymap {
104
/** The BLESS_APP_INPUT_DOMAIN_* for which this keymap will apply */
106
/** Whether the mapping may be remapped */
108
/** The key sequence to map */
110
/** The key sequence to map to */
116
* Structure used to pass information to register an action.
118
struct bless_app_input_action {
119
/** The key sequence associated with the action */
122
struct bless_app_action *action;
123
/** User data associated with the action */
125
/** Action usage flags (BLESS_APP_INPUT_ACTION_FLAG_*) */
130
* A data object argument to an input action.
132
struct bless_app_input_arg_data_object {
133
/** The start of the data object */
134
struct bless_pos start;
135
/** The end of the data object */
136
struct bless_pos end;
140
* An info argument to an input action.
142
struct bless_app_input_arg_info {
143
/** The purpose of the action invocation (BLESS_APP_INPUT_ACTION_FLAG_*) */
145
/** The count associated with the action invocation */
149
int bless_app_input_new(bless_app_input_t **input);
150
int bless_app_input_free(bless_app_input_t *input);
152
int bless_app_input_register_action(bless_app_input_t *input,
153
struct bless_app_input_action *action);
155
int bless_app_input_set_keymap(bless_app_input_t *input,
156
struct bless_app_input_keymap *keymap);
158
int bless_app_input_set_mode(bless_app_input_t *input, int mode);
159
int bless_app_input_get_mode(bless_app_input_t *input, int *mode);
161
int bless_app_input_append_keys(bless_app_input_t *input, char *keys);
163
int bless_app_input_inject_keys(bless_app_input_t *input, char *keys);
165
int bless_app_input_process_keys(bless_app_input_t *input,
166
struct bless_app_input_result *result);
168
int bless_app_input_reset(bless_app_input_t *input);
169
int bless_app_input_skip_keys(bless_app_input_t *input, size_t nskip);