From 3a817e2f96a30faef03565c510f626ac73fd46ed Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 12 Nov 2014 21:27:07 +0000 Subject: [PATCH] Cleanup includes --- src/alias_registry.hh | 1 - src/buffer.hh | 3 --- src/client.hh | 2 +- src/color.cc | 2 ++ src/color.hh | 2 -- src/debug.cc | 1 + src/debug.hh | 4 ++-- src/display_buffer.cc | 38 ++++++++++++++++++++++++++++++++++++++ src/display_buffer.hh | 41 ++++------------------------------------- src/env_vars.cc | 2 ++ src/env_vars.hh | 4 +--- src/file.cc | 1 + src/file.hh | 4 +++- src/hook_manager.hh | 1 - src/keymap_manager.cc | 2 ++ src/keymap_manager.hh | 3 +++ src/keys.hh | 9 +++++++-- src/ncurses.cc | 1 + src/ncurses.hh | 3 ++- src/option_types.hh | 1 + src/remote.hh | 8 ++++++-- src/shell_manager.hh | 5 ++++- src/string.hh | 2 +- src/user_interface.hh | 7 ++++--- src/value.hh | 2 +- src/window.hh | 3 +-- 26 files changed, 88 insertions(+), 64 deletions(-) diff --git a/src/alias_registry.hh b/src/alias_registry.hh index ae879eef..e2d4e271 100644 --- a/src/alias_registry.hh +++ b/src/alias_registry.hh @@ -1,7 +1,6 @@ #ifndef alias_registry_hh_INCLUDED #define alias_registry_hh_INCLUDED -#include "utils.hh" #include "safe_ptr.hh" #include "string.hh" diff --git a/src/buffer.hh b/src/buffer.hh index 4715ddc1..ebb3eed7 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -9,9 +9,6 @@ #include "value.hh" #include -#include -#include -#include namespace Kakoune { diff --git a/src/client.hh b/src/client.hh index 6da499a3..ebbc96e8 100644 --- a/src/client.hh +++ b/src/client.hh @@ -5,7 +5,6 @@ #include "env_vars.hh" #include "input_handler.hh" #include "safe_ptr.hh" -#include "string.hh" #include "utils.hh" #include "option_manager.hh" @@ -14,6 +13,7 @@ namespace Kakoune class UserInterface; class Window; +class String; class Client : public SafeCountable, public OptionManagerWatcher { diff --git a/src/color.cc b/src/color.cc index d056fb25..8f1b01c1 100644 --- a/src/color.cc +++ b/src/color.cc @@ -3,6 +3,8 @@ #include "exception.hh" #include "regex.hh" +#include + namespace Kakoune { diff --git a/src/color.hh b/src/color.hh index f6b3e842..1de59fcd 100644 --- a/src/color.hh +++ b/src/color.hh @@ -1,8 +1,6 @@ #ifndef color_hh_INCLUDED #define color_hh_INCLUDED -#include - namespace Kakoune { diff --git a/src/debug.cc b/src/debug.cc index 6d865013..c59a9802 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -3,6 +3,7 @@ #include "assert.hh" #include "buffer.hh" #include "buffer_manager.hh" +#include "string.hh" namespace Kakoune { diff --git a/src/debug.hh b/src/debug.hh index 26b94820..02e46708 100644 --- a/src/debug.hh +++ b/src/debug.hh @@ -1,11 +1,11 @@ #ifndef debug_hh_INCLUDED #define debug_hh_INCLUDED -#include "string.hh" - namespace Kakoune { +class StringView; + void write_debug(StringView str); } diff --git a/src/display_buffer.cc b/src/display_buffer.cc index af8d15e4..a56fe612 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -1,10 +1,48 @@ #include "display_buffer.hh" #include "assert.hh" +#include "buffer.hh" +#include "utf8.hh" namespace Kakoune { +StringView DisplayAtom::content() const +{ + switch (m_type) + { + case BufferRange: + { + auto line = (*m_buffer)[m_begin.line]; + if (m_begin.line == m_end.line) + return line.substr(m_begin.column, m_end.column - m_begin.column); + else if (m_begin.line+1 == m_end.line and m_end.column == 0) + return line.substr(m_begin.column); + break; + } + case Text: + case ReplacedBufferRange: + return m_text; + } + kak_assert(false); + return {}; +} + +CharCount DisplayAtom::length() const +{ + switch (m_type) + { + case BufferRange: + return utf8::distance(m_buffer->iterator_at(m_begin), + m_buffer->iterator_at(m_end)); + case Text: + case ReplacedBufferRange: + return m_text.char_length(); + } + kak_assert(false); + return 0; +} + void DisplayAtom::trim_begin(CharCount count) { if (m_type == BufferRange) diff --git a/src/display_buffer.hh b/src/display_buffer.hh index 8ad01661..83ba7d6b 100644 --- a/src/display_buffer.hh +++ b/src/display_buffer.hh @@ -1,17 +1,17 @@ #ifndef display_buffer_hh_INCLUDED #define display_buffer_hh_INCLUDED -#include "buffer.hh" #include "face.hh" #include "coord.hh" #include "string.hh" -#include "utf8.hh" #include namespace Kakoune { +class Buffer; + struct DisplayAtom { public: @@ -25,41 +25,8 @@ public: : m_type(Text), m_text(std::move(str)), face(face) { check_invariant(); } - StringView content() const - { - switch (m_type) - { - case BufferRange: - { - auto line = (*m_buffer)[m_begin.line]; - if (m_begin.line == m_end.line) - return line.substr(m_begin.column, m_end.column - m_begin.column); - else if (m_begin.line+1 == m_end.line and m_end.column == 0) - return line.substr(m_begin.column); - break; - } - case Text: - case ReplacedBufferRange: - return m_text; - } - kak_assert(false); - return {}; - } - - CharCount length() const - { - switch (m_type) - { - case BufferRange: - return utf8::distance(m_buffer->iterator_at(m_begin), - m_buffer->iterator_at(m_end)); - case Text: - case ReplacedBufferRange: - return m_text.char_length(); - } - kak_assert(false); - return 0; - } + StringView content() const; + CharCount length() const; const ByteCoord& begin() const { diff --git a/src/env_vars.cc b/src/env_vars.cc index 7a759399..f89fe7ff 100644 --- a/src/env_vars.cc +++ b/src/env_vars.cc @@ -1,5 +1,7 @@ #include "env_vars.hh" +#include "string.hh" + extern char **environ; namespace Kakoune diff --git a/src/env_vars.hh b/src/env_vars.hh index 087d51a7..89d3459e 100644 --- a/src/env_vars.hh +++ b/src/env_vars.hh @@ -1,13 +1,12 @@ #ifndef env_vars_hh_INCLUDED #define env_vars_hh_INCLUDED -#include "string.hh" - #include namespace Kakoune { +class String; using EnvVarMap = std::unordered_map; EnvVarMap get_env_vars(); @@ -15,4 +14,3 @@ EnvVarMap get_env_vars(); } #endif // env_vars_hh_INCLUDED - diff --git a/src/file.cc b/src/file.cc index 19f2a764..472d3fb9 100644 --- a/src/file.cc +++ b/src/file.cc @@ -8,6 +8,7 @@ #include "debug.hh" #include "unicode.hh" #include "regex.hh" +#include "string.hh" #include #include diff --git a/src/file.hh b/src/file.hh index 99bb3715..8cef4473 100644 --- a/src/file.hh +++ b/src/file.hh @@ -2,7 +2,6 @@ #define file_hh_INCLUDED #include "exception.hh" -#include "string.hh" #include "regex.hh" namespace Kakoune @@ -23,6 +22,9 @@ struct file_not_found : file_access_error }; class Buffer; +template class memoryview; +class String; +class StringView; // parse ~/ and $env values in filename and returns the translated filename String parse_filename(StringView filename); diff --git a/src/hook_manager.hh b/src/hook_manager.hh index 21aade05..93a67ef7 100644 --- a/src/hook_manager.hh +++ b/src/hook_manager.hh @@ -2,7 +2,6 @@ #define hook_manager_hh_INCLUDED #include "id_map.hh" -#include "utils.hh" #include diff --git a/src/keymap_manager.cc b/src/keymap_manager.cc index 71f936fd..0d376a1b 100644 --- a/src/keymap_manager.cc +++ b/src/keymap_manager.cc @@ -1,5 +1,7 @@ #include "keymap_manager.hh" +#include "memoryview.hh" + namespace std { diff --git a/src/keymap_manager.hh b/src/keymap_manager.hh index 6521f69c..b6b0bf52 100644 --- a/src/keymap_manager.hh +++ b/src/keymap_manager.hh @@ -5,6 +5,7 @@ #include "utils.hh" #include +#include namespace Kakoune { @@ -20,6 +21,8 @@ enum class KeymapMode : int View, }; +template class memoryview; + class KeymapManager { public: diff --git a/src/keys.hh b/src/keys.hh index d579395d..3123f7cc 100644 --- a/src/keys.hh +++ b/src/keys.hh @@ -1,8 +1,8 @@ #ifndef keys_hh_INCLUDED #define keys_hh_INCLUDED -#include "string.hh" #include "unicode.hh" +#include "flags.hh" #include @@ -64,8 +64,13 @@ struct Key { return modifiers != other.modifiers or key != other.key; } }; +template<> struct WithBitOps : std::true_type {}; + using KeyList = std::vector; +class String; +class StringView; + KeyList parse_keys(StringView str); String key_to_str(Key key); @@ -79,7 +84,7 @@ namespace std { template<> -struct hash : unary_function +struct hash { size_t operator()(Kakoune::Key key) const { diff --git a/src/ncurses.cc b/src/ncurses.cc index c479d66a..de72f320 100644 --- a/src/ncurses.cc +++ b/src/ncurses.cc @@ -2,6 +2,7 @@ #include "display_buffer.hh" #include "event_manager.hh" +#include "keys.hh" #include "register_manager.hh" #include "utf8_iterator.hh" diff --git a/src/ncurses.hh b/src/ncurses.hh index 3f59b05c..23d91f5c 100644 --- a/src/ncurses.hh +++ b/src/ncurses.hh @@ -1,8 +1,9 @@ #ifndef ncurses_hh_INCLUDED #define ncurses_hh_INCLUDED -#include "display_buffer.hh" +#include "coord.hh" #include "event_manager.hh" +#include "face.hh" #include "user_interface.hh" namespace Kakoune diff --git a/src/option_types.hh b/src/option_types.hh index f7f372fb..b304f12b 100644 --- a/src/option_types.hh +++ b/src/option_types.hh @@ -5,6 +5,7 @@ #include "string.hh" #include "units.hh" #include "coord.hh" +#include "memoryview.hh" #include #include diff --git a/src/remote.hh b/src/remote.hh index 90aa14da..0d85cf81 100644 --- a/src/remote.hh +++ b/src/remote.hh @@ -1,9 +1,13 @@ #ifndef remote_hh_INCLUDED #define remote_hh_INCLUDED -#include "display_buffer.hh" -#include "user_interface.hh" +#include "coord.hh" #include "env_vars.hh" +#include "exception.hh" +#include "user_interface.hh" +#include "utils.hh" + +#include namespace Kakoune { diff --git a/src/shell_manager.hh b/src/shell_manager.hh index e2af4241..8b930777 100644 --- a/src/shell_manager.hh +++ b/src/shell_manager.hh @@ -1,7 +1,6 @@ #ifndef shell_manager_hh_INCLUDED #define shell_manager_hh_INCLUDED -#include "string.hh" #include "regex.hh" #include "utils.hh" #include "env_vars.hh" @@ -10,6 +9,10 @@ namespace Kakoune { class Context; +template class memoryview; +class String; +class StringView; + using EnvVarRetriever = std::function; class ShellManager : public Singleton diff --git a/src/string.hh b/src/string.hh index f7311d9d..55276d73 100644 --- a/src/string.hh +++ b/src/string.hh @@ -1,13 +1,13 @@ #ifndef string_hh_INCLUDED #define string_hh_INCLUDED -#include "memoryview.hh" #include "units.hh" #include "utf8.hh" #include #include #include +#include namespace Kakoune { diff --git a/src/user_interface.hh b/src/user_interface.hh index dc415967..43d10377 100644 --- a/src/user_interface.hh +++ b/src/user_interface.hh @@ -1,11 +1,9 @@ #ifndef user_interface_hh_INCLUDED #define user_interface_hh_INCLUDED -#include "color.hh" -#include "keys.hh" -#include "memoryview.hh" #include "safe_ptr.hh" +#include #include namespace Kakoune @@ -15,6 +13,9 @@ class String; class DisplayBuffer; class DisplayLine; struct CharCoord; +struct Face; +struct Key; +template class memoryview; enum class MenuStyle { diff --git a/src/value.hh b/src/value.hh index bf051353..86bbfea2 100644 --- a/src/value.hh +++ b/src/value.hh @@ -67,7 +67,7 @@ private: struct ValueId : public StronglyTypedNumber { - constexpr ValueId(int value = 0) : StronglyTypedNumber(value) {} + constexpr ValueId(int value = 0) : StronglyTypedNumber(value) {} static ValueId get_free_id() { diff --git a/src/window.hh b/src/window.hh index e2bb91b1..c5efdf27 100644 --- a/src/window.hh +++ b/src/window.hh @@ -1,10 +1,9 @@ #ifndef window_hh_INCLUDED #define window_hh_INCLUDED -#include "completion.hh" #include "display_buffer.hh" #include "highlighter_group.hh" -#include "selection.hh" +#include "option_manager.hh" #include "safe_ptr.hh" #include "scope.hh"