1
1
" =============================================================================
2
2
" FILE: view.vim
3
3
" AUTHOR: Shougo Matsushita <[email protected] >
4
- " Last Modified: 11 Feb 2010
4
+ " Last Modified: 26 Feb 2010
5
5
" Usage: Just source this file.
6
6
" License: MIT license {{{
7
7
" Permission is hereby granted, free of charge, to any person obtaining
23
23
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
24
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
25
" }}}
26
- " Version: 1.5 , for Vim 7.0
26
+ " Version: 1.6 , for Vim 7.0
27
27
" -----------------------------------------------------------------------------
28
28
" ChangeLog: "{{{
29
+ " 1.6:
30
+ " - Print lines if one screen.
31
+ " - Fixed nomodifiable error.
32
+ "
29
33
" 1.5:
30
34
" - Catch error.
31
35
"
56
60
function ! vimshell#internal#view#execute (program, args , fd, other_info)
57
61
" View file.
58
62
59
- " Filename escape
60
- let l: arguments = join (a: args , ' ' )
63
+ if empty (a: args )
64
+ if a: fd .stdin == ' '
65
+ vimshell#error_line (a: fd , ' Filename required.' )
66
+ return 0
67
+ endif
68
+
69
+ " Read from stdin.
70
+ let l: filename = a: fd .stdin
71
+ else
72
+ let l: filename = a: args [0 ]
73
+ endif
61
74
62
- if isdirectory (l: arguments )
75
+ if isdirectory (l: filename )
63
76
" Ignore.
64
77
return 0
65
78
endif
66
79
67
- if empty (l: arguments )
68
- vimshell#error_line (a: fd , ' Filename required.' )
80
+ let l: lines = readfile (l: filename )
81
+ if len (l: lines ) < winheight (0 )
82
+ " Print lines if one screen.
83
+ for l: line in l: lines
84
+ call vimshell#print_line (a: fd , l: line )
85
+ endfor
86
+
69
87
return 0
70
88
endif
71
89
@@ -78,11 +96,12 @@ function! vimshell#internal#view#execute(program, args, fd, other_info)
78
96
call vimshell#split_nicely ()
79
97
80
98
try
81
- edit `= l: arguments `
99
+ edit `= l: filename `
82
100
catch /^.*/
83
101
echohl Error | echomsg v: errmsg | echohl None
84
102
endtry
85
103
86
104
lcd `= l: cwd `
87
105
setlocal nomodifiable
106
+ return 1
88
107
endfunction
0 commit comments