refactor 3 more functions out of the monolithic autoload file
This commit is contained in:
parent
f8499462c5
commit
973c9906f8
@ -95,25 +95,6 @@ function! nerdtree#runningWindows()
|
||||
return has("win16") || has("win32") || has("win64")
|
||||
endfunction
|
||||
|
||||
"FUNCTION: nerdtree#treeMarkupReg(dir) {{{2
|
||||
function! nerdtree#treeMarkupReg()
|
||||
if g:NERDTreeDirArrows
|
||||
return '^\([▾▸] \| \+[▾▸] \| \+\)'
|
||||
endif
|
||||
|
||||
return '^[ `|]*[\-+~]'
|
||||
endfunction
|
||||
|
||||
"FUNCTION: nerdtree#treeUpDirLine(dir) {{{2
|
||||
function! nerdtree#treeUpDirLine()
|
||||
return '.. (up a dir)'
|
||||
endfunction
|
||||
|
||||
"FUNCTION: nerdtree#treeWid(dir) {{{2
|
||||
function! nerdtree#treeWid()
|
||||
return 2
|
||||
endfunction
|
||||
|
||||
" SECTION: View Functions {{{1
|
||||
"============================================================
|
||||
|
||||
@ -374,7 +355,7 @@ endfunction
|
||||
function! nerdtree#stripMarkupFromLine(line, removeLeadingSpaces)
|
||||
let line = a:line
|
||||
"remove the tree parts and the leading space
|
||||
let line = substitute (line, nerdtree#treeMarkupReg(),"","")
|
||||
let line = substitute (line, g:NERDTreeUI.MarkupReg(),"","")
|
||||
|
||||
"strip off any read only flag
|
||||
let line = substitute (line, ' \[RO\]', "","")
|
||||
|
@ -85,7 +85,7 @@ endfunction
|
||||
"FUNCTION: s:activateAll() {{{1
|
||||
"handle the user activating the updir line
|
||||
function! s:activateAll()
|
||||
if getline(".") ==# nerdtree#treeUpDirLine()
|
||||
if getline(".") ==# g:NERDTreeUI.UpDirLine()
|
||||
return nerdtree#ui_glue#upDir(0)
|
||||
endif
|
||||
endfunction
|
||||
@ -312,7 +312,7 @@ function! s:handleLeftClick()
|
||||
endfor
|
||||
|
||||
if currentNode.path.isDirectory
|
||||
if startToCur =~# nerdtree#treeMarkupReg() && startToCur =~# '[+~▾▸] \?$'
|
||||
if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~▾▸] \?$'
|
||||
call currentNode.activate()
|
||||
return
|
||||
endif
|
||||
@ -320,7 +320,7 @@ function! s:handleLeftClick()
|
||||
|
||||
if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3
|
||||
let char = strpart(startToCur, strlen(startToCur)-1, 1)
|
||||
if char !~# nerdtree#treeMarkupReg()
|
||||
if char !~# g:NERDTreeUI.MarkupReg()
|
||||
if currentNode.path.isDirectory
|
||||
call currentNode.activate()
|
||||
else
|
||||
|
@ -56,7 +56,7 @@ function! s:UI.getPath(ln)
|
||||
endif
|
||||
endif
|
||||
|
||||
if line ==# nerdtree#treeUpDirLine()
|
||||
if line ==# s:UI.UpDirLine()
|
||||
return b:NERDTreeRoot.path.getParent()
|
||||
endif
|
||||
|
||||
@ -146,7 +146,6 @@ function! s:UI.getLineNum(file_node)
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
|
||||
"FUNCTION: s:UI.getRootLineNum(){{{1
|
||||
"gets the line number of the root node
|
||||
function! s:UI.getRootLineNum()
|
||||
@ -157,9 +156,9 @@ function! s:UI.getRootLineNum()
|
||||
return rootLine
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI._indentLevelFor(line) {{{2
|
||||
"FUNCTION: s:UI._indentLevelFor(line) {{{1
|
||||
function! s:UI._indentLevelFor(line)
|
||||
let level = match(a:line, '[^ \-+~▸▾`|]') / nerdtree#treeWid()
|
||||
let level = match(a:line, '[^ \-+~▸▾`|]') / s:UI.IndentWid()
|
||||
" check if line includes arrows
|
||||
if match(a:line, '[▸▾]') > -1
|
||||
" decrement level as arrow uses 3 ascii chars
|
||||
@ -168,8 +167,21 @@ function! s:UI._indentLevelFor(line)
|
||||
return level
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI.IndentWid() {{{1
|
||||
function! s:UI.IndentWid()
|
||||
return 2
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI.restoreScreenState() {{{2
|
||||
"FUNCTION: s:UI.MarkupReg() {{{1
|
||||
function! s:UI.MarkupReg()
|
||||
if g:NERDTreeDirArrows
|
||||
return '^\([▾▸] \| \+[▾▸] \| \+\)'
|
||||
endif
|
||||
|
||||
return '^[ `|]*[\-+~]'
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI.restoreScreenState() {{{1
|
||||
"
|
||||
"Sets the screen state back to what it was when nerdtree#saveScreenState was last
|
||||
"called.
|
||||
@ -189,7 +201,7 @@ function! s:UI.restoreScreenState()
|
||||
let &scrolloff=old_scrolloff
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI.saveScreenState() {{{2
|
||||
"FUNCTION: s:UI.saveScreenState() {{{1
|
||||
"Saves the current cursor position in the current buffer and the window
|
||||
"scroll position
|
||||
function! s:UI.saveScreenState()
|
||||
@ -205,7 +217,7 @@ function! s:UI.saveScreenState()
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI.render() {{{2
|
||||
"FUNCTION: s:UI.render() {{{1
|
||||
function! s:UI.render()
|
||||
setlocal modifiable
|
||||
|
||||
@ -232,7 +244,7 @@ function! s:UI.render()
|
||||
|
||||
"add the 'up a dir' line
|
||||
if !g:NERDTreeMinimalUI
|
||||
call setline(line(".")+1, nerdtree#treeUpDirLine())
|
||||
call setline(line(".")+1, s:UI.UpDirLine())
|
||||
call cursor(line(".")+1, col("."))
|
||||
endif
|
||||
|
||||
@ -330,3 +342,8 @@ function! s:UI.toggleZoom()
|
||||
let b:NERDTreeZoomed = 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI.UpDirLine() {{{1
|
||||
function! s:UI.UpDirLine()
|
||||
return '.. (up a dir)'
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user