mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-18 17:02:06 +03:00
Buffer: support creation of temporary windows to apply commands when no windows are in context
This commit is contained in:
parent
830d96f7a1
commit
3ef9895a97
@ -243,6 +243,11 @@ void Buffer::delete_window(Window* window)
|
||||
m_windows.erase(window_it);
|
||||
}
|
||||
|
||||
std::unique_ptr<Window> Buffer::create_temporary_window()
|
||||
{
|
||||
return std::unique_ptr<Window>(new Window(*this));
|
||||
}
|
||||
|
||||
bool Buffer::is_modified() const
|
||||
{
|
||||
size_t history_cursor_index = m_history_cursor - m_history.begin();
|
||||
|
@ -151,6 +151,8 @@ public:
|
||||
Window* get_or_create_window();
|
||||
void delete_window(Window* window);
|
||||
|
||||
std::unique_ptr<Window> create_temporary_window();
|
||||
|
||||
bool is_modified() const;
|
||||
Type type() const { return m_type; }
|
||||
void notify_saved();
|
||||
|
@ -1048,6 +1048,12 @@ void exec_string(const CommandParameters& params,
|
||||
return keys[pos++];
|
||||
};
|
||||
|
||||
std::unique_ptr<Window> temp_window;
|
||||
if (not context.has_window())
|
||||
temp_window = context.buffer().create_temporary_window();
|
||||
|
||||
Window& window = context.has_window() ? context.window() : *temp_window;
|
||||
|
||||
int count = 0;
|
||||
while(pos < keys.size())
|
||||
{
|
||||
@ -1059,7 +1065,7 @@ void exec_string(const CommandParameters& params,
|
||||
{
|
||||
auto it = keymap.find(key);
|
||||
if (it != keymap.end())
|
||||
it->second(context.window(), count);
|
||||
it->second(window, count);
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user