Skip to content

Commit 675b63d

Browse files
use x,y and w,h instead
1 parent 98f4d0e commit 675b63d

File tree

1 file changed

+33
-38
lines changed
  • autoload/vital/__vital__/Experimental/UI

1 file changed

+33
-38
lines changed

autoload/vital/__vital__/Experimental/UI/Popup.vim

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,44 @@ endfunction
1010

1111
" opt = {
1212
" 'contents': ['This', 'is', 'a', 'line'],
13-
" 'width': 5,
14-
" 'height': 5,
15-
" 'line': 1,
16-
" 'col': 1,
13+
" 'w': 5,
14+
" 'h': 5,
15+
" 'x': 1,
16+
" 'y': 1,
1717
" }
1818
function! s:create(opt) abort
1919
let data = {}
20-
call s:_set_width(data, get(a:opt, 'width', 5))
21-
call s:_set_height(data, get(a:opt, 'height', 5))
20+
call s:_set_w(data, get(a:opt, 'w', 5))
21+
call s:_set_h(data, get(a:opt, 'h', 5))
2222
call s:_set_contents(data, get(a:opt, 'contents', []))
23-
call s:_set_line(data, get(a:opt, 'line', 1))
24-
call s:_set_col(data, get(a:opt, 'col', 1))
23+
call s:_set_x(data, get(a:opt, 'x', 1))
24+
call s:_set_y(data, get(a:opt, 'y', 1))
25+
2526
if s:_has_nvim
2627
let buf = nvim_create_buf(0, 1)
2728
call nvim_buf_set_lines(buf, 0, -1, 1, s:_get_contents(data))
2829
let opt = {
2930
\ 'relative': 'editor',
3031
\ 'style': 'minimal',
31-
\ 'width': data['width'],
32-
\ 'height': data['height'],
33-
\ 'row': data['line'],
34-
\ 'col': data['col'],
32+
\ 'width': data['w'],
33+
\ 'height': data['h'],
34+
\ 'col': data['x'],
35+
\ 'row': data['y'],
3536
\ 'focusable': 0,
3637
\ }
3738
let id = nvim_open_win(buf, 1, opt)
3839
else
40+
" neovim doesn't support scrollbar so don't enable it
3941
let id = popup_create(s:_get_contents(data), {
40-
\ 'width': data['width'],
41-
\ 'height': data['height'],
42-
\ 'minwidth': data['width'],
43-
\ 'minheight': data['height'],
44-
\ 'maxwidth': data['width'],
45-
\ 'maxheight': data['height'],
46-
\ 'line': data['line'],
47-
\ 'col': data['col'],
42+
\ 'width': data['w'],
43+
\ 'height': data['h'],
44+
\ 'minwidth': data['w'],
45+
\ 'minheight': data['h'],
46+
\ 'maxwidth': data['w'],
47+
\ 'maxheight': data['h'],
48+
\ 'col': data['x'],
49+
\ 'line': data['y'],
50+
\ 'scrollbar': 0,
4851
\ })
4952
endif
5053
let s:_popups[id] = data
@@ -59,35 +62,27 @@ function! s:_get_contents(data) abort
5962
return get(a:data, 'contents', [])
6063
endfunction
6164

62-
function! s:_set_width(data, width) abort
63-
let a:data['width'] = a:width
64-
endfunction
65-
66-
function! s:_get_width(data) abort
67-
return a:data['width']
68-
endfunction
69-
70-
function! s:_get_height(data) abort
71-
return a:data['height']
65+
function! s:_set_w(data, w) abort
66+
let a:data['w'] = a:w
7267
endfunction
7368

74-
function! s:_set_height(data, height) abort
75-
let a:data['height'] = a:height
69+
function! s:_set_h(data, h) abort
70+
let a:data['h'] = a:h
7671
endfunction
7772

78-
function! s:_set_line(data, line) abort
73+
function! s:_set_y(data, y) abort
7974
if s:_has_nvim
80-
let a:data['line'] = a:line - 1
75+
let a:data['y'] = a:y - 1
8176
else
82-
let a:data['line'] = a:line
77+
let a:data['y'] = a:y
8378
endif
8479
endfunction
8580

86-
function! s:_set_col(data, col) abort
81+
function! s:_set_x(data, x) abort
8782
if s:_has_nvim
88-
let a:data['col'] = a:col - 1
83+
let a:data['x'] = a:x - 1
8984
else
90-
let a:data['col'] = a:col
85+
let a:data['x'] = a:x
9186
endif
9287
endfunction
9388

0 commit comments

Comments
 (0)