Skip to content

convert files (images for example) and output to vim as colored ascii chars

Notifications You must be signed in to change notification settings

ZSaberLv0/ZFVimAsciiPlayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

convert files (images for example) and output to vim as colored ascii chars

it's designed extensible, with some hacks, you may use it as video player, canvas drawer, or even game player

if you like my work, check here for a list of my vim plugins, or buy me a coffee

Install

use vim-plug or any other plugin manager you like to install

Plug 'ZSaberLv0/ZFVimAsciiPlayer'

this repo only holds basic API, you must also install extensions to support actual file types:

  • Plug 'ZSaberLv0/ZFVimAsciiPlayer_image' : image/gif viewer

    • you need python and pip install img2txt.py to make this extension to work, see ZFVimAsciiPlayer_image for detail

Usage

simply open a supported file

Extensions

see ZFVimAsciiPlayer_image for example

to write extensions:

  1. supply impl functions:

    " params: {
    "   'file' : 'file to open',
    "   'maxWidth' : 'max width (char count)',
    "   'maxHeight' : 'max height (char count)',
    "   'heightScale' : 'height scale to suit terminal char size',
    " }
    " return state: { // return empty for error
    "   'fps' : '-1 to use global g:ZFAsciiPlayer_fps',
    "   'totalFrame' : 'total frame count, -1 for infinite',
    "   ... // extra impl state
    " }
    function! MyExt_converterInit(params)
    endfunction
    
    " return frame data: {
    "   'time' : 'frame time, 0 to use global fps',
    "   'lines' : [],
    "   'hlCmds' : [
    "     {
    "       'group' : '',
    "       'iLine' : 'start from 1',
    "       'pos' : '',
    "       'len' : '',
    "     },
    "     ...
    "   ],
    " }
    function! MyExt_converterFrame(state, frame)
    endfunction
    
  2. register the impl functions:

    if !exists('g:ZFAsciiPlayer_converters')
        let g:ZFAsciiPlayer_converters = {}
    endif
    " register by file extension (must be lowercase)
    let g:ZFAsciiPlayer_converters['my_ext'] = {
            \   'init' : function('MyExt_converterInit'),
            \   'frame' : function('MyExt_converterFrame'),
            \ }
    
  3. now try to open *.my_ext files

About

convert files (images for example) and output to vim as colored ascii chars

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published