Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions autoload/floaterm.vim
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,30 @@ function! floaterm#toggle(bang, bufnr, name) abort
endif
endfunction

" ----------------------------------------------------------------------------
" toggle fullscreen on/off the floaterm
" ----------------------------------------------------------------------------
function! floaterm#toggle_fullscreen() abort
let bufnr = bufnr('%')
call floaterm#update({'fullscreen': !getbufvar(bufnr, 'floaterm_fullscreen', v:false)})
endfunction

" ----------------------------------------------------------------------------
" toggle border on/off the floaterm
" ----------------------------------------------------------------------------
function! floaterm#toggle_border() abort
let bufnr = bufnr('%')
call floaterm#update({'show_border': !getbufvar(bufnr, 'floaterm_show_border', v:false)})
endfunction

" ----------------------------------------------------------------------------
" toggle title on/off the floaterm
" ----------------------------------------------------------------------------
function! floaterm#toggle_title() abort
let bufnr = bufnr('%')
call floaterm#update({'show_title': !getbufvar(bufnr, 'floaterm_show_title', v:false)})
endfunction

" ----------------------------------------------------------------------------
" update the attributes of a floaterm
" ----------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions autoload/floaterm/config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ function! floaterm#config#parse(bufnr, config) abort
let a:config.autoclose = get(a:config, 'autoclose', g:floaterm_autoclose)
let a:config.borderchars = get(a:config, 'borderchars', g:floaterm_borderchars)
let a:config.titleposition = get(a:config, 'titleposition', g:floaterm_titleposition)
let a:config.padding = get(a:config, 'padding', g:floaterm_padding)
let a:config.fullscreen = get(a:config, 'fullscreen', g:floaterm_fullscreen)
let a:config.show_border = get(a:config, 'show_border', g:floaterm_show_border)
let a:config.show_title = get(a:config, 'show_title', g:floaterm_show_title)

" Edge cases
if type(a:config.height) == v:t_number && a:config.height < 3
Expand Down
38 changes: 29 additions & 9 deletions autoload/floaterm/window.vim
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,39 @@ function! s:open_popup(bufnr, config) abort
if a:config.titleposition != 'left'
let title = floaterm#buffer#create_top_border(a:config, a:config.width)
endif
let fullscreen = has_key(a:config, 'fullscreen') ? a:config.fullscreen : v:false
if fullscreen
let col = 0
let line = 0
let width = &columns
let height = &lines - &cmdheight
else
let col = a:config.col
let line = a:config.row
let width = a:config.width
let height = a:config.height
endif
let show_border = has_key(a:config, 'show_border') ? a:config.show_border : v:true
if show_border
let width -= 2 + a:config.padding[1] + a:config.padding[3]
let height -= 2 + a:config.padding[0] + a:config.padding[2]
endif
let show_title = (has_key(a:config, 'show_title') ?
\ (a:config.show_title == 'with-border' ?
\ show_border : a:config.show_title) : v:true) || show_border
let options = {
\ 'pos': a:config.anchor,
\ 'line': a:config.row,
\ 'col': a:config.col,
\ 'maxwidth': a:config.width - 2,
\ 'minwidth': a:config.width - 2,
\ 'maxheight': a:config.height - 2,
\ 'minheight': a:config.height - 2,
\ 'title': title,
\ 'border': [1, 1, 1, 1],
\ 'line': line,
\ 'col': col,
\ 'maxwidth': width,
\ 'minwidth': width,
\ 'maxheight': height,
\ 'minheight': height,
\ 'title': show_title ? title : '',
\ 'border': show_border ? [1, 1, 1, 1] : show_title ? [ 1, 0, 0, 0 ] : [0, 0, 0, 0],
\ 'borderchars': a:config.borderchars,
\ 'borderhighlight': ['FloatermBorder'],
\ 'padding': [0,1,0,1],
\ 'padding': show_border ? [0, 1, 0, 1] : [0, 0, 0, 0],
\ 'highlight': 'Floaterm',
\ 'zindex': len(floaterm#buflist#gather()) + 1
\ }
Expand Down
8 changes: 8 additions & 0 deletions plugin/floaterm.vim
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ let g:floaterm_rootmarkers = get(g:, 'floaterm_rootmarkers', ['.project', '
let g:floaterm_opener = get(g:, 'floaterm_opener', 'split')
let g:floaterm_giteditor = get(g:, 'floaterm_giteditor', v:true)
let g:floaterm_titleposition = get(g:, 'floaterm_titleposition', 'left')
let g:floaterm_padding = get(g:, 'floaterm_padding', [0, 1, 0, 1])
let g:floaterm_fullscreen = get(g:, 'floaterm_fullscreen', v:false)
let g:floaterm_show_border = get(g:, 'floaterm_show_border', v:true)
let g:floaterm_show_title = get(g:, 'floaterm_show_title', 'with-border')


command! -nargs=* -complete=customlist,floaterm#cmdline#complete -bang -range
Expand All @@ -48,6 +52,10 @@ command! -nargs=0 FloatermNext call floaterm#next()
command! -nargs=0 FloatermFirst call floaterm#first()
command! -nargs=0 FloatermLast call floaterm#last()

command! -nargs=0 FloatermToggleFullScreen call floaterm#toggle_fullscreen()
command! -nargs=0 FloatermToggleBorder call floaterm#toggle_border()
command! -nargs=0 FloatermToggleTitle call floaterm#toggle_title()

hi def link Floaterm Normal
hi def link FloatermNC NormalNC
hi def link FloatermBorder NormalFloat
Expand Down