Skip to content
Beautiful popup menus for Vim
Branch: master
Clone or download
skywind3000
skywind3000 new item_parse
Latest commit d69349a Jun 11, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
autoload new item_parse Jun 11, 2019
images update documents Jun 10, 2019
tests update documents Jun 10, 2019
.gitignore Initial commit Jun 1, 2019
LICENSE Initial commit Jun 1, 2019
README.md update documents Jun 10, 2019

README.md

Preface

Well designed and carefully colored Borland/Turbo C++ flavor popup menus for vim.

Installation

Plug 'skywind3000/vim-tvision'

Available Widgets

Popup Menu

Display a popup menu defined by itemlist, wait for user to make a selection and returns the result.

tvision#popup_menu({itemlist}, {options})

itemlist must be a list of strings. Each string in the list specifies a menu item:

  • A dash(-) represents a separator which is unselectable.
  • Shortcut keys can be defined after an & sign.
  • Script inside %{...} form will be evaluated before display.

options is a dictionary with optional keys:

  • line: y position of the screen coordinate (starts from 1).
  • col: x position of the screen coordinate (starts from 1).
  • cursor: default selection index, -1 for unselected by default.

Example:

" Each item is represented by one string, shortcut keys is defined by a `&` sign.
let lines = [
			\ "&New File\tCtrl+n",
			\ "&Open File\tCtrl+o", 
			\ "&Close",
			\ "--",
			\ "&Save\tCtrl+s",
			\ "Save &As",
			\ "Save All",
			\ "--",
			\ "&User Menu\tF9",
			\ "&Dos Shell",
			\ "~&Time %{&undolevels? '+':'-'}",
			\ "--",
			\ "E&xit\tAlt+x",
			\ ]
let index = tvision#popup_menu(lines, {'line':'cursor-1', 'col':'cursor'})
echo "Your selection is: " . index

Then you will get:

And use the default keymaps to interact with the popup menu:

Key Action
<esc> cancel
<cr> make the selection
<space> same as <cr>
<up> move the cursor up by one line
<down> move the cursor down by one line
j same as <down>
k same as <up>
<c-j> / <c-n> same as <down>
<c-k> / <c-p> same as <up>
g move the cursor to the first selectable item
G move the cursor to the last selectable item
J same as g
K same as k
q same as <esc>

Keymaps can be overrided by shortcuts defined in {itemlist}.

The function tvision#popup_menu will return if you make a selection or cancel by <ESC>.

Options

Border style

let g:tvision#border_style = 1

change the border style (1 by default), changed it to:

  • 0: disable
  • 1: ascii borders
  • 2: single unicode borders
  • 3: double unicode borders

Highlighting

The default highlighting groups are defined as:

hi! link TVisionBG Pmenu       " popup background
hi! link TVisionKey Keyword    " item shortcuts
hi! link TVisionOff Comment    " disabled items
hi! link TVisionSel PmenuSel   " current selected
hi! link TVisionHelp Title     " help text in command line

Customize as your preferences.

You can’t perform that action at this time.