richterm

"terminal emulator" with support for text fonts and images for plan9
git clone git://nsmpr.xyz/richterm.git
Log | Files | Refs | README

commit 1c17e535202a9ecacf402bf9a9265cb39ee41730
parent ff388fb3498387b4f6ecb7b4f1a71d3bb876d03a
Author: Pavel Renev <an2qzavok@gmail.com>
Date:   Sun,  5 Sep 2021 21:15:46 +0000

add simple link/menu handler based on Dir

Diffstat:
Abin/rc/Handler | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+), 0 deletions(-)

diff --git a/bin/rc/Handler b/bin/rc/Handler @@ -0,0 +1,51 @@ +#!/bin/rc + +rroot=/mnt/richterm + +fn clear { + echo clear > $rroot/ctl +} + +fn _exit { + clear + echo -n > $rroot/menu + exit +} + +fn menu { + switch ($1) { + case 'Exit'; _exit + } +} + +fn link { + f=`{file $1} + if (~ $f(2) 'directory') {cd $1; clear; Dir} + if not plumb $1 +} + +rfork + + +bind -a bin/$cputype /bin + +cat > $rroot/menu <<EOF +---- +Exit +EOF + +clear + +Dir + +event='' + +while ( { event=`{read $rroot/ctl} } ) { + if (test -z $"event) exit + type=$event(1) + action=$event(2) + switch($type) { + case 'menu'; menu $action + case 'link'; link $action + } +}