mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 00:50:05 +08:00
feat(notify): add winblend
option
This commit is contained in:
parent
813ad6c950
commit
71dd46e450
@ -7,6 +7,24 @@
|
|||||||
"=============================================================================
|
"=============================================================================
|
||||||
scriptencoding utf-8
|
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
|
" Global values, this can be used between different notify
|
||||||
|
|
||||||
let s:notifications = {}
|
let s:notifications = {}
|
||||||
@ -24,6 +42,7 @@ let s:self.border.winid = -1
|
|||||||
let s:self.border.bufnr = -1
|
let s:self.border.bufnr = -1
|
||||||
let s:self.borderchars = ['─', '│', '─', '│', '┌', '┐', '┘', '└']
|
let s:self.borderchars = ['─', '│', '─', '│', '┌', '┐', '┘', '└']
|
||||||
let s:self.title = ''
|
let s:self.title = ''
|
||||||
|
let s:self.winblend = 0
|
||||||
let s:self.timeout = 3000
|
let s:self.timeout = 3000
|
||||||
let s:self.hashkey = ''
|
let s:self.hashkey = ''
|
||||||
let s:self.config = {}
|
let s:self.config = {}
|
||||||
@ -143,6 +162,8 @@ endfunction
|
|||||||
function! s:self.notify(msg, ...) abort
|
function! s:self.notify(msg, ...) abort
|
||||||
call add(self.message, a:msg)
|
call add(self.message, a:msg)
|
||||||
let self.notification_color = get(a:000, 0, 'Normal')
|
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)
|
if empty(self.hashkey)
|
||||||
let self.hashkey = self.__password.generate_simple(10)
|
let self.hashkey = self.__password.generate_simple(10)
|
||||||
endif
|
endif
|
||||||
@ -220,6 +241,10 @@ function! s:self.redraw_windows() abort
|
|||||||
\ 'highlight' : 'VertSplit',
|
\ 'highlight' : 'VertSplit',
|
||||||
\ 'focusable' : v:false,
|
\ '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
|
endif
|
||||||
call self.__buffer.buf_set_lines(self.border.bufnr, 0 , -1, 0,
|
call self.__buffer.buf_set_lines(self.border.bufnr, 0 , -1, 0,
|
||||||
\ self.draw_border(self.title, self.notification_width, len(self.message)))
|
\ self.draw_border(self.title, self.notification_width, len(self.message)))
|
||||||
|
@ -246,17 +246,18 @@ CONTENTS *SpaceVim-contents*
|
|||||||
6. data#string................................|SpaceVim-api-data-string|
|
6. data#string................................|SpaceVim-api-data-string|
|
||||||
7. job................................................|SpaceVim-api-job|
|
7. job................................................|SpaceVim-api-job|
|
||||||
8. logger..........................................|SpaceVim-api-logger|
|
8. logger..........................................|SpaceVim-api-logger|
|
||||||
9. password......................................|SpaceVim-api-password|
|
9. notify..........................................|SpaceVim-api-notify|
|
||||||
10. prompt.........................................|SpaceVim-api-prompt|
|
10. password.....................................|SpaceVim-api-password|
|
||||||
11. sid...........................................|SpaceVim-api-vim-sid|
|
11. prompt.........................................|SpaceVim-api-prompt|
|
||||||
12. system.........................................|SpaceVim-api-system|
|
12. sid...........................................|SpaceVim-api-vim-sid|
|
||||||
13. time.............................................|SpaceVim-api-time|
|
13. system.........................................|SpaceVim-api-system|
|
||||||
14. unicode#box...............................|SpaceVim-api-unicode-box|
|
14. time.............................................|SpaceVim-api-time|
|
||||||
15. vim#buffer.................................|SpaceVim-api-vim-buffer|
|
15. unicode#box...............................|SpaceVim-api-unicode-box|
|
||||||
16. vim#command...............................|SpaceVim-api-vim-command|
|
16. vim#buffer.................................|SpaceVim-api-vim-buffer|
|
||||||
17. vim#compatible.........................|SpaceVim-api-vim-compatible|
|
17. vim#command...............................|SpaceVim-api-vim-command|
|
||||||
18. vim#message...............................|SpaceVim-api-vim-message|
|
18. vim#compatible.........................|SpaceVim-api-vim-compatible|
|
||||||
19. vim#window.................................|SpaceVim-api-vim-window|
|
19. vim#message...............................|SpaceVim-api-vim-message|
|
||||||
|
20. vim#window.................................|SpaceVim-api-vim-window|
|
||||||
10. Development...............................................|SpaceVim-dev|
|
10. Development...............................................|SpaceVim-dev|
|
||||||
1. commit-style-guide..................|SpaceVim-dev-commit-style-guide|
|
1. commit-style-guide..................|SpaceVim-dev-commit-style-guide|
|
||||||
11. FAQ.......................................................|SpaceVim-faq|
|
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
|
{silent} is a Boolean. by default it is false, and log will be print to
|
||||||
screen.
|
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*
|
PASSWORD *SpaceVim-api-password*
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user