Expose selection(s) length with a value
This commit is contained in:
parent
8c2c3d27ad
commit
b96ab67479
|
@ -265,6 +265,14 @@ The following expansions are supported (with required context _in italics_):
|
||||||
unquoted list of the ranges of all selections, in the same format as
|
unquoted list of the ranges of all selections, in the same format as
|
||||||
`%val{selection_desc}`
|
`%val{selection_desc}`
|
||||||
|
|
||||||
|
*%val{selection_length}*::
|
||||||
|
_in window scope_ +
|
||||||
|
length (in codepoints) of the main selection
|
||||||
|
|
||||||
|
*%val{selections_length}*::
|
||||||
|
_in window scope_ +
|
||||||
|
unquoted list of the lengths (in codepoints) of the selections
|
||||||
|
|
||||||
*%val{session}*::
|
*%val{session}*::
|
||||||
name of the current session
|
name of the current session
|
||||||
|
|
||||||
|
|
10
src/main.cc
10
src/main.cc
|
@ -234,6 +234,16 @@ static const EnvVarDesc builtin_env_vars[] = { {
|
||||||
"selections_desc", false,
|
"selections_desc", false,
|
||||||
[](StringView name, const Context& context, Quoting quoting)
|
[](StringView name, const Context& context, Quoting quoting)
|
||||||
{ return selection_list_to_string(context.selections()); }
|
{ return selection_list_to_string(context.selections()); }
|
||||||
|
}, {
|
||||||
|
"selection_length", false,
|
||||||
|
[](StringView name, const Context& context, Quoting quoting) -> String
|
||||||
|
{ return to_string(char_length(context.buffer(), context.selections().main())); }
|
||||||
|
}, {
|
||||||
|
"selections_length", false,
|
||||||
|
[](StringView name, const Context& context, Quoting quoting)
|
||||||
|
{ return join(context.selections() |
|
||||||
|
transform([&](const Selection& s)
|
||||||
|
{ return to_string(char_length(context.buffer(), s)); }), ' ', false); }
|
||||||
}, {
|
}, {
|
||||||
"window_width", false,
|
"window_width", false,
|
||||||
[](StringView name, const Context& context, Quoting quoting) -> String
|
[](StringView name, const Context& context, Quoting quoting) -> String
|
||||||
|
|
Loading…
Reference in New Issue
Block a user