Skip to content

Taking Screenshots

Roger Bongers edited this page Sep 1, 2023 · 2 revisions

All screenshots are listed in README.

To take screenshots like the ones in the README, use the below .vimrc.

Requirements:

Instructions:

  • Load the .vimrc below
  • Run gvim
  • Run :PlugInstall
  • Run :call TakeScreenshots()
  • Adjust the .vimrc on failure

Screenshots are saved to $HOME/crystalline_<theme>.png.

" Statusline

let g:mode = 'n'
function! g:CrystallineStatuslineFn(winnr)
  let l:mode = g:crystalline_mode_hi_groups[g:mode]
  return crystalline#HiItem(l:mode . 'A') . g:crystalline_mode_labels[g:mode] . crystalline#Sep(0, l:mode . 'A', l:mode . 'B')
        \ . ' [No Name] ' . crystalline#Sep(0, l:mode . 'B', l:mode . 'Fill')
        \ . ' %='
        \ . crystalline#Sep(1, l:mode . 'Fill', l:mode . 'B') . ' '
        \ . crystalline#Sep(1, l:mode . 'B', l:mode . 'A') . ' [utf-8][unix] 0/1 0-1 All '
endfunction

" Options

set laststatus=2
set showtabline=0
set guicursor=a:xxx
set guifont=Iosevka\ Term\ SS01\ Extended\ 13
set guioptions=
set titlestring=CRYSTALLINE_SCREENSHOTS
let g:crystalline_separators = [
      \ { 'ch': '', 'alt_ch': ' ', 'dir': '>' },
      \ { 'ch': '', 'alt_ch': ' ', 'dir': '<' },
      \ ]

" Plugins

call plug#begin()
Plug 'rbong/vim-crystalline'
Plug 'luxed/ayu-vim'
Plug 'sjl/badwolf'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'gruvbox-community/gruvbox'
Plug 'w0ng/vim-hybrid'
Plug 'cocopon/iceberg.vim'
Plug 'nanotech/jellybeans.vim'
Plug 'tomasr/molokai'
Plug 'nordtheme/vim', { 'as': 'nordtheme' }
Plug 'joshdick/onedark.vim'
Plug 'sonph/onehalf', { 'rtp': 'vim/' }
Plug 'NLKNguyen/papercolor-theme'
Plug 'Rigellute/shades-of-purple.vim'
Plug 'altercation/vim-colors-solarized'
call plug#end()

" Functions

function! System(cmd) abort
  let l:result = system(a:cmd)
  if v:shell_error != 0
    echoerr l:result
    throw 'shell error: ' . v:shell_error
  endif
  return l:result
endfunction

function! SetStatusline(mode, theme, ...) abort
  let g:mode = a:mode
  exec 'set background=' . get(a:, 1, 'dark')

  if a:theme ==# 'papercolor'
    colorscheme PaperColor
  elseif a:theme ==# 'shadesofpurple'
    colorscheme shades_of_purple
  elseif a:theme ==# 'default'
    colorscheme elflord
  else
    exec 'colorscheme ' . a:theme
  endif

  call crystalline#SetTheme(a:theme)
endfunction

function! TakeThemeScreenshots(theme, ...) abort
  let l:bg = get(a:, 1, 'dark')
  let l:name = $HOME . '/crystalline_' . a:theme
  if has_key(a:, 1) && a:theme !~# '\(dark\|light\)$'
    let l:name .= '_' . l:bg
  endif

  for l:mode in ['n', 'i', 'v']
    call SetStatusline(l:mode, a:theme, l:bg)
    redraw!

    " This will change based on window borders, adjust for your system
    let l:x = 22
    let l:y = 44

    " Take screenshot
    call System('shotgun -g 822x24+' . l:x . '+' . l:y . ' "' . l:name . '_' . l:mode . '.png"')
  endfor

  let l:files = '"' . l:name . '_n.png" "' . l:name . '_i.png" "' . l:name . '_v.png"'
  call System('convert ' . l:files . ' -append "' . l:name . '.png"')
  call System('rm ' . l:files)
endfunction

function! TakeScreenshots() abort
  " Set window position and size
  set lines=3
  set columns=82
  call System('xdotool search --name CRYSTALLINE_SCREENSHOTS windowmove 20 20')
  redraw!

  call TakeThemeScreenshots('ayu', 'dark')
  call TakeThemeScreenshots('ayu', 'light')
  call TakeThemeScreenshots('badwolf')
  call TakeThemeScreenshots('default')
  call TakeThemeScreenshots('dracula')
  call TakeThemeScreenshots('gruvbox', 'dark')
  call TakeThemeScreenshots('gruvbox', 'light')
  call TakeThemeScreenshots('hybrid', 'dark')
  call TakeThemeScreenshots('hybrid', 'light')
  call TakeThemeScreenshots('iceberg', 'dark')
  call TakeThemeScreenshots('iceberg', 'light')
  call TakeThemeScreenshots('jellybeans')
  call TakeThemeScreenshots('molokai')
  call TakeThemeScreenshots('nord')
  call TakeThemeScreenshots('onedark')
  call TakeThemeScreenshots('onehalfdark', 'dark')
  call TakeThemeScreenshots('onehalflight', 'light')
  call TakeThemeScreenshots('papercolor', 'light')
  call TakeThemeScreenshots('shadesofpurple')
  call TakeThemeScreenshots('solarized', 'dark')
  call TakeThemeScreenshots('solarized', 'light')
endfunction
Clone this wiki locally