diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2017-08-16 13:57:58 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2017-10-26 20:28:49 +0200 |
commit | a68817f56517a31943806bd0b5a0030cdd35e182 (patch) | |
tree | 2d61152a77c18a56768fa1bf073142322e1131fe /src/nvim/ex_getln.c | |
parent | ddfc077da468450d1fab81fe3b3f594bb6ebf6dd (diff) | |
download | rneovim-a68817f56517a31943806bd0b5a0030cdd35e182.tar.gz rneovim-a68817f56517a31943806bd0b5a0030cdd35e182.tar.bz2 rneovim-a68817f56517a31943806bd0b5a0030cdd35e182.zip |
ext_cmdline: extend "function" to generic "block" mechanism
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r-- | src/nvim/ex_getln.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 0e620e59d8..50cccc8d10 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -186,6 +186,8 @@ static int cmd_showtail; /* Only show path tail in lists ? */ static int new_cmdpos; /* position set by set_cmdline_pos() */ +static Array cmdline_block; ///< currently displayed block of context + /* * Type used by call_user_expand_func */ @@ -2759,6 +2761,32 @@ void ui_ext_cmdline_show(void) ccline.level); } +void ui_ext_cmdline_block_append(int indent, const char *line) +{ + char *buf = xmallocz(indent + strlen(line)); + memset(buf, ' ', indent); + memcpy(buf+indent, line, strlen(line)); + + Array item = ARRAY_DICT_INIT; + ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT)); + ADD(item, STRING_OBJ(cstr_as_string(buf))); + Array content = ARRAY_DICT_INIT; + ADD(content, ARRAY_OBJ(item)); + ADD(cmdline_block, ARRAY_OBJ(content)); + if (cmdline_block.size > 1) { + ui_call_cmdline_block_append(copy_array(content)); + } else { + ui_call_cmdline_block_show(copy_array(cmdline_block)); + } +} + +void ui_ext_cmdline_block_leave(void) +{ + api_free_array(cmdline_block); + ui_call_cmdline_block_hide(); +} + + /* * Put a character on the command line. Shifts the following text to the * right when "shift" is TRUE. Used for CTRL-V, CTRL-K, etc. |