mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 11:23:48 -05:00
some cosmetic updates to the class files
* fix the fold markers (they were unnecessarily deep) * always have one line under each method * update some of the fold comments -> always use FUNCTION in all caps * add a modeline to each class file
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
"CLASS: Bookmark {{{2
|
"CLASS: Bookmark
|
||||||
"============================================================
|
"============================================================
|
||||||
let s:Bookmark = {}
|
let s:Bookmark = {}
|
||||||
let g:NERDTreeBookmark = s:Bookmark
|
let g:NERDTreeBookmark = s:Bookmark
|
||||||
" FUNCTION: Bookmark.activate() {{{3
|
|
||||||
|
" FUNCTION: Bookmark.activate() {{{1
|
||||||
function! s:Bookmark.activate(...)
|
function! s:Bookmark.activate(...)
|
||||||
call self.open(a:0 ? a:1 : {})
|
call self.open(a:0 ? a:1 : {})
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.AddBookmark(name, path) {{{3
|
|
||||||
|
" FUNCTION: Bookmark.AddBookmark(name, path) {{{1
|
||||||
" Class method to add a new bookmark to the list, if a previous bookmark exists
|
" Class method to add a new bookmark to the list, if a previous bookmark exists
|
||||||
" with the same name, just update the path for that bookmark
|
" with the same name, just update the path for that bookmark
|
||||||
function! s:Bookmark.AddBookmark(name, path)
|
function! s:Bookmark.AddBookmark(name, path)
|
||||||
@@ -19,7 +21,8 @@ function! s:Bookmark.AddBookmark(name, path)
|
|||||||
call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path))
|
call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path))
|
||||||
call s:Bookmark.Sort()
|
call s:Bookmark.Sort()
|
||||||
endfunction
|
endfunction
|
||||||
" Function: Bookmark.Bookmarks() {{{3
|
|
||||||
|
" FUNCTION: Bookmark.Bookmarks() {{{1
|
||||||
" Class method to get all bookmarks. Lazily initializes the bookmarks global
|
" Class method to get all bookmarks. Lazily initializes the bookmarks global
|
||||||
" variable
|
" variable
|
||||||
function! s:Bookmark.Bookmarks()
|
function! s:Bookmark.Bookmarks()
|
||||||
@@ -28,7 +31,8 @@ function! s:Bookmark.Bookmarks()
|
|||||||
endif
|
endif
|
||||||
return g:NERDTreeBookmarks
|
return g:NERDTreeBookmarks
|
||||||
endfunction
|
endfunction
|
||||||
" Function: Bookmark.BookmarkExistsFor(name) {{{3
|
|
||||||
|
" FUNCTION: Bookmark.BookmarkExistsFor(name) {{{1
|
||||||
" class method that returns 1 if a bookmark with the given name is found, 0
|
" class method that returns 1 if a bookmark with the given name is found, 0
|
||||||
" otherwise
|
" otherwise
|
||||||
function! s:Bookmark.BookmarkExistsFor(name)
|
function! s:Bookmark.BookmarkExistsFor(name)
|
||||||
@@ -39,7 +43,8 @@ function! s:Bookmark.BookmarkExistsFor(name)
|
|||||||
return 0
|
return 0
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
" Function: Bookmark.BookmarkFor(name) {{{3
|
|
||||||
|
" FUNCTION: Bookmark.BookmarkFor(name) {{{1
|
||||||
" Class method to get the bookmark that has the given name. {} is return if no
|
" Class method to get the bookmark that has the given name. {} is return if no
|
||||||
" bookmark is found
|
" bookmark is found
|
||||||
function! s:Bookmark.BookmarkFor(name)
|
function! s:Bookmark.BookmarkFor(name)
|
||||||
@@ -50,7 +55,8 @@ function! s:Bookmark.BookmarkFor(name)
|
|||||||
endfor
|
endfor
|
||||||
throw "NERDTree.BookmarkNotFoundError: no bookmark found for name: \"". a:name .'"'
|
throw "NERDTree.BookmarkNotFoundError: no bookmark found for name: \"". a:name .'"'
|
||||||
endfunction
|
endfunction
|
||||||
" Function: Bookmark.BookmarkNames() {{{3
|
|
||||||
|
" FUNCTION: Bookmark.BookmarkNames() {{{1
|
||||||
" Class method to return an array of all bookmark names
|
" Class method to return an array of all bookmark names
|
||||||
function! s:Bookmark.BookmarkNames()
|
function! s:Bookmark.BookmarkNames()
|
||||||
let names = []
|
let names = []
|
||||||
@@ -59,7 +65,8 @@ function! s:Bookmark.BookmarkNames()
|
|||||||
endfor
|
endfor
|
||||||
return names
|
return names
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.CacheBookmarks(silent) {{{3
|
|
||||||
|
" FUNCTION: Bookmark.CacheBookmarks(silent) {{{1
|
||||||
" Class method to read all bookmarks from the bookmarks file intialize
|
" Class method to read all bookmarks from the bookmarks file intialize
|
||||||
" bookmark objects for each one.
|
" bookmark objects for each one.
|
||||||
"
|
"
|
||||||
@@ -97,12 +104,13 @@ function! s:Bookmark.CacheBookmarks(silent)
|
|||||||
call s:Bookmark.Sort()
|
call s:Bookmark.Sort()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.compareTo(otherbookmark) {{{3
|
|
||||||
|
" FUNCTION: Bookmark.compareTo(otherbookmark) {{{1
|
||||||
" Compare these two bookmarks for sorting purposes
|
" Compare these two bookmarks for sorting purposes
|
||||||
function! s:Bookmark.compareTo(otherbookmark)
|
function! s:Bookmark.compareTo(otherbookmark)
|
||||||
return a:otherbookmark.name < self.name
|
return a:otherbookmark.name < self.name
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.ClearAll() {{{3
|
" FUNCTION: Bookmark.ClearAll() {{{1
|
||||||
" Class method to delete all bookmarks.
|
" Class method to delete all bookmarks.
|
||||||
function! s:Bookmark.ClearAll()
|
function! s:Bookmark.ClearAll()
|
||||||
for i in s:Bookmark.Bookmarks()
|
for i in s:Bookmark.Bookmarks()
|
||||||
@@ -110,7 +118,8 @@ function! s:Bookmark.ClearAll()
|
|||||||
endfor
|
endfor
|
||||||
call s:Bookmark.Write()
|
call s:Bookmark.Write()
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.delete() {{{3
|
|
||||||
|
" FUNCTION: Bookmark.delete() {{{1
|
||||||
" Delete this bookmark. If the node for this bookmark is under the current
|
" Delete this bookmark. If the node for this bookmark is under the current
|
||||||
" root, then recache bookmarks for its Path object
|
" root, then recache bookmarks for its Path object
|
||||||
function! s:Bookmark.delete()
|
function! s:Bookmark.delete()
|
||||||
@@ -125,7 +134,8 @@ function! s:Bookmark.delete()
|
|||||||
endif
|
endif
|
||||||
call s:Bookmark.Write()
|
call s:Bookmark.Write()
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.getNode(searchFromAbsoluteRoot) {{{3
|
|
||||||
|
" FUNCTION: Bookmark.getNode(searchFromAbsoluteRoot) {{{1
|
||||||
" Gets the treenode for this bookmark
|
" Gets the treenode for this bookmark
|
||||||
"
|
"
|
||||||
" Args:
|
" Args:
|
||||||
@@ -139,14 +149,16 @@ function! s:Bookmark.getNode(searchFromAbsoluteRoot)
|
|||||||
endif
|
endif
|
||||||
return targetNode
|
return targetNode
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) {{{3
|
|
||||||
|
" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) {{{1
|
||||||
" Class method that finds the bookmark with the given name and returns the
|
" Class method that finds the bookmark with the given name and returns the
|
||||||
" treenode for it.
|
" treenode for it.
|
||||||
function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot)
|
function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot)
|
||||||
let bookmark = s:Bookmark.BookmarkFor(a:name)
|
let bookmark = s:Bookmark.BookmarkFor(a:name)
|
||||||
return bookmark.getNode(a:searchFromAbsoluteRoot)
|
return bookmark.getNode(a:searchFromAbsoluteRoot)
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.GetSelected() {{{3
|
|
||||||
|
" FUNCTION: Bookmark.GetSelected() {{{1
|
||||||
" returns the Bookmark the cursor is over, or {}
|
" returns the Bookmark the cursor is over, or {}
|
||||||
function! s:Bookmark.GetSelected()
|
function! s:Bookmark.GetSelected()
|
||||||
let line = getline(".")
|
let line = getline(".")
|
||||||
@@ -161,7 +173,7 @@ function! s:Bookmark.GetSelected()
|
|||||||
return {}
|
return {}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: Bookmark.InvalidBookmarks() {{{3
|
" FUNCTION: Bookmark.InvalidBookmarks() {{{1
|
||||||
" Class method to get all invalid bookmark strings read from the bookmarks
|
" Class method to get all invalid bookmark strings read from the bookmarks
|
||||||
" file
|
" file
|
||||||
function! s:Bookmark.InvalidBookmarks()
|
function! s:Bookmark.InvalidBookmarks()
|
||||||
@@ -170,7 +182,8 @@ function! s:Bookmark.InvalidBookmarks()
|
|||||||
endif
|
endif
|
||||||
return g:NERDTreeInvalidBookmarks
|
return g:NERDTreeInvalidBookmarks
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.mustExist() {{{3
|
|
||||||
|
" FUNCTION: Bookmark.mustExist() {{{1
|
||||||
function! s:Bookmark.mustExist()
|
function! s:Bookmark.mustExist()
|
||||||
if !self.path.exists()
|
if !self.path.exists()
|
||||||
call s:Bookmark.CacheBookmarks(1)
|
call s:Bookmark.CacheBookmarks(1)
|
||||||
@@ -178,7 +191,8 @@ function! s:Bookmark.mustExist()
|
|||||||
\ self.name ."\" points to a non existing location: \"". self.path.str()
|
\ self.name ."\" points to a non existing location: \"". self.path.str()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.New(name, path) {{{3
|
|
||||||
|
" FUNCTION: Bookmark.New(name, path) {{{1
|
||||||
" Create a new bookmark object with the given name and path object
|
" Create a new bookmark object with the given name and path object
|
||||||
function! s:Bookmark.New(name, path)
|
function! s:Bookmark.New(name, path)
|
||||||
if a:name =~# ' '
|
if a:name =~# ' '
|
||||||
@@ -190,7 +204,8 @@ function! s:Bookmark.New(name, path)
|
|||||||
let newBookmark.path = a:path
|
let newBookmark.path = a:path
|
||||||
return newBookmark
|
return newBookmark
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.open([options]) {{{3
|
|
||||||
|
" FUNCTION: Bookmark.open([options]) {{{1
|
||||||
"Args:
|
"Args:
|
||||||
"A dictionary containing the following keys (all optional):
|
"A dictionary containing the following keys (all optional):
|
||||||
" 'where': Specifies whether the node should be opened in new split/tab or in
|
" 'where': Specifies whether the node should be opened in new split/tab or in
|
||||||
@@ -210,24 +225,28 @@ function! s:Bookmark.open(...)
|
|||||||
call opener.open(self)
|
call opener.open(self)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.openInNewTab(options) {{{3
|
|
||||||
|
" FUNCTION: Bookmark.openInNewTab(options) {{{1
|
||||||
" Create a new bookmark object with the given name and path object
|
" Create a new bookmark object with the given name and path object
|
||||||
function! s:Bookmark.openInNewTab(options)
|
function! s:Bookmark.openInNewTab(options)
|
||||||
call nerdtree#deprecated('Bookmark.openInNewTab', 'is deprecated, use open() instead')
|
call nerdtree#deprecated('Bookmark.openInNewTab', 'is deprecated, use open() instead')
|
||||||
call self.open(a:options)
|
call self.open(a:options)
|
||||||
endfunction
|
endfunction
|
||||||
" Function: Bookmark.setPath(path) {{{3
|
|
||||||
|
" FUNCTION: Bookmark.setPath(path) {{{1
|
||||||
" makes this bookmark point to the given path
|
" makes this bookmark point to the given path
|
||||||
function! s:Bookmark.setPath(path)
|
function! s:Bookmark.setPath(path)
|
||||||
let self.path = a:path
|
let self.path = a:path
|
||||||
endfunction
|
endfunction
|
||||||
" Function: Bookmark.Sort() {{{3
|
|
||||||
|
" FUNCTION: Bookmark.Sort() {{{1
|
||||||
" Class method that sorts all bookmarks
|
" Class method that sorts all bookmarks
|
||||||
function! s:Bookmark.Sort()
|
function! s:Bookmark.Sort()
|
||||||
let CompareFunc = function("nerdtree#compareBookmarks")
|
let CompareFunc = function("nerdtree#compareBookmarks")
|
||||||
call sort(s:Bookmark.Bookmarks(), CompareFunc)
|
call sort(s:Bookmark.Bookmarks(), CompareFunc)
|
||||||
endfunction
|
endfunction
|
||||||
" Function: Bookmark.str() {{{3
|
|
||||||
|
" FUNCTION: Bookmark.str() {{{1
|
||||||
" Get the string that should be rendered in the view for this bookmark
|
" Get the string that should be rendered in the view for this bookmark
|
||||||
function! s:Bookmark.str()
|
function! s:Bookmark.str()
|
||||||
let pathStrMaxLen = winwidth(nerdtree#getTreeWinNum()) - 4 - len(self.name)
|
let pathStrMaxLen = winwidth(nerdtree#getTreeWinNum()) - 4 - len(self.name)
|
||||||
@@ -241,7 +260,8 @@ function! s:Bookmark.str()
|
|||||||
endif
|
endif
|
||||||
return '>' . self.name . ' ' . pathStr
|
return '>' . self.name . ' ' . pathStr
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.toRoot() {{{3
|
|
||||||
|
" FUNCTION: Bookmark.toRoot() {{{1
|
||||||
" Make the node for this bookmark the new tree root
|
" Make the node for this bookmark the new tree root
|
||||||
function! s:Bookmark.toRoot()
|
function! s:Bookmark.toRoot()
|
||||||
if self.validate()
|
if self.validate()
|
||||||
@@ -255,15 +275,15 @@ function! s:Bookmark.toRoot()
|
|||||||
call targetNode.putCursorHere(0, 0)
|
call targetNode.putCursorHere(0, 0)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: Bookmark.ToRoot(name) {{{3
|
|
||||||
|
" FUNCTION: Bookmark.ToRoot(name) {{{1
|
||||||
" Make the node for this bookmark the new tree root
|
" Make the node for this bookmark the new tree root
|
||||||
function! s:Bookmark.ToRoot(name)
|
function! s:Bookmark.ToRoot(name)
|
||||||
let bookmark = s:Bookmark.BookmarkFor(a:name)
|
let bookmark = s:Bookmark.BookmarkFor(a:name)
|
||||||
call bookmark.toRoot()
|
call bookmark.toRoot()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" FUNCTION: Bookmark.validate() {{{1
|
||||||
"FUNCTION: Bookmark.validate() {{{3
|
|
||||||
function! s:Bookmark.validate()
|
function! s:Bookmark.validate()
|
||||||
if self.path.exists()
|
if self.path.exists()
|
||||||
return 1
|
return 1
|
||||||
@@ -275,7 +295,7 @@ function! s:Bookmark.validate()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: Bookmark.Write() {{{3
|
" FUNCTION: Bookmark.Write() {{{1
|
||||||
" Class method to write all bookmarks to the bookmarks file
|
" Class method to write all bookmarks to the bookmarks file
|
||||||
function! s:Bookmark.Write()
|
function! s:Bookmark.Write()
|
||||||
let bookmarkStrings = []
|
let bookmarkStrings = []
|
||||||
@@ -291,3 +311,5 @@ function! s:Bookmark.Write()
|
|||||||
endfor
|
endfor
|
||||||
call writefile(bookmarkStrings, g:NERDTreeBookmarksFile)
|
call writefile(bookmarkStrings, g:NERDTreeBookmarksFile)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
"CLASS: KeyMap {{{2
|
"CLASS: KeyMap
|
||||||
"============================================================
|
"============================================================
|
||||||
let s:KeyMap = {}
|
let s:KeyMap = {}
|
||||||
let g:NERDTreeKeyMap = s:KeyMap
|
let g:NERDTreeKeyMap = s:KeyMap
|
||||||
"FUNCTION: KeyMap.All() {{{3
|
|
||||||
|
"FUNCTION: KeyMap.All() {{{1
|
||||||
function! s:KeyMap.All()
|
function! s:KeyMap.All()
|
||||||
if !exists("s:keyMaps")
|
if !exists("s:keyMaps")
|
||||||
let s:keyMaps = []
|
let s:keyMaps = []
|
||||||
@@ -10,7 +11,7 @@ function! s:KeyMap.All()
|
|||||||
return s:keyMaps
|
return s:keyMaps
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: KeyMap.FindFor(key, scope) {{{3
|
"FUNCTION: KeyMap.FindFor(key, scope) {{{1
|
||||||
function! s:KeyMap.FindFor(key, scope)
|
function! s:KeyMap.FindFor(key, scope)
|
||||||
for i in s:KeyMap.All()
|
for i in s:KeyMap.All()
|
||||||
if i.key ==# a:key && i.scope ==# a:scope
|
if i.key ==# a:key && i.scope ==# a:scope
|
||||||
@@ -20,14 +21,14 @@ function! s:KeyMap.FindFor(key, scope)
|
|||||||
return {}
|
return {}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: KeyMap.BindAll() {{{3
|
"FUNCTION: KeyMap.BindAll() {{{1
|
||||||
function! s:KeyMap.BindAll()
|
function! s:KeyMap.BindAll()
|
||||||
for i in s:KeyMap.All()
|
for i in s:KeyMap.All()
|
||||||
call i.bind()
|
call i.bind()
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: KeyMap.bind() {{{3
|
"FUNCTION: KeyMap.bind() {{{1
|
||||||
function! s:KeyMap.bind()
|
function! s:KeyMap.bind()
|
||||||
" If the key sequence we're trying to map contains any '<>' notation, we
|
" If the key sequence we're trying to map contains any '<>' notation, we
|
||||||
" must replace each of the '<' characters with '<lt>' to ensure the string
|
" must replace each of the '<' characters with '<lt>' to ensure the string
|
||||||
@@ -46,7 +47,7 @@ function! s:KeyMap.bind()
|
|||||||
exec 'nnoremap <buffer> <silent> '. self.key . premap . ':call nerdtree#invokeKeyMap("'. keymapInvokeString .'")<cr>'
|
exec 'nnoremap <buffer> <silent> '. self.key . premap . ':call nerdtree#invokeKeyMap("'. keymapInvokeString .'")<cr>'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: KeyMap.Remove(key, scope) {{{3
|
"FUNCTION: KeyMap.Remove(key, scope) {{{1
|
||||||
function! s:KeyMap.Remove(key, scope)
|
function! s:KeyMap.Remove(key, scope)
|
||||||
let maps = s:KeyMap.All()
|
let maps = s:KeyMap.All()
|
||||||
for i in range(len(maps))
|
for i in range(len(maps))
|
||||||
@@ -55,7 +56,8 @@ function! s:KeyMap.Remove(key, scope)
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: KeyMap.invoke() {{{3
|
|
||||||
|
"FUNCTION: KeyMap.invoke() {{{1
|
||||||
"Call the KeyMaps callback function
|
"Call the KeyMaps callback function
|
||||||
function! s:KeyMap.invoke(...)
|
function! s:KeyMap.invoke(...)
|
||||||
let Callback = function(self.callback)
|
let Callback = function(self.callback)
|
||||||
@@ -66,8 +68,7 @@ function! s:KeyMap.invoke(...)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: KeyMap.Invoke() {{{1
|
||||||
"FUNCTION: KeyMap.Invoke() {{{3
|
|
||||||
"Find a keymapping for a:key and the current scope invoke it.
|
"Find a keymapping for a:key and the current scope invoke it.
|
||||||
"
|
"
|
||||||
"Scope is determined as follows:
|
"Scope is determined as follows:
|
||||||
@@ -121,7 +122,7 @@ function! s:KeyMap.Invoke(key)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: KeyMap.Create(options) {{{3
|
"FUNCTION: KeyMap.Create(options) {{{1
|
||||||
function! s:KeyMap.Create(options)
|
function! s:KeyMap.Create(options)
|
||||||
let newKeyMap = copy(self)
|
let newKeyMap = copy(self)
|
||||||
let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options))
|
let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options))
|
||||||
@@ -133,7 +134,7 @@ function! s:KeyMap.Create(options)
|
|||||||
call s:KeyMap.Add(newKeyMap)
|
call s:KeyMap.Add(newKeyMap)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: KeyMap.Add(keymap) {{{3
|
"FUNCTION: KeyMap.Add(keymap) {{{1
|
||||||
function! s:KeyMap.Add(keymap)
|
function! s:KeyMap.Add(keymap)
|
||||||
call s:KeyMap.Remove(a:keymap.key, a:keymap.scope)
|
call s:KeyMap.Remove(a:keymap.key, a:keymap.scope)
|
||||||
call add(s:KeyMap.All(), a:keymap)
|
call add(s:KeyMap.All(), a:keymap)
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
"CLASS: MenuController {{{2
|
"CLASS: MenuController
|
||||||
"============================================================
|
"============================================================
|
||||||
let s:MenuController = {}
|
let s:MenuController = {}
|
||||||
let g:NERDTreeMenuController = s:MenuController
|
let g:NERDTreeMenuController = s:MenuController
|
||||||
"FUNCTION: MenuController.New(menuItems) {{{3
|
|
||||||
|
"FUNCTION: MenuController.New(menuItems) {{{1
|
||||||
"create a new menu controller that operates on the given menu items
|
"create a new menu controller that operates on the given menu items
|
||||||
function! s:MenuController.New(menuItems)
|
function! s:MenuController.New(menuItems)
|
||||||
let newMenuController = copy(self)
|
let newMenuController = copy(self)
|
||||||
@@ -14,7 +15,7 @@ function! s:MenuController.New(menuItems)
|
|||||||
return newMenuController
|
return newMenuController
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuController.showMenu() {{{3
|
"FUNCTION: MenuController.showMenu() {{{1
|
||||||
"start the main loop of the menu and get the user to choose/execute a menu
|
"start the main loop of the menu and get the user to choose/execute a menu
|
||||||
"item
|
"item
|
||||||
function! s:MenuController.showMenu()
|
function! s:MenuController.showMenu()
|
||||||
@@ -40,7 +41,7 @@ function! s:MenuController.showMenu()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuController._echoPrompt() {{{3
|
"FUNCTION: MenuController._echoPrompt() {{{1
|
||||||
function! s:MenuController._echoPrompt()
|
function! s:MenuController._echoPrompt()
|
||||||
echo "NERDTree Menu. Use j/k/enter and the shortcuts indicated"
|
echo "NERDTree Menu. Use j/k/enter and the shortcuts indicated"
|
||||||
echo "=========================================================="
|
echo "=========================================================="
|
||||||
@@ -54,13 +55,13 @@ function! s:MenuController._echoPrompt()
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuController._current(key) {{{3
|
"FUNCTION: MenuController._current(key) {{{1
|
||||||
"get the MenuItem that is currently selected
|
"get the MenuItem that is currently selected
|
||||||
function! s:MenuController._current()
|
function! s:MenuController._current()
|
||||||
return self.menuItems[self.selection]
|
return self.menuItems[self.selection]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuController._handleKeypress(key) {{{3
|
"FUNCTION: MenuController._handleKeypress(key) {{{1
|
||||||
"change the selection (if appropriate) and return 1 if the user has made
|
"change the selection (if appropriate) and return 1 if the user has made
|
||||||
"their choice, 0 otherwise
|
"their choice, 0 otherwise
|
||||||
function! s:MenuController._handleKeypress(key)
|
function! s:MenuController._handleKeypress(key)
|
||||||
@@ -86,7 +87,7 @@ function! s:MenuController._handleKeypress(key)
|
|||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuController._allIndexesFor(shortcut) {{{3
|
"FUNCTION: MenuController._allIndexesFor(shortcut) {{{1
|
||||||
"get indexes to all menu items with the given shortcut
|
"get indexes to all menu items with the given shortcut
|
||||||
function! s:MenuController._allIndexesFor(shortcut)
|
function! s:MenuController._allIndexesFor(shortcut)
|
||||||
let toReturn = []
|
let toReturn = []
|
||||||
@@ -100,7 +101,7 @@ function! s:MenuController._allIndexesFor(shortcut)
|
|||||||
return toReturn
|
return toReturn
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuController._nextIndexFor(shortcut) {{{3
|
"FUNCTION: MenuController._nextIndexFor(shortcut) {{{1
|
||||||
"get the index to the next menu item with the given shortcut, starts from the
|
"get the index to the next menu item with the given shortcut, starts from the
|
||||||
"current cursor location and wraps around to the top again if need be
|
"current cursor location and wraps around to the top again if need be
|
||||||
function! s:MenuController._nextIndexFor(shortcut)
|
function! s:MenuController._nextIndexFor(shortcut)
|
||||||
@@ -119,13 +120,13 @@ function! s:MenuController._nextIndexFor(shortcut)
|
|||||||
return -1
|
return -1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuController._setCmdheight() {{{3
|
"FUNCTION: MenuController._setCmdheight() {{{1
|
||||||
"sets &cmdheight to whatever is needed to display the menu
|
"sets &cmdheight to whatever is needed to display the menu
|
||||||
function! s:MenuController._setCmdheight()
|
function! s:MenuController._setCmdheight()
|
||||||
let &cmdheight = len(self.menuItems) + 3
|
let &cmdheight = len(self.menuItems) + 3
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuController._saveOptions() {{{3
|
"FUNCTION: MenuController._saveOptions() {{{1
|
||||||
"set any vim options that are required to make the menu work (saving their old
|
"set any vim options that are required to make the menu work (saving their old
|
||||||
"values)
|
"values)
|
||||||
function! s:MenuController._saveOptions()
|
function! s:MenuController._saveOptions()
|
||||||
@@ -135,14 +136,14 @@ function! s:MenuController._saveOptions()
|
|||||||
call self._setCmdheight()
|
call self._setCmdheight()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuController._restoreOptions() {{{3
|
"FUNCTION: MenuController._restoreOptions() {{{1
|
||||||
"restore the options we saved in _saveOptions()
|
"restore the options we saved in _saveOptions()
|
||||||
function! s:MenuController._restoreOptions()
|
function! s:MenuController._restoreOptions()
|
||||||
let &cmdheight = self._oldCmdheight
|
let &cmdheight = self._oldCmdheight
|
||||||
let &lazyredraw = self._oldLazyredraw
|
let &lazyredraw = self._oldLazyredraw
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuController._cursorDown() {{{3
|
"FUNCTION: MenuController._cursorDown() {{{1
|
||||||
"move the cursor to the next menu item, skipping separators
|
"move the cursor to the next menu item, skipping separators
|
||||||
function! s:MenuController._cursorDown()
|
function! s:MenuController._cursorDown()
|
||||||
let done = 0
|
let done = 0
|
||||||
@@ -159,7 +160,7 @@ function! s:MenuController._cursorDown()
|
|||||||
endwhile
|
endwhile
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuController._cursorUp() {{{3
|
"FUNCTION: MenuController._cursorUp() {{{1
|
||||||
"move the cursor to the previous menu item, skipping separators
|
"move the cursor to the previous menu item, skipping separators
|
||||||
function! s:MenuController._cursorUp()
|
function! s:MenuController._cursorUp()
|
||||||
let done = 0
|
let done = 0
|
||||||
@@ -176,3 +177,4 @@ function! s:MenuController._cursorUp()
|
|||||||
endwhile
|
endwhile
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
"CLASS: MenuItem {{{2
|
"CLASS: MenuItem
|
||||||
"============================================================
|
"============================================================
|
||||||
let s:MenuItem = {}
|
let s:MenuItem = {}
|
||||||
let g:NERDTreeMenuItem = s:MenuItem
|
let g:NERDTreeMenuItem = s:MenuItem
|
||||||
"FUNCTION: MenuItem.All() {{{3
|
|
||||||
|
"FUNCTION: MenuItem.All() {{{1
|
||||||
"get all top level menu items
|
"get all top level menu items
|
||||||
function! s:MenuItem.All()
|
function! s:MenuItem.All()
|
||||||
if !exists("s:menuItems")
|
if !exists("s:menuItems")
|
||||||
@@ -11,7 +12,7 @@ function! s:MenuItem.All()
|
|||||||
return s:menuItems
|
return s:menuItems
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuItem.AllEnabled() {{{3
|
"FUNCTION: MenuItem.AllEnabled() {{{1
|
||||||
"get all top level menu items that are currently enabled
|
"get all top level menu items that are currently enabled
|
||||||
function! s:MenuItem.AllEnabled()
|
function! s:MenuItem.AllEnabled()
|
||||||
let toReturn = []
|
let toReturn = []
|
||||||
@@ -23,7 +24,7 @@ function! s:MenuItem.AllEnabled()
|
|||||||
return toReturn
|
return toReturn
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuItem.Create(options) {{{3
|
"FUNCTION: MenuItem.Create(options) {{{1
|
||||||
"make a new menu item and add it to the global list
|
"make a new menu item and add it to the global list
|
||||||
function! s:MenuItem.Create(options)
|
function! s:MenuItem.Create(options)
|
||||||
let newMenuItem = copy(self)
|
let newMenuItem = copy(self)
|
||||||
@@ -51,7 +52,7 @@ function! s:MenuItem.Create(options)
|
|||||||
return newMenuItem
|
return newMenuItem
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuItem.CreateSeparator(options) {{{3
|
"FUNCTION: MenuItem.CreateSeparator(options) {{{1
|
||||||
"make a new separator menu item and add it to the global list
|
"make a new separator menu item and add it to the global list
|
||||||
function! s:MenuItem.CreateSeparator(options)
|
function! s:MenuItem.CreateSeparator(options)
|
||||||
let standard_options = { 'text': '--------------------',
|
let standard_options = { 'text': '--------------------',
|
||||||
@@ -62,7 +63,7 @@ function! s:MenuItem.CreateSeparator(options)
|
|||||||
return s:MenuItem.Create(options)
|
return s:MenuItem.Create(options)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuItem.CreateSubmenu(options) {{{3
|
"FUNCTION: MenuItem.CreateSubmenu(options) {{{1
|
||||||
"make a new submenu and add it to global list
|
"make a new submenu and add it to global list
|
||||||
function! s:MenuItem.CreateSubmenu(options)
|
function! s:MenuItem.CreateSubmenu(options)
|
||||||
let standard_options = { 'callback': -1 }
|
let standard_options = { 'callback': -1 }
|
||||||
@@ -71,7 +72,7 @@ function! s:MenuItem.CreateSubmenu(options)
|
|||||||
return s:MenuItem.Create(options)
|
return s:MenuItem.Create(options)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuItem.enabled() {{{3
|
"FUNCTION: MenuItem.enabled() {{{1
|
||||||
"return 1 if this menu item should be displayed
|
"return 1 if this menu item should be displayed
|
||||||
"
|
"
|
||||||
"delegates off to the isActiveCallback, and defaults to 1 if no callback was
|
"delegates off to the isActiveCallback, and defaults to 1 if no callback was
|
||||||
@@ -83,7 +84,7 @@ function! s:MenuItem.enabled()
|
|||||||
return 1
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuItem.execute() {{{3
|
"FUNCTION: MenuItem.execute() {{{1
|
||||||
"perform the action behind this menu item, if this menuitem has children then
|
"perform the action behind this menu item, if this menuitem has children then
|
||||||
"display a new menu for them, otherwise deletegate off to the menuitem's
|
"display a new menu for them, otherwise deletegate off to the menuitem's
|
||||||
"callback
|
"callback
|
||||||
@@ -98,15 +99,16 @@ function! s:MenuItem.execute()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuItem.isSeparator() {{{3
|
"FUNCTION: MenuItem.isSeparator() {{{1
|
||||||
"return 1 if this menuitem is a separator
|
"return 1 if this menuitem is a separator
|
||||||
function! s:MenuItem.isSeparator()
|
function! s:MenuItem.isSeparator()
|
||||||
return self.callback == -1 && self.children == []
|
return self.callback == -1 && self.children == []
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: MenuItem.isSubmenu() {{{3
|
"FUNCTION: MenuItem.isSubmenu() {{{1
|
||||||
"return 1 if this menuitem is a submenu
|
"return 1 if this menuitem is a submenu
|
||||||
function! s:MenuItem.isSubmenu()
|
function! s:MenuItem.isSubmenu()
|
||||||
return self.callback == -1 && !empty(self.children)
|
return self.callback == -1 && !empty(self.children)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
"CLASS: Opener {{{2
|
"CLASS: Opener
|
||||||
"============================================================
|
"============================================================
|
||||||
let s:Opener = {}
|
let s:Opener = {}
|
||||||
let g:NERDTreeOpener = s:Opener
|
let g:NERDTreeOpener = s:Opener
|
||||||
|
|
||||||
"FUNCTION: Opener._checkToCloseTree(newtab) {{{3
|
"FUNCTION: Opener._checkToCloseTree(newtab) {{{1
|
||||||
"Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see
|
"Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see
|
||||||
"if the tree should be closed now.
|
"if the tree should be closed now.
|
||||||
"
|
"
|
||||||
@@ -21,7 +21,7 @@ function! s:Opener._checkToCloseTree(newtab)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Opener._gotoTargetWin() {{{3
|
"FUNCTION: Opener._gotoTargetWin() {{{1
|
||||||
function! s:Opener._gotoTargetWin()
|
function! s:Opener._gotoTargetWin()
|
||||||
if b:NERDTreeType ==# "secondary"
|
if b:NERDTreeType ==# "secondary"
|
||||||
if self._where == 'v'
|
if self._where == 'v'
|
||||||
@@ -48,7 +48,7 @@ function! s:Opener._gotoTargetWin()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Opener.New(path, opts) {{{3
|
"FUNCTION: Opener.New(path, opts) {{{1
|
||||||
"Args:
|
"Args:
|
||||||
"
|
"
|
||||||
"a:path: The path object that is to be opened.
|
"a:path: The path object that is to be opened.
|
||||||
@@ -76,7 +76,7 @@ function! s:Opener.New(path, opts)
|
|||||||
return newObj
|
return newObj
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Opener._newSplit() {{{3
|
"FUNCTION: Opener._newSplit() {{{1
|
||||||
function! s:Opener._newSplit()
|
function! s:Opener._newSplit()
|
||||||
" Save the user's settings for splitbelow and splitright
|
" Save the user's settings for splitbelow and splitright
|
||||||
let savesplitbelow=&splitbelow
|
let savesplitbelow=&splitbelow
|
||||||
@@ -136,7 +136,7 @@ function! s:Opener._newSplit()
|
|||||||
let &splitright=savesplitright
|
let &splitright=savesplitright
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Opener._newVSplit() {{{3
|
"FUNCTION: Opener._newVSplit() {{{1
|
||||||
function! s:Opener._newVSplit()
|
function! s:Opener._newVSplit()
|
||||||
let winwidth = winwidth(".")
|
let winwidth = winwidth(".")
|
||||||
if winnr("$")==#1
|
if winnr("$")==#1
|
||||||
@@ -152,7 +152,7 @@ function! s:Opener._newVSplit()
|
|||||||
call nerdtree#exec('wincmd p')
|
call nerdtree#exec('wincmd p')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Opener.open(target) {{{3
|
"FUNCTION: Opener.open(target) {{{1
|
||||||
function! s:Opener.open(target)
|
function! s:Opener.open(target)
|
||||||
if self._path.isDirectory
|
if self._path.isDirectory
|
||||||
call self._openDirectory(a:target)
|
call self._openDirectory(a:target)
|
||||||
@@ -161,7 +161,7 @@ function! s:Opener.open(target)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Opener._openFile() {{{3
|
"FUNCTION: Opener._openFile() {{{1
|
||||||
function! s:Opener._openFile()
|
function! s:Opener._openFile()
|
||||||
if self._reuse && self._reuseWindow()
|
if self._reuse && self._reuseWindow()
|
||||||
return
|
return
|
||||||
@@ -181,7 +181,7 @@ function! s:Opener._openFile()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Opener._openDirectory(node) {{{3
|
"FUNCTION: Opener._openDirectory(node) {{{1
|
||||||
function! s:Opener._openDirectory(node)
|
function! s:Opener._openDirectory(node)
|
||||||
if self._treetype ==# "secondary"
|
if self._treetype ==# "secondary"
|
||||||
call self._gotoTargetWin()
|
call self._gotoTargetWin()
|
||||||
@@ -204,7 +204,7 @@ function! s:Opener._openDirectory(node)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Opener._previousWindow() {{{3
|
"FUNCTION: Opener._previousWindow() {{{1
|
||||||
function! s:Opener._previousWindow()
|
function! s:Opener._previousWindow()
|
||||||
if !nerdtree#isWindowUsable(winnr("#")) && nerdtree#firstUsableWindow() ==# -1
|
if !nerdtree#isWindowUsable(winnr("#")) && nerdtree#firstUsableWindow() ==# -1
|
||||||
call self._newSplit()
|
call self._newSplit()
|
||||||
@@ -224,13 +224,13 @@ function! s:Opener._previousWindow()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Opener._restoreCursorPos(){{{3
|
"FUNCTION: Opener._restoreCursorPos(){{{1
|
||||||
function! s:Opener._restoreCursorPos()
|
function! s:Opener._restoreCursorPos()
|
||||||
call nerdtree#exec('normal ' . self._tabnr . 'gt')
|
call nerdtree#exec('normal ' . self._tabnr . 'gt')
|
||||||
call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w')
|
call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Opener._reuseWindow(){{{3
|
"FUNCTION: Opener._reuseWindow(){{{1
|
||||||
"put the cursor in the first window we find for this file
|
"put the cursor in the first window we find for this file
|
||||||
"
|
"
|
||||||
"return 1 if we were successful
|
"return 1 if we were successful
|
||||||
@@ -255,9 +255,10 @@ function! s:Opener._reuseWindow()
|
|||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Opener._saveCursorPos(){{{3
|
"FUNCTION: Opener._saveCursorPos(){{{1
|
||||||
function! s:Opener._saveCursorPos()
|
function! s:Opener._saveCursorPos()
|
||||||
let self._bufnr = bufnr("")
|
let self._bufnr = bufnr("")
|
||||||
let self._tabnr = tabpagenr()
|
let self._tabnr = tabpagenr()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
"once here
|
"once here
|
||||||
let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*')
|
let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*')
|
||||||
|
|
||||||
"CLASS: Path {{{2
|
"CLASS: Path
|
||||||
"============================================================
|
"============================================================
|
||||||
let s:Path = {}
|
let s:Path = {}
|
||||||
let g:NERDTreePath = s:Path
|
let g:NERDTreePath = s:Path
|
||||||
"FUNCTION: Path.AbsolutePathFor(str) {{{3
|
|
||||||
|
"FUNCTION: Path.AbsolutePathFor(str) {{{1
|
||||||
function! s:Path.AbsolutePathFor(str)
|
function! s:Path.AbsolutePathFor(str)
|
||||||
let prependCWD = 0
|
let prependCWD = 0
|
||||||
if nerdtree#runningWindows()
|
if nerdtree#runningWindows()
|
||||||
@@ -22,14 +23,16 @@ function! s:Path.AbsolutePathFor(str)
|
|||||||
|
|
||||||
return toReturn
|
return toReturn
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path.bookmarkNames() {{{3
|
|
||||||
|
"FUNCTION: Path.bookmarkNames() {{{1
|
||||||
function! s:Path.bookmarkNames()
|
function! s:Path.bookmarkNames()
|
||||||
if !exists("self._bookmarkNames")
|
if !exists("self._bookmarkNames")
|
||||||
call self.cacheDisplayString()
|
call self.cacheDisplayString()
|
||||||
endif
|
endif
|
||||||
return self._bookmarkNames
|
return self._bookmarkNames
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path.cacheDisplayString() {{{3
|
|
||||||
|
"FUNCTION: Path.cacheDisplayString() {{{1
|
||||||
function! s:Path.cacheDisplayString()
|
function! s:Path.cacheDisplayString()
|
||||||
let self.cachedDisplayString = self.getLastPathComponent(1)
|
let self.cachedDisplayString = self.getLastPathComponent(1)
|
||||||
|
|
||||||
@@ -55,7 +58,8 @@ function! s:Path.cacheDisplayString()
|
|||||||
let self.cachedDisplayString .= ' [RO]'
|
let self.cachedDisplayString .= ' [RO]'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path.changeToDir() {{{3
|
|
||||||
|
"FUNCTION: Path.changeToDir() {{{1
|
||||||
function! s:Path.changeToDir()
|
function! s:Path.changeToDir()
|
||||||
let dir = self.str({'format': 'Cd'})
|
let dir = self.str({'format': 'Cd'})
|
||||||
if self.isDirectory ==# 0
|
if self.isDirectory ==# 0
|
||||||
@@ -70,7 +74,7 @@ function! s:Path.changeToDir()
|
|||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.compareTo() {{{3
|
"FUNCTION: Path.compareTo() {{{1
|
||||||
"
|
"
|
||||||
"Compares this Path to the given path and returns 0 if they are equal, -1 if
|
"Compares this Path to the given path and returns 0 if they are equal, -1 if
|
||||||
"this Path is "less than" the given path, or 1 if it is "greater".
|
"this Path is "less than" the given path, or 1 if it is "greater".
|
||||||
@@ -110,7 +114,7 @@ function! s:Path.compareTo(path)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.Create(fullpath) {{{3
|
"FUNCTION: Path.Create(fullpath) {{{1
|
||||||
"
|
"
|
||||||
"Factory method.
|
"Factory method.
|
||||||
"
|
"
|
||||||
@@ -146,7 +150,7 @@ function! s:Path.Create(fullpath)
|
|||||||
return s:Path.New(a:fullpath)
|
return s:Path.New(a:fullpath)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.copy(dest) {{{3
|
"FUNCTION: Path.copy(dest) {{{1
|
||||||
"
|
"
|
||||||
"Copies the file/dir represented by this Path to the given location
|
"Copies the file/dir represented by this Path to the given location
|
||||||
"
|
"
|
||||||
@@ -166,15 +170,14 @@ function! s:Path.copy(dest)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.CopyingSupported() {{{3
|
"FUNCTION: Path.CopyingSupported() {{{1
|
||||||
"
|
"
|
||||||
"returns 1 if copying is supported for this OS
|
"returns 1 if copying is supported for this OS
|
||||||
function! s:Path.CopyingSupported()
|
function! s:Path.CopyingSupported()
|
||||||
return exists('g:NERDTreeCopyCmd')
|
return exists('g:NERDTreeCopyCmd')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: Path.copyingWillOverwrite(dest) {{{1
|
||||||
"FUNCTION: Path.copyingWillOverwrite(dest) {{{3
|
|
||||||
"
|
"
|
||||||
"returns 1 if copy this path to the given location will cause files to
|
"returns 1 if copy this path to the given location will cause files to
|
||||||
"overwritten
|
"overwritten
|
||||||
@@ -194,7 +197,7 @@ function! s:Path.copyingWillOverwrite(dest)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.delete() {{{3
|
"FUNCTION: Path.delete() {{{1
|
||||||
"
|
"
|
||||||
"Deletes the file represented by this path.
|
"Deletes the file represented by this path.
|
||||||
"Deletion of directories is not supported
|
"Deletion of directories is not supported
|
||||||
@@ -223,7 +226,7 @@ function! s:Path.delete()
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.displayString() {{{3
|
"FUNCTION: Path.displayString() {{{1
|
||||||
"
|
"
|
||||||
"Returns a string that specifies how the path should be represented as a
|
"Returns a string that specifies how the path should be represented as a
|
||||||
"string
|
"string
|
||||||
@@ -234,11 +237,13 @@ function! s:Path.displayString()
|
|||||||
|
|
||||||
return self.cachedDisplayString
|
return self.cachedDisplayString
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path.edit() {{{3
|
|
||||||
|
"FUNCTION: Path.edit() {{{1
|
||||||
function! s:Path.edit()
|
function! s:Path.edit()
|
||||||
exec "edit " . self.str({'format': 'Edit'})
|
exec "edit " . self.str({'format': 'Edit'})
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path.extractDriveLetter(fullpath) {{{3
|
|
||||||
|
"FUNCTION: Path.extractDriveLetter(fullpath) {{{1
|
||||||
"
|
"
|
||||||
"If running windows, cache the drive letter for this path
|
"If running windows, cache the drive letter for this path
|
||||||
function! s:Path.extractDriveLetter(fullpath)
|
function! s:Path.extractDriveLetter(fullpath)
|
||||||
@@ -255,13 +260,15 @@ function! s:Path.extractDriveLetter(fullpath)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path.exists() {{{3
|
|
||||||
|
"FUNCTION: Path.exists() {{{1
|
||||||
"return 1 if this path points to a location that is readable or is a directory
|
"return 1 if this path points to a location that is readable or is a directory
|
||||||
function! s:Path.exists()
|
function! s:Path.exists()
|
||||||
let p = self.str()
|
let p = self.str()
|
||||||
return filereadable(p) || isdirectory(p)
|
return filereadable(p) || isdirectory(p)
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path.getDir() {{{3
|
|
||||||
|
"FUNCTION: Path.getDir() {{{1
|
||||||
"
|
"
|
||||||
"Returns this path if it is a directory, else this paths parent.
|
"Returns this path if it is a directory, else this paths parent.
|
||||||
"
|
"
|
||||||
@@ -274,7 +281,8 @@ function! s:Path.getDir()
|
|||||||
return self.getParent()
|
return self.getParent()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path.getParent() {{{3
|
|
||||||
|
"FUNCTION: Path.getParent() {{{1
|
||||||
"
|
"
|
||||||
"Returns a new path object for this paths parent
|
"Returns a new path object for this paths parent
|
||||||
"
|
"
|
||||||
@@ -289,7 +297,8 @@ function! s:Path.getParent()
|
|||||||
|
|
||||||
return s:Path.New(path)
|
return s:Path.New(path)
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path.getLastPathComponent(dirSlash) {{{3
|
|
||||||
|
"FUNCTION: Path.getLastPathComponent(dirSlash) {{{1
|
||||||
"
|
"
|
||||||
"Gets the last part of this path.
|
"Gets the last part of this path.
|
||||||
"
|
"
|
||||||
@@ -307,7 +316,7 @@ function! s:Path.getLastPathComponent(dirSlash)
|
|||||||
return toReturn
|
return toReturn
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.getSortOrderIndex() {{{3
|
"FUNCTION: Path.getSortOrderIndex() {{{1
|
||||||
"returns the index of the pattern in g:NERDTreeSortOrder that this path matches
|
"returns the index of the pattern in g:NERDTreeSortOrder that this path matches
|
||||||
function! s:Path.getSortOrderIndex()
|
function! s:Path.getSortOrderIndex()
|
||||||
let i = 0
|
let i = 0
|
||||||
@@ -320,14 +329,13 @@ function! s:Path.getSortOrderIndex()
|
|||||||
return s:NERDTreeSortStarIndex
|
return s:NERDTreeSortStarIndex
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"FUNCTION: Path.isUnixHiddenFile() {{{1
|
||||||
"FUNCTION: Path.isUnixHiddenFile() {{{3
|
|
||||||
"check for unix hidden files
|
"check for unix hidden files
|
||||||
function! s:Path.isUnixHiddenFile()
|
function! s:Path.isUnixHiddenFile()
|
||||||
return self.getLastPathComponent(0) =~# '^\.'
|
return self.getLastPathComponent(0) =~# '^\.'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.isUnixHiddenPath() {{{3
|
"FUNCTION: Path.isUnixHiddenPath() {{{1
|
||||||
"check for unix path with hidden components
|
"check for unix path with hidden components
|
||||||
function! s:Path.isUnixHiddenPath()
|
function! s:Path.isUnixHiddenPath()
|
||||||
if self.getLastPathComponent(0) =~# '^\.'
|
if self.getLastPathComponent(0) =~# '^\.'
|
||||||
@@ -342,7 +350,7 @@ function! s:Path.isUnixHiddenPath()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.ignore() {{{3
|
"FUNCTION: Path.ignore() {{{1
|
||||||
"returns true if this path should be ignored
|
"returns true if this path should be ignored
|
||||||
function! s:Path.ignore()
|
function! s:Path.ignore()
|
||||||
"filter out the user specified paths to ignore
|
"filter out the user specified paths to ignore
|
||||||
@@ -370,7 +378,7 @@ function! s:Path.ignore()
|
|||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path._ignorePatternMatches(pattern) {{{3
|
"FUNCTION: Path._ignorePatternMatches(pattern) {{{1
|
||||||
"returns true if this path matches the given ignore pattern
|
"returns true if this path matches the given ignore pattern
|
||||||
function! s:Path._ignorePatternMatches(pattern)
|
function! s:Path._ignorePatternMatches(pattern)
|
||||||
let pat = a:pattern
|
let pat = a:pattern
|
||||||
@@ -388,7 +396,8 @@ function! s:Path._ignorePatternMatches(pattern)
|
|||||||
|
|
||||||
return self.getLastPathComponent(0) =~# pat
|
return self.getLastPathComponent(0) =~# pat
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path.isUnder(path) {{{3
|
|
||||||
|
"FUNCTION: Path.isUnder(path) {{{1
|
||||||
"return 1 if this path is somewhere under the given path in the filesystem.
|
"return 1 if this path is somewhere under the given path in the filesystem.
|
||||||
"
|
"
|
||||||
"a:path should be a dir
|
"a:path should be a dir
|
||||||
@@ -402,7 +411,7 @@ function! s:Path.isUnder(path)
|
|||||||
return stridx(this, that . s:Path.Slash()) == 0
|
return stridx(this, that . s:Path.Slash()) == 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.JoinPathStrings(...) {{{3
|
"FUNCTION: Path.JoinPathStrings(...) {{{1
|
||||||
function! s:Path.JoinPathStrings(...)
|
function! s:Path.JoinPathStrings(...)
|
||||||
let components = []
|
let components = []
|
||||||
for i in a:000
|
for i in a:000
|
||||||
@@ -411,7 +420,7 @@ function! s:Path.JoinPathStrings(...)
|
|||||||
return '/' . join(components, '/')
|
return '/' . join(components, '/')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.equals() {{{3
|
"FUNCTION: Path.equals() {{{1
|
||||||
"
|
"
|
||||||
"Determines whether 2 path objects are "equal".
|
"Determines whether 2 path objects are "equal".
|
||||||
"They are equal if the paths they represent are the same
|
"They are equal if the paths they represent are the same
|
||||||
@@ -422,7 +431,7 @@ function! s:Path.equals(path)
|
|||||||
return self.str() ==# a:path.str()
|
return self.str() ==# a:path.str()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.New() {{{3
|
"FUNCTION: Path.New() {{{1
|
||||||
"The Constructor for the Path object
|
"The Constructor for the Path object
|
||||||
function! s:Path.New(path)
|
function! s:Path.New(path)
|
||||||
let newPath = copy(self)
|
let newPath = copy(self)
|
||||||
@@ -434,13 +443,13 @@ function! s:Path.New(path)
|
|||||||
return newPath
|
return newPath
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.Slash() {{{3
|
"FUNCTION: Path.Slash() {{{1
|
||||||
"return the slash to use for the current OS
|
"return the slash to use for the current OS
|
||||||
function! s:Path.Slash()
|
function! s:Path.Slash()
|
||||||
return nerdtree#runningWindows() ? '\' : '/'
|
return nerdtree#runningWindows() ? '\' : '/'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.Resolve() {{{3
|
"FUNCTION: Path.Resolve() {{{1
|
||||||
"Invoke the vim resolve() function and return the result
|
"Invoke the vim resolve() function and return the result
|
||||||
"This is necessary because in some versions of vim resolve() removes trailing
|
"This is necessary because in some versions of vim resolve() removes trailing
|
||||||
"slashes while in other versions it doesn't. This always removes the trailing
|
"slashes while in other versions it doesn't. This always removes the trailing
|
||||||
@@ -450,7 +459,7 @@ function! s:Path.Resolve(path)
|
|||||||
return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp
|
return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.readInfoFromDisk(fullpath) {{{3
|
"FUNCTION: Path.readInfoFromDisk(fullpath) {{{1
|
||||||
"
|
"
|
||||||
"
|
"
|
||||||
"Throws NERDTree.Path.InvalidArguments exception.
|
"Throws NERDTree.Path.InvalidArguments exception.
|
||||||
@@ -504,13 +513,13 @@ function! s:Path.readInfoFromDisk(fullpath)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.refresh() {{{3
|
"FUNCTION: Path.refresh() {{{1
|
||||||
function! s:Path.refresh()
|
function! s:Path.refresh()
|
||||||
call self.readInfoFromDisk(self.str())
|
call self.readInfoFromDisk(self.str())
|
||||||
call self.cacheDisplayString()
|
call self.cacheDisplayString()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.rename() {{{3
|
"FUNCTION: Path.rename() {{{1
|
||||||
"
|
"
|
||||||
"Renames this node on the filesystem
|
"Renames this node on the filesystem
|
||||||
function! s:Path.rename(newPath)
|
function! s:Path.rename(newPath)
|
||||||
@@ -531,7 +540,7 @@ function! s:Path.rename(newPath)
|
|||||||
call g:NERDTreeBookmark.Write()
|
call g:NERDTreeBookmark.Write()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.str() {{{3
|
"FUNCTION: Path.str() {{{1
|
||||||
"
|
"
|
||||||
"Returns a string representation of this Path
|
"Returns a string representation of this Path
|
||||||
"
|
"
|
||||||
@@ -582,7 +591,7 @@ function! s:Path.str(...)
|
|||||||
return toReturn
|
return toReturn
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path._strForUI() {{{3
|
"FUNCTION: Path._strForUI() {{{1
|
||||||
function! s:Path._strForUI()
|
function! s:Path._strForUI()
|
||||||
let toReturn = '/' . join(self.pathSegments, '/')
|
let toReturn = '/' . join(self.pathSegments, '/')
|
||||||
if self.isDirectory && toReturn != '/'
|
if self.isDirectory && toReturn != '/'
|
||||||
@@ -591,13 +600,14 @@ function! s:Path._strForUI()
|
|||||||
return toReturn
|
return toReturn
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path._strForCd() {{{3
|
"FUNCTION: Path._strForCd() {{{1
|
||||||
"
|
"
|
||||||
" returns a string that can be used with :cd
|
" returns a string that can be used with :cd
|
||||||
function! s:Path._strForCd()
|
function! s:Path._strForCd()
|
||||||
return escape(self.str(), nerdtree#escChars())
|
return escape(self.str(), nerdtree#escChars())
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path._strForEdit() {{{3
|
|
||||||
|
"FUNCTION: Path._strForEdit() {{{1
|
||||||
"
|
"
|
||||||
"Return: the string for this path that is suitable to be used with the :edit
|
"Return: the string for this path that is suitable to be used with the :edit
|
||||||
"command
|
"command
|
||||||
@@ -629,7 +639,8 @@ function! s:Path._strForEdit()
|
|||||||
|
|
||||||
return p
|
return p
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path._strForGlob() {{{3
|
|
||||||
|
"FUNCTION: Path._strForGlob() {{{1
|
||||||
function! s:Path._strForGlob()
|
function! s:Path._strForGlob()
|
||||||
let lead = s:Path.Slash()
|
let lead = s:Path.Slash()
|
||||||
|
|
||||||
@@ -645,7 +656,8 @@ function! s:Path._strForGlob()
|
|||||||
endif
|
endif
|
||||||
return toReturn
|
return toReturn
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path._str() {{{3
|
|
||||||
|
"FUNCTION: Path._str() {{{1
|
||||||
"
|
"
|
||||||
"Gets the string path for this path object that is appropriate for the OS.
|
"Gets the string path for this path object that is appropriate for the OS.
|
||||||
"EG, in windows c:\foo\bar
|
"EG, in windows c:\foo\bar
|
||||||
@@ -661,13 +673,13 @@ function! s:Path._str()
|
|||||||
return lead . join(self.pathSegments, s:Path.Slash())
|
return lead . join(self.pathSegments, s:Path.Slash())
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: Path.strTrunk() {{{3
|
"FUNCTION: Path.strTrunk() {{{1
|
||||||
"Gets the path without the last segment on the end.
|
"Gets the path without the last segment on the end.
|
||||||
function! s:Path.strTrunk()
|
function! s:Path.strTrunk()
|
||||||
return self.drive . '/' . join(self.pathSegments[0:-2], '/')
|
return self.drive . '/' . join(self.pathSegments[0:-2], '/')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" FUNCTION: Path.tabnr() {{{3
|
" FUNCTION: Path.tabnr() {{{1
|
||||||
" return the number of the first tab that is displaying this file
|
" return the number of the first tab that is displaying this file
|
||||||
"
|
"
|
||||||
" return 0 if no tab was found
|
" return 0 if no tab was found
|
||||||
@@ -682,7 +694,8 @@ function! s:Path.tabnr()
|
|||||||
endfor
|
endfor
|
||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: Path.WinToUnixPath(pathstr){{{3
|
|
||||||
|
"FUNCTION: Path.WinToUnixPath(pathstr){{{1
|
||||||
"Takes in a windows path and returns the unix equiv
|
"Takes in a windows path and returns the unix equiv
|
||||||
"
|
"
|
||||||
"A class level method
|
"A class level method
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
"CLASS: TreeDirNode {{{2
|
"CLASS: TreeDirNode
|
||||||
"This class is a child of the TreeFileNode class and constitutes the
|
"A subclass of NERDTreeFileNode.
|
||||||
"'Composite' part of the composite design pattern between the treenode
|
"
|
||||||
"classes.
|
"The 'composite' part of the file/dir composite.
|
||||||
"============================================================
|
"============================================================
|
||||||
let s:TreeDirNode = copy(g:NERDTreeFileNode)
|
let s:TreeDirNode = copy(g:NERDTreeFileNode)
|
||||||
let g:NERDTreeDirNode = s:TreeDirNode
|
let g:NERDTreeDirNode = s:TreeDirNode
|
||||||
"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{3
|
|
||||||
|
"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{1
|
||||||
"class method that returns the highest cached ancestor of the current root
|
"class method that returns the highest cached ancestor of the current root
|
||||||
function! s:TreeDirNode.AbsoluteTreeRoot()
|
function! s:TreeDirNode.AbsoluteTreeRoot()
|
||||||
let currentNode = b:NERDTreeRoot
|
let currentNode = b:NERDTreeRoot
|
||||||
@@ -14,7 +15,8 @@ function! s:TreeDirNode.AbsoluteTreeRoot()
|
|||||||
endwhile
|
endwhile
|
||||||
return currentNode
|
return currentNode
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeDirNode.activate([options]) {{{3
|
|
||||||
|
"FUNCTION: TreeDirNode.activate([options]) {{{1
|
||||||
unlet s:TreeDirNode.activate
|
unlet s:TreeDirNode.activate
|
||||||
function! s:TreeDirNode.activate(...)
|
function! s:TreeDirNode.activate(...)
|
||||||
let opts = a:0 ? a:1 : {}
|
let opts = a:0 ? a:1 : {}
|
||||||
@@ -22,7 +24,8 @@ function! s:TreeDirNode.activate(...)
|
|||||||
call nerdtree#renderView()
|
call nerdtree#renderView()
|
||||||
call self.putCursorHere(0, 0)
|
call self.putCursorHere(0, 0)
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{3
|
|
||||||
|
"FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{1
|
||||||
"Adds the given treenode to the list of children for this node
|
"Adds the given treenode to the list of children for this node
|
||||||
"
|
"
|
||||||
"Args:
|
"Args:
|
||||||
@@ -37,13 +40,13 @@ function! s:TreeDirNode.addChild(treenode, inOrder)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.close() {{{3
|
"FUNCTION: TreeDirNode.close() {{{1
|
||||||
"Closes this directory
|
"Closes this directory
|
||||||
function! s:TreeDirNode.close()
|
function! s:TreeDirNode.close()
|
||||||
let self.isOpen = 0
|
let self.isOpen = 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.closeChildren() {{{3
|
"FUNCTION: TreeDirNode.closeChildren() {{{1
|
||||||
"Closes all the child dir nodes of this node
|
"Closes all the child dir nodes of this node
|
||||||
function! s:TreeDirNode.closeChildren()
|
function! s:TreeDirNode.closeChildren()
|
||||||
for i in self.children
|
for i in self.children
|
||||||
@@ -54,7 +57,7 @@ function! s:TreeDirNode.closeChildren()
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.createChild(path, inOrder) {{{3
|
"FUNCTION: TreeDirNode.createChild(path, inOrder) {{{1
|
||||||
"Instantiates a new child node for this node with the given path. The new
|
"Instantiates a new child node for this node with the given path. The new
|
||||||
"nodes parent is set to this node.
|
"nodes parent is set to this node.
|
||||||
"
|
"
|
||||||
@@ -70,7 +73,7 @@ function! s:TreeDirNode.createChild(path, inOrder)
|
|||||||
return newTreeNode
|
return newTreeNode
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.findNode(path) {{{3
|
"FUNCTION: TreeDirNode.findNode(path) {{{1
|
||||||
"Will find one of the children (recursively) that has the given path
|
"Will find one of the children (recursively) that has the given path
|
||||||
"
|
"
|
||||||
"Args:
|
"Args:
|
||||||
@@ -94,13 +97,14 @@ function! s:TreeDirNode.findNode(path)
|
|||||||
endif
|
endif
|
||||||
return {}
|
return {}
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeDirNode.getChildCount() {{{3
|
|
||||||
|
"FUNCTION: TreeDirNode.getChildCount() {{{1
|
||||||
"Returns the number of children this node has
|
"Returns the number of children this node has
|
||||||
function! s:TreeDirNode.getChildCount()
|
function! s:TreeDirNode.getChildCount()
|
||||||
return len(self.children)
|
return len(self.children)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.getChild(path) {{{3
|
"FUNCTION: TreeDirNode.getChild(path) {{{1
|
||||||
"Returns child node of this node that has the given path or {} if no such node
|
"Returns child node of this node that has the given path or {} if no such node
|
||||||
"exists.
|
"exists.
|
||||||
"
|
"
|
||||||
@@ -122,7 +126,7 @@ function! s:TreeDirNode.getChild(path)
|
|||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.getChildByIndex(indx, visible) {{{3
|
"FUNCTION: TreeDirNode.getChildByIndex(indx, visible) {{{1
|
||||||
"returns the child at the given index
|
"returns the child at the given index
|
||||||
"Args:
|
"Args:
|
||||||
"indx: the index to get the child from
|
"indx: the index to get the child from
|
||||||
@@ -136,7 +140,7 @@ function! s:TreeDirNode.getChildByIndex(indx, visible)
|
|||||||
return array_to_search[a:indx]
|
return array_to_search[a:indx]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.getChildIndex(path) {{{3
|
"FUNCTION: TreeDirNode.getChildIndex(path) {{{1
|
||||||
"Returns the index of the child node of this node that has the given path or
|
"Returns the index of the child node of this node that has the given path or
|
||||||
"-1 if no such node exists.
|
"-1 if no such node exists.
|
||||||
"
|
"
|
||||||
@@ -167,7 +171,7 @@ function! s:TreeDirNode.getChildIndex(path)
|
|||||||
return -1
|
return -1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.GetSelected() {{{3
|
"FUNCTION: TreeDirNode.GetSelected() {{{1
|
||||||
"Returns the current node if it is a dir node, or else returns the current
|
"Returns the current node if it is a dir node, or else returns the current
|
||||||
"nodes parent
|
"nodes parent
|
||||||
unlet s:TreeDirNode.GetSelected
|
unlet s:TreeDirNode.GetSelected
|
||||||
@@ -180,13 +184,14 @@ function! s:TreeDirNode.GetSelected()
|
|||||||
endif
|
endif
|
||||||
return currentDir
|
return currentDir
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeDirNode.getVisibleChildCount() {{{3
|
|
||||||
|
"FUNCTION: TreeDirNode.getVisibleChildCount() {{{1
|
||||||
"Returns the number of visible children this node has
|
"Returns the number of visible children this node has
|
||||||
function! s:TreeDirNode.getVisibleChildCount()
|
function! s:TreeDirNode.getVisibleChildCount()
|
||||||
return len(self.getVisibleChildren())
|
return len(self.getVisibleChildren())
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.getVisibleChildren() {{{3
|
"FUNCTION: TreeDirNode.getVisibleChildren() {{{1
|
||||||
"Returns a list of children to display for this node, in the correct order
|
"Returns a list of children to display for this node, in the correct order
|
||||||
"
|
"
|
||||||
"Return:
|
"Return:
|
||||||
@@ -201,13 +206,13 @@ function! s:TreeDirNode.getVisibleChildren()
|
|||||||
return toReturn
|
return toReturn
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.hasVisibleChildren() {{{3
|
"FUNCTION: TreeDirNode.hasVisibleChildren() {{{1
|
||||||
"returns 1 if this node has any childre, 0 otherwise..
|
"returns 1 if this node has any childre, 0 otherwise..
|
||||||
function! s:TreeDirNode.hasVisibleChildren()
|
function! s:TreeDirNode.hasVisibleChildren()
|
||||||
return self.getVisibleChildCount() != 0
|
return self.getVisibleChildCount() != 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode._initChildren() {{{3
|
"FUNCTION: TreeDirNode._initChildren() {{{1
|
||||||
"Removes all childen from this node and re-reads them
|
"Removes all childen from this node and re-reads them
|
||||||
"
|
"
|
||||||
"Args:
|
"Args:
|
||||||
@@ -264,7 +269,8 @@ function! s:TreeDirNode._initChildren(silent)
|
|||||||
endif
|
endif
|
||||||
return self.getChildCount()
|
return self.getChildCount()
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeDirNode.New(path) {{{3
|
|
||||||
|
"FUNCTION: TreeDirNode.New(path) {{{1
|
||||||
"Returns a new TreeNode object with the given path and parent
|
"Returns a new TreeNode object with the given path and parent
|
||||||
"
|
"
|
||||||
"Args:
|
"Args:
|
||||||
@@ -285,7 +291,8 @@ function! s:TreeDirNode.New(path)
|
|||||||
|
|
||||||
return newTreeNode
|
return newTreeNode
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeDirNode.open([opts]) {{{3
|
|
||||||
|
"FUNCTION: TreeDirNode.open([opts]) {{{1
|
||||||
"Open the dir in the current tree or in a new tree elsewhere.
|
"Open the dir in the current tree or in a new tree elsewhere.
|
||||||
"
|
"
|
||||||
"If opening in the current tree, return the number of cached nodes.
|
"If opening in the current tree, return the number of cached nodes.
|
||||||
@@ -305,7 +312,8 @@ function! s:TreeDirNode.open(...)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeDirNode.openAlong([opts]) {{{3
|
|
||||||
|
"FUNCTION: TreeDirNode.openAlong([opts]) {{{1
|
||||||
"recursive open the dir if it has only one directory child.
|
"recursive open the dir if it has only one directory child.
|
||||||
"
|
"
|
||||||
"return the level of opened directories.
|
"return the level of opened directories.
|
||||||
@@ -325,24 +333,28 @@ function! s:TreeDirNode.openAlong(...)
|
|||||||
endwhile
|
endwhile
|
||||||
return level
|
return level
|
||||||
endfunction
|
endfunction
|
||||||
" FUNCTION: TreeDirNode.openExplorer() {{{3
|
|
||||||
|
" FUNCTION: TreeDirNode.openExplorer() {{{1
|
||||||
" opens an explorer window for this node in the previous window (could be a
|
" opens an explorer window for this node in the previous window (could be a
|
||||||
" nerd tree or a netrw)
|
" nerd tree or a netrw)
|
||||||
function! s:TreeDirNode.openExplorer()
|
function! s:TreeDirNode.openExplorer()
|
||||||
call self.open({'where': 'p'})
|
call self.open({'where': 'p'})
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeDirNode.openInNewTab(options) {{{3
|
|
||||||
|
"FUNCTION: TreeDirNode.openInNewTab(options) {{{1
|
||||||
unlet s:TreeDirNode.openInNewTab
|
unlet s:TreeDirNode.openInNewTab
|
||||||
function! s:TreeDirNode.openInNewTab(options)
|
function! s:TreeDirNode.openInNewTab(options)
|
||||||
call nerdtree#deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead')
|
call nerdtree#deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead')
|
||||||
call self.open({'where': 't'})
|
call self.open({'where': 't'})
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeDirNode._openInNewTab() {{{3
|
|
||||||
|
"FUNCTION: TreeDirNode._openInNewTab() {{{1
|
||||||
function! s:TreeDirNode._openInNewTab()
|
function! s:TreeDirNode._openInNewTab()
|
||||||
tabnew
|
tabnew
|
||||||
call nerdtree#initNerdTree(self.path.str())
|
call nerdtree#initNerdTree(self.path.str())
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeDirNode.openRecursively() {{{3
|
|
||||||
|
"FUNCTION: TreeDirNode.openRecursively() {{{1
|
||||||
"Opens this treenode and all of its children whose paths arent 'ignored'
|
"Opens this treenode and all of its children whose paths arent 'ignored'
|
||||||
"because of the file filters.
|
"because of the file filters.
|
||||||
"
|
"
|
||||||
@@ -352,7 +364,7 @@ function! s:TreeDirNode.openRecursively()
|
|||||||
call self._openRecursively2(1)
|
call self._openRecursively2(1)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode._openRecursively2() {{{3
|
"FUNCTION: TreeDirNode._openRecursively2() {{{1
|
||||||
"Opens this all children of this treenode recursively if either:
|
"Opens this all children of this treenode recursively if either:
|
||||||
" *they arent filtered by file filters
|
" *they arent filtered by file filters
|
||||||
" *a:forceOpen is 1
|
" *a:forceOpen is 1
|
||||||
@@ -374,7 +386,7 @@ function! s:TreeDirNode._openRecursively2(forceOpen)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.refresh() {{{3
|
"FUNCTION: TreeDirNode.refresh() {{{1
|
||||||
unlet s:TreeDirNode.refresh
|
unlet s:TreeDirNode.refresh
|
||||||
function! s:TreeDirNode.refresh()
|
function! s:TreeDirNode.refresh()
|
||||||
call self.path.refresh()
|
call self.path.refresh()
|
||||||
@@ -426,7 +438,7 @@ function! s:TreeDirNode.refresh()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.reveal(path) {{{3
|
"FUNCTION: TreeDirNode.reveal(path) {{{1
|
||||||
"reveal the given path, i.e. cache and open all treenodes needed to display it
|
"reveal the given path, i.e. cache and open all treenodes needed to display it
|
||||||
"in the UI
|
"in the UI
|
||||||
function! s:TreeDirNode.reveal(path)
|
function! s:TreeDirNode.reveal(path)
|
||||||
@@ -451,7 +463,8 @@ function! s:TreeDirNode.reveal(path)
|
|||||||
let n = self.findNode(p)
|
let n = self.findNode(p)
|
||||||
call n.reveal(a:path)
|
call n.reveal(a:path)
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeDirNode.removeChild(treenode) {{{3
|
|
||||||
|
"FUNCTION: TreeDirNode.removeChild(treenode) {{{1
|
||||||
"
|
"
|
||||||
"Removes the given treenode from this nodes set of children
|
"Removes the given treenode from this nodes set of children
|
||||||
"
|
"
|
||||||
@@ -470,7 +483,7 @@ function! s:TreeDirNode.removeChild(treenode)
|
|||||||
throw "NERDTree.ChildNotFoundError: child node was not found"
|
throw "NERDTree.ChildNotFoundError: child node was not found"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.sortChildren() {{{3
|
"FUNCTION: TreeDirNode.sortChildren() {{{1
|
||||||
"
|
"
|
||||||
"Sorts the children of this node according to alphabetical order and the
|
"Sorts the children of this node according to alphabetical order and the
|
||||||
"directory priority.
|
"directory priority.
|
||||||
@@ -480,7 +493,7 @@ function! s:TreeDirNode.sortChildren()
|
|||||||
call sort(self.children, CompareFunc)
|
call sort(self.children, CompareFunc)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeDirNode.toggleOpen([options]) {{{3
|
"FUNCTION: TreeDirNode.toggleOpen([options]) {{{1
|
||||||
"Opens this directory if it is closed and vice versa
|
"Opens this directory if it is closed and vice versa
|
||||||
function! s:TreeDirNode.toggleOpen(...)
|
function! s:TreeDirNode.toggleOpen(...)
|
||||||
let opts = a:0 ? a:1 : {}
|
let opts = a:0 ? a:1 : {}
|
||||||
@@ -494,7 +507,8 @@ function! s:TreeDirNode.toggleOpen(...)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeDirNode.transplantChild(newNode) {{{3
|
|
||||||
|
"FUNCTION: TreeDirNode.transplantChild(newNode) {{{1
|
||||||
"Replaces the child of this with the given node (where the child node's full
|
"Replaces the child of this with the given node (where the child node's full
|
||||||
"path matches a:newNode's fullpath). The search for the matching node is
|
"path matches a:newNode's fullpath). The search for the matching node is
|
||||||
"non-recursive
|
"non-recursive
|
||||||
@@ -510,4 +524,5 @@ function! s:TreeDirNode.transplantChild(newNode)
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
"============================================================
|
|
||||||
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
"CLASS: TreeFileNode {{{2
|
"CLASS: TreeFileNode
|
||||||
"This class is the parent of the TreeDirNode class and constitures the
|
"This class is the parent of the TreeDirNode class and is the
|
||||||
"'Component' part of the composite design pattern between the treenode
|
"'Component' part of the composite design pattern between the treenode
|
||||||
"classes.
|
"classes.
|
||||||
"============================================================
|
"============================================================
|
||||||
let s:TreeFileNode = {}
|
let s:TreeFileNode = {}
|
||||||
let g:NERDTreeFileNode = s:TreeFileNode
|
let g:NERDTreeFileNode = s:TreeFileNode
|
||||||
"FUNCTION: TreeFileNode.activate(...) {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.activate(...) {{{1
|
||||||
function! s:TreeFileNode.activate(...)
|
function! s:TreeFileNode.activate(...)
|
||||||
call self.open(a:0 ? a:1 : {})
|
call self.open(a:0 ? a:1 : {})
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.bookmark(name) {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.bookmark(name) {{{1
|
||||||
"bookmark this node with a:name
|
"bookmark this node with a:name
|
||||||
function! s:TreeFileNode.bookmark(name)
|
function! s:TreeFileNode.bookmark(name)
|
||||||
|
|
||||||
@@ -30,7 +32,8 @@ function! s:TreeFileNode.bookmark(name)
|
|||||||
call oldMarkedNode.path.cacheDisplayString()
|
call oldMarkedNode.path.cacheDisplayString()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.cacheParent() {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.cacheParent() {{{1
|
||||||
"initializes self.parent if it isnt already
|
"initializes self.parent if it isnt already
|
||||||
function! s:TreeFileNode.cacheParent()
|
function! s:TreeFileNode.cacheParent()
|
||||||
if empty(self.parent)
|
if empty(self.parent)
|
||||||
@@ -42,7 +45,7 @@ function! s:TreeFileNode.cacheParent()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.clearBookmarks() {{{3
|
"FUNCTION: TreeFileNode.clearBookmarks() {{{1
|
||||||
function! s:TreeFileNode.clearBookmarks()
|
function! s:TreeFileNode.clearBookmarks()
|
||||||
for i in g:NERDTreeBookmark.Bookmarks()
|
for i in g:NERDTreeBookmark.Bookmarks()
|
||||||
if i.path.equals(self.path)
|
if i.path.equals(self.path)
|
||||||
@@ -51,7 +54,8 @@ function! s:TreeFileNode.clearBookmarks()
|
|||||||
endfor
|
endfor
|
||||||
call self.path.cacheDisplayString()
|
call self.path.cacheDisplayString()
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.copy(dest) {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.copy(dest) {{{1
|
||||||
function! s:TreeFileNode.copy(dest)
|
function! s:TreeFileNode.copy(dest)
|
||||||
call self.path.copy(a:dest)
|
call self.path.copy(a:dest)
|
||||||
let newPath = s:NERDTreePath.New(a:dest)
|
let newPath = s:NERDTreePath.New(a:dest)
|
||||||
@@ -64,14 +68,14 @@ function! s:TreeFileNode.copy(dest)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.delete {{{3
|
"FUNCTION: TreeFileNode.delete {{{1
|
||||||
"Removes this node from the tree and calls the Delete method for its path obj
|
"Removes this node from the tree and calls the Delete method for its path obj
|
||||||
function! s:TreeFileNode.delete()
|
function! s:TreeFileNode.delete()
|
||||||
call self.path.delete()
|
call self.path.delete()
|
||||||
call self.parent.removeChild(self)
|
call self.parent.removeChild(self)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.displayString() {{{3
|
"FUNCTION: TreeFileNode.displayString() {{{1
|
||||||
"
|
"
|
||||||
"Returns a string that specifies how the node should be represented as a
|
"Returns a string that specifies how the node should be represented as a
|
||||||
"string
|
"string
|
||||||
@@ -82,7 +86,7 @@ function! s:TreeFileNode.displayString()
|
|||||||
return self.path.displayString()
|
return self.path.displayString()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.equals(treenode) {{{3
|
"FUNCTION: TreeFileNode.equals(treenode) {{{1
|
||||||
"
|
"
|
||||||
"Compares this treenode to the input treenode and returns 1 if they are the
|
"Compares this treenode to the input treenode and returns 1 if they are the
|
||||||
"same node.
|
"same node.
|
||||||
@@ -96,7 +100,7 @@ function! s:TreeFileNode.equals(treenode)
|
|||||||
return self.path.str() ==# a:treenode.path.str()
|
return self.path.str() ==# a:treenode.path.str()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.findNode(path) {{{3
|
"FUNCTION: TreeFileNode.findNode(path) {{{1
|
||||||
"Returns self if this node.path.Equals the given path.
|
"Returns self if this node.path.Equals the given path.
|
||||||
"Returns {} if not equal.
|
"Returns {} if not equal.
|
||||||
"
|
"
|
||||||
@@ -108,7 +112,8 @@ function! s:TreeFileNode.findNode(path)
|
|||||||
endif
|
endif
|
||||||
return {}
|
return {}
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{1
|
||||||
"
|
"
|
||||||
"Finds the next sibling for this node in the indicated direction. This sibling
|
"Finds the next sibling for this node in the indicated direction. This sibling
|
||||||
"must be a directory and may/may not have children as specified.
|
"must be a directory and may/may not have children as specified.
|
||||||
@@ -133,7 +138,8 @@ function! s:TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction)
|
|||||||
|
|
||||||
return {}
|
return {}
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.findSibling(direction) {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.findSibling(direction) {{{1
|
||||||
"
|
"
|
||||||
"Finds the next sibling for this node in the indicated direction
|
"Finds the next sibling for this node in the indicated direction
|
||||||
"
|
"
|
||||||
@@ -172,7 +178,7 @@ function! s:TreeFileNode.findSibling(direction)
|
|||||||
return {}
|
return {}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.getLineNum(){{{3
|
"FUNCTION: TreeFileNode.getLineNum(){{{1
|
||||||
"returns the line number this node is rendered on, or -1 if it isnt rendered
|
"returns the line number this node is rendered on, or -1 if it isnt rendered
|
||||||
function! s:TreeFileNode.getLineNum()
|
function! s:TreeFileNode.getLineNum()
|
||||||
"if the node is the root then return the root line no.
|
"if the node is the root then return the root line no.
|
||||||
@@ -221,7 +227,7 @@ function! s:TreeFileNode.getLineNum()
|
|||||||
return -1
|
return -1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.GetRootForTab(){{{3
|
"FUNCTION: TreeFileNode.GetRootForTab(){{{1
|
||||||
"get the root node for this tab
|
"get the root node for this tab
|
||||||
function! s:TreeFileNode.GetRootForTab()
|
function! s:TreeFileNode.GetRootForTab()
|
||||||
if nerdtree#treeExistsForTab()
|
if nerdtree#treeExistsForTab()
|
||||||
@@ -229,7 +235,8 @@ function! s:TreeFileNode.GetRootForTab()
|
|||||||
end
|
end
|
||||||
return {}
|
return {}
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.GetRootLineNum(){{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.GetRootLineNum(){{{1
|
||||||
"gets the line number of the root node
|
"gets the line number of the root node
|
||||||
function! s:TreeFileNode.GetRootLineNum()
|
function! s:TreeFileNode.GetRootLineNum()
|
||||||
let rootLine = 1
|
let rootLine = 1
|
||||||
@@ -239,7 +246,7 @@ function! s:TreeFileNode.GetRootLineNum()
|
|||||||
return rootLine
|
return rootLine
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.GetSelected() {{{3
|
"FUNCTION: TreeFileNode.GetSelected() {{{1
|
||||||
"gets the treenode that the cursor is currently over
|
"gets the treenode that the cursor is currently over
|
||||||
function! s:TreeFileNode.GetSelected()
|
function! s:TreeFileNode.GetSelected()
|
||||||
try
|
try
|
||||||
@@ -252,13 +259,15 @@ function! s:TreeFileNode.GetSelected()
|
|||||||
return {}
|
return {}
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.isVisible() {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.isVisible() {{{1
|
||||||
"returns 1 if this node should be visible according to the tree filters and
|
"returns 1 if this node should be visible according to the tree filters and
|
||||||
"hidden file filters (and their on/off status)
|
"hidden file filters (and their on/off status)
|
||||||
function! s:TreeFileNode.isVisible()
|
function! s:TreeFileNode.isVisible()
|
||||||
return !self.path.ignore()
|
return !self.path.ignore()
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.isRoot() {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.isRoot() {{{1
|
||||||
"returns 1 if this node is b:NERDTreeRoot
|
"returns 1 if this node is b:NERDTreeRoot
|
||||||
function! s:TreeFileNode.isRoot()
|
function! s:TreeFileNode.isRoot()
|
||||||
if !nerdtree#treeExistsForBuf()
|
if !nerdtree#treeExistsForBuf()
|
||||||
@@ -268,7 +277,7 @@ function! s:TreeFileNode.isRoot()
|
|||||||
return self.equals(b:NERDTreeRoot)
|
return self.equals(b:NERDTreeRoot)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.makeRoot() {{{3
|
"FUNCTION: TreeFileNode.makeRoot() {{{1
|
||||||
"Make this node the root of the tree
|
"Make this node the root of the tree
|
||||||
function! s:TreeFileNode.makeRoot()
|
function! s:TreeFileNode.makeRoot()
|
||||||
if self.path.isDirectory
|
if self.path.isDirectory
|
||||||
@@ -287,7 +296,8 @@ function! s:TreeFileNode.makeRoot()
|
|||||||
|
|
||||||
silent doautocmd User NERDTreeNewRoot
|
silent doautocmd User NERDTreeNewRoot
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.New(path) {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.New(path) {{{1
|
||||||
"Returns a new TreeNode object with the given path and parent
|
"Returns a new TreeNode object with the given path and parent
|
||||||
"
|
"
|
||||||
"Args:
|
"Args:
|
||||||
@@ -303,31 +313,34 @@ function! s:TreeFileNode.New(path)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.open() {{{3
|
"FUNCTION: TreeFileNode.open() {{{1
|
||||||
function! s:TreeFileNode.open(...)
|
function! s:TreeFileNode.open(...)
|
||||||
let opts = a:0 ? a:1 : {}
|
let opts = a:0 ? a:1 : {}
|
||||||
let opener = g:NERDTreeOpener.New(self.path, opts)
|
let opener = g:NERDTreeOpener.New(self.path, opts)
|
||||||
call opener.open(self)
|
call opener.open(self)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.openSplit() {{{3
|
"FUNCTION: TreeFileNode.openSplit() {{{1
|
||||||
"Open this node in a new window
|
"Open this node in a new window
|
||||||
function! s:TreeFileNode.openSplit()
|
function! s:TreeFileNode.openSplit()
|
||||||
call nerdtree#deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.')
|
call nerdtree#deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.')
|
||||||
call self.open({'where': 'h'})
|
call self.open({'where': 'h'})
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.openVSplit() {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.openVSplit() {{{1
|
||||||
"Open this node in a new vertical window
|
"Open this node in a new vertical window
|
||||||
function! s:TreeFileNode.openVSplit()
|
function! s:TreeFileNode.openVSplit()
|
||||||
call nerdtree#deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.')
|
call nerdtree#deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.')
|
||||||
call self.open({'where': 'v'})
|
call self.open({'where': 'v'})
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.openInNewTab(options) {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.openInNewTab(options) {{{1
|
||||||
function! s:TreeFileNode.openInNewTab(options)
|
function! s:TreeFileNode.openInNewTab(options)
|
||||||
echomsg 'TreeFileNode.openInNewTab is deprecated'
|
echomsg 'TreeFileNode.openInNewTab is deprecated'
|
||||||
call self.open(extend({'where': 't'}, a:options))
|
call self.open(extend({'where': 't'}, a:options))
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{1
|
||||||
"Places the cursor on the line number this node is rendered on
|
"Places the cursor on the line number this node is rendered on
|
||||||
"
|
"
|
||||||
"Args:
|
"Args:
|
||||||
@@ -354,11 +367,12 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: TreeFileNode.refresh() {{{3
|
"FUNCTION: TreeFileNode.refresh() {{{1
|
||||||
function! s:TreeFileNode.refresh()
|
function! s:TreeFileNode.refresh()
|
||||||
call self.path.refresh()
|
call self.path.refresh()
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.rename() {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.rename() {{{1
|
||||||
"Calls the rename method for this nodes path obj
|
"Calls the rename method for this nodes path obj
|
||||||
function! s:TreeFileNode.rename(newName)
|
function! s:TreeFileNode.rename(newName)
|
||||||
let newName = substitute(a:newName, '\(\\\|\/\)$', '', '')
|
let newName = substitute(a:newName, '\(\\\|\/\)$', '', '')
|
||||||
@@ -373,13 +387,13 @@ function! s:TreeFileNode.rename(newName)
|
|||||||
call newParent.refresh()
|
call newParent.refresh()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
"FUNCTION: TreeFileNode.renderToString {{{3
|
|
||||||
|
"FUNCTION: TreeFileNode.renderToString {{{1
|
||||||
"returns a string representation for this tree to be rendered in the view
|
"returns a string representation for this tree to be rendered in the view
|
||||||
function! s:TreeFileNode.renderToString()
|
function! s:TreeFileNode.renderToString()
|
||||||
return self._renderToString(0, 0, [], self.getChildCount() ==# 1)
|
return self._renderToString(0, 0, [], self.getChildCount() ==# 1)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
"Args:
|
"Args:
|
||||||
"depth: the current depth in the tree for this call
|
"depth: the current depth in the tree for this call
|
||||||
"drawText: 1 if we should actually draw the line for this node (if 0 then the
|
"drawText: 1 if we should actually draw the line for this node (if 0 then the
|
||||||
@@ -467,3 +481,5 @@ function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
|
|||||||
|
|
||||||
return output
|
return output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
|||||||
Reference in New Issue
Block a user