patch 9.1.0741: No way to get prompt for input()/confirm()
Problem: No way to get prompt for input()/confirm()
Solution: add getcmdprompt() function (Shougo Matsushita)
(Shougo Matsushita)
closes: #15667
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index af918d1..fe0b9aa 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -1,4 +1,4 @@
-*builtin.txt* For Vim version 9.1. Last change: 2024 Sep 10
+*builtin.txt* For Vim version 9.1. Last change: 2024 Sep 23
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -232,8 +232,9 @@
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
+getcmdline() String return the current command-line input
getcmdpos() Number return cursor position in command-line
+getcmdprompt() String return the current command-line prompt
getcmdscreenpos() Number return cursor screen position in
command-line
getcmdtype() String return current command-line type
@@ -3978,21 +3979,21 @@
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()|, |getcmdline()| and
- |setcmdline()|.
+ Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
+ |getcmdprompt()| and |setcmdline()|.
Returns an empty string when completion is not defined.
Return type: |String|
getcmdline() *getcmdline()*
- Return the current command-line. Only works when the command
- line is being edited, thus requires use of |c_CTRL-\_e| or
- |c_CTRL-R_=|.
+ Return the current command-line input. Only works when the
+ command line is being edited, thus requires use of
+ |c_CTRL-\_e| or |c_CTRL-R_=|.
Example: >
:cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
-< Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()| and
- |setcmdline()|.
+< Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()|,
+ |getcmdprompt()| and |setcmdline()|.
Returns an empty string when entering a password or using
|inputsecret()|.
@@ -4005,12 +4006,23 @@
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 |getcmdtype()|, |setcmdpos()|, |getcmdline()| and
- |setcmdline()|.
+ Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
+ |getcmdprompt()| and |setcmdline()|.
Return type: |Number|
+getcmdprompt() *getcmdprompt()*
+ Return the current command-line prompt when using functions
+ like |input()| or |confirm()|.
+ Only works when the command line is being edited, thus
+ requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
+ Also see |getcmdtype()|, |getcmdline()|, |getcmdpos()|,
+ |setcmdpos()| and |setcmdline()|.
+
+ Return type: |String|
+
+
getcmdscreenpos() *getcmdscreenpos()*
Return the screen position of the cursor in the command line
as a byte count. The first column is 1.
diff --git a/runtime/doc/tags b/runtime/doc/tags
index dd5a0a6..fb6adf8 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -7827,6 +7827,7 @@
getcmdcompltype() builtin.txt /*getcmdcompltype()*
getcmdline() builtin.txt /*getcmdline()*
getcmdpos() builtin.txt /*getcmdpos()*
+getcmdprompt() builtin.txt /*getcmdprompt()*
getcmdscreenpos() builtin.txt /*getcmdscreenpos()*
getcmdtype() builtin.txt /*getcmdtype()*
getcmdwintype() builtin.txt /*getcmdwintype()*
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 765eab5..27df85a 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -1,4 +1,4 @@
-*usr_41.txt* For Vim version 9.1. Last change: 2024 Jun 09
+*usr_41.txt* For Vim version 9.1. Last change: 2024 Sep 23
VIM USER MANUAL - by Bram Moolenaar
@@ -1070,7 +1070,8 @@
Command line: *command-line-functions*
getcmdcompltype() get the type of the current command line
completion
- getcmdline() get the current command line
+ getcmdline() get the current command line input
+ getcmdprompt() get the current command line prompt
getcmdpos() get position of the cursor in the command line
getcmdscreenpos() get screen position of the cursor in the
command line
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 9d22521..94e662d 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -41608,6 +41608,7 @@
|diff()| diff two Lists of strings
|filecopy()| copy a file {from} to {to}
|foreach()| apply function to List items
+|getcmdprompt()| get prompt for input()/confirm()
|getregion()| get a region of text from a buffer
|getregionpos()| get a list of positions for a region
|id()| get unique identifier for a Dict, List, Object,