"====================================================================== " " menu_help.vim - menu functions " " Created by skywind on 2019/12/30 " Last Modified: 2019/12/30 14:47:29 " "====================================================================== let s:keymaps = '123456789abcdefimnopqrstuvwxyz' function! MenuHelp_PlugEvent(event) exec "normal \(" . a:event . ")" endfunc function! MenuHelp_FormatJson() exec "%!python -m json.tool" endfunc function! MenuHelp_Fscope(scope) exec "GscopeFind ". a:scope . " " . fnameescape(expand('')) endfunc function! MenuHelp_Gscope(what) let p = asyncrun#get_root('%') let t = '' let m = {} let m["s"] = "string symbol" let m['g'] = 'definition' let m['d'] = 'functions called by this' let m['c'] = 'functions calling this' let m['t'] = 'string' let m['e'] = 'egrep pattern' let m['f'] = 'file' let m['i'] = 'files #including this file' let m['a'] = 'places where this symbol is assigned' let m['z'] = 'ctags database' if a:what == 'f' || a:what == 'i' " let t = expand('') endif echohl Type call inputsave() let t = input('Find '.m[a:what].' in (' . p . '): ', t) call inputrestore() echohl None redraw | echo "" | redraw if t == '' return 0 endif exec 'GscopeFind '. a:what. ' ' . fnameescape(t) endfunc function! MenuHelp_Proxy(enable) let $http_proxy = (a:enable)? 'http://localhost:1080' : '' let $https_proxy = $http_proxy let $all_proxy = $http_proxy endfunc function! MenuHelp_WinHelp(help) let t = expand('') echohl Type call inputsave() let t = input('Search help of ('. fnamemodify(a:help, ':t').'): ', t) call inputrestore() echohl None redraw if t == '' return 0 endif let extname = tolower(fnamemodify(a:help, ':e')) if extname == 'hlp' call asclib#win32#open_hlp(a:help, t) elseif extname == 'chm' call asclib#win32#open_chm(a:help, t) else echo "unknow filetype" endif endfunc function! MenuHelp_HelpList(name, content) let content = [] let index = 0 for item in a:content let key = (index < len(s:keymaps))? strpart(s:keymaps, index, 1) : '' let text = '[' . ((key == '')? ' ' : ('&' . key)) . "]\t" let text = text . item[0] . "\t" . item[1] let cmd = 'call MenuHelp_WinHelp("' . item[1] . '")' let content += [[text, cmd]] let index += 1 endfor let opts = {'title': 'Help Content', 'index':0, 'close':'button'} call quickui#tools#clever_listbox(a:name, content, opts) endfunc function! MenuHelp_SplitLine() echohl Type call inputsave() let t = input('Enter maximum line width: ') call inputrestore() redraw | echo "" | redraw if t == '' return 0 endif let width = str2nr(t) if width <= 0 echohl ErrorMsg echo "Invalid number: " . t echohl None redraw return 0 endif exec 'LineBreaker ' . width endfunc function! MenuHelp_FeedPlug(text) call feedkeys("\" . a:text) endfunc