mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-23 23:34:12 +03:00
parent
7061001728
commit
85b78dda2e
@ -374,10 +374,10 @@ The default command comes from the *|* register by default (See <<registers#,`:d
|
|||||||
ignore its output.
|
ignore its output.
|
||||||
|
|
||||||
*!*::
|
*!*::
|
||||||
insert command output before each selection.
|
insert and select command output before each selection.
|
||||||
|
|
||||||
*<a-!>*::
|
*<a-!>*::
|
||||||
append command output after each selection.
|
append and select command output after each selection.
|
||||||
|
|
||||||
== Searching
|
== Searching
|
||||||
|
|
||||||
|
@ -765,6 +765,7 @@ void insert_output(Context& context, NormalParams params)
|
|||||||
auto& selections = context.selections();
|
auto& selections = context.selections();
|
||||||
auto& buffer = context.buffer();
|
auto& buffer = context.buffer();
|
||||||
const size_t old_main = selections.main_index();
|
const size_t old_main = selections.main_index();
|
||||||
|
Vector<BufferRange> ins_range;
|
||||||
|
|
||||||
selections.for_each([&](size_t index, Selection& sel) {
|
selections.for_each([&](size_t index, Selection& sel) {
|
||||||
selections.set_main_index(index);
|
selections.set_main_index(index);
|
||||||
@ -772,10 +773,16 @@ void insert_output(Context& context, NormalParams params)
|
|||||||
cmdline, context, content(context.buffer(), sel),
|
cmdline, context, content(context.buffer(), sel),
|
||||||
ShellManager::Flags::WaitForStdout);
|
ShellManager::Flags::WaitForStdout);
|
||||||
|
|
||||||
insert(buffer, sel, paste_pos(buffer, sel, mode, false), out);
|
auto range = insert(buffer, sel, paste_pos(buffer, sel, mode, false), out);
|
||||||
|
ins_range.push_back(range);
|
||||||
});
|
});
|
||||||
|
|
||||||
selections.set_main_index(old_main);
|
selections.set(ins_range | transform([&buffer](auto& range) {
|
||||||
|
if (range.empty())
|
||||||
|
return Selection{range.begin, range.end};
|
||||||
|
return Selection{range.begin,
|
||||||
|
buffer.char_prev(range.end)};
|
||||||
|
}) | gather<Vector>(), old_main);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,11 +399,12 @@ void replace(Buffer& buffer, Selection& sel, StringView content)
|
|||||||
max = range.end > range.begin ? buffer.char_prev(range.end) : range.begin;
|
max = range.end > range.begin ? buffer.char_prev(range.end) : range.begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void insert(Buffer& buffer, Selection& sel, BufferCoord pos, StringView content)
|
BufferRange insert(Buffer& buffer, Selection& sel, BufferCoord pos, StringView content)
|
||||||
{
|
{
|
||||||
auto range = buffer.insert(pos, content);
|
auto range = buffer.insert(pos, content);
|
||||||
sel.anchor() = buffer.clamp(update_insert(sel.anchor(), range.begin, range.end));
|
sel.anchor() = buffer.clamp(update_insert(sel.anchor(), range.begin, range.end));
|
||||||
sel.cursor() = buffer.clamp(update_insert(sel.cursor(), range.begin, range.end));
|
sel.cursor() = buffer.clamp(update_insert(sel.cursor(), range.begin, range.end));
|
||||||
|
return range;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectionList::replace(ConstArrayView<String> strings)
|
void SelectionList::replace(ConstArrayView<String> strings)
|
||||||
|
@ -75,7 +75,7 @@ void merge_overlapping_selections(Vector<Selection>& selections, size_t& main);
|
|||||||
void clamp_selections(Vector<Selection>& sel, const Buffer& buffer);
|
void clamp_selections(Vector<Selection>& sel, const Buffer& buffer);
|
||||||
|
|
||||||
void replace(Buffer& buffer, Selection& sel, StringView content);
|
void replace(Buffer& buffer, Selection& sel, StringView content);
|
||||||
void insert(Buffer& buffer, Selection& sel, BufferCoord pos, StringView content);
|
BufferRange insert(Buffer& buffer, Selection& sel, BufferCoord pos, StringView content);
|
||||||
|
|
||||||
struct SelectionList
|
struct SelectionList
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user