Skip to content

Commit

Permalink
new: textbox/listbox/preview add a new option: bordercolor
Browse files Browse the repository at this point in the history
  • Loading branch information
skywind3000 committed Feb 14, 2020
1 parent 0e339a8 commit 181d28d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 14 deletions.
15 changes: 11 additions & 4 deletions autoload/quickui/listbox.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
" listbox.vim -
"
" Created by skywind on 2019/12/20
" Last Modified: 2020/02/13 16:26
" Last Modified: 2020/02/14 21:06
"
"======================================================================

Expand Down Expand Up @@ -194,9 +194,11 @@ function! s:vim_create_listbox(textlist, opts)
let opts.borderchars = quickui#core#border_vim(border)
let opts.border = [1,1,1,1,1,1,1,1,1]
endif
let opts.title = has_key(a:opts, 'title')? ' ' . a:opts.title . ' ' : ''
if has_key(a:opts, 'title') && (a:opts.title != '')
let opts.title = ' ' . a:opts.title . ' '
endif
let opts.padding = [0,1,0,1]
if has_key(a:opts, 'close')
if has_key(a:opts, 'close') && (a:opts.close != '')
let opts.close = a:opts.close
endif
let local = quickui#core#popup_local(winid)
Expand All @@ -217,6 +219,10 @@ function! s:vim_create_listbox(textlist, opts)
let hwnd.state = 1
let hwnd.code = 0
let hwnd.tag = ''
if has_key(hwnd.opts, 'bordercolor')
let c = hwnd.opts.bordercolor
let opts.borderhighlight = [c, c, c, c]
endif
call popup_setoptions(winid, opts)
call win_execute(winid, 'syn clear')
if has_key(a:opts, 'syntax')
Expand Down Expand Up @@ -514,8 +520,9 @@ function! s:nvim_create_listbox(textlist, opts)
let op.height = h + 2
let op.row = opts.row - 1
let op.col = opts.col - 1
let bordercolor = get(a:opts, 'bordercolor', color)
let background = nvim_open_win(nbid, 0, op)
call nvim_win_set_option(background, 'winhl', 'Normal:'. color)
call nvim_win_set_option(background, 'winhl', 'Normal:'. bordercolor)
endif
let hwnd.winid = winid
call nvim_win_set_option(winid, 'winhl', 'Normal:'. color)
Expand Down
20 changes: 17 additions & 3 deletions autoload/quickui/preview.vim
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ function! quickui#preview#display(content, opts)
let source = a:content
endif
let winid = -1
let title = has_key(a:opts, 'title')? (' ' . a:opts.title .' ') : ''
let title = ''
if has_key(a:opts, 'title') && (a:opts.title != '')
let title = ' ' . a:opts.title .' '
endif
let w = get(a:opts, 'w', -1)
let h = get(a:opts, 'h', -1)
let w = (w < 0)? 50 : w
Expand All @@ -82,7 +85,7 @@ function! quickui#preview#display(content, opts)
let winid = popup_create(source, {'wrap':1, 'mapping':0, 'hidden':1})
let opts = {'maxwidth':w, 'maxheight':h, 'minwidth':w, 'minheight':h}
call popup_move(winid, opts)
let opts = {'close':'button', 'title':title}
let opts = {'close':'button'}
let opts.border = border? [1,1,1,1,1,1,1,1,1] : repeat([0], 9)
let opts.resize = 0
let opts.highlight = color
Expand All @@ -93,8 +96,15 @@ function! quickui#preview#display(content, opts)
let opts.drag = 1
let opts.line = p[0]
let opts.col = p[1]
if title != ''
let opts.title = title
endif
let opts.callback = function('s:popup_exit')
" let opts.fixed = 'true'
if has_key(a:opts, 'bordercolor')
let c = a:opts.bordercolor
let opts.borderhighlight = [c, c, c, c]
endif
call popup_setoptions(winid, opts)
let s:private.winid = winid
call popup_show(winid)
Expand Down Expand Up @@ -126,8 +136,9 @@ function! quickui#preview#display(content, opts)
let pos = nvim_win_get_config(winid)
let op.row = pos.row - 1
let op.col = pos.col - 1
let bordercolor = get(a:opts, 'bordercolor', color)
let background = nvim_open_win(nbid, 0, op)
call nvim_win_set_option(background, 'winhl', 'Normal:'. color)
call nvim_win_set_option(background, 'winhl', 'Normal:'. bordercolor)
let s:private.background = background
endif
endif
Expand Down Expand Up @@ -242,6 +253,9 @@ function! quickui#preview#open(content, opts)
else
let opts.title = 'Preview' .. ((title == '')? '' : (':' .. title))
endif
if g:quickui#style#preview_bordercolor != ''
let opts.bordercolor = g:quickui#style#preview_bordercolor
endif
let opts.persist = get(a:opts, 'persist', 0)
let opts.focusable = get(g:, 'quickui_preview_focusable', 1)
if has_key(a:opts, 'syntax')
Expand Down
2 changes: 1 addition & 1 deletion autoload/quickui/style.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ let g:quickui#style#tip_head = '[tip]'
let g:quickui#style#preview_w = 85
let g:quickui#style#preview_h = 10
let g:quickui#style#preview_number = 1

let g:quickui#style#preview_bordercolor = ''


23 changes: 17 additions & 6 deletions autoload/quickui/textbox.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
" textbox.vim -
"
" Created by skywind on 2019/12/27
" Last Modified: 2020/01/02 04:21
" Last Modified: 2020/02/14 21:06
"
"======================================================================

Expand Down Expand Up @@ -64,11 +64,16 @@ function! s:vim_create_textbox(textlist, opts)
endif
let opts = {'mapping':0, 'cursorline':0, 'drag':1}
let border = get(a:opts, 'border', 1)
let opts.borderchars = quickui#core#border_vim(border)
let opts.border = [1,1,1,1,1,1,1,1,1]
let opts.title = has_key(a:opts, 'title')? ' ' . a:opts.title . ' ' : ''
let opts.border = [0,0,0,0,0,0,0,0,0]
if border > 0
let opts.borderchars = quickui#core#border_vim(border)
let opts.border = [1,1,1,1,1,1,1,1,1]
let opts.close = 'button'
endif
let opts.padding = [0,1,0,1]
let opts.close = 'button'
if has_key(a:opts, 'title') && (a:opts.title != '')
let opts.title = ' '. a:opts.title . ' '
endif
let opts.filter = function('s:popup_filter')
let opts.callback = function('s:popup_exit')
let opts.resize = get(a:opts, 'resize', 0)
Expand Down Expand Up @@ -111,6 +116,10 @@ function! s:vim_create_textbox(textlist, opts)
if cursor < 0
call win_execute(winid, 'setlocal nocursorline')
endif
if has_key(a:opts, 'bordercolor')
let c = a:opts.bordercolor
let opts.borderhighlight = [c, c, c, c]
endif
call popup_setoptions(winid, opts)
call win_execute(winid, 'setlocal scrolloff=0')
if has_key(a:opts, 'command')
Expand Down Expand Up @@ -235,8 +244,9 @@ function! s:nvim_create_textbox(textlist, opts)
let pos = nvim_win_get_config(winid)
let op.row = pos.row - 1
let op.col = pos.col - 1
let bordercolor = get(a:opts, 'bordercolor', color)
let background = nvim_open_win(nbid, 0, op)
call nvim_win_set_option(background, 'winhl', 'Normal:'. color)
call nvim_win_set_option(background, 'winhl', 'Normal:'. bordercolor)
endif
let init = ['syn clear']
if has_key(a:opts, 'tabstop')
Expand Down Expand Up @@ -421,6 +431,7 @@ if 0
let opts.title = "title"
let opts.syntax = "cpp"
let opts.color = "QuickBox"
let opts.border = 0
" let opts.bordercolor = "QuickBG"
let opts.cursor = 38
let opts.number = 1
Expand Down

0 comments on commit 181d28d

Please sign in to comment.