@@ -14,17 +14,20 @@ import { BuiltinCompletion, isValidBuiltinCompletion } from "./types.ts";
14
14
* :if input("Coffee or beer? ") == "beer"
15
15
* : echo "Cheers!"
16
16
* :endif
17
+ *
17
18
* If the optional {text} argument is present and not empty, this
18
19
* is used for the default reply, as if the user typed this.
19
20
* Example:
20
21
* :let color = input("Color? ", "white")
22
+ *
21
23
* The optional {completion} argument specifies the type of
22
24
* completion supported for the input. Without it completion is
23
25
* not performed. The supported completion types are the same as
24
26
* that can be supplied to a user-defined command using the
25
27
* "-complete=" argument. Refer to |:command-completion| for
26
28
* more information. Example:
27
29
* let fname = input("File: ", "", "file")
30
+ *
28
31
* NOTE: This function must not be used in a startup file, for
29
32
* the versions that only run in GUI mode (e.g., the Win32 GUI).
30
33
* Note: When input() is called from within a mapping it will
@@ -34,13 +37,15 @@ import { BuiltinCompletion, isValidBuiltinCompletion } from "./types.ts";
34
37
* after input() to avoid that. Another solution is to avoid
35
38
* that further characters follow in the mapping, e.g., by using
36
39
* |:execute| or |:normal|.
40
+ *
37
41
* Example with a mapping:
38
- * :nmap \x :call GetFoo()<CR>:exe "/" . Foo<CR
42
+ * :nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
39
43
* :function GetFoo()
40
44
* : call inputsave()
41
45
* : let g:Foo = input("enter search pattern: ")
42
46
* : call inputrestore()
43
47
* :endfunction
48
+ *
44
49
* Can also be used as a |method|:
45
50
* GetPrompt()->input()
46
51
*/
@@ -65,16 +70,18 @@ export function input(
65
70
* displayed, one string per line. The user will be prompted to
66
71
* enter a number, which is returned.
67
72
* The user can also select an item by clicking on it with the
68
- * mouse. For the first string 0 is returned. When clicking
69
- * above the first item a negative number is returned. When
70
- * clicking on the prompt one more than the length of {textlist}
71
- * is returned.
73
+ * mouse, if the mouse is enabled in the command line ('mouse' is
74
+ * "a" or includes "c"). For the first string 0 is returned.
75
+ * When clicking above the first item a negative number is
76
+ * returned. When clicking on the prompt one more than the
77
+ * length of {textlist} is returned.
72
78
* Make sure {textlist} has less than 'lines' entries, otherwise
73
79
* it won't work. It's a good idea to put the entry number at
74
80
* the start of the string. And put a prompt in the first item.
75
81
* Example:
76
82
* let color = inputlist(['Select color:', '1. red',
77
83
* \ '2. green', '3. blue'])
84
+ *
78
85
* Can also be used as a |method|:
79
86
* GetChoices()->inputlist()
80
87
*/
@@ -86,10 +93,11 @@ export function inputlist(denops: Denops, textlist: string[]): Promise<number> {
86
93
* Restore typeahead that was saved with a previous |inputsave()|.
87
94
* Should be called the same number of times inputsave() is
88
95
* called. Calling it more often is harmless though.
89
- * Returns 1 when there is nothing to restore, 0 otherwise.
96
+ * Returns TRUE when there is nothing to restore, FALSE otherwise.
90
97
*/
91
- export function inputrestore ( denops : Denops ) : Promise < void > {
92
- return denops . call ( "inputrestore" ) as Promise < void > ;
98
+ export async function inputrestore ( denops : Denops ) : Promise < boolean > {
99
+ const result = await denops . call ( "inputrestore" ) as number ;
100
+ return ! ! result ;
93
101
}
94
102
95
103
/**
@@ -98,10 +106,11 @@ export function inputrestore(denops: Denops): Promise<void> {
98
106
* followed by a matching inputrestore() after the prompt. Can
99
107
* be used several times, in which case there must be just as
100
108
* many inputrestore() calls.
101
- * Returns 1 when out of memory, 0 otherwise.
109
+ * Returns TRUE when out of memory, FALSE otherwise.
102
110
*/
103
- export function inputsave ( denops : Denops ) : Promise < void > {
104
- return denops . call ( "inputsave" ) as Promise < void > ;
111
+ export async function inputsave ( denops : Denops ) : Promise < boolean > {
112
+ const result = await denops . call ( "inputsave" ) as number ;
113
+ return ! ! result ;
105
114
}
106
115
107
116
/**
@@ -114,6 +123,7 @@ export function inputsave(denops: Denops): Promise<void> {
114
123
* The result is a String, which is whatever the user actually
115
124
* typed on the command-line in response to the issued prompt.
116
125
* NOTE: Command-line completion is not supported.
126
+ *
117
127
* Can also be used as a |method|:
118
128
* GetPrompt()->inputsecret()
119
129
*/
0 commit comments