Merge branch 'expose-cursor-byte-offset' of git://github.com/pauldub/kakoune

This commit is contained in:
Maxime Coste 2016-04-09 01:05:18 +01:00
commit a12475d88c
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_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_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_height`: height of the current kakoune window
* `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
{ auto coord = context.selections().main().cursor();
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,
[](StringView name, const Context& context)