From c744b59f7d14e735391acf8395fc8d1be28d6ed5 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Sun, 16 Dec 2018 13:39:50 +0300 Subject: [PATCH 1/3] src: Add a `window_range` default expansion This commit adds a `window_range` default expansion that holds the coordinates and size of the buffer-space on the window. Fixes #675 --- src/main.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.cc b/src/main.cc index 5cc39286..9c3b4287 100644 --- a/src/main.cc +++ b/src/main.cc @@ -280,6 +280,17 @@ static const EnvVarDesc builtin_env_vars[] = { { "user_modes", false, [](StringView name, const Context& context, Quoting quoting) -> String { return join(context.keymaps().user_modes(), ' ', false); } + }, { + "window_range", false, + [](StringView name, const Context& context, Quoting quoting) -> String + { + const auto top_left = context.window().display_position({0, 0}); + const auto window_dim = context.window().dimensions(); + + return format("{} {} {} {}", top_left->line, top_left->column, + window_dim.line - top_left->line, + window_dim.column - top_left->column); + } } }; From 44992860701c6728dda018b38754d709e3a4e10a Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Wed, 19 Dec 2018 15:21:45 +0300 Subject: [PATCH 2/3] doc: Document the `window_range` expansion --- doc/pages/expansions.asciidoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/pages/expansions.asciidoc b/doc/pages/expansions.asciidoc index 63980b8e..2b2ae010 100644 --- a/doc/pages/expansions.asciidoc +++ b/doc/pages/expansions.asciidoc @@ -355,6 +355,12 @@ The following expansions are supported (with required context _in italics_): _in window scope_ + width of the current Kakoune window +*%val{window_range}*:: + _in window scope_ + + list of coordinates and dimensions of the buffer-space + available on the current window, in the following format: + ` ` + Values in the above list that do not mention a context are available everywhere. From 2ed70ad5cc606d604a0b9573b5e279463fc79721 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Sun, 20 Oct 2019 21:38:58 +0200 Subject: [PATCH 3/3] rc man: Expose the actual buffer-space's width Fixes #675 --- rc/tools/man.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/tools/man.kak b/rc/tools/man.kak index b167343e..8d450fab 100644 --- a/rc/tools/man.kak +++ b/rc/tools/man.kak @@ -33,7 +33,7 @@ define-command -hidden -params 2..3 man-impl %{ evaluate-commands %sh{ manout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) manerr=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) colout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) - MANWIDTH=${kak_window_width} man "$@" > "$manout" 2> "$manerr" + env MANWIDTH=${kak_window_range##* } man "$@" > "$manout" 2> "$manerr" retval=$? col -b -x > ${colout} < ${manout} rm ${manout}