From 17fd1c4dc245ac614b4ab7a47d255aad3d3afd23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A4=20=CE=99=20=CE=9B=20=CF=9F=20=CE=97?= Date: Sun, 24 Jul 2022 15:10:26 +0600 Subject: [PATCH] prep for external editor app support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit usages: > acc -c|-l|-r app todo: - proper ACTION_VIEW support for log/md files - update string in language files Signed-off-by: Τ Ι Λ ϟ Η --- install/acc.sh | 19 +++++++++++++++++-- install/strings.sh | 13 +++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/install/acc.sh b/install/acc.sh index 6f57224..8908d85 100644 --- a/install/acc.sh +++ b/install/acc.sh @@ -97,6 +97,16 @@ daemon_ctrl() { edit() { + ext_app() { + case $1 in + e) ACT=EDIT; print_ext_app e ;; + v) ACT=VIEW; print_ext_app v ;; + esac + sleep 2.5 + am start -a android.intent.action.$ACT \ + -t 'text/plain' \ + -d file://$2 &>/dev/null + } local file="$1" shift if [ -n "${1-}" ]; then @@ -106,6 +116,9 @@ edit() { echo "$@" >> $file elif [ "$1" = d ]; then sed -Ei "\#$2#d" $file + elif [ "$1" = app ]; then + shift + ext_app e $file else IFS="$(printf ' \t\n')" eval "$* $file" fi @@ -115,8 +128,10 @@ edit() { *.txt) if which nano > /dev/null; then print_quit CTRL-X - else + elif which vim vi > /dev/null; then print_quit "[esc] :q! [enter]" "[esc] :wq [enter]" + else + print_ext_app e fi ;; *.log|*.md|*.help) @@ -128,7 +143,7 @@ edit() { } case $file in *.log|*.md|*.help) less $file;; - *) nano -$ $file || vim $file || vi $file;; + *) nano -$ $file || vim $file || vi $file || ext_app e $file ;; esac 2>/dev/null fi } diff --git a/install/strings.sh b/install/strings.sh index cd783a4..118e4b0 100644 --- a/install/strings.sh +++ b/install/strings.sh @@ -76,6 +76,19 @@ print_not_found() { echo "$1 not found" } +print_ext_app() { + case $1 in + e) act=editor ;; + v) act=viewer ;; + esac + cat << EOF + Opening external text $act app choosing + dialog and select any root-compatible + text $act app. +  + e.g., MiXplorer, QuickEdit, etc. +EOF +} print_help() { cat << EOF