From dbdd58e548fcf55848359b696275fd848756db7b Mon Sep 17 00:00:00 2001 From: Shougo Date: Mon, 9 May 2022 13:52:31 +0900 Subject: feat: cmdline funcs (#18284) vim-patch:8.2.4903: cannot get the current cmdline completion type and position Problem: Cannot get the current cmdline completion type and position. Solution: Add getcmdcompltype() and getcmdscreenpos(). (Shougo Matsushita, closes vim/vim#10344) https://github.com/vim/vim/commit/79d599b8772022af1d657f368c2fc97aa342c0da vim-patch:8.2.4910: imperfect coding Problem: Imperfect coding. Solution: Make code nicer. https://github.com/vim/vim/commit/9ff7d717aa3176de5c61de340deb93f41c7780fc --- runtime/doc/builtin.txt | 20 ++++++++++++++++++++ runtime/doc/usr_41.txt | 4 ++++ 2 files changed, 24 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index a909fd0d6b..b9954dc99c 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -179,8 +179,12 @@ getcharmod() Number modifiers for the last typed character getcharpos({expr}) List position of cursor, mark, etc. getcharsearch() Dict last character search getcharstr([expr]) String get one character from the user +getcmdcompltype() String return the type of the current + command-line completion getcmdline() String return the current command-line getcmdpos() Number return cursor position in command-line +getcmdscreenpos() Number return cursor screen position in + command-line getcmdtype() String return current command-line type getcmdwintype() String return current command-line window type getcompletion({pat}, {type} [, {filtered}]) @@ -2792,6 +2796,13 @@ getcharstr([expr]) *getcharstr()* Otherwise this works like |getchar()|, except that a number result is converted to a string. +getcmdcompltype() *getcmdcompltype()* + Return the type of the current command-line completion. + Only works when the command line is being edited, thus + requires use of |c_CTRL-\_e| or |c_CTRL-R_=|. + See |command-completion| for the return string. + Also see |getcmdtype()|, |setcmdpos()| and |getcmdline()|. + Returns an empty string when completion is not defined. getcmdline() *getcmdline()* Return the current command-line. Only works when the command @@ -2811,6 +2822,15 @@ getcmdpos() *getcmdpos()* Returns 0 otherwise. Also see |getcmdtype()|, |setcmdpos()| and |getcmdline()|. +getcmdscreenpos() *getcmdscreenpos()* + Return the screen position of the cursor in the command line + as a byte count. The first column is 1. + Instead of |getcmdpos()|, it adds the prompt position. + Only works when editing the command line, thus requires use of + |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. + Returns 0 otherwise. + Also see |getcmdpos()|, |setcmdpos()|. + getcmdtype() *getcmdtype()* Return the current command-line type. Possible return values are: diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index ff69b8f224..60bcadd582 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -855,8 +855,12 @@ Buffers, windows and the argument list: swapname() get the swap file path of a buffer Command line: *command-line-functions* + getcmdcompltype() get the type of the current command line + completion getcmdline() get the current command line getcmdpos() get position of the cursor in the command line + getcmdscreenpos() get screen position of the cursor in the + command line setcmdpos() set position of the cursor in the command line getcmdtype() return the current command-line type getcmdwintype() return the current command-line window type -- cgit