diff --git a/README.asciidoc b/README.asciidoc index a49d5d845..1a54dd49c 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -805,6 +805,7 @@ Some of Kakoune state is available through environment variables: * `kak_source`: path of the file currently getting executed (through the source command) * `kak_cursor_line`: line of the end of the main selection * `kak_cursor_column`: column of the end of the main selection (in byte) + * `kak_cursor_char_value`: unicode value of the codepoint under the cursor * `kak_cursor_char_column`: column of the end of the main selection (in character) * `kak_cursor_byte_offset`: offset of the main selection from the beginning of the buffer (in byte). * `kak_window_width`: width of the current kakoune window diff --git a/doc/manpages/expansions.asciidoc b/doc/manpages/expansions.asciidoc index 72f6daa31..9b48f64cb 100644 --- a/doc/manpages/expansions.asciidoc +++ b/doc/manpages/expansions.asciidoc @@ -100,6 +100,8 @@ informations about Kakoune's state: line of the end of the main selection *kak_cursor_column*:: column of the end of the main selection (in byte) +*kak_cursor_char_value*:: + unicode value of the codepoint under the cursor *kak_cursor_char_column*:: column of the end of the main selection (in character) *kak_cursor_byte_offset*:: diff --git a/src/main.cc b/src/main.cc index 0108df17e..3e970fe7e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -146,6 +146,12 @@ void register_env_vars() "cursor_column", false, [](StringView name, const Context& context) -> String { return to_string(context.selections().main().cursor().column + 1); } + }, { + "cursor_char_value", false, + [](StringView name, const Context& context) -> String + { auto coord = context.selections().main().cursor(); + auto& buffer = context.buffer(); + return to_string((size_t)utf8::codepoint(buffer.iterator_at(coord), buffer.end())); } }, { "cursor_char_column", false, [](StringView name, const Context& context) -> String