vtv-player: add -r option and manpage. - vtv-tools - virtual terminal video tools
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 316ac104daa62edf5d30bf8c8ee8729d29a305c0
 (DIR) parent 02e71d857c5dc511e66c79877d77658e379243ab
 (HTM) Author: Troels Henriksen <athas@sigkill.dk>
       Date:   Tue, 15 Aug 2023 00:28:22 +0200
       
       vtv-player: add -r option and manpage.
       
       Diffstat:
         M bin/vtv-player                      |      20 ++++++++++++--------
         A man/vtv-player.1                    |      36 +++++++++++++++++++++++++++++++
       
       2 files changed, 48 insertions(+), 8 deletions(-)
       ---
 (DIR) diff --git a/bin/vtv-player b/bin/vtv-player
       @@ -8,25 +8,29 @@
        
        trap 'clear; tput cvvis; exit 0' SIGINT
        
       +fps=20
        
       -if [ $# -lt 1 ];
       -then
       -    echo "Usage: $0 ADDIR" >&2
       +if [ "$1" = "-r" ]; then
       +    fps=$2
       +    shift; shift;
       +fi
       +
       +if [ $# -ne 1 ]; then
       +    echo "Usage: $0 FILE" >&2
            exit 1
       -    year="$(date +%Y)"
        fi
        
       -adfile="$1"
       -frametime=0.05
       +vtv="$1"
       +frametime=$(echo "scale =2; 1 / $fps" | bc)
        framelines=25
        
        tput civis
        clear
        i=0
       -nframes=$(echo "$(wc -l < "${adfile}")" / "$framelines" | bc)
       +nframes=$(echo "$(wc -l < "${vtv}")" / "$framelines" | bc)
        while true; do
            tput cup 0 0
       -    tail -n +$(echo "(1+${i} % ${nframes} * ${framelines})" | bc) "$adfile" | head -n $framelines
       +    tail -n +$(echo "(1+${i} % ${nframes} * ${framelines})" | bc) "$vtv" | head -n $framelines
            i=$(($i + 1))
        
            userinput=""
 (DIR) diff --git a/man/vtv-player.1 b/man/vtv-player.1
       @@ -0,0 +1,36 @@
       +.Dd August 14, 2023
       +.Dt VTV-PLAYER 1
       +.OS
       +.
       +.sh NAME
       +.Nm vtv-player
       +.Nd Play vtv files in console.
       +.
       +.Sh SYNOPSIS
       +.Nm
       +.Bk
       +.Op Fl r Ar fps
       +.Ar FILE
       +.Ek
       +.
       +.Sh DESCRIPTION
       +.Bd -filled
       +.Nm
       +plays a VTV file in the terminal.
       +.
       +.Sh OPTIONS
       +.Bl -tag -width Ds
       +.It Fl r Ar fps
       +Show this many frames per second.  Defaults to 20.
       +.El
       +.
       +.Sh FORMAT
       +.Bd -filled
       +A VTV file consists of frames in sequence.  A frame consists of 25
       +lines, each terminated by a newline character.  This means the number
       +of lines in a file must be divisible by 25.  A line can contain
       +arbitrary terminal control codes (or just plain text).  Playing a VTV
       +file is done by printing the frames to the console.
       +.
       +.Sh LICENSE
       +The vtv-tools are released under the GPLv3 or later.