Add cursor_char_column env variable

This commit is contained in:
Maxime Coste 2013-12-11 13:46:33 +00:00
parent f0c336a283
commit 91cc8dd8bf
2 changed files with 7 additions and 1 deletions

View File

@ -655,7 +655,8 @@ Some of kakoune state is available through environment variables:
* +kak_socket+: filename of session socket (/tmp/kak-<session>) * +kak_socket+: filename of session socket (/tmp/kak-<session>)
* +kak_client+: name of current client * +kak_client+: name of current client
* +kak_cursor_line+: line of the end of the main selection * +kak_cursor_line+: line of the end of the main selection
* +kak_cursor_cursor+: column of the end of the main selection * +kak_cursor_column+: column of the end of the main selection (in byte)
* +kak_cursor_char_column+: column of the end of the main selection (in character)
* +kak_hook_param+: filtering text passed to the currently executing hook * +kak_hook_param+: filtering text passed to the currently executing hook
Note that in order to make only needed information available, Kakoune needs Note that in order to make only needed information available, Kakoune needs

View File

@ -111,6 +111,11 @@ void register_env_vars()
"cursor_column", "cursor_column",
[](const String& name, const Context& context) [](const String& name, const Context& context)
{ return to_string(context.editor().main_selection().last().column + 1); } { return to_string(context.editor().main_selection().last().column + 1); }
}, {
"cursor_char_column",
[](const String& name, const Context& context)
{ auto coord = context.editor().main_selection().last();
return to_string(context.buffer()[coord.line].char_count_to(coord.column) + 1); }
}, { }, {
"selection_desc", "selection_desc",
[](const String& name, const Context& context) [](const String& name, const Context& context)