Merge branch 'expose-cursor-byte-offset' of git://github.com/pauldub/kakoune
This commit is contained in:
commit
a12475d88c
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user