git://git.nikiroo.be
/
gofetch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0eb21b2
)
gopher.sh: use same colours as lynx for menu
author
Niki Roo
<niki@nikiroo.be>
Sun, 1 Apr 2018 10:53:31 +0000
(12:53 +0200)
committer
Niki Roo
<niki@nikiroo.be>
Sun, 1 Apr 2018 10:53:31 +0000
(12:53 +0200)
gopher.sh
patch
|
blob
|
blame
|
history
diff --git
a/gopher.sh
b/gopher.sh
index f91be7a8c6f27fa1a30be4086280f1fab2a0538b..93715fca3de805898818f472c72df10af51e81a2 100755
(executable)
--- a/
gopher.sh
+++ b/
gopher.sh
@@
-18,7
+18,18
@@
if [ "$SERVER" = "" ]; then
exit 2
fi
exit 2
fi
+LINK_COLOR=2 # can be empty for no escape sequences
+
+# Start and end link tags
+SL=
+EL=
+if [ "$LINK_COLOR" != "" ]; then
+ SL="`tput setf $LINK_COLOR``tput setaf $LINK_COLOR`"
+ EL="`tput init`";
+fi
+
# $0 [FILE]
# $0 [FILE]
+# Display a gopher menu for the given resource
cat_menu() {
i=0
cat "$1" | grep '^[i0-9]' | while read ln; do
cat_menu() {
i=0
cat "$1" | grep '^[i0-9]' | while read ln; do
@@
-32,29
+43,20
@@
cat_menu() {
case "$field" in
0) typ='TXT';;
1) typ='DIR';;
case "$field" in
0) typ='TXT';;
1) typ='DIR';;
- 7) typ='
SRH
';;
+ 7) typ='
(?)
';;
8) typ='TEL';;
8) typ='TEL';;
- *) typ='
???
';;
+ *) typ='
!!!
';;
esac
esac
- echo "$ln" | sed "s:^.
:$typ $i
:g"
+ echo "$ln" | sed "s:^.
\\(.*\\):$typ $i $SL\\1$EL
:g"
#else
# Bad line
fi
done
}
#else
# Bad line
fi
done
}
-# $0 [FILE]
-choices() {
- i=0
- cat "$1" | grep '^[0-9]' | while read choice; do
- i=`expr $i + 1`
- i=`printf %2.f $i`
-
- echo "$i --> $choice"
- done
-}
-
# $0 [FILE] [INDEX] [FIELD]
# $0 [FILE] [INDEX] [FIELD]
+# Get a field from the given-by-index link in FILE
+#
# Fields:
# 1 = type/name
# 2 = selector
# Fields:
# 1 = type/name
# 2 = selector