summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands.cc8
-rw-r--r--src/option_types.hh6
-rw-r--r--src/selection.cc11
-rw-r--r--src/selection.hh2
-rw-r--r--src/string_utils.hh5
5 files changed, 15 insertions, 17 deletions
diff --git a/src/commands.cc b/src/commands.cc
index 7c840fb7..233c8f89 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -2113,16 +2113,16 @@ const CommandDesc set_register_cmd = {
const CommandDesc select_cmd = {
"select",
nullptr,
- "select <selections_desc>: select given selections\n"
+ "select <selection_desc>...: select given selections\n"
"\n"
- "selections_desc format is <anchor_line>.<anchor_column>,<cursor_line>.<cursor_column>:...",
- single_param,
+ "selection_desc format is <anchor_line>.<anchor_column>,<cursor_line>.<cursor_column>",
+ ParameterDesc{{}, ParameterDesc::Flags::SwitchesAsPositional, 1},
CommandFlags::None,
CommandHelper{},
CommandCompleter{},
[](const ParametersParser& parser, Context& context, const ShellContext&)
{
- context.selections_write_only() = selection_list_from_string(context.buffer(), parser[0]);
+ context.selections_write_only() = selection_list_from_string(context.buffer(), parser.positionals_from(0));
}
};
diff --git a/src/option_types.hh b/src/option_types.hh
index 886008b7..8a782e15 100644
--- a/src/option_types.hh
+++ b/src/option_types.hh
@@ -18,12 +18,6 @@
namespace Kakoune
{
-
-inline String quote(StringView s)
-{
- return format("'{}'", replace(s, "'", "''"));
-}
-
template<typename T>
constexpr decltype(T::option_type_name) option_type_name(Meta::Type<T>)
{
diff --git a/src/selection.cc b/src/selection.cc
index 2a4a4629..1cd8641c 100644
--- a/src/selection.cc
+++ b/src/selection.cc
@@ -477,7 +477,7 @@ String selection_list_to_string(const SelectionList& selections)
auto main = beg + selections.main_index();
using View = ConstArrayView<Selection>;
return join(concatenated(View{main, end}, View{beg, main}) |
- transform(selection_to_string), ':', false);
+ transform(selection_to_string), ' ', false);
}
Selection selection_from_string(StringView desc)
@@ -502,14 +502,13 @@ Selection selection_from_string(StringView desc)
return Selection{anchor, cursor};
}
-SelectionList selection_list_from_string(Buffer& buffer, StringView desc)
+SelectionList selection_list_from_string(Buffer& buffer, ConstArrayView<String> descs)
{
- if (desc.empty())
+ if (descs.empty())
throw runtime_error{"empty selection description"};
- auto sels = desc | split<StringView>(':')
- | transform([&](auto&& d) { auto s = selection_from_string(d); clamp(s, buffer); return s; })
- | gather<Vector<Selection>>();
+ auto sels = descs | transform([&](auto&& d) { auto s = selection_from_string(d); clamp(s, buffer); return s; })
+ | gather<Vector<Selection>>();
return {SelectionList::UnsortedTag{}, buffer, std::move(sels)};
}
diff --git a/src/selection.hh b/src/selection.hh
index bf24ad95..33df78ce 100644
--- a/src/selection.hh
+++ b/src/selection.hh
@@ -155,7 +155,7 @@ Vector<Selection> compute_modified_ranges(Buffer& buffer, size_t timestamp);
String selection_to_string(const Selection& selection);
String selection_list_to_string(const SelectionList& selection);
Selection selection_from_string(StringView desc);
-SelectionList selection_list_from_string(Buffer& buffer, StringView desc);
+SelectionList selection_list_from_string(Buffer& buffer, ConstArrayView<String> descs);
}
diff --git a/src/string_utils.hh b/src/string_utils.hh
index bd803536..61a28cad 100644
--- a/src/string_utils.hh
+++ b/src/string_utils.hh
@@ -128,6 +128,11 @@ StringView format_to(ArrayView<char> buffer, StringView fmt, Types&&... params)
return format_to(buffer, fmt, ArrayView<const StringView>{detail::format_param(std::forward<Types>(params))...});
}
+inline String quote(StringView s)
+{
+ return format("'{}'", replace(s, "'", "''"));
+}
+
}
#endif // string_utils_hh_INCLUDED