Skip to content

Commit 110e2fb

Browse files
unknownunknown
unknown
authored and
unknown
committed
* Print lines if one screen in view.
* Fixed nomodifiable error in view. * Revised internal vim command.
1 parent a51c293 commit 110e2fb

File tree

3 files changed

+45
-14
lines changed

3 files changed

+45
-14
lines changed

autoload/vimshell/internal/view.vim

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"=============================================================================
22
" FILE: view.vim
33
" AUTHOR: Shougo Matsushita <[email protected]>
4-
" Last Modified: 11 Feb 2010
4+
" Last Modified: 26 Feb 2010
55
" Usage: Just source this file.
66
" License: MIT license {{{
77
" Permission is hereby granted, free of charge, to any person obtaining
@@ -23,9 +23,13 @@
2323
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2424
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2525
" }}}
26-
" Version: 1.5, for Vim 7.0
26+
" Version: 1.6, for Vim 7.0
2727
"-----------------------------------------------------------------------------
2828
" ChangeLog: "{{{
29+
" 1.6:
30+
" - Print lines if one screen.
31+
" - Fixed nomodifiable error.
32+
"
2933
" 1.5:
3034
" - Catch error.
3135
"
@@ -56,16 +60,30 @@
5660
function! vimshell#internal#view#execute(program, args, fd, other_info)
5761
" View file.
5862

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
6174

62-
if isdirectory(l:arguments)
75+
if isdirectory(l:filename)
6376
" Ignore.
6477
return 0
6578
endif
6679

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+
6987
return 0
7088
endif
7189

@@ -78,11 +96,12 @@ function! vimshell#internal#view#execute(program, args, fd, other_info)
7896
call vimshell#split_nicely()
7997

8098
try
81-
edit `=l:arguments`
99+
edit `=l:filename`
82100
catch /^.*/
83101
echohl Error | echomsg v:errmsg | echohl None
84102
endtry
85103

86104
lcd `=l:cwd`
87105
setlocal nomodifiable
106+
return 1
88107
endfunction

autoload/vimshell/internal/vim.vim

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"=============================================================================
22
" FILE: vim.vim
33
" AUTHOR: Shougo Matsushita <[email protected]>
4-
" Last Modified: 11 Feb 2010
4+
" Last Modified: 26 Feb 2010
55
" Usage: Just source this file.
66
" License: MIT license {{{
77
" Permission is hereby granted, free of charge, to any person obtaining
@@ -23,9 +23,12 @@
2323
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2424
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2525
" }}}
26-
" Version: 1.5, for Vim 7.0
26+
" Version: 1.6, for Vim 7.0
2727
"-----------------------------------------------------------------------------
2828
" ChangeLog: "{{{
29+
" 1.6:
30+
" - Revised.
31+
"
2932
" 1.5:
3033
" - Catch error.
3134
"
@@ -56,8 +59,12 @@
5659
function! vimshell#internal#vim#execute(program, args, fd, other_info)
5760
" Edit file.
5861

59-
" Filename escape
60-
let l:arguments = join(a:args, ' ')
62+
if empty(a:args)
63+
" Read from stdin.
64+
let l:filename = a:fd.stdin
65+
else
66+
let l:filename = a:args[0]
67+
endif
6168

6269
call vimshell#print_prompt()
6370

@@ -71,7 +78,7 @@ function! vimshell#internal#vim#execute(program, args, fd, other_info)
7178
let l:is_split = 1
7279
endif
7380

74-
if empty(l:arguments)
81+
if l:filename == ''
7582
if l:is_split
7683
new
7784
else
@@ -85,7 +92,7 @@ function! vimshell#internal#vim#execute(program, args, fd, other_info)
8592
endif
8693

8794
try
88-
edit `=l:arguments`
95+
edit `=l:filename`
8996
catch
9097
echohl Error | echomsg v:errmsg | echohl None
9198
endtry

doc/vimshell.txt

+5
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ ability of vimshell will spread by creating plugin by yourself.
117117
==============================================================================
118118
CHANGELOG *vimshell-changelog*
119119

120+
2010-02-26
121+
* Print lines if one screen in view.
122+
* Fixed nomodifiable error in view.
123+
* Revised internal vim command.
124+
120125
2010-02-24
121126
* Fixed interactive filetype.
122127
* Ignore .gitignore in vcs_git.

0 commit comments

Comments
 (0)