From 2f3a7112eafe7bfa6ddd9c6b8a3e6d11a44ce49d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 28 Nov 2016 13:59:55 +0000 Subject: [PATCH] Add more memory domains to certain data --- src/buffer_manager.hh | 2 +- src/client_manager.hh | 2 +- src/commands.cc | 6 +++++- src/completion.hh | 2 +- src/event_manager.hh | 6 +++--- src/file.cc | 2 +- src/highlighter.hh | 2 +- src/hook_manager.hh | 2 +- src/input_handler.hh | 2 +- src/insert_completer.hh | 2 +- src/json_ui.hh | 2 +- src/memory.hh | 4 ++++ src/remote.hh | 2 +- src/shell_manager.hh | 2 +- src/window.cc | 2 +- src/window.hh | 2 +- 16 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/buffer_manager.hh b/src/buffer_manager.hh index d12c515b..50d75b7d 100644 --- a/src/buffer_manager.hh +++ b/src/buffer_manager.hh @@ -12,7 +12,7 @@ namespace Kakoune class BufferManager : public Singleton { public: - using BufferList = Vector>; + using BufferList = Vector, MemoryDomain::BufferMeta>; using iterator = BufferList::const_iterator; ~BufferManager(); diff --git a/src/client_manager.hh b/src/client_manager.hh index b7a085a2..cb05d83e 100644 --- a/src/client_manager.hh +++ b/src/client_manager.hh @@ -58,7 +58,7 @@ private: ClientList m_clients; ClientList m_client_trash; Vector m_free_windows; - Vector> m_window_trash; + Vector, MemoryDomain::Client> m_window_trash; }; } diff --git a/src/commands.cc b/src/commands.cc index b7f4bd01..32d54996 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -940,7 +940,11 @@ void define_command(const ParametersParser& parser, Context& context, const Shel String output = ShellManager::instance().eval(shell_cmd, context, {}, ShellManager::Flags::WaitForStdout, shell_context).first; - return Completions{ 0_byte, pos_in_token, split(output, '\n', 0) }; + CandidateList candidates; + for (auto& str : split(output, '\n', 0)) + candidates.push_back(std::move(str)); + + return Completions{ 0_byte, pos_in_token, std::move(candidates) }; }; } else if (auto shell_cmd_opt = parser.get_switch("shell-candidates")) diff --git a/src/completion.hh b/src/completion.hh index 6743194e..95dc7deb 100644 --- a/src/completion.hh +++ b/src/completion.hh @@ -15,7 +15,7 @@ namespace Kakoune class Context; -using CandidateList = Vector; +using CandidateList = Vector; struct Completions { diff --git a/src/event_manager.hh b/src/event_manager.hh index 3c1567c9..49edb1af 100644 --- a/src/event_manager.hh +++ b/src/event_manager.hh @@ -82,11 +82,11 @@ public: private: friend class FDWatcher; friend class Timer; - Vector m_fd_watchers; - Vector m_timers; + Vector m_fd_watchers; + Vector m_timers; fd_set m_forced_fd; - TimePoint m_last; + TimePoint m_last; }; using SignalHandler = void(*)(int); diff --git a/src/file.cc b/src/file.cc index 9620467a..92ddcf13 100644 --- a/src/file.cc +++ b/src/file.cc @@ -421,7 +421,7 @@ CandidateList complete_filename(StringView prefix, const Regex& ignored_regex, return candidates(matches, expand ? parsed_dirname : dirname); } -Vector complete_command(StringView prefix, ByteCount cursor_pos) +CandidateList complete_command(StringView prefix, ByteCount cursor_pos) { String real_prefix = parse_filename(prefix.substr(0, cursor_pos)); StringView dirname, fileprefix; diff --git a/src/highlighter.hh b/src/highlighter.hh index 18255b82..2845f9ad 100644 --- a/src/highlighter.hh +++ b/src/highlighter.hh @@ -71,7 +71,7 @@ struct HighlighterFactoryAndDocstring String docstring; }; -struct HighlighterRegistry : IdMap, +struct HighlighterRegistry : IdMap, Singleton {}; diff --git a/src/hook_manager.hh b/src/hook_manager.hh index d6b8d0a8..f5e55739 100644 --- a/src/hook_manager.hh +++ b/src/hook_manager.hh @@ -30,7 +30,7 @@ private: SafePtr m_parent; IdMap, MemoryDomain::Hooks> m_hook; - mutable Vector> m_running_hooks; + mutable Vector, MemoryDomain::Hooks> m_running_hooks; }; } diff --git a/src/input_handler.hh b/src/input_handler.hh index 14e9d048..43fd9ecb 100644 --- a/src/input_handler.hh +++ b/src/input_handler.hh @@ -106,7 +106,7 @@ private: Context m_context; friend class InputMode; - Vector> m_mode_stack; + Vector, MemoryDomain::Client> m_mode_stack; InputMode& current_mode() const { return *m_mode_stack.back(); } diff --git a/src/insert_completer.hh b/src/insert_completer.hh index 064047f8..ac1fa22b 100644 --- a/src/insert_completer.hh +++ b/src/insert_completer.hh @@ -62,7 +62,7 @@ struct InsertCompletion bool operator<(const Candidate& other) const { return completion < other.completion; } }; - using CandidateList = Vector; + using CandidateList = Vector; BufferCoord begin; BufferCoord end; diff --git a/src/json_ui.hh b/src/json_ui.hh index f8b48924..026481dc 100644 --- a/src/json_ui.hh +++ b/src/json_ui.hh @@ -54,7 +54,7 @@ private: InputCallback m_input_callback; FDWatcher m_stdin_watcher; - Vector m_pending_keys; + Vector m_pending_keys; DisplayCoord m_dimensions; String m_requests; }; diff --git a/src/memory.hh b/src/memory.hh index 19fa6a40..4d41c0c0 100644 --- a/src/memory.hh +++ b/src/memory.hh @@ -33,6 +33,8 @@ enum class MemoryDomain Selections, History, Remote, + Events, + Completion, Count }; @@ -61,6 +63,8 @@ inline const char* domain_name(MemoryDomain domain) case MemoryDomain::Selections: return "Selections"; case MemoryDomain::History: return "History"; case MemoryDomain::Remote: return "Remote"; + case MemoryDomain::Events: return "Events"; + case MemoryDomain::Completion: return "Completion"; case MemoryDomain::Count: break; } kak_assert(false); diff --git a/src/remote.hh b/src/remote.hh index 5537e3fd..7e171b17 100644 --- a/src/remote.hh +++ b/src/remote.hh @@ -60,7 +60,7 @@ private: String m_session; std::unique_ptr m_listener; - Vector> m_accepters; + Vector, MemoryDomain::Remote> m_accepters; }; bool check_session(StringView session); diff --git a/src/shell_manager.hh b/src/shell_manager.hh index 0d9a16a1..2f2608ef 100644 --- a/src/shell_manager.hh +++ b/src/shell_manager.hh @@ -44,7 +44,7 @@ public: private: struct EnvVarDesc { String str; bool prefix; EnvVarRetriever func; }; - Vector m_env_vars; + Vector m_env_vars; }; template<> struct WithBitOps : std::true_type {}; diff --git a/src/window.cc b/src/window.cc index 78e75be9..54fffc6a 100644 --- a/src/window.cc +++ b/src/window.cc @@ -76,7 +76,7 @@ void Window::center_column(ColumnCount buffer_column) Window::Setup Window::build_setup(const Context& context) const { - Vector selections; + Vector selections; for (auto& sel : context.selections()) selections.push_back({sel.cursor(), sel.anchor()}); diff --git a/src/window.hh b/src/window.hh index 68ecc636..d4359864 100644 --- a/src/window.hh +++ b/src/window.hh @@ -75,7 +75,7 @@ private: DisplayCoord dimensions; size_t timestamp; size_t main_selection; - Vector selections; + Vector selections; }; Setup build_setup(const Context& context) const; Setup m_last_setup;