download

Sign in or create your account | Project List | Help

download Git Source Tree

Root/vimm200807/sample_7.vim

1" 1xǂݍ܂ȂB {{{
2" J̓RgAEgĂƊyłB
3"if exists('g:loaded_sample')
4" finish
5"endif
6"let g:loaded_sample = 1
7
8" cpoIvV𓦂B
9let s:save_cpo = &cpo
10set cpo&vim
11
12" OutCommandViewerR}hsƁAs:OutCommandViewer()Ăяo܂B
13command! -nargs=0 OutCommandViewer :call s:OutCommandViewer()
14
15
16" OutCommandViewerR}hĂяo܂B
17function! s:OutCommandViewer()
18
19    " WorldIuWFNg𐶐
20    let l:world = tlib#World#New()
21
22    " WorldIuWFNg̑ݒ
23
24    " XNb`̖O
25    let l:world.scratch = "SCRATCH_NAME"
26
27    " EBhEcɕ邩Aɕ邩
28    let l:world.scratch_vertical = 1
29
30    " XgIAǂɂ邩
31    " key ̓L[
32    " key_name wvŎgp
33    " help wvŎgp
34    " agent ǂ̃t@NVĂяo
35    let l:world.key_handlers = [
36    \ {'key':1, 'key_name':'<c-a>', 'help':'push Control-A.', 'agent':'g:CallCtrlA' },
37    \ {'key':16, 'key_name':'<c-p>', 'help':'push Control-P.', 'agent':'g:CallCtrlP' },
38    \ {'key':21, 'key_name':'<c-u>', 'help':'push Control-U.', 'agent':'g:CallCtrlU' }
39    \ ]
40
41
42    " JXNb`EBhEŕ\ꗗ
43    " ̃RgAEg
44    " let l:world.base = [ "A", "B", "C" ]
45
46    " OR}hs
47    let l:ls_result = system('ls')
48
49    " ʂҏWăXgɕϊ
50    let l:ls_list = split(l:ls_result, '\n')
51
52    " baseL[ɃZbg
53    let l:world.base = l:ls_list
54
55
56    " nꂽWorldIuWFNg̃p[^ɁA
57    " XNb`EBhEJ܂B
58    call tlib#input#ListW(l:world)
59
60endfunction
61
62
63" Control-AƌĂяo
64function! g:CallCtrlA(world, selected)
65    " IeLXg擾
66    let l:entry = a:selected[0]
67
68    " p^[1 PɃR}hs
69    let l:files = system('ls')
70    echo l:files
71" }}}
72    return a:world
73endfunction
74
75
76" Control-PƌĂяo
77function! g:CallCtrlP(world, selected)
78    " IeLXg擾
79    let l:entry = a:selected[0]
80
81    " p^[2 ̃EBhEʼnR}hs
82    let l:sb = a:world.SwitchWindow('win')
83
84    " SwitchWindow()sɏs
85    "let l:files = system('ls')
86    "echo l:files
87
88
89    " It@Cǂ
90    for l:line in readfile(l:entry)
91        " Ō̍šɒlj.
92        call append(line("$"), l:line)
93    endfor
94
95
96    " IASwitchWindow()return values
97    execute l:sb
98
99    return a:world
100endfunction
101
102
103" Control-UƌĂяo
104function! g:CallCtrlU(world, selected) " {{{
105    " IeLXg擾
106    let l:entry = a:selected[0]
107
108    " p^[3 R}hsAEBhE‚
109    let l:files = system('ls')
110    echo l:files
111
112    " CloseScratch()ŃEBhE‚B
113    silent call a:world.CloseScratch()
114
115    return a:world
116endfunction
117
118
119" cpoIvVɖ߂B
120let &cpo = s:save_cpo
121finish
122
123" TITLE: s鏈ύX
124" vim:set ft=vim ff=unix fenc=cp932 nolist number hlsearch nowrap foldmethod=marker : }}}
125

Archive Download this file

Branches:
master