forked from atomantic/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtail-3.0.vba
487 lines (404 loc) · 15.7 KB
/
tail-3.0.vba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
" Vimball Archiver by Charles E. Campbell, Jr., Ph.D.
UseVimball
finish
tail_options.vim [[[1
63
"------------------------------------------------------------------------------
" Description: Options setable by the Tail plugin
" $Id: tail_options.vim 773 2007-09-17 08:58:57Z krischik $
" Copyright: Copyright (C) 2006 Martin Krischik
" Maintainer: Martin Krischik ([email protected])
" $Author: krischik $
" $Date: 2007-09-17 10:58:57 +0200 (Mo, 17 Sep 2007) $
" Version: 2.2
" $Revision: 773 $
" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/tail_options.vim $
" History: 17.11.2006 MK Tail_Options
" 01.01.2007 MK Bug fixing
" Usage: copy content into your .vimrc and change options to your
" likeing.
" Help Page: tail.txt
"------------------------------------------------------------------------------
echoerr 'It is suggested to copy the content of ada_options into .vimrc!'
finish " 1}}}
" Section: Tail options {{{1
let g:tail#Height = 10
let g:tail#Center_Win = 0
let g:mapleader = "<F12>"
filetype plugin indent on
syntax enable
" }}}1
" Section: Vimball options {{{1
:set noexpandtab fileformat=unix encoding=utf-8
:.+2,.+6 MkVimball tail-3.0.vba
tail_options.vim
autoload/tail.vim
doc/tail.txt
macros/vim-tail.zsh
plugin/tail.vim
" }}}1
" Section: Tar options {{{1
tar --create --bzip2 \
--file="tail-3.0.tar.bz2" \
tail_options.vim \
autoload/tail.vim \
doc/tail.txt \
macros/vim-tail.zsh \
plugin/tail.vim ;
" }}}1
"------------------------------------------------------------------------------
" Copyright (C) 2006 Martin Krischik
"
" Vim is Charityware - see ":help license" or uganda.txt for licence details.
"------------------------------------------------------------------------------
" vim: textwidth=0 nowrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
" vim: foldmethod=marker
autoload/tail.vim [[[1
235
"------------------------------------------------------------------------------
" Description: Works like "tail -f" .
" $Id: tail.vim 773 2007-09-17 08:58:57Z krischik $
" Maintainer: Martin Krischik ([email protected])
" Jason Heddings (vim at heddway dot com)
" $Author: krischik $
" $Date: 2007-09-17 10:58:57 +0200 (Mo, 17 Sep 2007) $
" Version: 3.0
" $Revision: 773 $
" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/tail.vim $
" History: 22.09.2006 MK Improve for vim 7.0
" 15.10.2006 MK Bram's suggestion for runtime integration
" 05.11.2006 MK Bram suggested not to use include protection for
" autoload
" 07.11.2006 MK Tabbed Tail
" 31.12.2006 MK Bug fixing
" 01.01.2007 MK Bug fixing
" Help Page: tail.txt
"------------------------------------------------------------------------------
if version < 700
finish
else
let s:Status_Char = "|"
" set the default options for the plugin
if !exists("g:tail#Height")
let g:tail#Height = 10
endif
if !exists("g:tail#Center_Win")
let g:tail#Center_Win = 0
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" sets up the preview window to watch the specified file for changes
"
function tail#Open (type, file) " {{{1
let l:file = substitute(expand(a:file), "\\", "/", "g")
if !filereadable(l:file)
echohl ErrorMsg
echo "Cannot open for reading: " . l:file
echohl None
else
" if the buffer is already open, kill it
" in case there is a preview window already, also removes autocmd's
"silent pclose
if bufexists (bufnr (l:file))
execute ':' . bufnr(l:file) . 'bwipeout'
endif
" set it up to be watched closely
augroup Tail
" monitor calls -- try to catch the update as much as possible
autocmd CursorHold * :call tail#Monitor()
autocmd CursorHoldI * :call tail#Monitor()
autocmd FocusLost * :call tail#Monitor()
autocmd FocusGained * :call tail#Monitor()
autocmd BufEnter * :call tail#Monitor()
" utility calls
execute 'autocmd BufWinEnter ' . l:file . " :call tail#Setup()"
execute 'autocmd BufWinLeave ' . l:file . " :call tail#Stop()"
execute 'autocmd FileChangedShell ' . l:file . " :call tail#Refresh()"
augroup END
" set up the new window with minimal functionality
silent execute a:type . " " . l:file
endif
return
endfunction " }}}1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" watch the specified file for changes in different split window
"
function tail#Open_Split (file) " {{{1
"if has ('win32') || has ('win64')
"call tail#Open ('pedit', a:file)
"else
call tail#Open (g:tail#Height . 'new', a:file)
"endif
return
endfunction tail#Open_Spluit " }}}1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" watch the specified file for changes in different tabs
"
function tail#Open_Tabs (...) " {{{1
for l:i in a:000
call tail#Open ('tabnew', l:i)
endfor
return
endfunction tail#Open_Tabs " }}}1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" used by Tail to check the file status
"
function tail#Monitor () " {{{1
" do our file change checks
"if has ('win32') || has ('win64')
"" checktime won't work all that well with windows
"pedit!
"else
" the easy check
checktime " the easy check
"endif
call tail#Status ()
endfunction " }}}1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" used by Tail to check the file status
"
function tail#Status () " {{{1
" update the status indicator
if s:Status_Char == "|"
let s:Status_Char = "/"
elseif s:Status_Char == "/"
let s:Status_Char = "-"
elseif s:Status_Char == "-"
let s:Status_Char = "\\"
elseif s:Status_Char == "\\"
let s:Status_Char = "|"
endif
return s:Status_Char
endfunction " }}}1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" used by Tail to set up the preview window settings
"
function tail#Setup () " {{{1
setlocal autoread
setlocal bufhidden=delete
setlocal nobuflisted
setlocal nomodifiable
setlocal nonumber
setlocal noshowcmd
setlocal noswapfile
setlocal nowrap
setlocal previewwindow
nnoremap <buffer> i :setlocal wrap<CR>
nnoremap <buffer> I :setlocal nowrap<CR>
nnoremap <buffer> a :setlocal number<CR>
nnoremap <buffer> A :setlocal nonumber<CR>
nnoremap <buffer> o :setlocal statusline=%F\ %{tail#Status()}<CR>
nnoremap <buffer> O :setlocal statusline<<CR>
nnoremap <buffer> r :call tail#Refresh ()<CR>
nnoremap <buffer> R :view!<CR>
call tail#SetCursor()
endfunction " }}}1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" used by Tail to refresh the window contents & position
" use this instead of autoread for silent reloading and better control
"
function tail#Refresh() " {{{1
if &previewwindow
" if the cursor is on the last line, we'll move it with the update
let l:update_cursor = line(".") == line("$")
let l:wrap = &wrap
let l:number = &number
let l:statusline = &statusline
" do all the necessary updates
silent execute "view!"
if l:wrap
set wrap
endif
if l:number
set number
endif
execute 'set statusline=' . escape (l:statusline, ' \')
if l:update_cursor
call tail#SetCursor()
endif
else
try
" jump to the preview window to reload
wincmd P
" do all the necessary updates
silent execute "view!"
call tail#SetCursor()
" jump back
wincmd p
endtry
endif
endfunction " }}}1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" used by Tail to set the cursor position in the preview window
" assumes that the correct window has already been selected
"
function tail#SetCursor() " {{{1
normal G
if g:tail#Center_Win
normal zz
endif
endfunction " }}}1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" used by Tail to stop watching the file and clean up
"
function tail#Stop() " {{{1
autocmd! Tail
augroup! Tail
endfunction " }}}1
finish
"------------------------------------------------------------------------------
" Copyright (C) 2006 Martin Krischik
"
" Vim is Charityware - see ":help license" or uganda.txt for licence details.
"------------------------------------------------------------------------------
" vim: textwidth=78 nowrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
" vim: filetype=vim foldmethod=marker
doc/tail.txt [[[1
102
*Tail.txt* Watch the contents of a file in real time
Author: Jason Heddings ([email protected])
Martin Krischik ([email protected])
For Vim version 7.0 and above
Last change: 17 September, 2007
1. Overview |tail-about|
2. Commands |tail-commands|
2. Mappings |tail-mappings|
3. Configuration |tail-configure|
==============================================================================
*tail-about*
1. Overview~
Tail allows you to view the contents of a file in real time. When a
change in the file is detected, the window displaying the file is updated and
repositioned to the last line.
The update is not exactly real time, but usually updates within a few seconds
of the file change. The update interval of the output is determined by the
|updatetime| parameter, along with continued usage of Vim. This means that if
you are not doing any editing or motion commands, the preview window will not
be updated. See |CursorHold| for more information.
Because this window becomes the preview window, it will accept all related
commands. For more information, see |preview-window|.
==============================================================================
*tail-commands*
2. Commands~
The Tail plugin does not create any automatic mappings, but provides the
following commands:
|:Tail| begin watching the specified file
|:STail| Same as :Tail
|:TabTail| begin watching the specified files in seperate Tabs
*:Tail* *:STail*
:Tail <filename>
:STail <filename>
Begin watching the specified file in the preview window. This will
cause any existing preview windows to be closed. If the file is
already open in another buffer, that buffer will be wiped out.
*:TabTail*
:TabTail <filenames>
Begin watching the specified files in tabed preview windows.
Once open, the window accepts all preview window commands. For example, to
close the preview window, use |:pclose|.
*:vim-tail.zsh*
You can also open one or more files for (tabbed) tailing using |vim-tail.zsh|
which is provided in the macros directory. |vim-tail.zsh| will use a single
gvim server and |:TabTail| to open the files.
==============================================================================
*tail-mappings*
2. Mappings~
Once the Tail windows is opened it offeres the following mappings:
<i> :setlocal wrap<CR>
<I> :setlocal nowrap<CR>
<a> :setlocal number<CR>
<A> :setlocal nonumber<CR>
<o> :setlocal statusline=%F\ %{tail#Status()}<CR>
<O> :setlocal statusline<<CR>
<r> :call tail#Refresh ()<CR>
<R> :view!<CR>
==============================================================================
*tail-configure*
3. Configuration~
Tail may be customized using variables set by the |let| command in your
.vimrc file. The default values for the options are shown in square brackets.
|'Tail_Height'| Specify the height of the preview window [10]
|'Tail_Center_Win'| Center the output in the preview window [0]
*'Tail_Height'*
Tail_Height~
Using this setting, you can alter the height of the preview window that is
created when |:Tail| is called for a file. >
let g:Tail_Height = 12
<
Tail_Center_Win~
When set to true, this will cause the last line of the output to be centered
in the preview window. By default, the last line of output will be on the
last line of the window >
let g:Tail_Center_Win = 1
<
==============================================================================
vim:textwidth=78:tabstop=8:noexpandtab:filetype=help
macros/vim-tail.zsh [[[1
34
#!/bin/zsh
#------------------------------------------------------------------------------
# Description: Works like "tail -f" .
# $Id: tail.vim,v 1.1 2007/09/10 09:31:47 krischikm Exp $
# Maintainer: Martin Krischik ([email protected])
# $Author: krischikm $
# $Date: 2007/09/10 09:31:47 $
# Version: 3.0
# $Revision: 1.1 $
# $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/plugin/tail.vim $
# History: 17.11.2007 Now with Startup Scripts.
# Help Page: tail.txt
#------------------------------------------------------------------------------
setopt No_X_Trace;
for I ; do
if
gvim --servername "tail" --remote-send ":TabTail ${I}<CR>";
then
; # do nothing
else
gvim --servername "tail" --remote-silent +":TabTail %<CR>" "${I}"
fi
sleep 1;
done;
#------------------------------------------------------------------------------
# Copyright (C) 2006 Martin Krischik
#
# Vim is Charityware - see ":help license" or uganda.txt for licence details.
#------------------------------------------------------------------------------
#vim: set nowrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab :
#vim: set textwidth=0 filetype=zsh foldmethod=marker nospell :
plugin/tail.vim [[[1
40
"------------------------------------------------------------------------------
" Description: Works like "tail -f" .
" $Id: tail.vim 773 2007-09-17 08:58:57Z krischik $
" Maintainer: Martin Krischik ([email protected])
" Jason Heddings (vim at heddway dot com)
" $Author: krischik $
" $Date: 2007-09-17 10:58:57 +0200 (Mo, 17 Sep 2007) $
" Version: 3.0
" $Revision: 773 $
" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/plugin/tail.vim $
" History: 22.09.2006 MK Improve for vim 7.0
" 15.10.2006 MK Bram's suggestion for runtime integration
" 05.11.2006 MK Bram suggested to save on spaces
" 07.11.2006 MK Tabbed Tail
" 31.12.2006 MK Bug fixing
" 01.01.2007 MK Bug fixing
" 17.11.2007 Now with Startup Scripts.
" Help Page: tail.txt
"------------------------------------------------------------------------------
if exists('g:Tail_Loaded') || version < 700
finish
endif
let g:Tail_Loaded = 22
" command exports
command -nargs=1 -complete=file Tail call tail#Open_Split (<q-args>)
command -nargs=1 -complete=file STail call tail#Open_Split (<q-args>)
command -nargs=* -complete=file TabTail call tail#Open_Tabs (<f-args>)
finish " 1}}}
"------------------------------------------------------------------------------
" Copyright (C) 2006 Martin Krischik
"
" Vim is Charityware - see ":help license" or uganda.txt for licence details.
"------------------------------------------------------------------------------
" vim: textwidth=0 nowrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
" vim: filetype=vim foldmethod=marker