Skip to content

Asking the user for input ​

There are seven ways a plugin can ask the user for input. Each example adds an Ask: … command to the command palette. Paste one into ~/.config/fresh/init.ts to try it.

1. Prompt line ​

Asks for text on the bottom line. This takes the least code.

ts
const value = await editor.prompt("Issue number:", "");

Example code · API: prompt

Prompt line

2. Floating prompt ​

Asks for text in a box in the middle of the screen, with a list under it. The list can update as the user types.

Example code · API: startPrompt, setPromptSuggestions, setPromptFooter, prompt events

Floating prompt

3. Pick list ​

Shows a list of choices on the bottom line. The user picks one.

Example code · API: startPrompt, setPromptSuggestions, prompt events

Pick list

4. Dialog ​

Shows a dialog box with fields, checkboxes and buttons. Use it to ask for several things at once.

Example code · API: mountFloatingWidget, updateFloatingWidget, unmountFloatingWidget, widget_event

Dialog

5. Popup ​

Shows a short message with a few choices.

Example code · API: showActionPopup, action_popup_result

Popup

6. Single key ​

Waits for the user to press one key. The user doesn't press Enter.

Example code · API: getNextKey

Single key

7. File picker ​

Lets the user choose a file. Returns the file's path.

Example code · API: pickFile

File picker

Released under the Apache 2.0 License