Expose a WinResize hook when a window changes size

Fixes #661
This commit is contained in:
Maxime Coste 2016-05-04 23:26:15 +01:00
parent d4e9f30e5f
commit a132eb6b5b
2 changed files with 8 additions and 2 deletions

View File

@ -1303,6 +1303,7 @@ existing hooks are:
* `WinClose`: A window was destroyed, the filtering text is the buffer name
* `WinDisplay`: A window was bound a client, the filtering text is the buffer
name
* `WinResize`: A window resized, the filtering text is '<line>.<column>'
* `WinSetOption`: An option was set in a window context, the filtering text
is '<option_name>=<new_value>'
* `BufSetOption`: An option was set in a buffer context, the filtering text

View File

@ -111,7 +111,7 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context)
DisplayBuffer::LineList& lines = m_display_buffer.lines();
lines.clear();
m_dimensions = context.client().dimensions();
set_dimensions(context.client().dimensions());
if (m_dimensions == CharCoord{0,0})
return m_display_buffer;
@ -149,7 +149,12 @@ void Window::set_position(CharCoord position)
void Window::set_dimensions(CharCoord dimensions)
{
m_dimensions = dimensions;
if (m_dimensions != dimensions)
{
m_dimensions = dimensions;
run_hook_in_own_context("WinResize", format("{}.{}", dimensions.line,
dimensions.column));
}
}
static LineCount adapt_view_pos(LineCount line, LineCount offset,