Header and dependency cleanup

main
Maxime Coste 2019-01-24 21:02:07 +11:00
parent 4b72cfe530
commit 346c78f5e0
21 changed files with 41 additions and 48 deletions

View File

@ -1,7 +1,6 @@
#ifndef array_view_hh_INCLUDED
#define array_view_hh_INCLUDED
#include <vector>
#include <initializer_list>
#include <iterator>
@ -31,10 +30,10 @@ public:
template<size_t N>
constexpr ArrayView(T(&array)[N]) : m_pointer(array), m_size(N) {}
template<typename Alloc, typename U,
typename = std::enable_if_t<sizeof(U) == sizeof(T)>>
constexpr ArrayView(const std::vector<U, Alloc>& v)
: m_pointer(v.data()), m_size(v.size()) {}
template<typename Container,
typename = std::enable_if_t<sizeof(decltype(*std::declval<Container>().data())) == sizeof(T)>>
constexpr ArrayView(const Container& c)
: m_pointer(c.data()), m_size(c.size()) {}
constexpr ArrayView(const std::initializer_list<T>& v)
: m_pointer(v.begin()), m_size(v.size()) {}

View File

@ -29,7 +29,6 @@
#include "user_interface.hh"
#include "window.hh"
#include <cstring>
#include <functional>
#include <utility>
@ -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()};

View File

@ -42,9 +42,6 @@ enum class CompletionFlags
constexpr bool with_bit_ops(Meta::Type<CompletionFlags>) { return true; }
using Completer = std::function<Completions (const Context&, CompletionFlags,
StringView, ByteCount)>;
inline Completions complete_nothing(const Context&, CompletionFlags,
StringView, ByteCount cursor_pos)
{

View File

@ -5,6 +5,8 @@
#include "optional.hh"
#include "utils.hh"
#include <functional>
namespace Kakoune
{

View File

@ -2,7 +2,7 @@
#define hash_hh_INCLUDED
#include <type_traits>
#include <functional>
#include <utility>
#include <cstddef>
@ -11,13 +11,6 @@ namespace Kakoune
size_t hash_data(const char* data, size_t len);
template<typename... Type>
constexpr size_t hash_value(const Type&... val)
{
static_assert(sizeof...(Type) == 1, "");
return std::hash<Type...>()(val...);
}
template<typename Type>
std::enable_if_t<std::is_integral<Type>::value, size_t>
constexpr hash_value(const Type& val)

View File

@ -11,7 +11,7 @@
#include "string.hh"
#include "utils.hh"
#include <functional>
#include <memory>
namespace Kakoune
{
@ -84,7 +84,7 @@ private:
};
using HighlighterParameters = ConstArrayView<String>;
using HighlighterFactory = std::function<std::unique_ptr<Highlighter> (HighlighterParameters params, Highlighter* parent)>;
using HighlighterFactory = std::unique_ptr<Highlighter> (*)(HighlighterParameters params, Highlighter* parent);
struct HighlighterFactoryAndDocstring
{

View File

@ -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 <locale>
#include <cstdio>
namespace Kakoune
{

View File

@ -7,6 +7,8 @@
#include "meta.hh"
#include "enum.hh"
#include <memory>
namespace Kakoune
{

View File

@ -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)));

View File

@ -47,6 +47,10 @@ enum class InsertMode : unsigned;
enum class KeymapMode : char;
enum class CursorMode;
using PromptCompleter = std::function<Completions (const Context&, CompletionFlags,
StringView, ByteCount)>;
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,

View File

@ -90,8 +90,8 @@ Vector<LineModification> 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<LineModification> modifs)

View File

@ -7,6 +7,8 @@
#include "range.hh"
#include "vector.hh"
#include <functional>
namespace Kakoune
{

View File

@ -29,7 +29,6 @@
#include "clock.hh"
#include <fcntl.h>
#include <locale>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

View File

@ -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"

View File

@ -11,7 +11,7 @@
#include "string_utils.hh"
#include <memory>
#include <type_traits>
#include <utility>
namespace Kakoune
{

View File

@ -6,9 +6,6 @@
#include "assert.hh"
#include "ref_ptr.hh"
#include <type_traits>
#include <utility>
#ifdef SAFE_PTR_TRACK_CALLSTACKS
#include "backtrace.hh"
#include "vector.hh"

View File

@ -3,7 +3,6 @@
#include <cwctype>
#include <cwchar>
#include <locale>
#include "array_view.hh"
#include "ranges.hh"

View File

@ -18,11 +18,15 @@ template<typename BaseIt,
typename CodepointType = Codepoint,
typename DifferenceType = CharCount,
typename InvalidPolicy = utf8::InvalidPolicy::Pass>
class iterator : public std::iterator<std::bidirectional_iterator_tag,
CodepointType, DifferenceType,
CodepointType*, CodepointType>
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));

View File

@ -12,7 +12,6 @@
#include "option_types.hh"
#include <algorithm>
#include <sstream>
namespace Kakoune
{

View File

@ -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<std::forward_iterator_tag, StringView>
struct Iterator
{
Iterator(const char* begin, const WordSplitter& splitter)
: m_word_begin{begin}, m_word_end{begin}, m_splitter{&splitter}

View File

@ -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<RankedMatch>;
class Buffer;
// maintain a database of words available in a buffer
class WordDB : public OptionManagerWatcher