Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/denops_std/function/vim/mod.ts>test_gui_event

📚 Standard module for denops.vim
Go to Latest
function test_gui_event
import { test_gui_event } from "https://deno.land/x/denops_std@v5.1.0/function/vim/mod.ts";

Generate a GUI {event} with arguments {args} for testing Vim functionality. This function works only when the GUI is running.

{event} is a String and the supported values are: "dropfiles" drop one or more files in a window. "findrepl" search and replace text. "mouse" mouse button click event. "scrollbar" move or drag the scrollbar. "key" send a low-level keyboard event. "tabline" select a tab page by mouse click. "tabmenu" select a tabline menu entry.

{args} is a Dict and contains the arguments for the event.

"dropfiles": Drop one or more files in a specified window. The supported items in {args} are: files: List of file names row: window row number col: window column number modifiers: key modifiers. The supported values are: 0x4 Shift 0x8 Alt 0x10 Ctrl The files are added to the argument-list and the first file in {files} is edited in the window. See drag-n-drop for more information. This event works only when the drop_file feature is present.

"findrepl": only available when the GUI has a find/replace dialog Perform a search and replace of text. The supported items in {args} are: find_text: string to find. repl_text: replacement string. flags: flags controlling the find/replace. Supported values are: 1 search next string (find dialog) 2 search next string (replace dialog) 3 replace string once 4 replace all matches 8 match whole words only 16 match case forward: set to 1 for forward search.

"mouse": Inject either a mouse button click, or a mouse move, event. The supported items in {args} are: button: mouse button. The supported values are: 0 left mouse button 1 middle mouse button 2 right mouse button 3 mouse button release 4 scroll wheel down 5 scroll wheel up 6 scroll wheel left 7 scroll wheel right row: mouse click row number. The first row of the Vim window is 1 and the last row is 'lines'. col: mouse click column number. The maximum value of {col} is 'columns'. multiclick: set to 1 to inject a multiclick mouse event. modifiers: key modifiers. The supported values are: 4 shift is pressed 8 alt is pressed 16 ctrl is pressed move: Optional; if used and TRUE then a mouse move event can be generated. Only {args} row: and col: are used and required; they are interpreted as pixels or screen cells, depending on "cell". Only results in an event when 'mousemoveevent' is set or a popup uses mouse move events. cell: Optional: when present and TRUE then "move" uses screen cells instead of pixel positions

"scrollbar": Set or drag the left, right or horizontal scrollbar. Only works when the scrollbar actually exists. The supported items in {args} are: which: scrollbar. The supported values are: left Left scrollbar of the current window right Right scrollbar of the current window hor Horizontal scrollbar value: amount to scroll. For the vertical scrollbars the value can be 1 to the line-count of the buffer. For the horizontal scrollbar the value can be between 1 and the maximum line length, assuming 'wrap' is not set. dragging: 1 to drag the scrollbar and 0 to click in the scrollbar.

"key": Send a low-level keyboard event (e.g. key-up or down). Currently only supported on MS-Windows. The supported items in {args} are: event: The supported string values are: keyup generate a keyup event keydown generate a keydown event keycode: Keycode to use for a keyup or a keydown event.

"tabline": Inject a mouse click event on the tabline to select a tabpage. The supported items in {args} are: tabnr: tab page number

"tabmenu": Inject an event to select a tabline menu entry. The supported items in {args} are: tabnr: tab page number item: tab page menu item number. 1 for the first menu item, 2 for the second item and so on.

After injecting the GUI events you probably should call feedkeys() to have them processed, e.g.:

call feedkeys("y", 'Lx!')

Returns TRUE if the event is successfully added, FALSE if there is a failure.

Can also be used as a method:

GetEvent()->test_gui_event({args})

Parameters

denops: Denops
event: unknown
args: unknown

Returns

Promise<boolean>