mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 15:19:12 +08:00
parent
4006e9b912
commit
ee07874b8b
@ -24,7 +24,6 @@ let s:self.border.winid = -1
|
||||
let s:self.border.bufnr = -1
|
||||
let s:self.borderchars = ['─', '│', '─', '│', '┌', '┐', '┘', '└']
|
||||
let s:self.title = ''
|
||||
let s:self.win_is_open = 0
|
||||
let s:self.timeout = 3000
|
||||
let s:self.hashkey = ''
|
||||
let s:self.config = {}
|
||||
@ -60,9 +59,19 @@ function! s:self.draw_border(title, width, height) abort
|
||||
return lines
|
||||
endfunction
|
||||
|
||||
function! s:self.win_is_open() abort
|
||||
try
|
||||
return self.winid >= 0 && self.border.winid >= 0
|
||||
\ && has_key(nvim_win_get_config(self.winid), 'col')
|
||||
\ && has_key(nvim_win_get_config(self.border.winid), 'col')
|
||||
catch
|
||||
return 0
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:self.increase_window(...) abort
|
||||
" let self.notification_width = self.__floating.get_width(self.winid)
|
||||
if self.notification_width <= self.notify_max_width && self.win_is_open
|
||||
if self.notification_width <= self.notify_max_width && self.win_is_open()
|
||||
let self.notification_width += min([float2nr((self.notify_max_width - self.notification_width) * 1 / 10), float2nr(self.notify_max_width)])
|
||||
call self.__buffer.buf_set_lines(self.border.bufnr, 0 , -1, 0,
|
||||
\ self.draw_border(self.title, self.notification_width, len(self.message)))
|
||||
@ -102,7 +111,6 @@ function! s:self.close(...) abort
|
||||
noautocmd call self.__floating.win_close(self.border.winid, v:true)
|
||||
noautocmd call self.__floating.win_close(self.winid, v:true)
|
||||
call remove(s:notifications, self.hashkey)
|
||||
let self.win_is_open = v:false
|
||||
let self.notification_width = 1
|
||||
endif
|
||||
for hashkey in keys(s:notifications)
|
||||
@ -113,12 +121,6 @@ endfunction
|
||||
function! s:self.notify(msg, ...) abort
|
||||
call add(self.message, a:msg)
|
||||
let self.notification_color = get(a:000, 0, 'Normal')
|
||||
if !bufexists(self.border.bufnr)
|
||||
let self.border.bufnr = self.__buffer.create_buf(0, 1)
|
||||
endif
|
||||
if !bufexists(self.bufnr)
|
||||
let self.bufnr = self.__buffer.create_buf(0, 1)
|
||||
endif
|
||||
if empty(self.hashkey)
|
||||
let self.hashkey = self.__password.generate_simple(10)
|
||||
endif
|
||||
@ -148,7 +150,7 @@ function! s:self.redraw_windows() abort
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if self.win_is_open
|
||||
if self.win_is_open()
|
||||
call self.__floating.win_config(self.winid,
|
||||
\ {
|
||||
\ 'relative': 'editor',
|
||||
@ -170,6 +172,12 @@ function! s:self.redraw_windows() abort
|
||||
\ 'focusable' : v:false,
|
||||
\ })
|
||||
else
|
||||
if !bufexists(self.border.bufnr)
|
||||
let self.border.bufnr = self.__buffer.create_buf(0, 1)
|
||||
endif
|
||||
if !bufexists(self.bufnr)
|
||||
let self.bufnr = self.__buffer.create_buf(0, 1)
|
||||
endif
|
||||
let self.winid = self.__floating.open_win(self.bufnr, v:false,
|
||||
\ {
|
||||
\ 'relative': 'editor',
|
||||
@ -190,7 +198,6 @@ function! s:self.redraw_windows() abort
|
||||
\ 'highlight' : 'VertSplit',
|
||||
\ 'focusable' : v:false,
|
||||
\ })
|
||||
let self.win_is_open = v:true
|
||||
endif
|
||||
call self.__buffer.buf_set_lines(self.border.bufnr, 0 , -1, 0,
|
||||
\ self.draw_border(self.title, self.notification_width, len(self.message)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user