diff options
Diffstat (limited to '.vim/pack/vendor/start/nerdtree/lib/nerdtree/notifier.vim')
-rw-r--r-- | .vim/pack/vendor/start/nerdtree/lib/nerdtree/notifier.vim | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/.vim/pack/vendor/start/nerdtree/lib/nerdtree/notifier.vim b/.vim/pack/vendor/start/nerdtree/lib/nerdtree/notifier.vim new file mode 100644 index 0000000..ffa2853 --- /dev/null +++ b/.vim/pack/vendor/start/nerdtree/lib/nerdtree/notifier.vim | |||
@@ -0,0 +1,35 @@ | |||
1 | "CLASS: Notifier | ||
2 | "============================================================ | ||
3 | let s:Notifier = {} | ||
4 | |||
5 | function! s:Notifier.AddListener(event, funcname) | ||
6 | let listeners = s:Notifier.GetListenersForEvent(a:event) | ||
7 | if listeners == [] | ||
8 | let listenersMap = s:Notifier.GetListenersMap() | ||
9 | let listenersMap[a:event] = listeners | ||
10 | endif | ||
11 | call add(listeners, a:funcname) | ||
12 | endfunction | ||
13 | |||
14 | function! s:Notifier.NotifyListeners(event, path, nerdtree, params) | ||
15 | let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params) | ||
16 | |||
17 | for Listener in s:Notifier.GetListenersForEvent(a:event) | ||
18 | let l:Callback = type(Listener) == type(function('tr')) ? Listener : function(Listener) | ||
19 | call l:Callback(event) | ||
20 | endfor | ||
21 | endfunction | ||
22 | |||
23 | function! s:Notifier.GetListenersMap() | ||
24 | if !exists('s:refreshListenersMap') | ||
25 | let s:refreshListenersMap = {} | ||
26 | endif | ||
27 | return s:refreshListenersMap | ||
28 | endfunction | ||
29 | |||
30 | function! s:Notifier.GetListenersForEvent(name) | ||
31 | let listenersMap = s:Notifier.GetListenersMap() | ||
32 | return get(listenersMap, a:name, []) | ||
33 | endfunction | ||
34 | |||
35 | let g:NERDTreePathNotifier = deepcopy(s:Notifier) | ||