From 91cc8dd8bf25fcef0bafd962b3011c71fdbac18e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 11 Dec 2013 13:46:33 +0000 Subject: [PATCH] Add cursor_char_column env variable --- README.asciidoc | 3 ++- src/main.cc | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index 7d79346b..066beab7 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -655,7 +655,8 @@ Some of kakoune state is available through environment variables: * +kak_socket+: filename of session socket (/tmp/kak-) * +kak_client+: name of current client * +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 Note that in order to make only needed information available, Kakoune needs diff --git a/src/main.cc b/src/main.cc index e035971a..b1feb55e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -111,6 +111,11 @@ void register_env_vars() "cursor_column", [](const String& name, const Context& context) { 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", [](const String& name, const Context& context)