2013-04-09 19:39:03 +02:00
|
|
|
#include "context.hh"
|
|
|
|
|
2014-10-30 00:22:54 +01:00
|
|
|
#include "alias_registry.hh"
|
2013-09-12 23:47:23 +02:00
|
|
|
#include "client.hh"
|
2017-09-27 17:26:39 +02:00
|
|
|
#include "face_registry.hh"
|
2019-07-22 12:05:42 +02:00
|
|
|
#include "buffer_manager.hh"
|
2014-06-21 12:31:08 +02:00
|
|
|
#include "register_manager.hh"
|
2013-04-09 19:39:03 +02:00
|
|
|
#include "window.hh"
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2013-12-20 21:10:08 +01:00
|
|
|
Context::~Context() = default;
|
2013-04-09 19:39:03 +02:00
|
|
|
|
2014-05-13 00:25:15 +02:00
|
|
|
Context::Context(InputHandler& input_handler, SelectionList selections,
|
2014-12-19 00:12:58 +01:00
|
|
|
Flags flags, String name)
|
2019-02-09 05:41:09 +01:00
|
|
|
: m_flags(flags),
|
|
|
|
m_input_handler{&input_handler},
|
2022-08-15 22:21:53 +02:00
|
|
|
m_selection_history{*this, std::move(selections)},
|
2014-04-04 01:00:06 +02:00
|
|
|
m_name(std::move(name))
|
|
|
|
{}
|
2013-12-17 00:24:08 +01:00
|
|
|
|
2022-08-15 22:21:53 +02:00
|
|
|
Context::Context(EmptyContextFlag) : m_selection_history{*this} {}
|
2015-04-19 19:47:52 +02:00
|
|
|
|
2013-04-09 19:39:03 +02:00
|
|
|
Buffer& Context::buffer() const
|
|
|
|
{
|
|
|
|
if (not has_buffer())
|
|
|
|
throw runtime_error("no buffer in context");
|
2022-08-06 21:51:35 +02:00
|
|
|
return const_cast<Buffer&>(selections(false).buffer());
|
2013-04-09 19:39:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Window& Context::window() const
|
|
|
|
{
|
|
|
|
if (not has_window())
|
|
|
|
throw runtime_error("no window in context");
|
2013-12-20 21:10:08 +01:00
|
|
|
return *m_window;
|
2013-04-09 19:39:03 +02:00
|
|
|
}
|
|
|
|
|
2013-11-14 19:09:15 +01:00
|
|
|
InputHandler& Context::input_handler() const
|
|
|
|
{
|
|
|
|
if (not has_input_handler())
|
|
|
|
throw runtime_error("no input handler in context");
|
|
|
|
return *m_input_handler;
|
|
|
|
}
|
|
|
|
|
2013-09-12 23:47:23 +02:00
|
|
|
Client& Context::client() const
|
2013-04-09 19:39:03 +02:00
|
|
|
{
|
2013-09-12 23:47:23 +02:00
|
|
|
if (not has_client())
|
2013-11-14 19:09:15 +01:00
|
|
|
throw runtime_error("no client in context");
|
2013-09-12 23:47:23 +02:00
|
|
|
return *m_client;
|
2013-04-09 19:39:03 +02:00
|
|
|
}
|
|
|
|
|
2014-10-30 15:00:42 +01:00
|
|
|
Scope& Context::scope() const
|
2013-04-09 19:39:03 +02:00
|
|
|
{
|
|
|
|
if (has_window())
|
2014-10-30 15:00:42 +01:00
|
|
|
return window();
|
2013-04-09 19:39:03 +02:00
|
|
|
if (has_buffer())
|
2014-10-30 15:00:42 +01:00
|
|
|
return buffer();
|
|
|
|
return GlobalScope::instance();
|
|
|
|
}
|
|
|
|
|
2013-11-14 19:09:15 +01:00
|
|
|
void Context::set_client(Client& client)
|
|
|
|
{
|
|
|
|
kak_assert(not has_client());
|
|
|
|
m_client.reset(&client);
|
|
|
|
}
|
|
|
|
|
2013-12-20 21:10:08 +01:00
|
|
|
void Context::set_window(Window& window)
|
|
|
|
{
|
|
|
|
kak_assert(&window.buffer() == &buffer());
|
|
|
|
m_window.reset(&window);
|
|
|
|
}
|
|
|
|
|
2018-03-30 00:58:18 +02:00
|
|
|
void Context::print_status(DisplayLine status) const
|
2013-04-09 19:39:03 +02:00
|
|
|
{
|
2013-09-16 20:15:13 +02:00
|
|
|
if (has_client())
|
2018-03-30 00:58:18 +02:00
|
|
|
client().print_status(std::move(status));
|
2013-04-09 19:39:03 +02:00
|
|
|
}
|
|
|
|
|
2019-02-17 00:19:54 +01:00
|
|
|
void JumpList::push(SelectionList jump, Optional<size_t> index)
|
2013-04-09 19:39:03 +02:00
|
|
|
{
|
2019-02-17 00:19:54 +01:00
|
|
|
if (index)
|
|
|
|
{
|
|
|
|
m_current = *index;
|
|
|
|
kak_assert(m_current <= m_jumps.size());
|
|
|
|
}
|
|
|
|
|
2015-12-23 03:31:03 +01:00
|
|
|
if (m_current != m_jumps.size())
|
|
|
|
m_jumps.erase(m_jumps.begin()+m_current+1, m_jumps.end());
|
2015-12-23 02:56:54 +01:00
|
|
|
m_jumps.erase(std::remove(begin(m_jumps), end(m_jumps), jump),
|
|
|
|
end(m_jumps));
|
|
|
|
m_jumps.push_back(jump);
|
2015-12-23 03:31:03 +01:00
|
|
|
m_current = m_jumps.size();
|
2013-04-09 19:39:03 +02:00
|
|
|
}
|
|
|
|
|
2017-11-13 08:34:02 +01:00
|
|
|
const SelectionList& JumpList::forward(Context& context, int count)
|
2013-04-09 19:39:03 +02:00
|
|
|
{
|
2015-12-23 03:31:03 +01:00
|
|
|
if (m_current != m_jumps.size() and
|
2017-11-13 08:34:02 +01:00
|
|
|
m_current + count < m_jumps.size())
|
2014-05-13 21:09:37 +02:00
|
|
|
{
|
2017-11-13 08:34:02 +01:00
|
|
|
m_current += count;
|
|
|
|
SelectionList& res = m_jumps[m_current];
|
2014-05-13 21:09:37 +02:00
|
|
|
res.update();
|
2017-09-27 17:26:39 +02:00
|
|
|
context.print_status({ format("jumped to #{} ({})",
|
|
|
|
m_current, m_jumps.size() - 1),
|
2018-04-07 07:36:39 +02:00
|
|
|
context.faces()["Information"] });
|
2014-05-13 21:09:37 +02:00
|
|
|
return res;
|
|
|
|
}
|
2013-04-09 19:39:03 +02:00
|
|
|
throw runtime_error("no next jump");
|
|
|
|
}
|
|
|
|
|
2017-11-13 08:34:02 +01:00
|
|
|
const SelectionList& JumpList::backward(Context& context, int count)
|
2013-04-09 19:39:03 +02:00
|
|
|
{
|
2017-11-13 08:34:02 +01:00
|
|
|
if ((int)m_current - count < 0)
|
|
|
|
throw runtime_error("no previous jump");
|
|
|
|
|
2017-09-27 17:26:39 +02:00
|
|
|
const SelectionList& current = context.selections();
|
2015-12-23 03:31:03 +01:00
|
|
|
if (m_current != m_jumps.size() and
|
|
|
|
m_jumps[m_current] != current)
|
2013-10-02 19:48:50 +02:00
|
|
|
{
|
2015-12-23 02:56:54 +01:00
|
|
|
push(current);
|
2017-11-13 08:34:02 +01:00
|
|
|
m_current -= count;
|
|
|
|
SelectionList& res = m_jumps[m_current];
|
2014-05-13 21:09:37 +02:00
|
|
|
res.update();
|
2017-09-27 17:26:39 +02:00
|
|
|
context.print_status({ format("jumped to #{} ({})",
|
|
|
|
m_current, m_jumps.size() - 1),
|
2018-04-07 07:36:39 +02:00
|
|
|
context.faces()["Information"] });
|
2014-05-13 21:09:37 +02:00
|
|
|
return res;
|
2013-10-02 19:48:50 +02:00
|
|
|
}
|
2015-12-23 03:31:03 +01:00
|
|
|
if (m_current != 0)
|
2013-04-09 19:39:03 +02:00
|
|
|
{
|
2015-12-23 03:31:03 +01:00
|
|
|
if (m_current == m_jumps.size())
|
2013-04-09 19:39:03 +02:00
|
|
|
{
|
2015-12-23 02:56:54 +01:00
|
|
|
push(current);
|
2015-12-23 03:31:03 +01:00
|
|
|
if (--m_current == 0)
|
2015-08-26 11:54:51 +02:00
|
|
|
throw runtime_error("no previous jump");
|
2013-04-09 19:39:03 +02:00
|
|
|
}
|
2017-11-13 08:34:02 +01:00
|
|
|
m_current -= count;
|
|
|
|
SelectionList& res = m_jumps[m_current];
|
2014-05-13 21:09:37 +02:00
|
|
|
res.update();
|
2017-09-27 17:26:39 +02:00
|
|
|
context.print_status({ format("jumped to #{} ({})",
|
|
|
|
m_current, m_jumps.size() - 1),
|
2018-04-07 07:36:39 +02:00
|
|
|
context.faces()["Information"] });
|
2014-05-13 21:09:37 +02:00
|
|
|
return res;
|
2013-04-09 19:39:03 +02:00
|
|
|
}
|
|
|
|
throw runtime_error("no previous jump");
|
|
|
|
}
|
|
|
|
|
2015-12-23 02:56:54 +01:00
|
|
|
void JumpList::forget_buffer(Buffer& buffer)
|
2013-04-09 19:39:03 +02:00
|
|
|
{
|
2015-12-23 03:31:03 +01:00
|
|
|
for (size_t i = 0; i < m_jumps.size();)
|
2013-04-09 19:39:03 +02:00
|
|
|
{
|
2015-12-23 03:31:03 +01:00
|
|
|
if (&m_jumps[i].buffer() == &buffer)
|
2013-04-09 19:39:03 +02:00
|
|
|
{
|
2015-12-23 03:31:03 +01:00
|
|
|
if (i < m_current)
|
2015-12-23 02:56:54 +01:00
|
|
|
--m_current;
|
2015-12-23 03:31:03 +01:00
|
|
|
else if (i == m_current)
|
|
|
|
m_current = m_jumps.size()-1;
|
2013-04-09 19:39:03 +02:00
|
|
|
|
2015-12-23 03:31:03 +01:00
|
|
|
m_jumps.erase(m_jumps.begin() + i);
|
2013-04-09 19:39:03 +02:00
|
|
|
}
|
|
|
|
else
|
2015-12-23 03:31:03 +01:00
|
|
|
++i;
|
2013-04-09 19:39:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-15 22:21:53 +02:00
|
|
|
Context::SelectionHistory::SelectionHistory(Context& context) : m_context(context) {}
|
|
|
|
|
|
|
|
Context::SelectionHistory::SelectionHistory(Context& context, SelectionList selections)
|
|
|
|
: m_context(context),
|
|
|
|
m_history{HistoryNode{std::move(selections), HistoryId::Invalid}},
|
|
|
|
m_history_id(HistoryId::First) {}
|
|
|
|
|
|
|
|
void Context::SelectionHistory::initialize(SelectionList selections)
|
|
|
|
{
|
|
|
|
kak_assert(empty());
|
|
|
|
m_history = {HistoryNode{std::move(selections), HistoryId::Invalid}};
|
|
|
|
m_history_id = HistoryId::First;
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectionList& Context::SelectionHistory::selections(bool update)
|
|
|
|
{
|
|
|
|
if (empty())
|
|
|
|
throw runtime_error("no selections in context");
|
|
|
|
auto& sels = m_staging ? m_staging->selections : current_history_node().selections;
|
|
|
|
if (update)
|
|
|
|
sels.update();
|
|
|
|
return sels;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Context::SelectionHistory::begin_edition()
|
|
|
|
{
|
|
|
|
if (not in_edition())
|
|
|
|
m_staging = HistoryNode{selections(), m_history_id};
|
|
|
|
m_in_edition.set();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Context::SelectionHistory::end_edition()
|
|
|
|
{
|
|
|
|
kak_assert(in_edition());
|
|
|
|
m_in_edition.unset();
|
|
|
|
if (in_edition())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (m_history_id != HistoryId::Invalid and current_history_node().selections == m_staging->selections)
|
|
|
|
{
|
|
|
|
auto& sels = m_history[(size_t)m_history_id].selections;
|
|
|
|
sels.force_timestamp(m_staging->selections.timestamp());
|
|
|
|
sels.set_main_index(m_staging->selections.main_index());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_history_id = next_history_id();
|
|
|
|
m_history.push_back(std::move(*m_staging));
|
|
|
|
}
|
|
|
|
m_staging.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Context::SelectionHistory::undo()
|
|
|
|
{
|
|
|
|
if (in_edition())
|
|
|
|
throw runtime_error("selection undo is only supported at top-level");
|
|
|
|
kak_assert(not empty());
|
|
|
|
begin_edition();
|
|
|
|
auto end = on_scope_end([&] {
|
|
|
|
kak_assert(current_history_node().selections == m_staging->selections);
|
|
|
|
end_edition();
|
|
|
|
});
|
|
|
|
HistoryId parent = current_history_node().parent;
|
|
|
|
if (parent == HistoryId::Invalid)
|
|
|
|
throw runtime_error("no selection change to undo");
|
|
|
|
auto select_parent = [&, parent] {
|
|
|
|
HistoryId before_undo = m_history_id;
|
|
|
|
m_history_id = parent;
|
|
|
|
current_history_node().redo_child = before_undo;
|
|
|
|
m_staging = current_history_node();
|
|
|
|
};
|
|
|
|
if (&history_node(parent).selections.buffer() == &m_context.buffer())
|
|
|
|
select_parent();
|
|
|
|
else
|
|
|
|
m_context.change_buffer(history_node(parent).selections.buffer(), { std::move(select_parent) });
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
|
|
|
|
void Context::SelectionHistory::redo()
|
|
|
|
{
|
|
|
|
if (in_edition())
|
|
|
|
throw runtime_error("selection redo is only supported at top-level");
|
|
|
|
kak_assert(not empty());
|
|
|
|
begin_edition();
|
|
|
|
auto end = on_scope_end([&] {
|
|
|
|
kak_assert(current_history_node().selections == m_staging->selections);
|
|
|
|
end_edition();
|
|
|
|
});
|
|
|
|
HistoryId child = current_history_node().redo_child;
|
|
|
|
if (child == HistoryId::Invalid)
|
|
|
|
throw runtime_error("no selection change to redo");
|
|
|
|
auto select_child = [&, child] {
|
|
|
|
m_history_id = child;
|
|
|
|
m_staging = current_history_node();
|
|
|
|
};
|
|
|
|
if (&history_node(child).selections.buffer() == &m_context.buffer())
|
|
|
|
select_child();
|
|
|
|
else
|
|
|
|
m_context.change_buffer(history_node(child).selections.buffer(), { std::move(select_child) });
|
|
|
|
}
|
|
|
|
|
|
|
|
void Context::SelectionHistory::forget_buffer(Buffer& buffer)
|
|
|
|
{
|
|
|
|
Vector<HistoryId, MemoryDomain::Selections> new_ids;
|
|
|
|
size_t bias = 0;
|
|
|
|
for (size_t i = 0; i < m_history.size(); ++i)
|
|
|
|
{
|
|
|
|
auto& node = history_node((HistoryId)i);
|
|
|
|
HistoryId id;
|
|
|
|
if (&node.selections.buffer() == &buffer)
|
|
|
|
{
|
|
|
|
id = HistoryId::Invalid;
|
|
|
|
++bias;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
id = (HistoryId)(i - bias);
|
|
|
|
new_ids.push_back(id);
|
|
|
|
}
|
|
|
|
auto new_id = [&new_ids](HistoryId old_id) -> HistoryId {
|
|
|
|
return old_id == HistoryId::Invalid ? HistoryId::Invalid : new_ids[(size_t)old_id];
|
|
|
|
};
|
|
|
|
|
|
|
|
m_history.erase(remove_if(m_history, [&buffer](const auto& node) {
|
|
|
|
return &node.selections.buffer() == &buffer;
|
|
|
|
}), m_history.end());
|
|
|
|
|
|
|
|
for (auto& node : m_history)
|
|
|
|
{
|
|
|
|
node.parent = new_id(node.parent);
|
|
|
|
node.redo_child = new_id(node.redo_child);
|
|
|
|
}
|
|
|
|
m_history_id = new_id(m_history_id);
|
|
|
|
if (m_staging)
|
|
|
|
{
|
|
|
|
m_staging->parent = new_id(m_staging->parent);
|
|
|
|
kak_assert(m_staging->redo_child == HistoryId::Invalid);
|
|
|
|
}
|
|
|
|
kak_assert(m_history_id != HistoryId::Invalid or m_staging);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Context::change_buffer(Buffer& buffer, Optional<FunctionRef<void()>> set_selections)
|
2013-04-09 19:39:03 +02:00
|
|
|
{
|
2017-12-12 08:22:05 +01:00
|
|
|
if (has_buffer() and &buffer == &this->buffer())
|
2014-10-10 15:00:24 +02:00
|
|
|
return;
|
|
|
|
|
2017-12-12 08:22:05 +01:00
|
|
|
if (has_buffer() and m_edition_level > 0)
|
2014-10-10 15:00:24 +02:00
|
|
|
this->buffer().commit_undo_group();
|
2014-11-21 19:56:39 +01:00
|
|
|
|
2013-12-20 21:10:08 +01:00
|
|
|
if (has_client())
|
2016-06-16 20:35:43 +02:00
|
|
|
{
|
|
|
|
client().info_hide();
|
|
|
|
client().menu_hide();
|
2022-08-15 22:21:53 +02:00
|
|
|
client().change_buffer(buffer, std::move(set_selections));
|
2016-06-16 20:35:43 +02:00
|
|
|
}
|
2013-12-20 21:10:08 +01:00
|
|
|
else
|
2019-12-28 01:27:04 +01:00
|
|
|
{
|
|
|
|
m_window.reset();
|
2022-08-15 22:21:53 +02:00
|
|
|
if (m_selection_history.empty())
|
|
|
|
m_selection_history.initialize(SelectionList{buffer, Selection{}});
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ScopedSelectionEdition selection_edition{*this};
|
|
|
|
selections_write_only() = SelectionList{buffer, Selection{}};
|
|
|
|
}
|
2019-12-28 01:27:04 +01:00
|
|
|
}
|
2017-05-22 17:56:06 +02:00
|
|
|
|
|
|
|
if (has_input_handler())
|
|
|
|
input_handler().reset_normal_mode();
|
2013-04-09 19:39:03 +02:00
|
|
|
}
|
|
|
|
|
2019-07-22 12:05:42 +02:00
|
|
|
void Context::forget_buffer(Buffer& buffer)
|
|
|
|
{
|
|
|
|
m_jump_list.forget_buffer(buffer);
|
|
|
|
|
2022-08-15 22:21:53 +02:00
|
|
|
if (&this->buffer() == &buffer)
|
|
|
|
{
|
|
|
|
if (is_editing() && has_input_handler())
|
|
|
|
input_handler().reset_normal_mode();
|
2019-07-22 12:05:42 +02:00
|
|
|
|
2022-08-15 22:21:53 +02:00
|
|
|
auto last_buffer = this->last_buffer();
|
|
|
|
change_buffer(last_buffer ? *last_buffer : BufferManager::instance().get_first_buffer());
|
|
|
|
}
|
2019-07-22 12:05:42 +02:00
|
|
|
|
2022-08-15 22:21:53 +02:00
|
|
|
m_selection_history.forget_buffer(buffer);
|
2021-09-11 09:43:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Buffer* Context::last_buffer() const
|
|
|
|
{
|
|
|
|
const auto jump_list = m_jump_list.get_as_list();
|
|
|
|
if (jump_list.empty())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
auto predicate = [this](const auto& sels) {
|
|
|
|
return &sels.buffer() != &this->buffer();
|
|
|
|
};
|
|
|
|
|
|
|
|
auto next_buffer = find_if(jump_list.subrange(m_jump_list.current_index()-1),
|
|
|
|
predicate);
|
|
|
|
if (next_buffer != jump_list.end())
|
|
|
|
return &next_buffer->buffer();
|
|
|
|
|
|
|
|
auto previous_buffer = find_if(jump_list.subrange(0, m_jump_list.current_index()) | reverse(),
|
|
|
|
predicate);
|
|
|
|
|
|
|
|
return previous_buffer != jump_list.rend() ? &previous_buffer->buffer() : nullptr;
|
2019-07-22 12:05:42 +02:00
|
|
|
}
|
|
|
|
|
2022-08-06 21:51:35 +02:00
|
|
|
SelectionList& Context::selections(bool update)
|
2013-12-15 15:25:23 +01:00
|
|
|
{
|
2022-08-15 22:21:53 +02:00
|
|
|
return m_selection_history.selections(update);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Context::undo_selection_change()
|
|
|
|
{
|
|
|
|
m_selection_history.undo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Context::redo_selection_change()
|
|
|
|
{
|
|
|
|
m_selection_history.redo();
|
2013-12-15 15:25:23 +01:00
|
|
|
}
|
|
|
|
|
2015-04-19 16:12:16 +02:00
|
|
|
SelectionList& Context::selections_write_only()
|
|
|
|
{
|
2022-08-06 21:51:35 +02:00
|
|
|
return selections(false);
|
2015-04-19 16:12:16 +02:00
|
|
|
}
|
|
|
|
|
2022-08-06 21:51:35 +02:00
|
|
|
const SelectionList& Context::selections(bool update) const
|
2013-12-15 15:25:23 +01:00
|
|
|
{
|
2022-08-06 21:51:35 +02:00
|
|
|
return const_cast<Context&>(*this).selections(update);
|
2013-12-15 15:25:23 +01:00
|
|
|
}
|
|
|
|
|
2015-01-12 14:58:41 +01:00
|
|
|
Vector<String> Context::selections_content() const
|
2013-12-15 21:37:07 +01:00
|
|
|
{
|
2014-04-04 01:00:06 +02:00
|
|
|
auto& buf = buffer();
|
2015-01-12 14:58:41 +01:00
|
|
|
Vector<String> contents;
|
2013-12-15 21:37:07 +01:00
|
|
|
for (auto& sel : selections())
|
2014-04-04 01:00:06 +02:00
|
|
|
contents.push_back(buf.string(sel.min(), buf.char_next(sel.max())));
|
2013-12-15 21:37:07 +01:00
|
|
|
return contents;
|
|
|
|
}
|
|
|
|
|
2013-12-15 19:07:51 +01:00
|
|
|
void Context::begin_edition()
|
|
|
|
{
|
2014-01-06 21:07:08 +01:00
|
|
|
if (m_edition_level >= 0)
|
2018-09-12 12:02:57 +02:00
|
|
|
{
|
|
|
|
if (m_edition_level == 0)
|
|
|
|
m_edition_timestamp = buffer().timestamp();
|
2014-01-06 21:07:08 +01:00
|
|
|
++m_edition_level;
|
2018-09-12 12:02:57 +02:00
|
|
|
}
|
2013-12-15 19:07:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Context::end_edition()
|
|
|
|
{
|
2014-01-06 21:07:08 +01:00
|
|
|
if (m_edition_level < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
kak_assert(m_edition_level != 0);
|
2018-09-12 12:02:57 +02:00
|
|
|
if (m_edition_level == 1 and
|
|
|
|
buffer().timestamp() != m_edition_timestamp)
|
2013-12-15 19:07:51 +01:00
|
|
|
buffer().commit_undo_group();
|
|
|
|
|
|
|
|
--m_edition_level;
|
|
|
|
}
|
|
|
|
|
2014-06-21 12:31:08 +02:00
|
|
|
StringView Context::main_sel_register_value(StringView reg) const
|
|
|
|
{
|
2022-08-06 21:51:35 +02:00
|
|
|
size_t index = has_buffer() ? selections(false).main_index() : 0;
|
2019-06-05 15:19:27 +02:00
|
|
|
return RegisterManager::instance()[reg].get_main(*this, index);
|
2014-06-21 12:31:08 +02:00
|
|
|
}
|
|
|
|
|
2013-04-09 19:39:03 +02:00
|
|
|
}
|