improvement: attachment feature
This commit is contained in:
parent
c39c45a23a
commit
871a000cbd
@ -1,7 +1,8 @@
|
|||||||
BEGIN { FS="[:;]" }
|
BEGIN { FS="[:;]" }
|
||||||
/^END:VEVENT$/ { ins = 0; exit }
|
/^END:VEVENT$/ { ins = 0; exit }
|
||||||
/^[^ ]/ && a { a = 0 }
|
/^[^ ]/ && a { a = 0 }
|
||||||
/^ / && a { print substr($0, 2) }
|
/^ / && a && p { print substr($0, 2); }
|
||||||
|
/^ / && a && !p { if (index($0, ":")) { p = 1; print substr($0, index($0, ":")+1) } }
|
||||||
/^ATTACH/ && ins { i++; }
|
/^ATTACH/ && ins { i++; }
|
||||||
/^ATTACH/ && ins && i == id { a = 1; print substr($0, index($0, ":")+1) }
|
/^ATTACH/ && ins && i == id { a = 1; if (index($0, ":")) { p = 1; print substr($0, index($0, ":")+1) } }
|
||||||
/^BEGIN:VEVENT$/ { ins = 1 }
|
/^BEGIN:VEVENT$/ { ins = 1 }
|
||||||
|
@ -14,7 +14,6 @@ function cont_reading(str) {
|
|||||||
function att_info(i, str, cnt, k, info) {
|
function att_info(i, str, cnt, k, info) {
|
||||||
str = substr(str, 1, index(str, ":") - 1)
|
str = substr(str, 1, index(str, ":") - 1)
|
||||||
cnt = split(str, props)
|
cnt = split(str, props)
|
||||||
info = "Attachment "i":"
|
|
||||||
if (cnt > 1) {
|
if (cnt > 1) {
|
||||||
for (k=2; k<=cnt; k++) {
|
for (k=2; k<=cnt; k++) {
|
||||||
pname = substr(props[k], 1, index(props[k], "=") - 1)
|
pname = substr(props[k], 1, index(props[k], "=") - 1)
|
||||||
@ -28,12 +27,8 @@ function att_info(i, str, cnt, k, info) {
|
|||||||
if (pname == "FMTTYPE")
|
if (pname == "FMTTYPE")
|
||||||
type = pvalu
|
type = pvalu
|
||||||
}
|
}
|
||||||
if (fin)
|
|
||||||
info = info " \"" fin "\""
|
|
||||||
if (type)
|
|
||||||
info = info " " type
|
|
||||||
if (enc)
|
if (enc)
|
||||||
info = info " (inline)"
|
info = "inline"
|
||||||
}
|
}
|
||||||
print i, fin, type, enc, info
|
print i, fin, type, enc, info
|
||||||
}
|
}
|
||||||
|
39
src/main.sh
39
src/main.sh
@ -1255,36 +1255,41 @@ while true; do
|
|||||||
elif [ "$key" = "c" ] && [ -f "$ROOT/$fpath" ]; then
|
elif [ "$key" = "c" ] && [ -f "$ROOT/$fpath" ]; then
|
||||||
__tentative_toggle "$fpath"
|
__tentative_toggle "$fpath"
|
||||||
elif [ "$key" = "a" ] && [ -f "$ROOT/$fpath" ]; then
|
elif [ "$key" = "a" ] && [ -f "$ROOT/$fpath" ]; then
|
||||||
echo "GO" >>/tmp/foo
|
|
||||||
att=$(
|
att=$(
|
||||||
(
|
awk "$AWK_ATTACHLS" "$ROOT/$fpath" |
|
||||||
echo "1\t2\t3\t4\t5\t6"
|
|
||||||
awk "$AWK_ATTACHLS" "$ROOT/$fpath"
|
|
||||||
) |
|
|
||||||
$FZF \
|
$FZF \
|
||||||
--no-clear \
|
|
||||||
--delimiter="\t" \
|
--delimiter="\t" \
|
||||||
--accept-nth=1,2,3,4 \
|
--accept-nth=1,2,3,4 \
|
||||||
--with-nth=5 \
|
--with-nth="Attachment {1}: \"{2}\" {3} ({5})" \
|
||||||
--no-sort \
|
--no-sort \
|
||||||
--tac \
|
--tac \
|
||||||
--no-input \
|
|
||||||
--margin="30%,30%" \
|
--margin="30%,30%" \
|
||||||
--border=bold \
|
--border=bold \
|
||||||
--border-label='Attachment View Keys: <enter> open, <ctrl-alt-d> delete, <shift-a> add' \
|
--border-label="Attachment View Keys: <enter> open, <ctrl-alt-d> delete, <shift-a> add" \
|
||||||
--expect="ctrl-c,esc,q,backspace,ctrl-alt-d,A" \
|
--expect="A" \
|
||||||
|
--expect="ctrl-c,ctrl-g,ctrl-q,ctrl-d,esc,q,backspace" \
|
||||||
|
--print-query \
|
||||||
|
--bind="start:hide-input" \
|
||||||
|
--bind="ctrl-alt-d:show-input+change-query(ctrl-alt-d)+accept" \
|
||||||
|
--bind="load:transform:[ \"\$FZF_TOTAL_COUNT\" -eq 0 ] && echo 'unbind(enter)+unbind(ctrl-alt-d)'" \
|
||||||
--bind="j:down" \
|
--bind="j:down" \
|
||||||
--bind="k:up"
|
--bind="k:up" ||
|
||||||
|
true
|
||||||
)
|
)
|
||||||
echo "GO" >>/tmp/foo
|
key=$(echo "$att" | head -2 | xargs)
|
||||||
echo "$att" >>/tmp/foo
|
|
||||||
key=$(echo "$att" | head -1)
|
|
||||||
sel=$(echo "$att" | tail -1)
|
sel=$(echo "$att" | tail -1)
|
||||||
if [ "$key" = "ctrl-c" ] || [ "$key" = "esc" ] || [ "$key" = "q" ] || [ "$key" = "backspace" ]; then
|
if [ "$key" = "ctrl-c" ] ||
|
||||||
|
[ "$key" = "ctrl-g" ] ||
|
||||||
|
[ "$key" = "ctrl-q" ] ||
|
||||||
|
[ "$key" = "ctrl-d" ] ||
|
||||||
|
[ "$key" = "esc" ] ||
|
||||||
|
[ "$key" = "q" ] ||
|
||||||
|
[ "$key" = "backspace" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [ "$key" = "A" ]; then
|
if [ "$key" = "A" ]; then
|
||||||
__add_attachment "$fpath"
|
__add_attachment "$fpath"
|
||||||
|
__refresh_data
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
attid=$(echo "$sel" | cut -f 1)
|
attid=$(echo "$sel" | cut -f 1)
|
||||||
@ -1292,6 +1297,7 @@ while true; do
|
|||||||
attfmt=$(echo "$sel" | cut -f 3)
|
attfmt=$(echo "$sel" | cut -f 3)
|
||||||
attenc=$(echo "$sel" | cut -f 4)
|
attenc=$(echo "$sel" | cut -f 4)
|
||||||
if [ -z "$attid" ]; then
|
if [ -z "$attid" ]; then
|
||||||
|
# This line should be unreachable
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [ "$key" = "ctrl-alt-d" ]; then
|
if [ "$key" = "ctrl-alt-d" ]; then
|
||||||
@ -1307,6 +1313,7 @@ while true; do
|
|||||||
$GIT add "$fpath"
|
$GIT add "$fpath"
|
||||||
$GIT commit -m "Deleted attachment from event '$(__summary_for_commit "$fpath") ...'" -- "$fpath"
|
$GIT commit -m "Deleted attachment from event '$(__summary_for_commit "$fpath") ...'" -- "$fpath"
|
||||||
fi
|
fi
|
||||||
|
__refresh_data
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
"no")
|
"no")
|
||||||
@ -1352,8 +1359,6 @@ while true; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
printf "Press <enter> to conintue" >/dev/tty
|
|
||||||
read -r tmp
|
|
||||||
# Clean up
|
# Clean up
|
||||||
rm -f "$attpath"
|
rm -f "$attpath"
|
||||||
if [ -n "${tmpdir:-}" ] && [ -d "${tmpdir:-}" ]; then
|
if [ -n "${tmpdir:-}" ] && [ -d "${tmpdir:-}" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user