From 5586619abf59425f50b669228820094ebaf1fe9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84min=20Baumeler?= Date: Tue, 10 Jun 2025 13:06:00 +0200 Subject: [PATCH] fix day view --- src/awk/dayview.awk | 27 ++++++++++++++++++++------- src/main.sh | 13 +++++++------ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/awk/dayview.awk b/src/awk/dayview.awk index d7b325c..953e708 100644 --- a/src/awk/dayview.awk +++ b/src/awk/dayview.awk @@ -15,8 +15,19 @@ function slice() { function hrline(hour) { print 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++) + hrline(i) + tmp = substr(stop, 4, 2) == "00" ? 0 : 1 + return stoph + tmp +} BEGIN { FS = "|"; + daystart = 8 + dayend = 18 GREEN = "\033[1;32m"; RED = "\033[1;31m"; WHITE = "\033[1;97m"; @@ -26,10 +37,12 @@ BEGIN { OFF = "\033[m"; OFS = "|" } -/^[0-9]+$/ && hour { hrline(hour) } -/^[0-9]+$/ { hour = $1 < 10 ? "0"$1 : $1; next } -$1 == hour":00" { print $1, $3, $4, $5, slice(); unset hour; next } -$1 == "00:00" && $2 == "00:00" { print $1, $3, $4, $5, allday(); next } -$1 == "00:00" { print $1, $3, $4, $5, endstoday();next } -hour { hrline(hour); print $1, $3, $4, $5, slice(); unset hour; next } - { print $1, $3, $4, $5, slice(); unset hour; next } +$1 == "00:00" && $2 == "00:00" { print $1, $3, $4, $5, allday(); next } +$1 == "00:00" { print $1, $3, $4, $5, endstoday(); next } +$1 ~ /^[0-9]{2}:[0-9]{2}$/ { + daystart = hrlines($1, $2, daystart, starth, stoph, tmp, i) + print $1, $3, $4, $5, slice() +} +END { + hrlines(dayend":00", 0, daystart, starth, stoph, tmp, i) +} diff --git a/src/main.sh b/src/main.sh index 6124f1b..8e6fd16 100755 --- a/src/main.sh +++ b/src/main.sh @@ -176,12 +176,7 @@ __show_day() { echo "$s|$e|$starttime|$endtime|$fpath|$description" done) fi - #echo "||||🗓️ $GREEN $(date -d "$DISPLAY_DATE" +"%a %e %b %Y")$OFF" - #echo "" - ( - echo "$sef" - seq 8 18 - ) | sort -n | awk "$AWK_DAYVIEW" + echo "$sef" | sort -n | awk "$AWK_DAYVIEW" } __list() { @@ -325,6 +320,12 @@ if [ "${1:-}" = "--preview" ]; then exit fi +if [ "${1:-}" = "--day-reload" ]; then + echo "Jumping to day $DISPLAY_DATE!" + __show_day + exit +fi + if [ "${1:-}" = "--day" ]; then DISPLAY_DATE="$2" echo "Jumping to day $DISPLAY_DATE!"