aboutsummaryrefslogtreecommitdiffhomepage
path: root/input.cpp
diff options
context:
space:
mode:
authorGravatar Sanne Wouda <sanne.wouda@gmail.com>2015-04-05 20:07:17 +0200
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-04-19 16:56:48 -0700
commit32936b0eb95c9cee54d3887328e4bfd01c961922 (patch)
treedfbaf159a3f6d20acaa4ab9de3515c76feb64ee4 /input.cpp
parent3559f20c8ffca8b036ff4aa6833e9e4c67eea7fc (diff)
Change lookahead_list into a queue
Using builtin `commandline -f`, one would expect to have commands executed in the order that they were given. This motivates the change to a queue. Unfortunately, fish internals still need lookahead_list to act as a stack. Add and rename functions to support both cases and have lookahead_list as a std::deque internally. This code is delicate, and we should probably dog-food this in nightly for a while before the next-minor release. Fixes #1567
Diffstat (limited to 'input.cpp')
-rw-r--r--input.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/input.cpp b/input.cpp
index 9e1560cf..4ddf3569 100644
--- a/input.cpp
+++ b/input.cpp
@@ -583,7 +583,7 @@ static void input_mapping_execute(const input_mapping_t &m, bool allow_commands)
wchar_t code = input_function_get_code(command);
if (code != (wchar_t)-1)
{
- input_unreadch(code);
+ input_common_next_ch(code);
}
else if (allow_commands)
{
@@ -596,16 +596,16 @@ static void input_mapping_execute(const input_mapping_t &m, bool allow_commands)
proc_set_last_status(last_status);
- input_unreadch(R_NULL);
+ input_common_next_ch(R_NULL);
}
else
{
/* We don't want to run commands yet. Put the characters back and return R_NULL */
for (wcstring::const_reverse_iterator it = m.seq.rbegin(), end = m.seq.rend(); it != end; ++it)
{
- input_unreadch(*it);
+ input_common_next_ch(*it);
}
- input_unreadch(R_NULL);
+ input_common_next_ch(R_NULL);
return; /* skip the input_set_bind_mode */
}
}
@@ -648,10 +648,10 @@ static bool input_mapping_is_match(const input_mapping_t &m)
/*
Return the read characters
*/
- input_unreadch(c);
+ input_common_next_ch(c);
for (k=j-1; k>=0; k--)
{
- input_unreadch(m.seq[k]);
+ input_common_next_ch(m.seq[k]);
}
}
@@ -659,9 +659,9 @@ static bool input_mapping_is_match(const input_mapping_t &m)
}
-void input_unreadch(wint_t ch)
+void input_queue_ch(wint_t ch)
{
- input_common_unreadch(ch);
+ input_common_queue_ch(ch);
}
static void input_mapping_execute_matching_or_generic(bool allow_commands)
@@ -679,7 +679,7 @@ static void input_mapping_execute_matching_or_generic(bool allow_commands)
if (m.mode != bind_mode)
{
- //debug(0, L"skipping mapping because mode %ls != %ls\n", m.mode.c_str(), input_get_bind_mode());
+ //debug(0, L"skipping mapping because mode %ls != %ls\n", m.mode.c_str(), input_get_bind_mode().c_str());
continue;
}
@@ -703,7 +703,7 @@ static void input_mapping_execute_matching_or_generic(bool allow_commands)
//debug(0, L"no generic found, ignoring...");
wchar_t c = input_common_readch(0);
if (c == R_EOF)
- input_common_unreadch(c);
+ input_common_next_ch(c);
}
}
@@ -745,7 +745,7 @@ wint_t input_readch(bool allow_commands)
else
{
while ((c = input_common_readch(0)) && c >= R_MIN && c <= R_MAX);
- input_unreadch(c);
+ input_common_next_ch(c);
return input_readch();
}
}
@@ -757,7 +757,7 @@ wint_t input_readch(bool allow_commands)
}
else
{
- input_unreadch(c);
+ input_common_next_ch(c);
input_mapping_execute_matching_or_generic(allow_commands);
// regarding allow_commands, we're in a loop, but if a fish command
// is executed, R_NULL is unread, so the next pass through the loop