Browse files

Improve cursor position

  • Loading branch information...
1 parent 4adfdbf commit 7f5303b337c05ba3b2a5b55917282fab5fadc122 @Shougo committed Jan 20, 2014
View
4 autoload/unite/kinds/vimshell_history.vim
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: vimshell/history.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
-" Last Modified: 24 Dec 2013.
+" Last Modified: 20 Jan 2014.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@@ -110,7 +110,7 @@ function! s:kind.action_table.insert.func(candidates) "{{{
if unite#get_context().complete
startinsert!
else
- normal! $
+ call cursor(0, col('$'))
endif
endfunction"}}}
View
4 autoload/vimshell/commands/less.vim
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: less.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
-" Last Modified: 27 Nov 2013.
+" Last Modified: 20 Jan 2014.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@@ -252,7 +252,7 @@ endfunction "}}}
function! s:print_output(line_num) "{{{
setlocal modifiable
- $
+ call cursor(line('$'), col('$'))
if b:interactive.stdout_cache == ''
if b:interactive.process.stdout.eof
View
10 autoload/vimshell/int_mappings.vim
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: int_mappings.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
-" Last Modified: 24 Nov 2013.
+" Last Modified: 20 Jan 2014.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@@ -198,7 +198,7 @@ function! vimshell#int_mappings#execute_line(is_insert) "{{{
endif
endif
- $
+ call cursor(line('$'), col('$'))
call vimshell#interactive#execute_pty_inout(a:is_insert)
@@ -212,7 +212,7 @@ function! s:paste_prompt() "{{{
" Set prompt line.
let cur_text = vimshell#interactive#get_cur_line(line('.'))
call setline(line('$'), vimshell#interactive#get_prompt(line('$')) . cur_text)
- $
+ call cursor(line('$'), col('$'))
endfunction"}}}
function! s:restart_command() "{{{
if exists('b:interactive') && !empty(b:interactive.process) && b:interactive.process.is_valid
@@ -240,7 +240,7 @@ function! s:restart_command() "{{{
call vimshell#interactive#execute_process_out(1)
- startinsert!
+ call vimshell#view#_start_insert()
endfunction"}}}
function! vimshell#int_mappings#command_complete() "{{{
let prompt = vimshell#interactive#get_prompt()
@@ -330,7 +330,7 @@ function! vimshell#int_mappings#clear() "{{{
call vimshell#interactive#execute_process_out(1)
- startinsert!
+ call vimshell#view#_start_insert()
endfunction"}}}
" vim: foldmethod=marker
View
23 autoload/vimshell/interactive.vim
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: interactive.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
-" Last Modified: 17 Jan 2014.
+" Last Modified: 20 Jan 2014.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@@ -178,7 +178,7 @@ function! vimshell#interactive#send(expr) "{{{
return
endif
- $
+ call cursor(line('$'), col('$'))
let list = type(a:expr) == type('') ?
\ [a:expr] : a:expr
@@ -324,11 +324,7 @@ function! s:set_output_pos(is_insert) "{{{
\ has_key(b:interactive.process, 'stdout')
\ && (!b:interactive.process.stdout.eof ||
\ !b:interactive.process.stderr.eof)
- if a:is_insert
- startinsert!
- else
- normal! $
- endif
+ call vimshell#view#_simple_insert(a:is_insert)
let b:interactive.output_pos = getpos('.')
endif
@@ -389,8 +385,7 @@ function! vimshell#interactive#exit() "{{{
setlocal modifiable
call append('$', '*Exit*')
- $
- normal! $
+ call cursor(line('$'), col('$'))
endif
endif
endfunction"}}}
@@ -409,9 +404,7 @@ function! vimshell#interactive#force_exit() "{{{
setlocal modifiable
call append('$', '*Killed*')
- $
- normal! $
-
+ call cursor(line('$'), col('$'))
stopinsert
endif
endfunction"}}}
@@ -439,9 +432,7 @@ function! vimshell#interactive#hang_up(afile) "{{{
setlocal modifiable
call append('$', '*Killed*')
- $
- normal! $
-
+ call cursor(line('$'), col('$'))
stopinsert
endif
endfunction"}}}
@@ -770,7 +761,7 @@ function! s:check_output(interactive, bufnr, bufnr_save) "{{{
elseif (!a:interactive.process.stdout.eof
\ || !a:interactive.process.stderr.eof)
\ && is_insert
- startinsert!
+ call vimshell#view#_simple_insert(is_insert)
endif
endif
View
9 autoload/vimshell/mappings.vim
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: mappings.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
-" Last Modified: 17 Jan 2014.
+" Last Modified: 20 Jan 2014.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@@ -216,7 +216,7 @@ function! s:push_current_line() "{{{
" Set prompt line.
call setline('.', vimshell#get_prompt())
- startinsert!
+ call vimshell#view#_simple_insert()
endfunction"}}}
function! s:push_and_execute(command) "{{{
" Check current line.
@@ -490,11 +490,8 @@ function! s:clear(is_insert) "{{{
call vimshell#view#_set_prompt_command(lines[0])
call append('$', map(lines[1:],
\ string(vimshell#get_secondary_prompt()).'.v:val'))
- $
- if a:is_insert
- call vimshell#start_insert()
- endif
+ call vimshell#start_insert(a:is_insert)
endfunction"}}}
function! s:expand_wildcard() "{{{
" Wildcard.
View
7 autoload/vimshell/terminal.vim
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: terminal.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
-" Last Modified: 05 Dec 2013.
+" Last Modified: 20 Jan 2014.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@@ -275,7 +275,7 @@ function! s:optimized_print(string, is_error) "{{{
call s:print_simple(a:is_error, lines)
endif
- normal! $
+ call cursor(0, col('$'))
let [s:virtual.line, s:virtual.col] =
\ s:get_virtual_col(line('.'), col('.')-1)
call s:set_cursor()
@@ -319,7 +319,8 @@ function! s:print_simple(is_error, lines) "{{{
call append('.', lines[0])
endif
- normal! j$
+ call cursor(line('.')+1, 0)
+ call cursor(0, col('$'))
elseif line('.') != b:interactive.echoback_linenr
call setline('.', substitute(
\ getline('.') . lines[0], '[^!]\zs!\{6}\ze[^!]', '', 'g'))
View
10 autoload/vimshell/view.vim
@@ -165,7 +165,7 @@ function! vimshell#view#_print_prompt(...) "{{{
call append('$', new_prompt)
endif
- $
+ call cursor(line('$'), col('$'))
let &modified = 0
endfunction"}}}
function! vimshell#view#_print_secondary_prompt() "{{{
@@ -175,7 +175,7 @@ function! vimshell#view#_print_secondary_prompt() "{{{
" Insert secondary prompt line.
call append('$', vimshell#get_secondary_prompt())
- $
+ call cursor(line('$'), col('$'))
let &modified = 0
endfunction"}}}
function! vimshell#view#_start_insert(...) "{{{
@@ -194,8 +194,10 @@ function! vimshell#view#_start_insert(...) "{{{
call vimshell#helpers#imdisable()
endif
endfunction"}}}
-function! vimshell#view#_simple_insert() "{{{
- if g:vimshell_enable_start_insert
+function! vimshell#view#_simple_insert(...) "{{{
+ let is_insert = (a:0 == 0)? 1 : a:1
+
+ if is_insert && g:vimshell_enable_start_insert
startinsert!
else
stopinsert
View
2 doc/vimshell.txt
@@ -365,7 +365,7 @@ g:vimshell_enable_transient_user_prompt
g:vimshell_enable_start_insert
If it is non-zero, vimshell will start in insert mode.
- Default value is 0.
+ Default value is 1.
*g:vimshell_execute_file_list*
g:vimshell_execute_file_list

0 comments on commit 7f5303b

Please sign in to comment.