Skip to main content
Module

x/ddc_vim/deps.ts>fn.confirm

Dark deno-powered completion framework for neovim/Vim8
Go to Latest
function fn.confirm
import { fn } from "https://deno.land/x/ddc_vim@v2.3.0/deps.ts";
const { confirm } = fn;

confirm() offers the user a dialog, from which a choice can be made. It returns the number of the choice. For the first choice this is 1. Note: confirm() is only supported when compiled with dialog support, see |+dialog_con| and |+dialog_gui|. {msg} is displayed in a |dialog| with {choices} as the alternatives. When {choices} is missing or empty, "&OK" is used (and translated). {msg} is a String, use '\n' to include a newline. Only on some systems the string is wrapped when it doesn't fit. {choices} is a String, with the individual choices separated by '\n', e.g. confirm("Save changes?", "&Yes\n&No\n&Cancel") The letter after the '&' is the shortcut key for that choice. Thus you can type 'c' to select "Cancel". The shortcut does not need to be the first letter: confirm("file has been modified", "&Save\nSave &All") For the console, the first letter of each choice is used as the default shortcut key. Case is ignored. The optional {default} argument is the number of the choice that is made if the user hits . Use 1 to make the first choice the default one. Use 0 to not set a default. If {default} is omitted, 1 is used. The optional {type} argument gives the type of dialog. This is only used for the icon of the GTK, Mac, Motif and Win32 GUI. It can be one of these values: "Error", "Question", "Info", "Warning" or "Generic". Only the first character is relevant. When {type} is omitted, "Generic" is used. If the user aborts the dialog by pressing , CTRL-C, or another valid interrupt key, confirm() returns 0. An example: :let choice = confirm("What do you want?", "&Apples\n&Oranges\n&Bananas", 2) :if choice == 0 : echo "make up your mind!" :elseif choice == 3 : echo "tasteful" :else : echo "I prefer bananas myself." :endif In a GUI dialog, buttons are used. The layout of the buttons depends on the 'v' flag in 'guioptions'. If it is included, the buttons are always put vertically. Otherwise, confirm() tries to put the buttons in one horizontal line. If they don't fit, a vertical layout is used anyway. For some systems the horizontal layout is always used. Can also be used as a |method|in: BuildMessage()->confirm("&Yes\n&No")

Parameters

denops: Denops
msg: unknown
optional
choices: unknown
optional
defaultValue: unknown
optional
type: unknown

Returns

Promise<unknown>