summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-12-11 13:46:33 +0000
committerMaxime Coste <frrrwww@gmail.com>2013-12-11 13:46:33 +0000
commit91cc8dd8bf25fcef0bafd962b3011c71fdbac18e (patch)
tree26101c60ad86ec7722f50c7be3e0644c8023160e
parentf0c336a28355a95d48c91dd762c00742511fb34e (diff)
Add cursor_char_column env variable
-rw-r--r--README.asciidoc3
-rw-r--r--src/main.cc5
2 files changed, 7 insertions, 1 deletions
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-<session>)
* +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
@@ -112,6 +112,11 @@ void register_env_vars()
[](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)
{ auto& sel = context.editor().main_selection();