Rename memoryview to ArrayView

This commit is contained in:
Maxime Coste 2015-01-06 13:40:56 +00:00
parent 8e92e0eebc
commit 295a97f2a6
29 changed files with 82 additions and 82 deletions

View File

@ -1,5 +1,5 @@
#ifndef memoryview_hh_INCLUDED #ifndef array_view_hh_INCLUDED
#define memoryview_hh_INCLUDED #define array_view_hh_INCLUDED
#include <vector> #include <vector>
#include <initializer_list> #include <initializer_list>
@ -7,34 +7,34 @@
namespace Kakoune namespace Kakoune
{ {
// A memoryview provides a typed, non owning view of a memory // An ArrayView provides a typed, non owning view of a memory
// range with an interface similar to std::vector. // range with an interface similar to std::vector.
template<typename T> template<typename T>
class memoryview class ArrayView
{ {
public: public:
using size_t = std::size_t; using size_t = std::size_t;
memoryview() ArrayView()
: m_pointer(nullptr), m_size(0) {} : m_pointer(nullptr), m_size(0) {}
memoryview(const T& oneval) ArrayView(const T& oneval)
: m_pointer(&oneval), m_size(1) {} : m_pointer(&oneval), m_size(1) {}
memoryview(const T* pointer, size_t size) ArrayView(const T* pointer, size_t size)
: m_pointer(pointer), m_size(size) {} : m_pointer(pointer), m_size(size) {}
memoryview(const T* begin, const T* end) ArrayView(const T* begin, const T* end)
: m_pointer(begin), m_size(end - begin) {} : m_pointer(begin), m_size(end - begin) {}
template<typename Iterator> template<typename Iterator>
memoryview(const Iterator& begin, const Iterator& end) ArrayView(const Iterator& begin, const Iterator& end)
: m_pointer(&(*begin)), m_size(end - begin) {} : m_pointer(&(*begin)), m_size(end - begin) {}
memoryview(const std::vector<T>& v) ArrayView(const std::vector<T>& v)
: m_pointer(&v[0]), m_size(v.size()) {} : m_pointer(&v[0]), m_size(v.size()) {}
memoryview(const std::initializer_list<T>& v) ArrayView(const std::initializer_list<T>& v)
: m_pointer(v.begin()), m_size(v.size()) {} : m_pointer(v.begin()), m_size(v.size()) {}
const T* pointer() const { return m_pointer; } const T* pointer() const { return m_pointer; }
@ -53,9 +53,9 @@ public:
bool empty() const { return m_size == 0; } bool empty() const { return m_size == 0; }
memoryview subrange(size_t first, size_t count) const ArrayView subrange(size_t first, size_t count) const
{ {
return memoryview(m_pointer + first, count); return ArrayView(m_pointer + first, count);
} }
private: private:
@ -65,4 +65,4 @@ private:
} }
#endif // memoryview_hh_INCLUDED #endif // array_view_hh_INCLUDED

View File

@ -160,7 +160,7 @@ public:
ByteCoord end; ByteCoord end;
bool at_end; bool at_end;
}; };
memoryview<Change> changes_since(size_t timestamp) const; ArrayView<Change> changes_since(size_t timestamp) const;
String debug_description() const; String debug_description() const;
private: private:

View File

@ -92,7 +92,7 @@ inline size_t Buffer::timestamp() const
return m_changes.size(); return m_changes.size();
} }
inline memoryview<Buffer::Change> Buffer::changes_since(size_t timestamp) const inline ArrayView<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() };

View File

@ -268,11 +268,11 @@ TokenList parse(StringView line)
} }
String eval_token(const Token& token, Context& context, String eval_token(const Token& token, Context& context,
memoryview<String> shell_params, ArrayView<String> shell_params,
const EnvVarMap& env_vars); const EnvVarMap& env_vars);
String eval(StringView str, Context& context, String eval(StringView str, Context& context,
memoryview<String> shell_params, ArrayView<String> shell_params,
const EnvVarMap& env_vars) const EnvVarMap& env_vars)
{ {
String res; String res;
@ -301,7 +301,7 @@ String eval(StringView str, Context& context,
} }
String eval_token(const Token& token, Context& context, String eval_token(const Token& token, Context& context,
memoryview<String> shell_params, ArrayView<String> shell_params,
const EnvVarMap& env_vars) const EnvVarMap& env_vars)
{ {
auto& content = token.content(); auto& content = token.content();
@ -354,7 +354,7 @@ void CommandManager::execute_single_command(CommandParameters params,
if (params.empty()) if (params.empty())
return; return;
memoryview<String> param_view(params.begin()+1, params.end()); ArrayView<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]);
@ -394,7 +394,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,
memoryview<String> shell_params, ArrayView<String> shell_params,
const EnvVarMap& env_vars) const EnvVarMap& env_vars)
{ {
TokenList tokens = parse<true>(command_line); TokenList tokens = parse<true>(command_line);

View File

@ -4,7 +4,7 @@
#include "coord.hh" #include "coord.hh"
#include "completion.hh" #include "completion.hh"
#include "flags.hh" #include "flags.hh"
#include "memoryview.hh" #include "array_view.hh"
#include "shell_manager.hh" #include "shell_manager.hh"
#include "parameters_parser.hh" #include "parameters_parser.hh"
#include "string.hh" #include "string.hh"
@ -18,7 +18,7 @@ namespace Kakoune
{ {
class Context; class Context;
using CommandParameters = memoryview<String>; using CommandParameters = ArrayView<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,
@ -38,7 +38,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 = memoryview<ArgumentCompleter>; using ArgumentCompleterList = ArrayView<ArgumentCompleter>;
PerArgumentCommandCompleter(ArgumentCompleterList completers) PerArgumentCommandCompleter(ArgumentCompleterList completers)
: m_completers(completers.begin(), completers.end()) {} : m_completers(completers.begin(), completers.end()) {}
@ -59,7 +59,7 @@ class CommandManager : public Singleton<CommandManager>
{ {
public: public:
void execute(StringView command_line, Context& context, void execute(StringView command_line, Context& context,
memoryview<String> shell_params = {}, ArrayView<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,

View File

@ -1185,7 +1185,7 @@ const CommandDesc prompt_cmd = {
{ {
if (event != PromptEvent::Validate) if (event != PromptEvent::Validate)
return; return;
RegisterManager::instance()[reg] = memoryview<String>(str); RegisterManager::instance()[reg] = ArrayView<String>(str);
CommandManager::instance().execute(command, context); CommandManager::instance().execute(command, context);
}); });
@ -1361,7 +1361,7 @@ const CommandDesc set_register_cmd = {
CommandCompleter{}, CommandCompleter{},
[](const ParametersParser& parser, Context& context) [](const ParametersParser& parser, Context& context)
{ {
RegisterManager::instance()[parser[0]] = memoryview<String>(parser[1]); RegisterManager::instance()[parser[0]] = ArrayView<String>(parser[1]);
} }
}; };
@ -1385,7 +1385,7 @@ public:
RegisterRestorer(char name, const Context& context) RegisterRestorer(char name, const Context& context)
: m_name(name) : m_name(name)
{ {
memoryview<String> save = RegisterManager::instance()[name].values(context); ArrayView<String> save = RegisterManager::instance()[name].values(context);
m_save = std::vector<String>(save.begin(), save.end()); m_save = std::vector<String>(save.begin(), save.end());
} }
@ -1399,7 +1399,7 @@ private:
} }
void exec_keys(memoryview<Key> keys, Context& context) void exec_keys(ArrayView<Key> keys, Context& context)
{ {
RegisterRestorer quote('"', context); RegisterRestorer quote('"', context);
RegisterRestorer slash('/', context); RegisterRestorer slash('/', context);

View File

@ -2,7 +2,7 @@
#define commands_hh_INCLUDED #define commands_hh_INCLUDED
#include "keys.hh" #include "keys.hh"
#include "memoryview.hh" #include "array_view.hh"
namespace Kakoune namespace Kakoune
{ {
@ -10,7 +10,7 @@ namespace Kakoune
class Context; class Context;
void register_commands(); void register_commands();
void exec_keys(memoryview<Key> keys, Context& context); void exec_keys(ArrayView<Key> keys, Context& context);
} }

View File

@ -230,7 +230,7 @@ void write_buffer_to_backup_file(Buffer& buffer)
} }
} }
String find_file(StringView filename, memoryview<String> paths) String find_file(StringView filename, ArrayView<String> paths)
{ {
struct stat buf; struct stat buf;
if (filename.length() > 1 and filename[0] == '/') if (filename.length() > 1 and filename[0] == '/')

View File

@ -22,7 +22,7 @@ struct file_not_found : file_access_error
}; };
class Buffer; class Buffer;
template<typename T> class memoryview; template<typename T> class ArrayView;
class String; class String;
class StringView; class StringView;
@ -42,7 +42,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, memoryview<String> paths); String find_file(StringView filename, ArrayView<String> paths);
time_t get_fs_timestamp(StringView filename); time_t get_fs_timestamp(StringView filename);

View File

@ -5,7 +5,7 @@
#include "completion.hh" #include "completion.hh"
#include "exception.hh" #include "exception.hh"
#include "id_map.hh" #include "id_map.hh"
#include "memoryview.hh" #include "array_view.hh"
#include "string.hh" #include "string.hh"
#include "utils.hh" #include "utils.hh"
@ -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 = memoryview<String>; using HighlighterParameters = ArrayView<String>;
using HighlighterFactory = std::function<HighlighterAndId (HighlighterParameters params)>; using HighlighterFactory = std::function<HighlighterAndId (HighlighterParameters params)>;
struct HighlighterRegistry : IdMap<HighlighterFactory>, struct HighlighterRegistry : IdMap<HighlighterFactory>,

View File

@ -733,7 +733,7 @@ void find_matches(const Buffer& buffer, RegexMatchList& matches, const Regex& re
} }
} }
void update_matches(const Buffer& buffer, memoryview<LineModification> modifs, void update_matches(const Buffer& buffer, ArrayView<LineModification> modifs,
RegexMatchList& matches, const Regex& regex) RegexMatchList& matches, const Regex& regex)
{ {
const size_t buf_timestamp = buffer.timestamp(); const size_t buf_timestamp = buffer.timestamp();
@ -857,7 +857,7 @@ struct RegionDesc
} }
void update_matches(const Buffer& buffer, void update_matches(const Buffer& buffer,
memoryview<LineModification> modifs, ArrayView<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);

View File

@ -340,7 +340,7 @@ private:
class Menu : public InputMode class Menu : public InputMode
{ {
public: public:
Menu(InputHandler& input_handler, memoryview<String> choices, Menu(InputHandler& input_handler, ArrayView<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()),
@ -458,7 +458,7 @@ private:
LineEditor m_filter_editor; LineEditor m_filter_editor;
}; };
String common_prefix(memoryview<String> strings) String common_prefix(ArrayView<String> strings)
{ {
String res; String res;
if (strings.empty()) if (strings.empty())
@ -925,7 +925,7 @@ private:
selections.sort_and_merge_overlapping(); selections.sort_and_merge_overlapping();
} }
void insert(memoryview<String> strings) void insert(ArrayView<String> strings)
{ {
context().selections().insert(strings, InsertMode::InsertCursor); context().selections().insert(strings, InsertMode::InsertCursor);
} }
@ -1093,7 +1093,7 @@ void InputHandler::set_prompt_face(Face prompt_face)
prompt->set_prompt_face(prompt_face); prompt->set_prompt_face(prompt_face);
} }
void InputHandler::menu(memoryview<String> choices, void InputHandler::menu(ArrayView<String> choices,
MenuCallback callback) MenuCallback callback)
{ {
change_input_mode(new InputModes::Menu(*this, choices, callback)); change_input_mode(new InputModes::Menu(*this, choices, callback));
@ -1150,7 +1150,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] = memoryview<String>(m_recorded_keys); RegisterManager::instance()[m_recording_reg] = ArrayView<String>(m_recorded_keys);
m_recording_reg = 0; m_recording_reg = 0;
} }

View File

@ -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(memoryview<String> choices, MenuCallback callback); void menu(ArrayView<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

View File

@ -1,6 +1,6 @@
#include "keymap_manager.hh" #include "keymap_manager.hh"
#include "memoryview.hh" #include "array_view.hh"
#include "assert.hh" #include "assert.hh"
namespace Kakoune namespace Kakoune
@ -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));
} }
memoryview<Key> KeymapManager::get_mapping(Key key, KeymapMode mode) const ArrayView<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())

View File

@ -22,7 +22,7 @@ enum class KeymapMode : int
User, User,
}; };
template<typename T> class memoryview; template<typename T> class ArrayView;
class KeymapManager class KeymapManager
{ {
@ -34,7 +34,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;
memoryview<Key> get_mapping(Key key, KeymapMode mode) const; ArrayView<Key> get_mapping(Key key, KeymapMode mode) const;
private: private:
KeymapManager() KeymapManager()
: m_parent(nullptr) {} : m_parent(nullptr) {}

View File

@ -311,7 +311,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, memoryview<StringView> files) bool ignore_kakrc, bool daemon, ArrayView<StringView> files)
{ {
static bool terminate = false; static bool terminate = false;
if (daemon) if (daemon)
@ -412,7 +412,7 @@ int run_server(StringView session, StringView init_command,
return 0; return 0;
} }
int run_filter(StringView keystr, memoryview<StringView> files, bool quiet) int run_filter(StringView keystr, ArrayView<StringView> files, bool quiet)
{ {
StringRegistry string_registry; StringRegistry string_registry;
GlobalScope global_scope; GlobalScope global_scope;

View File

@ -540,7 +540,7 @@ void NCursesUI::draw_menu()
m_dirty = true; m_dirty = true;
} }
void NCursesUI::menu_show(memoryview<String> items, void NCursesUI::menu_show(ArrayView<String> items,
CharCoord anchor, Face fg, Face bg, CharCoord anchor, Face fg, Face bg,
MenuStyle style) MenuStyle style)
{ {

View File

@ -27,7 +27,7 @@ public:
bool is_key_available() override; bool is_key_available() override;
Key get_key() override; Key get_key() override;
void menu_show(memoryview<String> items, void menu_show(ArrayView<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;

View File

@ -1049,7 +1049,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");
memoryview<String> reg_val = RegisterManager::instance()[name].values(context); ArrayView<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;

View File

@ -5,7 +5,7 @@
#include "string.hh" #include "string.hh"
#include "units.hh" #include "units.hh"
#include "coord.hh" #include "coord.hh"
#include "memoryview.hh" #include "array_view.hh"
#include "unordered_map.hh" #include "unordered_map.hh"
#include <tuple> #include <tuple>
@ -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(memoryview<String> elems, std::tuple<Types...>& opt) static void from_string(ArrayView<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(memoryview<String> elems, std::tuple<Types...>& opt) static void from_string(ArrayView<String> elems, std::tuple<Types...>& opt)
{ {
option_from_string(elems[0], std::get<0>(opt)); option_from_string(elems[0], std::get<0>(opt));
} }

View File

@ -3,14 +3,14 @@
#include "exception.hh" #include "exception.hh"
#include "id_map.hh" #include "id_map.hh"
#include "memoryview.hh" #include "array_view.hh"
#include "flags.hh" #include "flags.hh"
#include "string.hh" #include "string.hh"
namespace Kakoune namespace Kakoune
{ {
using ParameterList = memoryview<String>; using ParameterList = ArrayView<String>;
struct parameter_error : public runtime_error struct parameter_error : public runtime_error
{ {

View File

@ -1,7 +1,7 @@
#ifndef register_hh_INCLUDED #ifndef register_hh_INCLUDED
#define register_hh_INCLUDED #define register_hh_INCLUDED
#include "memoryview.hh" #include "array_view.hh"
#include "string.hh" #include "string.hh"
namespace Kakoune namespace Kakoune
@ -13,9 +13,9 @@ class Register
{ {
public: public:
virtual ~Register() {} virtual ~Register() {}
virtual Register& operator=(memoryview<String> values) = 0; virtual Register& operator=(ArrayView<String> values) = 0;
virtual memoryview<String> values(const Context& context) = 0; virtual ArrayView<String> values(const Context& context) = 0;
}; };
} }

View File

@ -12,18 +12,18 @@ namespace Kakoune
class StaticRegister : public Register class StaticRegister : public Register
{ {
public: public:
Register& operator=(memoryview<String> values) override Register& operator=(ArrayView<String> values) override
{ {
m_content = std::vector<String>(values.begin(), values.end()); m_content = std::vector<String>(values.begin(), values.end());
return *this; return *this;
} }
memoryview<String> values(const Context&) override ArrayView<String> values(const Context&) override
{ {
if (m_content.empty()) if (m_content.empty())
return memoryview<String>(ms_empty); return ArrayView<String>(ms_empty);
else else
return memoryview<String>(m_content); return ArrayView<String>(m_content);
} }
protected: protected:
std::vector<String> m_content; std::vector<String> 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=(memoryview<String> values) override Register& operator=(ArrayView<String> values) override
{ {
throw runtime_error("this register is not assignable"); throw runtime_error("this register is not assignable");
} }
memoryview<String> values(const Context& context) override ArrayView<String> values(const Context& context) override
{ {
m_content = m_function(context); m_content = m_function(context);
return StaticRegister::values(context); return StaticRegister::values(context);

View File

@ -68,7 +68,7 @@ public:
} }
template<typename T> template<typename T>
void write(memoryview<T> view) void write(ArrayView<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> template<typename T>
void write(const std::vector<T>& vec) void write(const std::vector<T>& vec)
{ {
write(memoryview<T>(vec)); write(ArrayView<T>(vec));
} }
template<typename Key, typename Val> template<typename Key, typename Val>
@ -249,7 +249,7 @@ public:
RemoteUI(int socket); RemoteUI(int socket);
~RemoteUI(); ~RemoteUI();
void menu_show(memoryview<String> choices, void menu_show(ArrayView<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(memoryview<String> choices, void RemoteUI::menu_show(ArrayView<String> choices,
CharCoord anchor, Face fg, Face bg, CharCoord anchor, Face fg, Face bg,
MenuStyle style) MenuStyle style)
{ {

View File

@ -196,7 +196,7 @@ const Buffer::Change* backward_sorted_until(const Buffer::Change* first, const B
return last; return last;
} }
void update_forward(memoryview<Buffer::Change> changes, std::vector<Selection>& selections, size_t& main) void update_forward(ArrayView<Buffer::Change> changes, std::vector<Selection>& selections, size_t& main)
{ {
ForwardChangesTracker changes_tracker; ForwardChangesTracker changes_tracker;
@ -221,7 +221,7 @@ void update_forward(memoryview<Buffer::Change> changes, std::vector<Selection>&
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(memoryview<Buffer::Change> changes, std::vector<Selection>& selections, size_t& main) void update_backward(ArrayView<Buffer::Change> changes, std::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(memoryview<String> strings, InsertMode mode, void SelectionList::insert(ArrayView<String> strings, InsertMode mode,
bool select_inserted) bool select_inserted)
{ {
if (strings.empty()) if (strings.empty())

View File

@ -124,7 +124,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(memoryview<String> strings, InsertMode mode, void insert(ArrayView<String> strings, InsertMode mode,
bool select_inserted = false); bool select_inserted = false);
void erase(); void erase();

View File

@ -29,7 +29,7 @@ ShellManager::ShellManager()
} }
String ShellManager::eval(StringView cmdline, const Context& context, String ShellManager::eval(StringView cmdline, const Context& context,
memoryview<String> params, ArrayView<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,
memoryview<String> params, ArrayView<String> params,
const EnvVarMap& env_vars, const EnvVarMap& env_vars,
int* exit_status) int* exit_status)
{ {

View File

@ -9,7 +9,7 @@ namespace Kakoune
{ {
class Context; class Context;
template<typename T> class memoryview; 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,
memoryview<String> params, ArrayView<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,
memoryview<String> params, ArrayView<String> params,
const EnvVarMap& env_vars, const EnvVarMap& env_vars,
int* exit_status = nullptr); int* exit_status = nullptr);

View File

@ -15,7 +15,7 @@ class DisplayLine;
struct CharCoord; struct CharCoord;
struct Face; struct Face;
struct Key; struct Key;
template<typename T> class memoryview; 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(memoryview<String> choices, virtual void menu_show(ArrayView<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;