diff --git a/src/array_view.hh b/src/array_view.hh index 7ee32d12..34bc376e 100644 --- a/src/array_view.hh +++ b/src/array_view.hh @@ -1,7 +1,6 @@ #ifndef array_view_hh_INCLUDED #define array_view_hh_INCLUDED -#include #include #include @@ -31,10 +30,10 @@ public: template constexpr ArrayView(T(&array)[N]) : m_pointer(array), m_size(N) {} - template> - constexpr ArrayView(const std::vector& v) - : m_pointer(v.data()), m_size(v.size()) {} + template().data())) == sizeof(T)>> + constexpr ArrayView(const Container& c) + : m_pointer(c.data()), m_size(c.size()) {} constexpr ArrayView(const std::initializer_list& v) : m_pointer(v.begin()), m_size(v.size()) {} diff --git a/src/commands.cc b/src/commands.cc index a4c99f02..706e86b4 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -29,7 +29,6 @@ #include "user_interface.hh" #include "window.hh" -#include #include #include @@ -1851,7 +1850,7 @@ const CommandDesc prompt_cmd = { const String& command = parser[1]; auto initstr = parser.get_switch("init").value_or(StringView{}); - Completer completer; + PromptCompleter completer; if (parser.get_switch("file-completion")) completer = [](const Context& context, CompletionFlags, StringView prefix, ByteCount cursor_pos) -> Completions { @@ -1896,7 +1895,7 @@ const CommandDesc prompt_cmd = { auto& text = sc.env_vars["text"_sv] = str.str(); auto clear_password = on_scope_end([&] { if (flags & PromptFlags::Password) - memset(text.data(), 0, (int)text.length()); + std::fill(text.begin(), text.end(), '\0'); }); ScopedSetBool disable_history{context.history_disabled()}; diff --git a/src/completion.hh b/src/completion.hh index 553b37e7..1cfd1f22 100644 --- a/src/completion.hh +++ b/src/completion.hh @@ -42,9 +42,6 @@ enum class CompletionFlags constexpr bool with_bit_ops(Meta::Type) { return true; } -using Completer = std::function; - inline Completions complete_nothing(const Context&, CompletionFlags, StringView, ByteCount cursor_pos) { diff --git a/src/context.hh b/src/context.hh index 14543946..d8830b2e 100644 --- a/src/context.hh +++ b/src/context.hh @@ -5,6 +5,8 @@ #include "optional.hh" #include "utils.hh" +#include + namespace Kakoune { diff --git a/src/hash.hh b/src/hash.hh index e90232d8..23ae50a9 100644 --- a/src/hash.hh +++ b/src/hash.hh @@ -2,7 +2,7 @@ #define hash_hh_INCLUDED #include -#include +#include #include @@ -11,13 +11,6 @@ namespace Kakoune size_t hash_data(const char* data, size_t len); -template -constexpr size_t hash_value(const Type&... val) -{ - static_assert(sizeof...(Type) == 1, ""); - return std::hash()(val...); -} - template std::enable_if_t::value, size_t> constexpr hash_value(const Type& val) diff --git a/src/highlighter.hh b/src/highlighter.hh index cceabba2..dd5e2285 100644 --- a/src/highlighter.hh +++ b/src/highlighter.hh @@ -11,7 +11,7 @@ #include "string.hh" #include "utils.hh" -#include +#include namespace Kakoune { @@ -84,7 +84,7 @@ private: }; using HighlighterParameters = ConstArrayView; -using HighlighterFactory = std::function (HighlighterParameters params, Highlighter* parent)>; +using HighlighterFactory = std::unique_ptr (*)(HighlighterParameters params, Highlighter* parent); struct HighlighterFactoryAndDocstring { diff --git a/src/highlighters.cc b/src/highlighters.cc index d39fbb69..05bc10e7 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -9,21 +9,16 @@ #include "face_registry.hh" #include "highlighter_group.hh" #include "line_modification.hh" -#include "option.hh" #include "option_types.hh" #include "parameters_parser.hh" #include "ranges.hh" #include "regex.hh" #include "register_manager.hh" #include "string.hh" -#include "unit_tests.hh" #include "utf8.hh" #include "utf8_iterator.hh" #include "window.hh" -#include -#include - namespace Kakoune { diff --git a/src/hook_manager.hh b/src/hook_manager.hh index bae6cca4..fa72cdc3 100644 --- a/src/hook_manager.hh +++ b/src/hook_manager.hh @@ -7,6 +7,8 @@ #include "meta.hh" #include "enum.hh" +#include + namespace Kakoune { diff --git a/src/input_handler.cc b/src/input_handler.cc index 0d9710dd..91acbc3f 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -751,7 +751,7 @@ class Prompt : public InputMode public: Prompt(InputHandler& input_handler, StringView prompt, String initstr, String emptystr, Face face, PromptFlags flags, - Completer completer, PromptCallback callback) + PromptCompleter completer, PromptCallback callback) : InputMode(input_handler), m_prompt(prompt.str()), m_prompt_face(face), m_empty_text{std::move(emptystr)}, m_flags(flags), m_completer(std::move(completer)), m_callback(std::move(callback)), @@ -1064,8 +1064,8 @@ private: context().client().menu_hide(); } - PromptCallback m_callback; - Completer m_completer; + PromptCallback m_callback; + PromptCompleter m_completer; const String m_prompt; Face m_prompt_face; Completions m_completions; @@ -1578,7 +1578,7 @@ void InputHandler::repeat_last_insert() void InputHandler::prompt(StringView prompt, String initstr, String emptystr, Face prompt_face, PromptFlags flags, - Completer completer, PromptCallback callback) + PromptCompleter completer, PromptCallback callback) { push_mode(new InputModes::Prompt(*this, prompt, std::move(initstr), std::move(emptystr), prompt_face, flags, std::move(completer), std::move(callback))); diff --git a/src/input_handler.hh b/src/input_handler.hh index 600d78b8..35dc718a 100644 --- a/src/input_handler.hh +++ b/src/input_handler.hh @@ -47,6 +47,10 @@ enum class InsertMode : unsigned; enum class KeymapMode : char; enum class CursorMode; +using PromptCompleter = std::function; + + class InputHandler : public SafeCountable { public: @@ -66,7 +70,7 @@ public: // not change the mode itself void prompt(StringView prompt, String initstr, String emptystr, Face prompt_face, PromptFlags flags, - Completer completer, PromptCallback callback); + PromptCompleter completer, PromptCallback callback); void set_prompt_face(Face prompt_face); // enter menu mode, callback is called on each selection change, diff --git a/src/line_modification.cc b/src/line_modification.cc index 30722368..d052cb54 100644 --- a/src/line_modification.cc +++ b/src/line_modification.cc @@ -90,8 +90,8 @@ Vector compute_line_modifications(const Buffer& buffer, size_t bool operator==(const LineModification& lhs, const LineModification& rhs) { - return std::tie(lhs.old_line, lhs.new_line, lhs.num_removed, lhs.num_added) == - std::tie(rhs.old_line, rhs.new_line, rhs.num_removed, rhs.num_added); + return lhs.old_line == rhs.old_line and lhs.new_line == rhs.new_line and + lhs.num_removed == rhs.num_removed and lhs.num_added == rhs.num_added; } void LineRangeSet::update(ConstArrayView modifs) diff --git a/src/line_modification.hh b/src/line_modification.hh index cdc601df..5cb4d350 100644 --- a/src/line_modification.hh +++ b/src/line_modification.hh @@ -7,6 +7,8 @@ #include "range.hh" #include "vector.hh" +#include + namespace Kakoune { diff --git a/src/main.cc b/src/main.cc index f0483835..b0b93edb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -29,7 +29,6 @@ #include "clock.hh" #include -#include #include #include #include diff --git a/src/normal.hh b/src/normal.hh index 9b6693cc..10ee5ffa 100644 --- a/src/normal.hh +++ b/src/normal.hh @@ -1,7 +1,6 @@ #ifndef normal_hh_INCLUDED #define normal_hh_INCLUDED -#include "context.hh" #include "optional.hh" #include "keys.hh" #include "keymap_manager.hh" diff --git a/src/option_manager.hh b/src/option_manager.hh index 77f482c0..81f3b1b9 100644 --- a/src/option_manager.hh +++ b/src/option_manager.hh @@ -11,7 +11,7 @@ #include "string_utils.hh" #include -#include +#include namespace Kakoune { diff --git a/src/safe_ptr.hh b/src/safe_ptr.hh index 38d58046..216a14ff 100644 --- a/src/safe_ptr.hh +++ b/src/safe_ptr.hh @@ -6,9 +6,6 @@ #include "assert.hh" #include "ref_ptr.hh" -#include -#include - #ifdef SAFE_PTR_TRACK_CALLSTACKS #include "backtrace.hh" #include "vector.hh" diff --git a/src/unicode.hh b/src/unicode.hh index d94fff8d..486fc381 100644 --- a/src/unicode.hh +++ b/src/unicode.hh @@ -3,7 +3,6 @@ #include #include -#include #include "array_view.hh" #include "ranges.hh" diff --git a/src/utf8_iterator.hh b/src/utf8_iterator.hh index 4dd9ffd0..81302ef9 100644 --- a/src/utf8_iterator.hh +++ b/src/utf8_iterator.hh @@ -18,11 +18,15 @@ template -class iterator : public std::iterator +class iterator { public: + using value_type = CodepointType; + using difference_type = DifferenceType; + using pointer = CodepointType*; + using reference = CodepointType&; + using iterator_category = std::bidirectional_iterator_tag; + iterator() = default; constexpr static bool noexcept_policy = noexcept(InvalidPolicy{}(0)); diff --git a/src/window.cc b/src/window.cc index a116abc4..b4bc922d 100644 --- a/src/window.cc +++ b/src/window.cc @@ -12,7 +12,6 @@ #include "option_types.hh" #include -#include namespace Kakoune { diff --git a/src/word_db.cc b/src/word_db.cc index 6d847952..a9f0b751 100644 --- a/src/word_db.cc +++ b/src/word_db.cc @@ -1,10 +1,11 @@ #include "word_db.hh" -#include "utils.hh" +#include "buffer.hh" #include "line_modification.hh" #include "option_types.hh" -#include "utf8_iterator.hh" #include "unit_tests.hh" +#include "utils.hh" +#include "value.hh" namespace Kakoune { @@ -20,7 +21,7 @@ WordDB& get_word_db(const Buffer& buffer) struct WordSplitter { - struct Iterator : std::iterator + struct Iterator { Iterator(const char* begin, const WordSplitter& splitter) : m_word_begin{begin}, m_word_end{begin}, m_splitter{&splitter} diff --git a/src/word_db.hh b/src/word_db.hh index 08234257..aef047d0 100644 --- a/src/word_db.hh +++ b/src/word_db.hh @@ -1,16 +1,18 @@ #ifndef word_db_hh_INCLUDED #define word_db_hh_INCLUDED -#include "buffer.hh" #include "shared_string.hh" #include "hash_map.hh" #include "vector.hh" #include "ranked_match.hh" +#include "option_manager.hh" +#include "safe_ptr.hh" namespace Kakoune { using RankedMatchList = Vector; +class Buffer; // maintain a database of words available in a buffer class WordDB : public OptionManagerWatcher