move more parameters from const String& to StringView
This commit is contained in:
parent
9a2822e329
commit
c04dfc7bb7
|
@ -35,7 +35,7 @@ namespace Kakoune
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
Buffer* open_fifo(const String& name , const String& filename, bool scroll)
|
Buffer* open_fifo(StringView name, StringView filename, bool scroll)
|
||||||
{
|
{
|
||||||
int fd = open(parse_filename(filename).c_str(), O_RDONLY);
|
int fd = open(parse_filename(filename).c_str(), O_RDONLY);
|
||||||
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||||
|
@ -44,7 +44,7 @@ Buffer* open_fifo(const String& name , const String& filename, bool scroll)
|
||||||
|
|
||||||
BufferManager::instance().delete_buffer_if_exists(name);
|
BufferManager::instance().delete_buffer_if_exists(name);
|
||||||
|
|
||||||
return create_fifo_buffer(std::move(name), fd, scroll);
|
return create_fifo_buffer(name, fd, scroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -1163,7 +1163,7 @@ const CommandDesc prompt_cmd = {
|
||||||
|
|
||||||
context.input_handler().prompt(
|
context.input_handler().prompt(
|
||||||
params[0], std::move(initstr), get_face("Prompt"), Completer{},
|
params[0], std::move(initstr), get_face("Prompt"), Completer{},
|
||||||
[=](const String& str, PromptEvent event, Context& context)
|
[=](StringView str, PromptEvent event, Context& context)
|
||||||
{
|
{
|
||||||
if (event != PromptEvent::Validate)
|
if (event != PromptEvent::Validate)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -474,7 +474,7 @@ void history_push(std::vector<String>& history, StringView entry)
|
||||||
class Prompt : public InputMode
|
class Prompt : public InputMode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Prompt(InputHandler& input_handler, const String& prompt,
|
Prompt(InputHandler& input_handler, StringView prompt,
|
||||||
String initstr, Face face, Completer completer,
|
String initstr, Face face, Completer completer,
|
||||||
PromptCallback callback)
|
PromptCallback callback)
|
||||||
: InputMode(input_handler), m_prompt(prompt), m_prompt_face(face),
|
: InputMode(input_handler), m_prompt(prompt), m_prompt_face(face),
|
||||||
|
@ -1058,7 +1058,7 @@ void InputHandler::repeat_last_insert()
|
||||||
kak_assert(dynamic_cast<InputModes::Normal*>(m_mode.get()) != nullptr);
|
kak_assert(dynamic_cast<InputModes::Normal*>(m_mode.get()) != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputHandler::prompt(const String& prompt, String initstr,
|
void InputHandler::prompt(StringView prompt, String initstr,
|
||||||
Face prompt_face, Completer completer,
|
Face prompt_face, Completer completer,
|
||||||
PromptCallback callback)
|
PromptCallback callback)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@ enum class PromptEvent
|
||||||
Abort,
|
Abort,
|
||||||
Validate
|
Validate
|
||||||
};
|
};
|
||||||
using PromptCallback = std::function<void (const String&, PromptEvent, Context&)>;
|
using PromptCallback = std::function<void (StringView, PromptEvent, Context&)>;
|
||||||
using KeyCallback = std::function<void (Key, Context&)>;
|
using KeyCallback = std::function<void (Key, Context&)>;
|
||||||
|
|
||||||
class InputMode;
|
class InputMode;
|
||||||
|
@ -50,7 +50,7 @@ public:
|
||||||
// abort or validation with corresponding PromptEvent value
|
// abort or validation with corresponding PromptEvent 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 prompt(const String& prompt, String initstr,
|
void prompt(StringView prompt, String initstr,
|
||||||
Face prompt_face, Completer completer,
|
Face prompt_face, Completer completer,
|
||||||
PromptCallback callback);
|
PromptCallback callback);
|
||||||
void set_prompt_face(Face prompt_face);
|
void set_prompt_face(Face prompt_face);
|
||||||
|
|
|
@ -355,7 +355,7 @@ void command(Context& context, int)
|
||||||
context.input_handler().prompt(
|
context.input_handler().prompt(
|
||||||
":", "", get_face("Prompt"),
|
":", "", get_face("Prompt"),
|
||||||
std::bind(&CommandManager::complete, &CommandManager::instance(), _1, _2, _3, _4),
|
std::bind(&CommandManager::complete, &CommandManager::instance(), _1, _2, _3, _4),
|
||||||
[](const String& cmdline, PromptEvent event, Context& context) {
|
[](StringView cmdline, PromptEvent event, Context& context) {
|
||||||
if (context.has_ui())
|
if (context.has_ui())
|
||||||
{
|
{
|
||||||
context.ui().info_hide();
|
context.ui().info_hide();
|
||||||
|
@ -379,7 +379,7 @@ void pipe(Context& context, int)
|
||||||
{
|
{
|
||||||
const char* prompt = mode == InsertMode::Replace ? "pipe:" : "pipe (ins):";
|
const char* prompt = mode == InsertMode::Replace ? "pipe:" : "pipe (ins):";
|
||||||
context.input_handler().prompt(prompt, "", get_face("Prompt"), shell_complete,
|
context.input_handler().prompt(prompt, "", get_face("Prompt"), shell_complete,
|
||||||
[](const String& cmdline, PromptEvent event, Context& context)
|
[](StringView cmdline, PromptEvent event, Context& context)
|
||||||
{
|
{
|
||||||
if (event != PromptEvent::Validate)
|
if (event != PromptEvent::Validate)
|
||||||
return;
|
return;
|
||||||
|
@ -389,7 +389,7 @@ void pipe(Context& context, int)
|
||||||
real_cmd = context.main_sel_register_value("|");
|
real_cmd = context.main_sel_register_value("|");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RegisterManager::instance()['|'] = cmdline;
|
RegisterManager::instance()['|'] = String{cmdline};
|
||||||
real_cmd = cmdline;
|
real_cmd = cmdline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,7 +530,7 @@ void regex_prompt(Context& context, const String prompt, T func)
|
||||||
{
|
{
|
||||||
SelectionList selections = context.selections();
|
SelectionList selections = context.selections();
|
||||||
context.input_handler().prompt(prompt, "", get_face("Prompt"), complete_nothing,
|
context.input_handler().prompt(prompt, "", get_face("Prompt"), complete_nothing,
|
||||||
[=](const String& str, PromptEvent event, Context& context) mutable {
|
[=](StringView str, PromptEvent event, Context& context) mutable {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (event != PromptEvent::Change and context.has_ui())
|
if (event != PromptEvent::Change and context.has_ui())
|
||||||
|
@ -546,7 +546,9 @@ void regex_prompt(Context& context, const String prompt, T func)
|
||||||
|
|
||||||
if (event == PromptEvent::Validate)
|
if (event == PromptEvent::Validate)
|
||||||
context.push_jump();
|
context.push_jump();
|
||||||
func(str.empty() ? Regex{} : Regex{str}, event, context);
|
Regex regex = str.empty() ? Regex{}
|
||||||
|
: Regex{str.begin(), str.end()};
|
||||||
|
func(std::move(regex), event, context);
|
||||||
}
|
}
|
||||||
catch (RegexError& err)
|
catch (RegexError& err)
|
||||||
{
|
{
|
||||||
|
@ -748,7 +750,7 @@ void keep_pipe(Context& context, int)
|
||||||
{
|
{
|
||||||
context.input_handler().prompt(
|
context.input_handler().prompt(
|
||||||
"keep pipe:", "", get_face("Prompt"), shell_complete,
|
"keep pipe:", "", get_face("Prompt"), shell_complete,
|
||||||
[](const String& cmdline, PromptEvent event, Context& context) {
|
[](StringView cmdline, PromptEvent event, Context& context) {
|
||||||
if (event != PromptEvent::Validate)
|
if (event != PromptEvent::Validate)
|
||||||
return;
|
return;
|
||||||
const Buffer& buffer = context.buffer();
|
const Buffer& buffer = context.buffer();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user