improvements: presentation

- collection label before time
- UTF8 arrow insead of `->`
This commit is contained in:
Ämin Baumeler 2025-06-14 23:11:55 +02:00
parent 903c870dba
commit 06020740cc
3 changed files with 29 additions and 20 deletions

View File

@ -1,26 +1,25 @@
# 11:00|13:00|1748422800|1748430000|fpath|desc...
# 00:00|00:00|1748296800|1748383200|fpath|desc...
function allday(desc) {
return ITALIC FAINT " (allday) " OFF desc
# $s|$e|$starttime|$endtime|$fpath|$collection|$description
function allday(collection, desc) {
return collection " " ITALIC FAINT " (allday) " OFF desc
}
function endstoday(stop, desc) {
return CYAN " -- " stop OFF ": " desc
function endstoday(stop, collection, desc) {
return collection " " CYAN " -- " stop OFF ": " desc
}
function slice(start, stop, desc) {
function slice(start, stop, collection, desc) {
if (stop == "00:00")
return CYAN start " -- " OFF ": " desc
return collection " " CYAN start " -- " OFF ": " desc
else
return CYAN start OFF " -- " CYAN stop OFF ": " desc
return collection " " CYAN start OFF " -- " CYAN stop OFF ": " desc
}
function hrline(hour) {
hour = hour < 10 ? "0"hour : hour
print today, hour, "", "", "", FAINT hour ":00 ----------------------" OFF
print today, hour, "", "", "", " " FAINT hour ":00 ----------------------" OFF
}
function hrlines(start, stop, h, starth, stoph, tmp, i) {
starth = substr(start, 1, 2)
stoph = substr(stop, 1, 2)
tmp = substr(start, 4, 2) == "00" ? 0 : 1
for (i=h; i < starth + tmp; i++)
for (i=h; i < starth + tmp && i < dayend; i++)
hrline(i)
tmp = substr(stop, 4, 2) == "00" ? 0 : 1
if (stoph + tmp < daystart)
@ -39,11 +38,11 @@ BEGIN {
OFF = "\033[m"
OFS = "|"
}
$1 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6); next }
$1 == "00:00" { print today, $1, $3, $4, $5, endstoday($2, $6); next }
$1 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6, $7); next }
$1 == "00:00" { print today, $1, $3, $4, $5, endstoday($2, $6, $7); next }
$1 ~ /^[0-9]{2}:[0-9]{2}$/ {
daystart = hrlines($1, $2, daystart, starth, stoph, tmp, i)
print today, $1, $3, $4, $5, slice($1, $2, $6)
print today, $1, $3, $4, $5, slice($1, $2, $6, $7)
}
END {
hrlines(dayend":00", 0, daystart, starth, stoph, tmp, i)

View File

@ -12,7 +12,7 @@ BEGIN {
}
/^[0-7] 00:00 -- 00:00/ { dayline = dayline " " c(); next }
/^[0-7] 00:00 -- / { dayline = dayline " <--" $4 " " c(); next }
/^[0-7] [0-9]{2}:[0-9]{2} -- 00:00/ { dayline = dayline " " $2 "--> " c(); next }
/^[0-7] [0-9]{2}:[0-9]{2} -- 00:00/ { dayline = dayline " " $2 "" c(); next }
/^[0-7] [0-9]{2}:[0-9]{2} -- [0-9]{2}:[0-9]{2}/ { dayline = dayline " " $2 " - " $4 " " c(); next }
/^[0-7]$/ && dayline { print "+", startofweek " +" $0-1 " days", "", dayline; }
/^[0-7]$/ {

View File

@ -123,7 +123,7 @@ if [ "${1:-}" = "--preview-event" ]; then
start=$(datetime_str "$start" "%a ")
end=$(datetime_str "$end" "%a ")
location=$(awk -v field="LOCATION" "$AWK_GET" "$fpath")
echo "📅 ${CYAN}$start${OFF} -> ${CYAN}$end${OFF}"
echo "📅 ${CYAN}$start${OFF} ${CYAN}$end${OFF}"
if [ -n "${location:-}" ]; then
echo "📍 ${CYAN}$location${OFF}"
fi
@ -240,6 +240,8 @@ __view_day() {
shift
fpath="$(echo "$1" | sed 's/|/ /g')" # we will use | as delimiter (need to convert back!)
shift
collection="$1"
shift
description="$(echo "$*" | sed 's/|/:/g')" # we will use | as delimiter
#
daystart=$(date -d "$today 00:00:00" +"%s")
@ -259,7 +261,7 @@ __view_day() {
else
continue
fi
echo "$s|$e|$starttime|$endtime|$fpath|$description"
echo "$s|$e|$starttime|$endtime|$fpath|$collection|$description"
done)
fi
echo "$sef" | sort -n | awk -v today="$today" -v daystart="$DAY_START" -v dayend="$DAY_END" "$AWK_DAYVIEW"
@ -995,13 +997,19 @@ while true; do
)+transform(
[ -n \"\${TZ:-}\" ] && echo \"change-list-label:\$WHITE\$ITALIC(\$TZ)\$OFF\"
)+transform(
echo {} | grep \|\| || echo show-preview
[ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview
)" \
--bind="start:hide-preview" \
--bind="j:down+hide-preview+transform:echo {} | grep \|\| || echo show-preview" \
--bind="k:up+hide-preview+transform:echo {} | grep \|\| || echo show-preview" \
--bind="j:down+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
--bind="k:up+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
--bind="ctrl-j:down+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
--bind="ctrl-k:up+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
--bind="down:down+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
--bind="up:up+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
--bind="l:hide-preview+reload:$0 --reload-day {1} '+1 day'" \
--bind="h:hide-preview+reload:$0 --reload-day {1} '-1 day'" \
--bind="right:hide-preview+reload:$0 --reload-day {1} '+1 day'" \
--bind="left:hide-preview+reload:$0 --reload-day {1} '-1 day'" \
--bind="ctrl-l:hide-preview+reload:$0 --reload-day {1} '+1 week'" \
--bind="ctrl-h:hide-preview+reload:$0 --reload-day {1} '-1 week'" \
--bind="alt-l:hide-preview+reload:$0 --reload-day {1} '+1 month'" \
@ -1074,6 +1082,8 @@ while true; do
--bind="k:up" \
--bind="l:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \
--bind="h:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \
--bind="right:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \
--bind="left:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \
--bind="ctrl-l:unbind(load)+reload:$0 --reload-week {2} '+1 month'" \
--bind="ctrl-h:unbind(load)+reload:$0 --reload-week {2} '-1 month'" \
--bind="alt-l:unbind(load)+reload:$0 --reload-week {2} '+1 year'" \