ArrayView content is not const anymore
As in upcoming std c++ array_view, ArrayView<T> points to mutable data, use ArrayView<const T> or alias ConstArrayView<T> for const data.
This commit is contained in:
parent
44f81d0b8b
commit
1cec8df45e
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
@ -18,42 +19,42 @@ public:
|
||||||
constexpr ArrayView()
|
constexpr ArrayView()
|
||||||
: m_pointer(nullptr), m_size(0) {}
|
: m_pointer(nullptr), m_size(0) {}
|
||||||
|
|
||||||
constexpr ArrayView(const T& oneval)
|
constexpr ArrayView(T& oneval)
|
||||||
: m_pointer(&oneval), m_size(1) {}
|
: m_pointer(&oneval), m_size(1) {}
|
||||||
|
|
||||||
constexpr ArrayView(const T* pointer, size_t size)
|
constexpr ArrayView(T* pointer, size_t size)
|
||||||
: m_pointer(pointer), m_size(size) {}
|
: m_pointer(pointer), m_size(size) {}
|
||||||
|
|
||||||
constexpr ArrayView(const T* begin, const T* end)
|
constexpr ArrayView(T* begin, T* end)
|
||||||
: m_pointer(begin), m_size(end - begin) {}
|
: m_pointer(begin), m_size(end - begin) {}
|
||||||
|
|
||||||
template<size_t N>
|
template<size_t N>
|
||||||
constexpr ArrayView(const T(&array)[N]) : m_pointer(array), m_size(N) {}
|
constexpr ArrayView(T(&array)[N]) : m_pointer(array), m_size(N) {}
|
||||||
|
|
||||||
template<typename Iterator>
|
template<typename Iterator>
|
||||||
constexpr ArrayView(const Iterator& begin, const Iterator& end)
|
constexpr ArrayView(const Iterator& begin, const Iterator& end)
|
||||||
: m_pointer(&(*begin)), m_size(end - begin) {}
|
: m_pointer(&(*begin)), m_size(end - begin) {}
|
||||||
|
|
||||||
template<typename Alloc>
|
template<typename Alloc, typename U>
|
||||||
constexpr ArrayView(const std::vector<T, Alloc>& v)
|
constexpr ArrayView(const std::vector<U, Alloc>& v)
|
||||||
: m_pointer(&v[0]), m_size(v.size()) {}
|
: m_pointer(&v[0]), m_size(v.size()) {}
|
||||||
|
|
||||||
constexpr ArrayView(const std::initializer_list<T>& v)
|
constexpr ArrayView(const std::initializer_list<T>& v)
|
||||||
: m_pointer(v.begin()), m_size(v.size()) {}
|
: m_pointer(v.begin()), m_size(v.size()) {}
|
||||||
|
|
||||||
constexpr const T* pointer() const { return m_pointer; }
|
constexpr T* pointer() const { return m_pointer; }
|
||||||
constexpr size_t size() const { return m_size; }
|
constexpr size_t size() const { return m_size; }
|
||||||
constexpr const T& operator[](size_t n) const { return *(m_pointer + n); }
|
constexpr T& operator[](size_t n) const { return *(m_pointer + n); }
|
||||||
|
|
||||||
constexpr const T* begin() const { return m_pointer; }
|
constexpr T* begin() const { return m_pointer; }
|
||||||
constexpr const T* end() const { return m_pointer+m_size; }
|
constexpr T* end() const { return m_pointer+m_size; }
|
||||||
|
|
||||||
using reverse_iterator = std::reverse_iterator<const T*>;
|
using reverse_iterator = std::reverse_iterator<T*>;
|
||||||
constexpr reverse_iterator rbegin() const { return reverse_iterator(m_pointer+m_size); }
|
constexpr reverse_iterator rbegin() const { return reverse_iterator(m_pointer+m_size); }
|
||||||
constexpr reverse_iterator rend() const { return reverse_iterator(m_pointer); }
|
constexpr reverse_iterator rend() const { return reverse_iterator(m_pointer); }
|
||||||
|
|
||||||
constexpr const T& front() const { return *m_pointer; }
|
constexpr T& front() const { return *m_pointer; }
|
||||||
constexpr const T& back() const { return *(m_pointer + m_size - 1); }
|
constexpr T& back() const { return *(m_pointer + m_size - 1); }
|
||||||
|
|
||||||
constexpr bool empty() const { return m_size == 0; }
|
constexpr bool empty() const { return m_size == 0; }
|
||||||
|
|
||||||
|
@ -63,10 +64,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const T* m_pointer;
|
T* m_pointer;
|
||||||
size_t m_size;
|
size_t m_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using ConstArrayView = ArrayView<const T>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // array_view_hh_INCLUDED
|
#endif // array_view_hh_INCLUDED
|
||||||
|
|
|
@ -164,7 +164,7 @@ public:
|
||||||
ByteCoord begin;
|
ByteCoord begin;
|
||||||
ByteCoord end;
|
ByteCoord end;
|
||||||
};
|
};
|
||||||
ArrayView<Change> changes_since(size_t timestamp) const;
|
ConstArrayView<Change> changes_since(size_t timestamp) const;
|
||||||
|
|
||||||
String debug_description() const;
|
String debug_description() const;
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -92,7 +92,7 @@ inline size_t Buffer::timestamp() const
|
||||||
return m_changes.size();
|
return m_changes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ArrayView<Buffer::Change> Buffer::changes_since(size_t timestamp) const
|
inline ConstArrayView<Buffer::Change> Buffer::changes_since(size_t timestamp) const
|
||||||
{
|
{
|
||||||
return { m_changes.data() + timestamp,
|
return { m_changes.data() + timestamp,
|
||||||
m_changes.data() + m_changes.size() };
|
m_changes.data() + m_changes.size() };
|
||||||
|
|
|
@ -270,11 +270,11 @@ TokenList parse(StringView line)
|
||||||
}
|
}
|
||||||
|
|
||||||
String eval_token(const Token& token, Context& context,
|
String eval_token(const Token& token, Context& context,
|
||||||
ArrayView<String> shell_params,
|
ConstArrayView<String> shell_params,
|
||||||
const EnvVarMap& env_vars);
|
const EnvVarMap& env_vars);
|
||||||
|
|
||||||
String eval(StringView str, Context& context,
|
String eval(StringView str, Context& context,
|
||||||
ArrayView<String> shell_params,
|
ConstArrayView<String> shell_params,
|
||||||
const EnvVarMap& env_vars)
|
const EnvVarMap& env_vars)
|
||||||
{
|
{
|
||||||
String res;
|
String res;
|
||||||
|
@ -303,7 +303,7 @@ String eval(StringView str, Context& context,
|
||||||
}
|
}
|
||||||
|
|
||||||
String eval_token(const Token& token, Context& context,
|
String eval_token(const Token& token, Context& context,
|
||||||
ArrayView<String> shell_params,
|
ConstArrayView<String> shell_params,
|
||||||
const EnvVarMap& env_vars)
|
const EnvVarMap& env_vars)
|
||||||
{
|
{
|
||||||
auto& content = token.content();
|
auto& content = token.content();
|
||||||
|
@ -356,7 +356,7 @@ void CommandManager::execute_single_command(CommandParameters params,
|
||||||
if (params.empty())
|
if (params.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ArrayView<String> param_view(params.begin()+1, params.end());
|
ConstArrayView<String> param_view(params.begin()+1, params.end());
|
||||||
auto command_it = find_command(context, params[0]);
|
auto command_it = find_command(context, params[0]);
|
||||||
if (command_it == m_commands.end())
|
if (command_it == m_commands.end())
|
||||||
throw command_not_found(params[0]);
|
throw command_not_found(params[0]);
|
||||||
|
@ -396,7 +396,7 @@ static CharCoord find_coord(StringView str, ByteCount offset)
|
||||||
|
|
||||||
void CommandManager::execute(StringView command_line,
|
void CommandManager::execute(StringView command_line,
|
||||||
Context& context,
|
Context& context,
|
||||||
ArrayView<String> shell_params,
|
ConstArrayView<String> shell_params,
|
||||||
const EnvVarMap& env_vars)
|
const EnvVarMap& env_vars)
|
||||||
{
|
{
|
||||||
TokenList tokens = parse<true>(command_line);
|
TokenList tokens = parse<true>(command_line);
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Kakoune
|
||||||
{
|
{
|
||||||
|
|
||||||
class Context;
|
class Context;
|
||||||
using CommandParameters = ArrayView<String>;
|
using CommandParameters = ConstArrayView<String>;
|
||||||
using Command = std::function<void (const ParametersParser& parser, Context& context)>;
|
using Command = std::function<void (const ParametersParser& parser, Context& context)>;
|
||||||
using CommandCompleter = std::function<Completions (const Context& context,
|
using CommandCompleter = std::function<Completions (const Context& context,
|
||||||
CompletionFlags,
|
CompletionFlags,
|
||||||
|
@ -40,7 +40,7 @@ public:
|
||||||
using ArgumentCompleter = std::function<Completions (const Context&,
|
using ArgumentCompleter = std::function<Completions (const Context&,
|
||||||
CompletionFlags flags,
|
CompletionFlags flags,
|
||||||
const String&, ByteCount)>;
|
const String&, ByteCount)>;
|
||||||
using ArgumentCompleterList = ArrayView<ArgumentCompleter>;
|
using ArgumentCompleterList = ConstArrayView<ArgumentCompleter>;
|
||||||
|
|
||||||
PerArgumentCommandCompleter(ArgumentCompleterList completers)
|
PerArgumentCommandCompleter(ArgumentCompleterList completers)
|
||||||
: m_completers(completers.begin(), completers.end()) {}
|
: m_completers(completers.begin(), completers.end()) {}
|
||||||
|
@ -61,7 +61,7 @@ class CommandManager : public Singleton<CommandManager>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void execute(StringView command_line, Context& context,
|
void execute(StringView command_line, Context& context,
|
||||||
ArrayView<String> shell_params = {},
|
ConstArrayView<String> shell_params = {},
|
||||||
const EnvVarMap& env_vars = EnvVarMap{});
|
const EnvVarMap& env_vars = EnvVarMap{});
|
||||||
|
|
||||||
Completions complete(const Context& context, CompletionFlags flags,
|
Completions complete(const Context& context, CompletionFlags flags,
|
||||||
|
|
|
@ -1267,7 +1267,7 @@ const CommandDesc prompt_cmd = {
|
||||||
{
|
{
|
||||||
if (event != PromptEvent::Validate)
|
if (event != PromptEvent::Validate)
|
||||||
return;
|
return;
|
||||||
RegisterManager::instance()[reg] = ArrayView<String>(str);
|
RegisterManager::instance()[reg] = ConstArrayView<String>(str);
|
||||||
|
|
||||||
CommandManager::instance().execute(command, context);
|
CommandManager::instance().execute(command, context);
|
||||||
});
|
});
|
||||||
|
@ -1449,7 +1449,7 @@ const CommandDesc set_register_cmd = {
|
||||||
CommandCompleter{},
|
CommandCompleter{},
|
||||||
[](const ParametersParser& parser, Context& context)
|
[](const ParametersParser& parser, Context& context)
|
||||||
{
|
{
|
||||||
RegisterManager::instance()[parser[0]] = ArrayView<String>(parser[1]);
|
RegisterManager::instance()[parser[0]] = ConstArrayView<String>(parser[1]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1474,7 +1474,7 @@ public:
|
||||||
RegisterRestorer(char name, const Context& context)
|
RegisterRestorer(char name, const Context& context)
|
||||||
: m_name(name)
|
: m_name(name)
|
||||||
{
|
{
|
||||||
ArrayView<String> save = RegisterManager::instance()[name].values(context);
|
ConstArrayView<String> save = RegisterManager::instance()[name].values(context);
|
||||||
m_save = Vector<String>(save.begin(), save.end());
|
m_save = Vector<String>(save.begin(), save.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1488,7 +1488,7 @@ private:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void exec_keys(ArrayView<Key> keys, Context& context)
|
void exec_keys(ConstArrayView<Key> keys, Context& context)
|
||||||
{
|
{
|
||||||
RegisterRestorer quote('"', context);
|
RegisterRestorer quote('"', context);
|
||||||
RegisterRestorer slash('/', context);
|
RegisterRestorer slash('/', context);
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Kakoune
|
||||||
class Context;
|
class Context;
|
||||||
|
|
||||||
void register_commands();
|
void register_commands();
|
||||||
void exec_keys(ArrayView<Key> keys, Context& context);
|
void exec_keys(ConstArrayView<Key> keys, Context& context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,7 @@ void write_buffer_to_backup_file(Buffer& buffer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String find_file(StringView filename, ArrayView<String> paths)
|
String find_file(StringView filename, ConstArrayView<String> paths)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (filename.length() > 1 and filename[0] == '/')
|
if (filename.length() > 1 and filename[0] == '/')
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef file_hh_INCLUDED
|
#ifndef file_hh_INCLUDED
|
||||||
#define file_hh_INCLUDED
|
#define file_hh_INCLUDED
|
||||||
|
|
||||||
|
#include "array_view.hh"
|
||||||
#include "completion.hh"
|
#include "completion.hh"
|
||||||
#include "exception.hh"
|
#include "exception.hh"
|
||||||
#include "regex.hh"
|
#include "regex.hh"
|
||||||
|
@ -23,7 +24,6 @@ struct file_not_found : file_access_error
|
||||||
};
|
};
|
||||||
|
|
||||||
class Buffer;
|
class Buffer;
|
||||||
template<typename T> class ArrayView;
|
|
||||||
class String;
|
class String;
|
||||||
class StringView;
|
class StringView;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ void write_buffer_to_file(Buffer& buffer, StringView filename);
|
||||||
void write_buffer_to_fd(Buffer& buffer, int fd);
|
void write_buffer_to_fd(Buffer& buffer, int fd);
|
||||||
void write_buffer_to_backup_file(Buffer& buffer);
|
void write_buffer_to_backup_file(Buffer& buffer);
|
||||||
|
|
||||||
String find_file(StringView filename, ArrayView<String> paths);
|
String find_file(StringView filename, ConstArrayView<String> paths);
|
||||||
|
|
||||||
time_t get_fs_timestamp(StringView filename);
|
time_t get_fs_timestamp(StringView filename);
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ std::unique_ptr<SimpleHighlighter<T>> make_simple_highlighter(T func)
|
||||||
return make_unique<SimpleHighlighter<T>>(std::move(func));
|
return make_unique<SimpleHighlighter<T>>(std::move(func));
|
||||||
}
|
}
|
||||||
|
|
||||||
using HighlighterParameters = ArrayView<String>;
|
using HighlighterParameters = ConstArrayView<String>;
|
||||||
using HighlighterFactory = std::function<HighlighterAndId (HighlighterParameters params)>;
|
using HighlighterFactory = std::function<HighlighterAndId (HighlighterParameters params)>;
|
||||||
|
|
||||||
struct HighlighterFactoryAndDocstring
|
struct HighlighterFactoryAndDocstring
|
||||||
|
|
|
@ -822,7 +822,7 @@ void find_matches(const Buffer& buffer, RegexMatchList& matches, const Regex& re
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_matches(const Buffer& buffer, ArrayView<LineModification> modifs,
|
void update_matches(const Buffer& buffer, ConstArrayView<LineModification> modifs,
|
||||||
RegexMatchList& matches, const Regex& regex)
|
RegexMatchList& matches, const Regex& regex)
|
||||||
{
|
{
|
||||||
// remove out of date matches and update line for others
|
// remove out of date matches and update line for others
|
||||||
|
@ -939,7 +939,7 @@ struct RegionDesc
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_matches(const Buffer& buffer,
|
void update_matches(const Buffer& buffer,
|
||||||
ArrayView<LineModification> modifs,
|
ConstArrayView<LineModification> modifs,
|
||||||
RegionMatches& matches) const
|
RegionMatches& matches) const
|
||||||
{
|
{
|
||||||
Kakoune::update_matches(buffer, modifs, matches.begin_matches, m_begin);
|
Kakoune::update_matches(buffer, modifs, matches.begin_matches, m_begin);
|
||||||
|
|
|
@ -342,7 +342,7 @@ private:
|
||||||
class Menu : public InputMode
|
class Menu : public InputMode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Menu(InputHandler& input_handler, ArrayView<String> choices,
|
Menu(InputHandler& input_handler, ConstArrayView<String> choices,
|
||||||
MenuCallback callback)
|
MenuCallback callback)
|
||||||
: InputMode(input_handler),
|
: InputMode(input_handler),
|
||||||
m_callback(callback), m_choices(choices.begin(), choices.end()),
|
m_callback(callback), m_choices(choices.begin(), choices.end()),
|
||||||
|
@ -460,7 +460,7 @@ private:
|
||||||
LineEditor m_filter_editor;
|
LineEditor m_filter_editor;
|
||||||
};
|
};
|
||||||
|
|
||||||
String common_prefix(ArrayView<String> strings)
|
String common_prefix(ConstArrayView<String> strings)
|
||||||
{
|
{
|
||||||
String res;
|
String res;
|
||||||
if (strings.empty())
|
if (strings.empty())
|
||||||
|
@ -928,7 +928,7 @@ private:
|
||||||
selections.sort_and_merge_overlapping();
|
selections.sort_and_merge_overlapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert(ArrayView<String> strings)
|
void insert(ConstArrayView<String> strings)
|
||||||
{
|
{
|
||||||
context().selections().insert(strings, InsertMode::InsertCursor);
|
context().selections().insert(strings, InsertMode::InsertCursor);
|
||||||
}
|
}
|
||||||
|
@ -1096,7 +1096,7 @@ void InputHandler::set_prompt_face(Face prompt_face)
|
||||||
prompt->set_prompt_face(prompt_face);
|
prompt->set_prompt_face(prompt_face);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputHandler::menu(ArrayView<String> choices,
|
void InputHandler::menu(ConstArrayView<String> choices,
|
||||||
MenuCallback callback)
|
MenuCallback callback)
|
||||||
{
|
{
|
||||||
change_input_mode(new InputModes::Menu(*this, choices, callback));
|
change_input_mode(new InputModes::Menu(*this, choices, callback));
|
||||||
|
@ -1153,7 +1153,7 @@ bool InputHandler::is_recording() const
|
||||||
void InputHandler::stop_recording()
|
void InputHandler::stop_recording()
|
||||||
{
|
{
|
||||||
kak_assert(m_recording_reg != 0);
|
kak_assert(m_recording_reg != 0);
|
||||||
RegisterManager::instance()[m_recording_reg] = ArrayView<String>(m_recorded_keys);
|
RegisterManager::instance()[m_recording_reg] = ConstArrayView<String>(m_recorded_keys);
|
||||||
m_recording_reg = 0;
|
m_recording_reg = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
// abort or validation with corresponding MenuEvent value
|
// abort or validation with corresponding MenuEvent value
|
||||||
// returns to normal mode after validation if callback does
|
// returns to normal mode after validation if callback does
|
||||||
// not change the mode itself
|
// not change the mode itself
|
||||||
void menu(ArrayView<String> choices, MenuCallback callback);
|
void menu(ArrayView<const String> choices, MenuCallback callback);
|
||||||
|
|
||||||
// execute callback on next keypress and returns to normal mode
|
// execute callback on next keypress and returns to normal mode
|
||||||
// if callback does not change the mode itself
|
// if callback does not change the mode itself
|
||||||
|
|
|
@ -23,7 +23,7 @@ bool KeymapManager::is_mapped(Key key, KeymapMode mode) const
|
||||||
(m_parent and m_parent->is_mapped(key, mode));
|
(m_parent and m_parent->is_mapped(key, mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayView<Key> KeymapManager::get_mapping(Key key, KeymapMode mode) const
|
ConstArrayView<Key> KeymapManager::get_mapping(Key key, KeymapMode mode) const
|
||||||
{
|
{
|
||||||
auto it = m_mapping.find({key, mode});
|
auto it = m_mapping.find({key, mode});
|
||||||
if (it != m_mapping.end())
|
if (it != m_mapping.end())
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef keymap_manager_hh_INCLUDED
|
#ifndef keymap_manager_hh_INCLUDED
|
||||||
#define keymap_manager_hh_INCLUDED
|
#define keymap_manager_hh_INCLUDED
|
||||||
|
|
||||||
|
#include "array_view.hh"
|
||||||
#include "keys.hh"
|
#include "keys.hh"
|
||||||
#include "hash.hh"
|
#include "hash.hh"
|
||||||
#include "unordered_map.hh"
|
#include "unordered_map.hh"
|
||||||
|
@ -21,8 +22,6 @@ enum class KeymapMode : int
|
||||||
User,
|
User,
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> class ArrayView;
|
|
||||||
|
|
||||||
class KeymapManager
|
class KeymapManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -33,7 +32,7 @@ public:
|
||||||
void unmap_key(Key key, KeymapMode mode);
|
void unmap_key(Key key, KeymapMode mode);
|
||||||
|
|
||||||
bool is_mapped(Key key, KeymapMode mode) const;
|
bool is_mapped(Key key, KeymapMode mode) const;
|
||||||
ArrayView<Key> get_mapping(Key key, KeymapMode mode) const;
|
ConstArrayView<Key> get_mapping(Key key, KeymapMode mode) const;
|
||||||
private:
|
private:
|
||||||
KeymapManager()
|
KeymapManager()
|
||||||
: m_parent(nullptr) {}
|
: m_parent(nullptr) {}
|
||||||
|
|
|
@ -314,7 +314,7 @@ int run_client(StringView session, StringView init_command)
|
||||||
}
|
}
|
||||||
|
|
||||||
int run_server(StringView session, StringView init_command,
|
int run_server(StringView session, StringView init_command,
|
||||||
bool ignore_kakrc, bool daemon, ArrayView<StringView> files)
|
bool ignore_kakrc, bool daemon, ConstArrayView<StringView> files)
|
||||||
{
|
{
|
||||||
static bool terminate = false;
|
static bool terminate = false;
|
||||||
if (daemon)
|
if (daemon)
|
||||||
|
@ -416,7 +416,7 @@ int run_server(StringView session, StringView init_command,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int run_filter(StringView keystr, ArrayView<StringView> files, bool quiet)
|
int run_filter(StringView keystr, ConstArrayView<StringView> files, bool quiet)
|
||||||
{
|
{
|
||||||
StringRegistry string_registry;
|
StringRegistry string_registry;
|
||||||
GlobalScope global_scope;
|
GlobalScope global_scope;
|
||||||
|
|
|
@ -564,7 +564,7 @@ void NCursesUI::draw_menu()
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NCursesUI::menu_show(ArrayView<String> items,
|
void NCursesUI::menu_show(ConstArrayView<String> items,
|
||||||
CharCoord anchor, Face fg, Face bg,
|
CharCoord anchor, Face fg, Face bg,
|
||||||
MenuStyle style)
|
MenuStyle style)
|
||||||
{
|
{
|
||||||
|
@ -714,7 +714,7 @@ static CharCoord compute_pos(CharCoord anchor, CharCoord size,
|
||||||
}
|
}
|
||||||
|
|
||||||
String make_info_box(StringView title, StringView message, CharCount max_width,
|
String make_info_box(StringView title, StringView message, CharCount max_width,
|
||||||
ArrayView<StringView> assistant)
|
ConstArrayView<StringView> assistant)
|
||||||
{
|
{
|
||||||
CharCoord assistant_size;
|
CharCoord assistant_size;
|
||||||
if (not assistant.empty())
|
if (not assistant.empty())
|
||||||
|
@ -851,7 +851,7 @@ void NCursesUI::set_ui_options(const Options& options)
|
||||||
else if (it->second == "clippy")
|
else if (it->second == "clippy")
|
||||||
m_assistant = assistant_clippy;
|
m_assistant = assistant_clippy;
|
||||||
else if (it->second == "none" or it->second == "off")
|
else if (it->second == "none" or it->second == "off")
|
||||||
m_assistant = ArrayView<StringView>{};
|
m_assistant = ConstArrayView<StringView>{};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
bool is_key_available() override;
|
bool is_key_available() override;
|
||||||
Key get_key() override;
|
Key get_key() override;
|
||||||
|
|
||||||
void menu_show(ArrayView<String> items,
|
void menu_show(ConstArrayView<String> items,
|
||||||
CharCoord anchor, Face fg, Face bg,
|
CharCoord anchor, Face fg, Face bg,
|
||||||
MenuStyle style) override;
|
MenuStyle style) override;
|
||||||
void menu_select(int selected) override;
|
void menu_select(int selected) override;
|
||||||
|
@ -73,7 +73,7 @@ private:
|
||||||
InputCallback m_input_callback;
|
InputCallback m_input_callback;
|
||||||
|
|
||||||
bool m_status_on_top = false;
|
bool m_status_on_top = false;
|
||||||
ArrayView<StringView> m_assistant;
|
ConstArrayView<StringView> m_assistant;
|
||||||
|
|
||||||
bool m_dirty = false;
|
bool m_dirty = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1079,7 +1079,7 @@ void replay_macro(Context& context, NormalParams params)
|
||||||
if (running_macros[idx])
|
if (running_macros[idx])
|
||||||
throw runtime_error("recursive macros call detected");
|
throw runtime_error("recursive macros call detected");
|
||||||
|
|
||||||
ArrayView<String> reg_val = RegisterManager::instance()[name].values(context);
|
ConstArrayView<String> reg_val = RegisterManager::instance()[name].values(context);
|
||||||
if (not reg_val.empty())
|
if (not reg_val.empty())
|
||||||
{
|
{
|
||||||
running_macros[idx] = true;
|
running_macros[idx] = true;
|
||||||
|
|
|
@ -109,7 +109,7 @@ struct TupleOptionDetail
|
||||||
tuple_separator + escape(option_to_string(std::get<I>(opt)), tuple_separator, '\\');
|
tuple_separator + escape(option_to_string(std::get<I>(opt)), tuple_separator, '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
static void from_string(ArrayView<String> elems, std::tuple<Types...>& opt)
|
static void from_string(ConstArrayView<String> elems, std::tuple<Types...>& opt)
|
||||||
{
|
{
|
||||||
option_from_string(elems[I], std::get<I>(opt));
|
option_from_string(elems[I], std::get<I>(opt));
|
||||||
TupleOptionDetail<I-1, Types...>::from_string(elems, opt);
|
TupleOptionDetail<I-1, Types...>::from_string(elems, opt);
|
||||||
|
@ -124,7 +124,7 @@ struct TupleOptionDetail<0, Types...>
|
||||||
return option_to_string(std::get<0>(opt));
|
return option_to_string(std::get<0>(opt));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void from_string(ArrayView<String> elems, std::tuple<Types...>& opt)
|
static void from_string(ConstArrayView<String> elems, std::tuple<Types...>& opt)
|
||||||
{
|
{
|
||||||
option_from_string(elems[0], std::get<0>(opt));
|
option_from_string(elems[0], std::get<0>(opt));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
|
||||||
using ParameterList = ArrayView<String>;
|
using ParameterList = ConstArrayView<String>;
|
||||||
|
|
||||||
struct parameter_error : public runtime_error
|
struct parameter_error : public runtime_error
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,9 +13,9 @@ class Register
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Register() {}
|
virtual ~Register() {}
|
||||||
virtual Register& operator=(ArrayView<String> values) = 0;
|
virtual Register& operator=(ConstArrayView<String> values) = 0;
|
||||||
|
|
||||||
virtual ArrayView<String> values(const Context& context) = 0;
|
virtual ConstArrayView<String> values(const Context& context) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,18 +12,18 @@ namespace Kakoune
|
||||||
class StaticRegister : public Register
|
class StaticRegister : public Register
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Register& operator=(ArrayView<String> values) override
|
Register& operator=(ConstArrayView<String> values) override
|
||||||
{
|
{
|
||||||
m_content = Vector<String, MemoryDomain::Registers>(values.begin(), values.end());
|
m_content = Vector<String, MemoryDomain::Registers>(values.begin(), values.end());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayView<String> values(const Context&) override
|
ConstArrayView<String> values(const Context&) override
|
||||||
{
|
{
|
||||||
if (m_content.empty())
|
if (m_content.empty())
|
||||||
return ArrayView<String>(ms_empty);
|
return ConstArrayView<String>(ms_empty);
|
||||||
else
|
else
|
||||||
return ArrayView<String>(m_content);
|
return ConstArrayView<String>(m_content);
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
Vector<String, MemoryDomain::Registers> m_content;
|
Vector<String, MemoryDomain::Registers> m_content;
|
||||||
|
@ -41,12 +41,12 @@ public:
|
||||||
DynamicRegister(RegisterRetriever function)
|
DynamicRegister(RegisterRetriever function)
|
||||||
: m_function(std::move(function)) {}
|
: m_function(std::move(function)) {}
|
||||||
|
|
||||||
Register& operator=(ArrayView<String> values) override
|
Register& operator=(ConstArrayView<String> values) override
|
||||||
{
|
{
|
||||||
throw runtime_error("this register is not assignable");
|
throw runtime_error("this register is not assignable");
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayView<String> values(const Context& context) override
|
ConstArrayView<String> values(const Context& context) override
|
||||||
{
|
{
|
||||||
m_content = m_function(context);
|
m_content = m_function(context);
|
||||||
return StaticRegister::values(context);
|
return StaticRegister::values(context);
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void write(ArrayView<T> view)
|
void write(ConstArrayView<T> view)
|
||||||
{
|
{
|
||||||
write<uint32_t>(view.size());
|
write<uint32_t>(view.size());
|
||||||
for (auto& val : view)
|
for (auto& val : view)
|
||||||
|
@ -78,7 +78,7 @@ public:
|
||||||
template<typename T, MemoryDomain domain>
|
template<typename T, MemoryDomain domain>
|
||||||
void write(const Vector<T, domain>& vec)
|
void write(const Vector<T, domain>& vec)
|
||||||
{
|
{
|
||||||
write(ArrayView<T>(vec));
|
write(ConstArrayView<T>(vec));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Key, typename Val, MemoryDomain domain>
|
template<typename Key, typename Val, MemoryDomain domain>
|
||||||
|
@ -249,7 +249,7 @@ public:
|
||||||
RemoteUI(int socket);
|
RemoteUI(int socket);
|
||||||
~RemoteUI();
|
~RemoteUI();
|
||||||
|
|
||||||
void menu_show(ArrayView<String> choices,
|
void menu_show(ConstArrayView<String> choices,
|
||||||
CharCoord anchor, Face fg, Face bg,
|
CharCoord anchor, Face fg, Face bg,
|
||||||
MenuStyle style) override;
|
MenuStyle style) override;
|
||||||
void menu_select(int selected) override;
|
void menu_select(int selected) override;
|
||||||
|
@ -298,7 +298,7 @@ RemoteUI::~RemoteUI()
|
||||||
m_socket_watcher.close_fd();
|
m_socket_watcher.close_fd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteUI::menu_show(ArrayView<String> choices,
|
void RemoteUI::menu_show(ConstArrayView<String> choices,
|
||||||
CharCoord anchor, Face fg, Face bg,
|
CharCoord anchor, Face fg, Face bg,
|
||||||
MenuStyle style)
|
MenuStyle style)
|
||||||
{
|
{
|
||||||
|
|
|
@ -196,7 +196,7 @@ const Buffer::Change* backward_sorted_until(const Buffer::Change* first, const B
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_forward(ArrayView<Buffer::Change> changes, Vector<Selection>& selections, size_t& main)
|
void update_forward(ConstArrayView<Buffer::Change> changes, Vector<Selection>& selections, size_t& main)
|
||||||
{
|
{
|
||||||
ForwardChangesTracker changes_tracker;
|
ForwardChangesTracker changes_tracker;
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ void update_forward(ArrayView<Buffer::Change> changes, Vector<Selection>& select
|
||||||
kak_assert(std::is_sorted(selections.begin(), selections.end(), compare_selections));
|
kak_assert(std::is_sorted(selections.begin(), selections.end(), compare_selections));
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_backward(ArrayView<Buffer::Change> changes, Vector<Selection>& selections, size_t& main)
|
void update_backward(ConstArrayView<Buffer::Change> changes, Vector<Selection>& selections, size_t& main)
|
||||||
{
|
{
|
||||||
ForwardChangesTracker changes_tracker;
|
ForwardChangesTracker changes_tracker;
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ BufferIterator prepare_insert(Buffer& buffer, const Selection& sel, InsertMode m
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectionList::insert(ArrayView<String> strings, InsertMode mode,
|
void SelectionList::insert(ConstArrayView<String> strings, InsertMode mode,
|
||||||
bool select_inserted)
|
bool select_inserted)
|
||||||
{
|
{
|
||||||
if (strings.empty())
|
if (strings.empty())
|
||||||
|
|
|
@ -128,7 +128,7 @@ struct SelectionList
|
||||||
size_t timestamp() const { return m_timestamp; }
|
size_t timestamp() const { return m_timestamp; }
|
||||||
void update_timestamp() { m_timestamp = m_buffer->timestamp(); }
|
void update_timestamp() { m_timestamp = m_buffer->timestamp(); }
|
||||||
|
|
||||||
void insert(ArrayView<String> strings, InsertMode mode,
|
void insert(ConstArrayView<String> strings, InsertMode mode,
|
||||||
bool select_inserted = false);
|
bool select_inserted = false);
|
||||||
void erase();
|
void erase();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ ShellManager::ShellManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
String ShellManager::eval(StringView cmdline, const Context& context,
|
String ShellManager::eval(StringView cmdline, const Context& context,
|
||||||
ArrayView<String> params,
|
ConstArrayView<String> params,
|
||||||
const EnvVarMap& env_vars,
|
const EnvVarMap& env_vars,
|
||||||
int* exit_status)
|
int* exit_status)
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ String ShellManager::eval(StringView cmdline, const Context& context,
|
||||||
|
|
||||||
String ShellManager::pipe(StringView input,
|
String ShellManager::pipe(StringView input,
|
||||||
StringView cmdline, const Context& context,
|
StringView cmdline, const Context& context,
|
||||||
ArrayView<String> params,
|
ConstArrayView<String> params,
|
||||||
const EnvVarMap& env_vars,
|
const EnvVarMap& env_vars,
|
||||||
int* exit_status)
|
int* exit_status)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef shell_manager_hh_INCLUDED
|
#ifndef shell_manager_hh_INCLUDED
|
||||||
#define shell_manager_hh_INCLUDED
|
#define shell_manager_hh_INCLUDED
|
||||||
|
|
||||||
|
#include "array_view.hh"
|
||||||
#include "regex.hh"
|
#include "regex.hh"
|
||||||
#include "utils.hh"
|
#include "utils.hh"
|
||||||
#include "env_vars.hh"
|
#include "env_vars.hh"
|
||||||
|
@ -9,7 +10,6 @@ namespace Kakoune
|
||||||
{
|
{
|
||||||
|
|
||||||
class Context;
|
class Context;
|
||||||
template<typename T> class ArrayView;
|
|
||||||
class String;
|
class String;
|
||||||
class StringView;
|
class StringView;
|
||||||
|
|
||||||
|
@ -21,13 +21,13 @@ public:
|
||||||
ShellManager();
|
ShellManager();
|
||||||
|
|
||||||
String eval(StringView cmdline, const Context& context,
|
String eval(StringView cmdline, const Context& context,
|
||||||
ArrayView<String> params,
|
ConstArrayView<String> params,
|
||||||
const EnvVarMap& env_vars,
|
const EnvVarMap& env_vars,
|
||||||
int* exit_status = nullptr);
|
int* exit_status = nullptr);
|
||||||
|
|
||||||
String pipe(StringView input,
|
String pipe(StringView input,
|
||||||
StringView cmdline, const Context& context,
|
StringView cmdline, const Context& context,
|
||||||
ArrayView<String> params,
|
ConstArrayView<String> params,
|
||||||
const EnvVarMap& env_vars,
|
const EnvVarMap& env_vars,
|
||||||
int* exit_status = nullptr);
|
int* exit_status = nullptr);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef user_interface_hh_INCLUDED
|
#ifndef user_interface_hh_INCLUDED
|
||||||
#define user_interface_hh_INCLUDED
|
#define user_interface_hh_INCLUDED
|
||||||
|
|
||||||
|
#include "array_view.hh"
|
||||||
#include "safe_ptr.hh"
|
#include "safe_ptr.hh"
|
||||||
#include "unordered_map.hh"
|
#include "unordered_map.hh"
|
||||||
|
|
||||||
|
@ -15,7 +16,6 @@ class DisplayLine;
|
||||||
struct CharCoord;
|
struct CharCoord;
|
||||||
struct Face;
|
struct Face;
|
||||||
struct Key;
|
struct Key;
|
||||||
template<typename T> class ArrayView;
|
|
||||||
|
|
||||||
enum class MenuStyle
|
enum class MenuStyle
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@ class UserInterface : public SafeCountable
|
||||||
public:
|
public:
|
||||||
virtual ~UserInterface() {}
|
virtual ~UserInterface() {}
|
||||||
|
|
||||||
virtual void menu_show(ArrayView<String> choices,
|
virtual void menu_show(ConstArrayView<String> choices,
|
||||||
CharCoord anchor, Face fg, Face bg,
|
CharCoord anchor, Face fg, Face bg,
|
||||||
MenuStyle style) = 0;
|
MenuStyle style) = 0;
|
||||||
virtual void menu_select(int selected) = 0;
|
virtual void menu_select(int selected) = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user