From a132eb6b5b535c26897810c54a0e5c561eb8ef36 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 4 May 2016 23:26:15 +0100 Subject: [PATCH] Expose a WinResize hook when a window changes size Fixes #661 --- README.asciidoc | 1 + src/window.cc | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index d78b034a..2221f856 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -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 '.' * `WinSetOption`: An option was set in a window context, the filtering text is '=' * `BufSetOption`: An option was set in a buffer context, the filtering text diff --git a/src/window.cc b/src/window.cc index ef4d3270..c80c1e61 100644 --- a/src/window.cc +++ b/src/window.cc @@ -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,