Add history memory domain
This commit is contained in:
parent
bb74770a24
commit
ffff4711c5
|
@ -476,18 +476,6 @@ String common_prefix(ArrayView<String> strings)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void history_push(Vector<String>& history, StringView entry)
|
|
||||||
{
|
|
||||||
if(entry.empty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Vector<String>::iterator it;
|
|
||||||
while ((it = find(history, entry)) != history.end())
|
|
||||||
history.erase(it);
|
|
||||||
history.push_back(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
class Prompt : public InputMode
|
class Prompt : public InputMode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -507,7 +495,7 @@ public:
|
||||||
|
|
||||||
void on_key(Key key) override
|
void on_key(Key key) override
|
||||||
{
|
{
|
||||||
Vector<String>& history = ms_history[m_prompt];
|
History& history = ms_history[m_prompt];
|
||||||
const String& line = m_line_editor.line();
|
const String& line = m_line_editor.line();
|
||||||
bool showcompl = false;
|
bool showcompl = false;
|
||||||
|
|
||||||
|
@ -739,10 +727,23 @@ private:
|
||||||
bool m_autoshowcompl;
|
bool m_autoshowcompl;
|
||||||
Mode m_mode = Mode::Default;
|
Mode m_mode = Mode::Default;
|
||||||
|
|
||||||
static UnorderedMap<String, Vector<String>> ms_history;
|
using History = Vector<String, MemoryDomain::History>;
|
||||||
Vector<String>::iterator m_history_it;
|
static UnorderedMap<String, History, MemoryDomain::History> 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<String, Vector<String>> Prompt::ms_history;
|
UnorderedMap<String, Prompt::History, MemoryDomain::History> Prompt::ms_history;
|
||||||
|
|
||||||
class NextKey : public InputMode
|
class NextKey : public InputMode
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,7 @@ enum class MemoryDomain
|
||||||
Client,
|
Client,
|
||||||
WordDB,
|
WordDB,
|
||||||
Selections,
|
Selections,
|
||||||
|
History,
|
||||||
Count
|
Count
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,6 +58,7 @@ inline const char* domain_name(MemoryDomain domain)
|
||||||
case MemoryDomain::Registers: return "Registers";
|
case MemoryDomain::Registers: return "Registers";
|
||||||
case MemoryDomain::Client: return "Client";
|
case MemoryDomain::Client: return "Client";
|
||||||
case MemoryDomain::Selections: return "Selections";
|
case MemoryDomain::Selections: return "Selections";
|
||||||
|
case MemoryDomain::History: return "History";
|
||||||
case MemoryDomain::Count: break;
|
case MemoryDomain::Count: break;
|
||||||
}
|
}
|
||||||
kak_assert(false);
|
kak_assert(false);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user