mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-23 01:09:56 +08:00
Add keys for buffer transient state
This commit is contained in:
parent
08ee17ab3b
commit
f8989a9269
@ -35,7 +35,7 @@ function! s:self.open() abort
|
|||||||
exe 'resize ' . line('$')
|
exe 'resize ' . line('$')
|
||||||
endif
|
endif
|
||||||
" move to prvious window
|
" move to prvious window
|
||||||
wincmd w
|
wincmd p
|
||||||
while 1
|
while 1
|
||||||
redraw!
|
redraw!
|
||||||
let char = self._getchar()
|
let char = self._getchar()
|
||||||
@ -94,7 +94,7 @@ function! s:self._update_content() abort
|
|||||||
let right = get(self._keys.right, i)
|
let right = get(self._keys.right, i)
|
||||||
let line = ''
|
let line = ''
|
||||||
if !empty(left)
|
if !empty(left)
|
||||||
if type(left.key) ==# type('')
|
if type(left.key) == 1
|
||||||
let line .= '[' . left.key . '] ' . left.desc
|
let line .= '[' . left.key . '] ' . left.desc
|
||||||
call self.highlight_keys(left.exit, i + 2, 1, 1 + len(left.key))
|
call self.highlight_keys(left.exit, i + 2, 1, 1 + len(left.key))
|
||||||
if !empty(left.cmd)
|
if !empty(left.cmd)
|
||||||
@ -102,6 +102,15 @@ function! s:self._update_content() abort
|
|||||||
elseif !empty(left.func)
|
elseif !empty(left.func)
|
||||||
call extend(self._handle_inputs, {left.key : left.func})
|
call extend(self._handle_inputs, {left.key : left.func})
|
||||||
endif
|
endif
|
||||||
|
elseif type(left.key) == 3
|
||||||
|
elseif type(left.key) == 4
|
||||||
|
let line .= '[' . left.key.name . '] ' . left.desc
|
||||||
|
for pos in left.key.pos
|
||||||
|
call self.highlight_keys(left.exit, i + 2, pos[0], pos[1])
|
||||||
|
endfor
|
||||||
|
for handles in left.key.handles
|
||||||
|
call extend(self._handle_inputs, {handles[0] : handles[1]})
|
||||||
|
endfor
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
let line .= repeat(' ', 40 - len(line))
|
let line .= repeat(' ', 40 - len(line))
|
||||||
|
@ -289,6 +289,29 @@ function! s:delete_current_buffer_file() abort
|
|||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:swap_buffer_with_nth_win(nr) abort
|
||||||
|
if a:nr <= winnr('$') && a:nr != winnr()
|
||||||
|
let cb = bufnr('%')
|
||||||
|
let tb = winbufnr(a:nr)
|
||||||
|
if cb != tb
|
||||||
|
exe a:nr . 'wincmd w'
|
||||||
|
exe 'b' . cb
|
||||||
|
wincmd p
|
||||||
|
exe 'b' . tb
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:move_buffer_to_nth_win(nr) abort
|
||||||
|
if a:nr <= winnr('$') && a:nr != winnr()
|
||||||
|
let cb = bufnr('%')
|
||||||
|
bp
|
||||||
|
exe a:nr . 'wincmd w'
|
||||||
|
exe 'b' . cb
|
||||||
|
wincmd p
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:buffer_transient_state() abort
|
function! s:buffer_transient_state() abort
|
||||||
let state = SpaceVim#api#import('transient_state')
|
let state = SpaceVim#api#import('transient_state')
|
||||||
call state.set_title('Buffer Selection Transient State')
|
call state.set_title('Buffer Selection Transient State')
|
||||||
@ -297,10 +320,45 @@ function! s:buffer_transient_state() abort
|
|||||||
\ 'layout' : 'vertical split',
|
\ 'layout' : 'vertical split',
|
||||||
\ 'left' : [
|
\ 'left' : [
|
||||||
\ {
|
\ {
|
||||||
\ 'key' : 'J',
|
\ 'key' : {
|
||||||
\ 'desc' : 'move text down',
|
\ 'name' : 'C-1..C-9',
|
||||||
|
\ 'pos' : [[1,4], [6,9]],
|
||||||
|
\ 'handles' : [
|
||||||
|
\ ["\<C-1>" , ''],
|
||||||
|
\ ["\<C-2>" , ''],
|
||||||
|
\ ["\<C-3>" , ''],
|
||||||
|
\ ["\<C-4>" , ''],
|
||||||
|
\ ["\<C-5>" , ''],
|
||||||
|
\ ["\<C-6>" , ''],
|
||||||
|
\ ["\<C-7>" , ''],
|
||||||
|
\ ["\<C-8>" , ''],
|
||||||
|
\ ["\<C-9>" , ''],
|
||||||
|
\ ],
|
||||||
|
\ },
|
||||||
|
\ 'desc' : 'goto nth window',
|
||||||
\ 'func' : '',
|
\ 'func' : '',
|
||||||
\ 'cmd' : 'normal! "_ddp',
|
\ 'cmd' : '',
|
||||||
|
\ 'exit' : 0,
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'key' : {
|
||||||
|
\ 'name' : '1..9',
|
||||||
|
\ 'pos' : [[1,2], [4,5]],
|
||||||
|
\ 'handles' : [
|
||||||
|
\ ['1' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [1])'],
|
||||||
|
\ ['2' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [2])'],
|
||||||
|
\ ['3' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [3])'],
|
||||||
|
\ ['4' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [4])'],
|
||||||
|
\ ['5' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [5])'],
|
||||||
|
\ ['6' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [6])'],
|
||||||
|
\ ['7' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [7])'],
|
||||||
|
\ ['8' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [8])'],
|
||||||
|
\ ['9' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [9])'],
|
||||||
|
\ ],
|
||||||
|
\ },
|
||||||
|
\ 'desc' : 'move buffer to nth window',
|
||||||
|
\ 'func' : '',
|
||||||
|
\ 'cmd' : '',
|
||||||
\ 'exit' : 0,
|
\ 'exit' : 0,
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user