aboutsummaryrefslogtreecommitdiffhomepage
path: root/input.cpp
diff options
context:
space:
mode:
authorGravatar Julian Aron Prenner <julian@linux4you.it>2014-01-23 10:23:04 +0100
committerGravatar Julian Aron Prenner <julian@linux4you.it>2014-01-23 10:23:04 +0100
commit844b01cb6be2ab3a3f7070112c94604b43710835 (patch)
tree0edb77427d3d7a49f2f8cdecc67f2f6da160611d /input.cpp
parent45465e0c450eb2e73ef43a553fe3bb0f72b53a7b (diff)
Add 'and' input function; fixes a bug with t,T
'and' will prevent later input functions from being executed if the previous one did not succeed (e.g. a jump to a char not on the command line)
Diffstat (limited to 'input.cpp')
-rw-r--r--input.cpp35
1 files changed, 31 insertions, 4 deletions
diff --git a/input.cpp b/input.cpp
index 576d7d56..d6b7edad 100644
--- a/input.cpp
+++ b/input.cpp
@@ -141,7 +141,8 @@ static const wchar_t * const name_arr[] =
L"end-selection",
L"kill-selection",
L"forward-jump",
- L"backward-jump"
+ L"backward-jump",
+ L"and"
}
;
@@ -236,7 +237,8 @@ static const wchar_t code_arr[] =
R_END_SELECTION,
R_KILL_SELECTION,
R_FORWARD_JUMP,
- R_BACKWARD_JUMP
+ R_BACKWARD_JUMP,
+ R_AND
}
;
@@ -266,6 +268,7 @@ static bool is_init = false;
static void input_terminfo_init();
wchar_t input_function_args[MAX_INPUT_FUNCTION_ARGS];
+bool input_function_status;
int input_function_args_index = 0;
/**
@@ -308,6 +311,14 @@ int input_function_arity(int function)
}
}
+/**
+ Sets the return status of the most recently executed input function
+*/
+void input_function_set_status(bool status)
+{
+ input_function_status = status;
+}
+
/**
Returns the nth argument for a given input function
*/
@@ -511,6 +522,9 @@ void input_function_push_args(int code)
*/
static void input_mapping_execute(const input_mapping_t &m)
{
+ /* By default input functions always succeed */
+ input_function_status = true;
+
for(int i = m.commands.size() - 1; i >= 0; i--)
{
wcstring command = m.commands.at(i);
@@ -647,12 +661,12 @@ wint_t input_readch()
/*
Clear the interrupted flag
- */
+ */
reader_reset_interrupted();
/*
Search for sequence in mapping tables
- */
+ */
while (1)
{
@@ -670,6 +684,19 @@ wint_t input_readch()
{
return input_common_readch(0);
}
+ case R_AND:
+ {
+ if(input_function_status)
+ {
+ return input_readch();
+ }
+ else
+ {
+ while((c = input_common_readch(0)) && c >= R_MIN && c <= R_MAX);
+ input_unreadch(c);
+ return input_readch();
+ }
+ }
default:
{
return c;