expose cursor_byte_offset env variable

Update README.asciidoc
This commit is contained in:
Paul d'Hubert 2016-04-08 13:26:26 +02:00
parent 3eca90f2b1
commit eb8ad56c87
2 changed files with 6 additions and 0 deletions

View File

@ -712,6 +712,7 @@ Some of Kakoune state is available through environment variables:
* `kak_cursor_line`: line of the end of the main selection * `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_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_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 * `kak_window_width`: width of the current kakoune window
* `kak_window_height`: height of the current kakoune window * `kak_window_height`: height of the current kakoune window
* `kak_hook_param`: filtering text passed to the currently executing hook * `kak_hook_param`: filtering text passed to the currently executing hook

View File

@ -114,6 +114,11 @@ void register_env_vars()
[](StringView name, const Context& context) -> String [](StringView name, const Context& context) -> String
{ auto coord = context.selections().main().cursor(); { auto coord = context.selections().main().cursor();
return to_string(context.buffer()[coord.line].char_count_to(coord.column) + 1); } return to_string(context.buffer()[coord.line].char_count_to(coord.column) + 1); }
}, {
"cursor_byte_offset", false,
[](StringView name, const Context& context) -> String
{ auto cursor = context.selections().main().cursor();
return to_string(context.buffer().distance(context.buffer().begin().coord(), cursor)); }
}, { }, {
"selection_desc", false, "selection_desc", false,
[](StringView name, const Context& context) [](StringView name, const Context& context)