From ffff4711c51c1a7aacdd40ab10be03fdcf627455 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 28 Jan 2015 22:33:29 +0000 Subject: Add history memory domain --- src/input_handler.cc | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/input_handler.cc') diff --git a/src/input_handler.cc b/src/input_handler.cc index afc6aecf..354fa973 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -476,18 +476,6 @@ String common_prefix(ArrayView strings) return res; } -void history_push(Vector& history, StringView entry) -{ - if(entry.empty()) - { - return; - } - Vector::iterator it; - while ((it = find(history, entry)) != history.end()) - history.erase(it); - history.push_back(entry); -} - class Prompt : public InputMode { public: @@ -507,7 +495,7 @@ public: void on_key(Key key) override { - Vector& history = ms_history[m_prompt]; + History& history = ms_history[m_prompt]; const String& line = m_line_editor.line(); bool showcompl = false; @@ -739,10 +727,23 @@ private: bool m_autoshowcompl; Mode m_mode = Mode::Default; - static UnorderedMap> ms_history; - Vector::iterator m_history_it; + using History = Vector; + static UnorderedMap ms_history; + History::iterator m_history_it; + + static void history_push(History& history, StringView entry) + { + if(entry.empty()) + { + return; + } + History::iterator it; + while ((it = find(history, entry)) != history.end()) + history.erase(it); + history.push_back(entry); + } }; -UnorderedMap> Prompt::ms_history; +UnorderedMap Prompt::ms_history; class NextKey : public InputMode { -- cgit v1.2.3