This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efm2.
View the commit online.
commit 029998f6c874eb4b1ea431360fb208d7e3282c2b
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Wed Oct 4 12:55:01 2023 +0100
flesh and comment out bash table fs
---
src/backends/table/open | 165 +++++++++++++++++++++++++++++++++++-------------
1 file changed, 121 insertions(+), 44 deletions(-)
diff --git a/src/backends/table/open b/src/backends/table/open
index e1e2ef6..1182a67 100755
--- a/src/backends/table/open
+++ b/src/backends/table/open
@@ -1,25 +1,42 @@
#!/bin/bash
-# global state
+##############################################################################
+# Global state for this backend everything needs access to
+##############################################################################
DIR=""
-function err() {
- >&2 echo $@
+##############################################################################
+# Helper functions useful for everyone
+##############################################################################
+
+# Print an error string to stderr
+# e.g. e_err "This is an error"
+function e_err() {
+ >&2 echo "$@"
}
-function val_unescape() {
+# take escaped str 2nd arg and produce non-escaped str in 1st arg var
+# like "boop%5f%5f%3d%3d%4073x" -> "boop__==@73x"
+# e.g. e_val_unescape VAR "boop%5f%5f%3d%3d%4073x"
+# echo $VAR
+# boop__==@73x
+function e_val_unescape() {
local -n V=$1
read <<< ${2}
V=$( echo -e ${REPLY//%/\\x} );
}
-function val_escape() {
+# take normal str 2nd arg and produce escaped str in 1st arg var
+# like "boop__==@73x" -> "boop%5f%5f%3d%3d%4073x"
+# e.g. e_val_unescape VAR "boop__==@73x"
+# echo $VAR
+# boop%5f%5f%3d%3d%4073x
+function e_val_escape() {
local -n V=$1
local STR=${2}
local STRLEN=${#STR}
local NEWSTR=""
local I CHR OUT
-
for (( I=0; I<$STRLEN; I++ )); do
CHR=${STR:$I:1}
case "$CHR" in
@@ -31,7 +48,11 @@ function val_escape() {
V=${NEWSTR}
}
-function line_read() {
+# read a line on stdin - check it starts with CMD if there reutrn 0 (success)
+# and if it's not, return an error (non-zero). line is broken into an array
+# delimted by spaces so it'll be: (command, arg1=x, arg2=y, arg3=z) for
+# example.
+function e_line_read() {
local -n V=${1}
local PIFS="$IFS"
IFS=" "
@@ -42,60 +63,116 @@ function line_read() {
return 0
}
+# produce proper command line back to efm - all command sstart with "CMD "
+function e_cmd() {
+ echo "CMD $@"
+}
+
+# loop forever handling input cmd son stdin from efm
+function e_loop() {
+ local CMD ARGS ARGSLEN NEWARGS PIFS KEY VAL
+ while [ 1 ]; do
+ if e_line_read LINE; then
+ CMD=${LINE[1]}
+ ARGS=("${LINE[@]:2}")
+ ARGSLEN=${#LINE[@]}
+ NEWARGS=()
+ for (( I=0; I<$ARGSLEN; I++ )); do
+ PIFS="$IFS"; IFS="="
+ read -a A <<< ${ARGS[$I]}
+ IFS="$PIFS"
+ KEY=${A[0]}
+ e_val_unescape VAL ${A[1]}
+ NEWARGS+=(${KEY})
+ NEWARGS+=(${VAL})
+ done
+ handle_cmd NEWARGS "$CMD"
+ fi
+ done
+}
+
+##############################################################################
+# FS backend code specific to this backend
+##############################################################################
+
function handle_cmd_dir_set() {
- echo "CMD viewmode-set mode=list_detailed"
- echo "CMD detail-header-set col=0 label=nomnom"
- echo "CMD detail-header-set col=1 label=h-one"
- echo "CMD detail-header-set col=2 label=h-two"
- echo "CMD detail-header-set col=3 label=h-three"
- echo "CMD detail-header-set col=4 label=h-four"
- echo "CMD detail-header-set col=5 label=h-five"
- echo "CMD detail-header-set col=6 label=h-six"
- echo "CMD list-begin"
+ local F M D
+# force detailed view mode
+ e_cmd "viewmode-set mode=list_detailed"
+# explicitly set column header strings
+ e_cmd "detail-header-set col=0 label=nomnom"
+ e_cmd "detail-header-set col=1 label=h-one"
+ e_cmd "detail-header-set col=2 label=h-two"
+ e_cmd "detail-header-set col=3 label=h-three"
+ e_cmd "detail-header-set col=4 label=h-four"
+ e_cmd "detail-header-set col=5 label=h-five"
+ e_cmd "detail-header-set col=6 label=h-six"
+
+# begin initial listing of files
+ e_cmd "list-begin"
+# define some params we're going to use
D="detail-format=text,text,text,text,timestamp,size detail1=one detail2=two detail3=three detail4=four"
- val_escape F ${DIR}"abba"
- val_escape M ${DIR}"ic.jpg"
+# an icon image to use
+ e_val_escape M ${DIR}"ic.jpg"
M="type=file icon="${M}
- echo "CMD file-add path="${F}" "${M}" "${D}" detail5=0 detail6=576/65536"
- val_escape F ${DIR}"boopy__==!@#$%^&*();"
- echo "CMD file-add path="${F}" "${M}" "${D}" detail5=1696332215 detail6=16384/65536"
- val_escape F ${DIR}"g h i"
- echo "CMD file-add path="${F}" "${M}" "${D}" detail5=1696322215 detail6=65535/65536"
- val_escape F ${DIR}"z~"
- echo "CMD file-add path="${F}" "${M}" "${D}" detail5=1296332215 detail6=7823/65536"
- echo "CMD list-end"
+# add one new file (4 of them) with params
+ e_val_escape F ${DIR}"abba"
+ e_cmd "file-add path="${F}" "${M}" "${D}" detail5=0 detail6=576/65536"
+ e_val_escape F ${DIR}"boopy__==!@#$%^&*();"
+ e_cmd "file-add path="${F}" "${M}" "${D}" detail5=1696332215 detail6=16384/65536"
+ e_val_escape F ${DIR}"g h i"
+ e_cmd "file-add path="${F}" "${M}" "${D}" detail5=1696322215 detail6=65535/65536"
+ e_val_escape F ${DIR}"z~"
+ e_cmd "file-add path="${F}" "${M}" "${D}" detail5=1296332215 detail6=7823/65536"
+# end initial listing of files
+ e_cmd "list-end"
}
+##############################################################################
+# This function must be provided by fs backend given above shared e_ script
+##############################################################################
function handle_cmd() {
local -n ARGS=${1}
local ARGSLEN=${#ARGS[@]}
+ local CMD
CMD=${2}
case "$CMD" in
+ # handle command to set the dir to scan/look at
dir-set )
if [ ${ARGS[0]} = "path" ]; then
DIR=${ARGS[1]}
handle_cmd_dir_set ${DIR}
fi
;;
+ # commands this fs doesn;'t handle (yet?)
+ meta-set )
+ ;;
+ cnp-cut )
+ ;;
+ cnp-copy )
+ ;;
+ cnp-paste )
+ ;;
+ dnd-drag-begin )
+ ;;
+ dnd-drag-end )
+ ;;
+ dnd-drop )
+ ;;
+ dnd-hover )
+ ;;
+ file-run )
+ ;;
+ file-clicked )
+ ;;
+ file-selected )
+ ;;
+ file-unselected )
+ ;;
+ file-delete )
+ ;;
esac
}
# loop parsing input lines
-while [ 1 ]; do
- if line_read LINE; then
- CMD=${LINE[1]}
- ARGS=("${LINE[@]:2}")
- ARGSLEN=${#LINE[@]}
- NEWARGS=()
- for (( I=0; I<$ARGSLEN; I++ )); do
- PIFS="$IFS"; IFS="="
- read -a A <<< ${ARGS[$I]}
- IFS="$PIFS"
- KEY=${A[0]}
- val_unescape VAL ${A[1]}
- NEWARGS+=(${KEY})
- NEWARGS+=(${VAL})
- done
- handle_cmd NEWARGS "$CMD"
- fi
-done
+e_loop
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.