1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 01:00:05 +08:00

feat(notify): add winblend option

This commit is contained in:
wsdjeg 2022-04-10 22:45:01 +08:00
parent 813ad6c950
commit 71dd46e450
2 changed files with 55 additions and 11 deletions

View File

@ -7,6 +7,24 @@
"=============================================================================
scriptencoding utf-8
""
" @section notify, api-notify
" @parentsection api
" The notification api for SpaceVim
"
" notify({msg} [, {Color}[, {option}]])
"
" Use floating windows to display notification {msg}. The {msg} should a no
" empty string. {Color} is the name of highlight ground defined in Vim. The
" {option} is a dictionary which support following key:
"
" - `winblend`: enable transparency for the notify windows. Valid values
" are in the range of 0 to 100. Default is 0.
"
" NOTE: Floating windows support pseudo-transparency (:help 'winblend')
" in #neovim HEAD (v0.4.x).
"
" Global values, this can be used between different notify
let s:notifications = {}
@ -24,6 +42,7 @@ let s:self.border.winid = -1
let s:self.border.bufnr = -1
let s:self.borderchars = ['─', '│', '─', '│', '┌', '┐', '┘', '└']
let s:self.title = ''
let s:self.winblend = 0
let s:self.timeout = 3000
let s:self.hashkey = ''
let s:self.config = {}
@ -143,6 +162,8 @@ endfunction
function! s:self.notify(msg, ...) abort
call add(self.message, a:msg)
let self.notification_color = get(a:000, 0, 'Normal')
let options = get(a:000, 1, {})
let self.winblend = get(options, 'winblend', self.winblend)
if empty(self.hashkey)
let self.hashkey = self.__password.generate_simple(10)
endif
@ -220,6 +241,10 @@ function! s:self.redraw_windows() abort
\ 'highlight' : 'VertSplit',
\ 'focusable' : v:false,
\ })
if self.winblend > 0 && exists('&winblend')
call nvim_win_set_var(self.winid, 'winblend', self.winblend)
call nvim_win_set_var(self.border.winid, 'winblend', self.winblend)
endif
endif
call self.__buffer.buf_set_lines(self.border.bufnr, 0 , -1, 0,
\ self.draw_border(self.title, self.notification_width, len(self.message)))

View File

@ -246,17 +246,18 @@ CONTENTS *SpaceVim-contents*
6. data#string................................|SpaceVim-api-data-string|
7. job................................................|SpaceVim-api-job|
8. logger..........................................|SpaceVim-api-logger|
9. password......................................|SpaceVim-api-password|
10. prompt.........................................|SpaceVim-api-prompt|
11. sid...........................................|SpaceVim-api-vim-sid|
12. system.........................................|SpaceVim-api-system|
13. time.............................................|SpaceVim-api-time|
14. unicode#box...............................|SpaceVim-api-unicode-box|
15. vim#buffer.................................|SpaceVim-api-vim-buffer|
16. vim#command...............................|SpaceVim-api-vim-command|
17. vim#compatible.........................|SpaceVim-api-vim-compatible|
18. vim#message...............................|SpaceVim-api-vim-message|
19. vim#window.................................|SpaceVim-api-vim-window|
9. notify..........................................|SpaceVim-api-notify|
10. password.....................................|SpaceVim-api-password|
11. prompt.........................................|SpaceVim-api-prompt|
12. sid...........................................|SpaceVim-api-vim-sid|
13. system.........................................|SpaceVim-api-system|
14. time.............................................|SpaceVim-api-time|
15. unicode#box...............................|SpaceVim-api-unicode-box|
16. vim#buffer.................................|SpaceVim-api-vim-buffer|
17. vim#command...............................|SpaceVim-api-vim-command|
18. vim#compatible.........................|SpaceVim-api-vim-compatible|
19. vim#message...............................|SpaceVim-api-vim-message|
20. vim#window.................................|SpaceVim-api-vim-window|
10. Development...............................................|SpaceVim-dev|
1. commit-style-guide..................|SpaceVim-dev-commit-style-guide|
11. FAQ.......................................................|SpaceVim-faq|
@ -5760,6 +5761,24 @@ set_silent({silent})
{silent} is a Boolean. by default it is false, and log will be print to
screen.
==============================================================================
NOTIFY *SpaceVim-api-notify*
The notification api for SpaceVim
notify({msg} [, {Color}[, {option}]])
Use floating windows to display notification {msg}. The {msg} should a no
empty string. {Color} is the name of highlight ground defined in Vim. The
{option} is a dictionary which support following key:
`winblend`: enable transparency for the notify windows. Valid values are in
the range of 0 to 100. Default is 0.
NOTE: Floating windows support pseudo-transparency (:help 'winblend') in
#neovim HEAD (v0.4.x).
==============================================================================
PASSWORD *SpaceVim-api-password*