aboutsummaryrefslogtreecommitdiffhomepage
path: root/reader.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-01-20 12:38:56 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-01-20 13:05:18 -0800
commit605c306bef3de7c2894130d856c837ca82905549 (patch)
treeca1d5c052926e0a181543c2326c8db6e6dbab64a /reader.cpp
parent998ce1fe89800994fb378e5f2c5554dcab6782fb (diff)
Correctly clear pager contents on ctrl-C
Diffstat (limited to 'reader.cpp')
-rw-r--r--reader.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/reader.cpp b/reader.cpp
index 3df18ca9..14d480a1 100644
--- a/reader.cpp
+++ b/reader.cpp
@@ -362,6 +362,9 @@ public:
}
};
+/* Sets the command line contents, without clearing the pager */
+static void reader_set_buffer_maintaining_pager(const wcstring &b, size_t pos);
+
/**
The current interactive reading context
*/
@@ -1211,7 +1214,7 @@ static void completion_insert(const wchar_t *val, complete_flags_t flags)
{
size_t cursor = data->buff_pos;
wcstring new_command_line = completion_apply_to_command_line(val, flags, data->command_line, &cursor, false /* not append only */);
- reader_set_buffer(new_command_line, cursor);
+ reader_set_buffer_maintaining_pager(new_command_line, cursor);
/* Since we just inserted a completion, don't immediately do a new autosuggestion */
data->suppress_autosuggestion = true;
@@ -1547,7 +1550,7 @@ static void select_completion_in_direction(enum selection_direction_t dir, const
{
size_t cursor_pos = cycle_cursor_pos;
const wcstring new_cmd_line = completion_apply_to_command_line(next_comp->completion, next_comp->flags, cycle_command_line, &cursor_pos, false);
- reader_set_buffer(new_cmd_line, cursor_pos);
+ reader_set_buffer_maintaining_pager(new_cmd_line, cursor_pos);
/* Since we just inserted a completion, don't immediately do a new autosuggestion */
data->suppress_autosuggestion = true;
@@ -2376,11 +2379,9 @@ history_t *reader_get_history(void)
return data ? data->history : NULL;
}
-void reader_set_buffer(const wcstring &b, size_t pos)
+/* Sets the command line contents, without clearing the pager */
+static void reader_set_buffer_maintaining_pager(const wcstring &b, size_t pos)
{
- if (!data)
- return;
-
/* Callers like to pass us pointers into ourselves, so be careful! I don't know if we can use operator= with a pointer to our interior, so use an intermediate. */
size_t command_line_len = b.size();
data->command_line = b;
@@ -2391,15 +2392,26 @@ void reader_set_buffer(const wcstring &b, size_t pos)
pos = command_line_len;
data->buff_pos = pos;
-
+
+ /* Clear history search and pager contents */
data->search_mode = NO_SEARCH;
data->search_buff.clear();
data->history_search.go_to_end();
-
+
reader_super_highlight_me_plenty(data->buff_pos);
reader_repaint_needed();
}
+/* Sets the command line contents, clearing the pager */
+void reader_set_buffer(const wcstring &b, size_t pos)
+{
+ if (!data)
+ return;
+
+ clear_pager();
+ reader_set_buffer_maintaining_pager(b, pos);
+}
+
size_t reader_get_cursor_pos()
{