@@ -10,41 +10,44 @@ endfunction
10
10
11
11
" opt = {
12
12
" '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,
17
17
" }
18
18
function ! s: create (opt ) abort
19
19
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 ))
22
22
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
+
25
26
if s: _has_nvim
26
27
let buf = nvim_create_buf (0 , 1 )
27
28
call nvim_buf_set_lines (buf , 0 , -1 , 1 , s: _get_contents (data))
28
29
let opt = {
29
30
\ ' relative' : ' editor' ,
30
31
\ ' 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 ' ],
35
36
\ ' focusable' : 0 ,
36
37
\ }
37
38
let id = nvim_open_win (buf , 1 , opt )
38
39
else
40
+ " neovim doesn't support scrollbar so don't enable it
39
41
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 ,
48
51
\ })
49
52
endif
50
53
let s: _popups [id] = data
@@ -59,35 +62,27 @@ function! s:_get_contents(data) abort
59
62
return get (a: data , ' contents' , [])
60
63
endfunction
61
64
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
72
67
endfunction
73
68
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
76
71
endfunction
77
72
78
- function ! s: _set_line (data, line ) abort
73
+ function ! s: _set_y (data, y ) abort
79
74
if s: _has_nvim
80
- let a: data [' line ' ] = a: line - 1
75
+ let a: data [' y ' ] = a: y - 1
81
76
else
82
- let a: data [' line ' ] = a: line
77
+ let a: data [' y ' ] = a: y
83
78
endif
84
79
endfunction
85
80
86
- function ! s: _set_col (data, col ) abort
81
+ function ! s: _set_x (data, x ) abort
87
82
if s: _has_nvim
88
- let a: data [' col ' ] = a: col - 1
83
+ let a: data [' x ' ] = a: x - 1
89
84
else
90
- let a: data [' col ' ] = a: col
85
+ let a: data [' x ' ] = a: x
91
86
endif
92
87
endfunction
93
88
0 commit comments