commit a60d13d524fc9eeb6edb6fd134150e69e8f12adb
parent f2eecab98bea02ff248e97d1e7bb8ca1aba070f7
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Mon, 11 Oct 2021 10:34:38 +0000
add history to handler
Diffstat:
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/bin/rc/Handler b/bin/rc/Handler
@@ -1,7 +1,12 @@
#!/bin/rc
+rfork
+
rroot=/mnt/richterm
+history=`{pwd}
+forward=()
+
fn clear {
echo clear > $rroot/ctl
}
@@ -14,23 +19,31 @@ fn _exit {
fn ldir {
cd $1
+ history = (`{pwd} $history)
+ forward = ()
clear
- echo ' '^`{pwd}
- echo
Dir
}
fn lmarkdown {
fname=`{basename $1}
cd `{basename -d $1}
+ history = (`{pwd}^/$fname $history)
+ forward = ()
clear
- echo ' '^`{pwd}^/$fname
- echo
Markdown $fname
}
fn menu {
switch ($1) {
+ case 'Back';
+ if (test $#history '!=' 1) {
+ newforward = ($history(1) $forward)
+ link = $history(2)
+ history = $history(3-)
+ link $link
+ forward = $newforward
+ }
case 'Exit'; _exit
}
}
@@ -41,7 +54,7 @@ fn link {
case *.md; lmarkdown $1
case *.html
md=`{echo $1|sed 's/\.html/\.md/'}
- if (test -r $md) lmarkdown $md
+ if (test -r $md) lmarkdown $md
if not echo 'can''t open file' $1
case *
if (test -d $1) ldir $1
@@ -49,18 +62,15 @@ fn link {
}
}
-rfork
-
bind -a bin/$cputype /bin
cat > $rroot/menu <<EOF
----
+Back
Exit
EOF
clear
-echo ' '^`{pwd}
-echo
Dir
event=''