rename MenuCallback -> MenuItem
This commit is contained in:
parent
a163f327eb
commit
a2ead3545e
@ -426,21 +426,21 @@ function! s:Bookmark.Write()
|
|||||||
endfor
|
endfor
|
||||||
call writefile(bookmarkStrings, g:NERDTreeBookmarksFile)
|
call writefile(bookmarkStrings, g:NERDTreeBookmarksFile)
|
||||||
endfunction
|
endfunction
|
||||||
"CLASS: MenuCallback {{{2
|
"CLASS: MenuItem {{{2
|
||||||
"============================================================
|
"============================================================
|
||||||
let s:MenuCallback = {}
|
let s:MenuItem = {}
|
||||||
"FUNCTION: MenuCallback.All() {{{3
|
"FUNCTION: MenuItem.All() {{{3
|
||||||
function! s:MenuCallback.All()
|
function! s:MenuItem.All()
|
||||||
if !exists("s:menuCallbacks")
|
if !exists("s:menuItems")
|
||||||
let s:menuCallbacks = []
|
let s:menuItems = []
|
||||||
endif
|
endif
|
||||||
return s:menuCallbacks
|
return s:menuItems
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuCallback.AllEnabledCallbacks() {{{3
|
"FUNCTION: MenuItem.AllEnabled() {{{3
|
||||||
function! s:MenuCallback.AllEnabledCallbacks()
|
function! s:MenuItem.AllEnabled()
|
||||||
let toReturn = []
|
let toReturn = []
|
||||||
for i in s:MenuCallback.All()
|
for i in s:MenuItem.All()
|
||||||
if i.enabled()
|
if i.enabled()
|
||||||
call add(toReturn, i)
|
call add(toReturn, i)
|
||||||
endif
|
endif
|
||||||
@ -448,9 +448,9 @@ function! s:MenuCallback.AllEnabledCallbacks()
|
|||||||
return toReturn
|
return toReturn
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuCallback.FindByShortcut(shortcut) {{{3
|
"FUNCTION: MenuItem.FindByShortcut(shortcut) {{{3
|
||||||
function! s:MenuCallback.FindByShortcut(shortcut)
|
function! s:MenuItem.FindByShortcut(shortcut)
|
||||||
for i in s:MenuCallback.All()
|
for i in s:MenuItem.All()
|
||||||
if i.shortcut ==# a:shortcut
|
if i.shortcut ==# a:shortcut
|
||||||
return i
|
return i
|
||||||
endif
|
endif
|
||||||
@ -458,39 +458,39 @@ function! s:MenuCallback.FindByShortcut(shortcut)
|
|||||||
return {}
|
return {}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuCallback.Create(options) {{{3
|
"FUNCTION: MenuItem.Create(options) {{{3
|
||||||
function! s:MenuCallback.Create(options)
|
function! s:MenuItem.Create(options)
|
||||||
let newCallback = {}
|
let newMenuItem = {}
|
||||||
let newCallback = copy(self)
|
let newMenuItem = copy(self)
|
||||||
|
|
||||||
let shortcut = a:options['shortcut']
|
let shortcut = a:options['shortcut']
|
||||||
let callback = a:options['callback']
|
let callback = a:options['callback']
|
||||||
|
|
||||||
|
|
||||||
let newCallback.text = a:options['text']
|
let newMenuItem.text = a:options['text']
|
||||||
let newCallback.shortcut = a:options['shortcut']
|
let newMenuItem.shortcut = a:options['shortcut']
|
||||||
let newCallback.callback = a:options['callback']
|
let newMenuItem.callback = a:options['callback']
|
||||||
if has_key(a:options, 'check_to_enable_callback')
|
if has_key(a:options, 'check_to_enable_callback')
|
||||||
let newCallback.check_to_enable_callback = a:options['check_to_enable_callback']
|
let newMenuItem.check_to_enable_callback = a:options['check_to_enable_callback']
|
||||||
endif
|
endif
|
||||||
call add(s:MenuCallback.All(), newCallback)
|
call add(s:MenuItem.All(), newMenuItem)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuCallback.enabled() {{{3
|
"FUNCTION: MenuItem.enabled() {{{3
|
||||||
function! s:MenuCallback.enabled()
|
function! s:MenuItem.enabled()
|
||||||
if has_key(self, "check_to_enable_callback")
|
if has_key(self, "check_to_enable_callback")
|
||||||
return {self.check_to_enable_callback}()
|
return {self.check_to_enable_callback}()
|
||||||
endif
|
endif
|
||||||
return 1
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuCallback.execute() {{{3
|
"FUNCTION: MenuItem.execute() {{{3
|
||||||
function! s:MenuCallback.execute()
|
function! s:MenuItem.execute()
|
||||||
call {self.callback}()
|
call {self.callback}()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuCallback.ShowMenu() {{{3
|
"FUNCTION: MenuItem.ShowMenu() {{{3
|
||||||
function! s:MenuCallback.ShowMenu()
|
function! s:MenuItem.ShowMenu()
|
||||||
let curNode = s:TreeFileNode.GetSelected()
|
let curNode = s:TreeFileNode.GetSelected()
|
||||||
if curNode ==# {}
|
if curNode ==# {}
|
||||||
call s:echo("Put the cursor on a node first" )
|
call s:echo("Put the cursor on a node first" )
|
||||||
@ -500,16 +500,16 @@ function! s:MenuCallback.ShowMenu()
|
|||||||
let prompt = "NERDTree Menu\n" .
|
let prompt = "NERDTree Menu\n" .
|
||||||
\ "==========================================================\n"
|
\ "==========================================================\n"
|
||||||
|
|
||||||
for i in s:MenuCallback.AllEnabledCallbacks()
|
for i in s:MenuItem.AllEnabled()
|
||||||
let prompt .= i.text . "\n"
|
let prompt .= i.text . "\n"
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
echo prompt
|
echo prompt
|
||||||
|
|
||||||
let callback = s:MenuCallback.FindByShortcut(nr2char(getchar()))
|
let menuItem = s:MenuItem.FindByShortcut(nr2char(getchar()))
|
||||||
if !empty(callback) && callback.enabled()
|
if !empty(menuItem) && menuItem.enabled()
|
||||||
redraw
|
redraw
|
||||||
call callback.execute()
|
call menuItem.execute()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
@ -2427,7 +2427,7 @@ function! NERDTreeGetCurrentPath()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! NERDTreeAddMenuItem(options)
|
function! NERDTreeAddMenuItem(options)
|
||||||
call s:MenuCallback.Create(a:options)
|
call s:MenuItem.Create(a:options)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! NERDTreeRender()
|
function! NERDTreeRender()
|
||||||
@ -3639,7 +3639,7 @@ function! s:refreshCurrent()
|
|||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: s:showMenu() {{{2
|
" FUNCTION: s:showMenu() {{{2
|
||||||
function! s:showMenu()
|
function! s:showMenu()
|
||||||
call s:MenuCallback.ShowMenu()
|
call s:MenuItem.ShowMenu()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: s:toggleIgnoreFilter() {{{2
|
" FUNCTION: s:toggleIgnoreFilter() {{{2
|
||||||
|
Loading…
Reference in New Issue
Block a user