move a bunch of b:NERDTree.* vars into the b:NERDTree.ui obj

This commit is contained in:
Martin Grenfell 2015-11-14 17:35:07 +00:00
parent 4d8a0c90cb
commit 83d108894e
5 changed files with 58 additions and 30 deletions

View File

@ -241,7 +241,7 @@ endfunction
" FUNCTION: s:displayHelp() {{{1 " FUNCTION: s:displayHelp() {{{1
" toggles the help display " toggles the help display
function! s:displayHelp() function! s:displayHelp()
let b:treeShowHelp = b:treeShowHelp ? 0 : 1 call b:NERDTree.ui.toggleHelp()
call b:NERDTree.render() call b:NERDTree.render()
call b:NERDTree.ui.centerView() call b:NERDTree.ui.centerView()
endfunction endfunction
@ -280,7 +280,7 @@ function! s:findAndRevealPath()
else else
call g:NERDTree.CursorToTreeWin() call g:NERDTree.CursorToTreeWin()
endif endif
let b:NERDTreeShowHidden = g:NERDTreeShowHidden call b:NERDTree.setShowHidden(g:NERDTreeShowHidden)
call s:chRoot(g:NERDTreeDirNode.New(p.getParent())) call s:chRoot(g:NERDTreeDirNode.New(p.getParent()))
else else
if !g:NERDTree.IsOpen() if !g:NERDTree.IsOpen()

View File

@ -67,12 +67,6 @@ function! s:Creator.createTabTree(name)
call self._createTreeWin() call self._createTreeWin()
call self._createNERDTree(path, "tab") call self._createNERDTree(path, "tab")
let b:treeShowHelp = 0
let b:NERDTreeIgnoreEnabled = 1
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
call b:NERDTree.render() call b:NERDTree.render()
call b:NERDTreeRoot.putCursorHere(0, 0) call b:NERDTreeRoot.putCursorHere(0, 0)
@ -285,12 +279,6 @@ function! s:Creator._setCommonBufOptions()
endif endif
call self._setupStatusline() call self._setupStatusline()
let b:treeShowHelp = 0
let b:NERDTreeIgnoreEnabled = 1
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
call self._bindMappings() call self._bindMappings()
setlocal filetype=nerdtree setlocal filetype=nerdtree
endfunction endfunction

View File

@ -43,7 +43,7 @@ endfunction
"FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1 "FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1
"Places the cursor at the top of the bookmarks table "Places the cursor at the top of the bookmarks table
function! s:NERDTree.CursorToBookmarkTable() function! s:NERDTree.CursorToBookmarkTable()
if !b:NERDTreeShowBookmarks if !b:NERDTree.ui.getShowBookmarks()
throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active" throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
endif endif
@ -128,7 +128,6 @@ function! s:NERDTree.New(path, type)
let newObj.ui = g:NERDTreeUI.New(newObj) let newObj.ui = g:NERDTreeUI.New(newObj)
let newObj.root = g:NERDTreeDirNode.New(a:path) let newObj.root = g:NERDTreeDirNode.New(a:path)
let newObj._type = a:type let newObj._type = a:type
return newObj return newObj
endfunction endfunction

View File

@ -410,7 +410,7 @@ endfunction
"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
if b:NERDTreeIgnoreEnabled if b:NERDTree.ui.isIgnoreFilterEnabled()
for i in g:NERDTreeIgnore for i in g:NERDTreeIgnore
if self._ignorePatternMatches(i) if self._ignorePatternMatches(i)
return 1 return 1
@ -425,11 +425,11 @@ function! s:Path.ignore()
endif endif
"dont show hidden files unless instructed to "dont show hidden files unless instructed to
if b:NERDTreeShowHidden ==# 0 && self.isUnixHiddenFile() if !b:NERDTree.ui.getShowHidden() && self.isUnixHiddenFile()
return 1 return 1
endif endif
if b:NERDTreeShowFiles ==# 0 && self.isDirectory ==# 0 if b:NERDTree.ui.getShowFiles() ==# 0 && self.isDirectory ==# 0
return 1 return 1
endif endif

View File

@ -21,7 +21,7 @@ endfunction
"prints out the quick help "prints out the quick help
function! s:UI._dumpHelp() function! s:UI._dumpHelp()
let old_h = @h let old_h = @h
if b:treeShowHelp ==# 1 if self.getShowHelp()
let @h= "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n" let @h= "\" NERD tree (" . nerdtree#version() . ") quickhelp~\n"
let @h=@h."\" ============================\n" let @h=@h."\" ============================\n"
let @h=@h."\" File node mappings~\n" let @h=@h."\" File node mappings~\n"
@ -87,10 +87,10 @@ function! s:UI._dumpHelp()
let @h=@h."\"\n\" ----------------------------\n" let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Tree filtering mappings~\n" let @h=@h."\" Tree filtering mappings~\n"
let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (b:NERDTreeShowHidden ? "on" : "off") . ")\n" let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (self.getShowHidden() ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (b:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n" let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (self.isIgnoreFilterEnabled() ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (b:NERDTreeShowFiles ? "on" : "off") . ")\n" let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (self.getShowFiles() ? "on" : "off") . ")\n"
let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n" let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (self.getShowBookmarks() ? "on" : "off") . ")\n"
"add quickhelp entries for each custom key map "add quickhelp entries for each custom key map
let @h=@h."\"\n\" ----------------------------\n" let @h=@h."\"\n\" ----------------------------\n"
@ -129,6 +129,12 @@ endfunction
function! s:UI.New(nerdtree) function! s:UI.New(nerdtree)
let newObj = copy(self) let newObj = copy(self)
let newObj.nerdtree = a:nerdtree let newObj.nerdtree = a:nerdtree
let newObj._showHelp = 0
let newObj._ignoreEnabled = 1
let newObj._showFiles = g:NERDTreeShowFiles
let newObj._showHidden = g:NERDTreeShowHidden
let newObj._showBookmarks = g:NERDTreeShowBookmarks
return newObj return newObj
endfunction endfunction
@ -259,6 +265,26 @@ function! s:UI.getRootLineNum()
return rootLine return rootLine
endfunction endfunction
"FUNCTION: s:UI.getShowBookmarks() {{{1
function! s:UI.getShowBookmarks()
return self._showBookmarks
endfunction
"FUNCTION: s:UI.getShowFiles() {{{1
function! s:UI.getShowFiles()
return self._showFiles
endfunction
"FUNCTION: s:UI.getShowHelp() {{{1
function! s:UI.getShowHelp()
return self._showHelp
endfunction
"FUNCTION: s:UI.getShowHidden() {{{1
function! s:UI.getShowHidden()
return self._showHidden
endfunction
"FUNCTION: s:UI._indentLevelFor(line) {{{1 "FUNCTION: s:UI._indentLevelFor(line) {{{1
function! s:UI._indentLevelFor(line) function! s:UI._indentLevelFor(line)
let level = match(a:line, '[^ \-+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'`|]') / s:UI.IndentWid() let level = match(a:line, '[^ \-+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'`|]') / s:UI.IndentWid()
@ -275,6 +301,11 @@ function! s:UI.IndentWid()
return 2 return 2
endfunction endfunction
"FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1
function! s:UI.isIgnoreFilterEnabled()
return self._ignoreEnabled == 1
endfunction
"FUNCTION: s:UI.MarkupReg() {{{1 "FUNCTION: s:UI.MarkupReg() {{{1
function! s:UI.MarkupReg() function! s:UI.MarkupReg()
if g:NERDTreeDirArrows if g:NERDTreeDirArrows
@ -334,6 +365,11 @@ function! s:UI.saveScreenState()
call nerdtree#exec(win . "wincmd w") call nerdtree#exec(win . "wincmd w")
endfunction endfunction
"FUNCTION: s:UI.setShowHidden(val) {{{1
function! s:UI.setShowHidden(val)
let self._showHidden = a:val
endfunction
"FUNCTION: s:UI._stripMarkup(line, removeLeadingSpaces){{{1 "FUNCTION: s:UI._stripMarkup(line, removeLeadingSpaces){{{1
"returns the given line with all the tree parts stripped off "returns the given line with all the tree parts stripped off
" "
@ -395,7 +431,7 @@ function! s:UI.render()
call cursor(line(".")+1, col(".")) call cursor(line(".")+1, col("."))
endif endif
if b:NERDTreeShowBookmarks if self.getShowBookmarks()
call self._renderBookmarks() call self._renderBookmarks()
endif endif
@ -450,10 +486,15 @@ function! s:UI.renderViewSavingPosition()
endif endif
endfunction endfunction
"FUNCTION: s:UI.toggleHelp() {{{1
function! s:UI.toggleHelp()
let self._showHelp = !self._showHelp
endfunction
" FUNCTION: s:UI.toggleIgnoreFilter() {{{1 " FUNCTION: s:UI.toggleIgnoreFilter() {{{1
" toggles the use of the NERDTreeIgnore option " toggles the use of the NERDTreeIgnore option
function! s:UI.toggleIgnoreFilter() function! s:UI.toggleIgnoreFilter()
let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled let self._ignoreEnabled = !self._ignoreEnabled
call b:NERDTree.ui.renderViewSavingPosition() call b:NERDTree.ui.renderViewSavingPosition()
call b:NERDTree.ui.centerView() call b:NERDTree.ui.centerView()
endfunction endfunction
@ -461,8 +502,8 @@ endfunction
" FUNCTION: s:UI.toggleShowBookmarks() {{{1 " FUNCTION: s:UI.toggleShowBookmarks() {{{1
" toggles the display of bookmarks " toggles the display of bookmarks
function! s:UI.toggleShowBookmarks() function! s:UI.toggleShowBookmarks()
let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks let self._showBookmarks = !self._showBookmarks
if b:NERDTreeShowBookmarks if self.getShowBookmarks()
call b:NERDTree.render() call b:NERDTree.render()
call g:NERDTree.CursorToBookmarkTable() call g:NERDTree.CursorToBookmarkTable()
else else
@ -474,7 +515,7 @@ endfunction
" FUNCTION: s:UI.toggleShowFiles() {{{1 " FUNCTION: s:UI.toggleShowFiles() {{{1
" toggles the display of hidden files " toggles the display of hidden files
function! s:UI.toggleShowFiles() function! s:UI.toggleShowFiles()
let b:NERDTreeShowFiles = !b:NERDTreeShowFiles let self._showFiles = !self._showFiles
call b:NERDTree.ui.renderViewSavingPosition() call b:NERDTree.ui.renderViewSavingPosition()
call b:NERDTree.ui.centerView() call b:NERDTree.ui.centerView()
endfunction endfunction
@ -482,7 +523,7 @@ endfunction
" FUNCTION: s:UI.toggleShowHidden() {{{1 " FUNCTION: s:UI.toggleShowHidden() {{{1
" toggles the display of hidden files " toggles the display of hidden files
function! s:UI.toggleShowHidden() function! s:UI.toggleShowHidden()
let b:NERDTreeShowHidden = !b:NERDTreeShowHidden let self._showHidden = !self._showHidden
call b:NERDTree.ui.renderViewSavingPosition() call b:NERDTree.ui.renderViewSavingPosition()
call self.centerView() call self.centerView()
endfunction endfunction