some initial previewk lots ofs fixes
This commit is contained in:
parent
19c65d7ce1
commit
1fd35de475
@ -1,14 +1,16 @@
|
|||||||
|
# 11:00|13:00|1748422800|1748430000|fpath|desc...
|
||||||
|
# 00:00|00:00|1748296800|1748383200|fpath|desc...
|
||||||
function allday() {
|
function allday() {
|
||||||
return ITALIC FAINT " (allday) " OFF $4
|
return ITALIC FAINT " (allday) " OFF $6
|
||||||
}
|
}
|
||||||
function endstoday() {
|
function endstoday() {
|
||||||
return CYAN " -- " $2 OFF ": " $4
|
return CYAN " -- " $2 OFF ": " $6
|
||||||
}
|
}
|
||||||
function slice() {
|
function slice() {
|
||||||
if ($2 == "00:00")
|
if ($2 == "00:00")
|
||||||
return CYAN $1 " -- " OFF ": " $4
|
return CYAN $1 " -- " OFF ": " $6
|
||||||
else
|
else
|
||||||
return CYAN $1 OFF " -- " CYAN $2 OFF ": " $4
|
return CYAN $1 OFF " -- " CYAN $2 OFF ": " $6
|
||||||
}
|
}
|
||||||
BEGIN {
|
BEGIN {
|
||||||
FS = "|";
|
FS = "|";
|
||||||
@ -21,8 +23,8 @@ BEGIN {
|
|||||||
OFF = "\033[m";
|
OFF = "\033[m";
|
||||||
OFS = "|"
|
OFS = "|"
|
||||||
}
|
}
|
||||||
/^[0-9]+$/ && hour { print hour, FAINT hour ":00 ----------------------" OFF }
|
/^[0-9]+$/ && hour { print hour, "", "", "", FAINT hour ":00 ----------------------" OFF }
|
||||||
/^[0-9]+$/ { hour = $1 < 10 ? "0"$1 : $1; next }
|
/^[0-9]+$/ { hour = $1 < 10 ? "0"$1 : $1; next }
|
||||||
$1 == hour":00" { print $3, slice(); unset hour; next }
|
$1 == hour":00" { print $1, $3, $4, $5, slice(); unset hour; next }
|
||||||
$1 == "00:00" && $2 == "00:00" { print $3, allday(); next }
|
$1 == "00:00" && $2 == "00:00" { print $1, $3, $4, $5, allday(); next }
|
||||||
$1 == "00:00" { print $3, endstoday();next }
|
$1 == "00:00" { print $1, $3, $4, $5, endstoday();next }
|
||||||
|
18
src/awk/preview.awk
Normal file
18
src/awk/preview.awk
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# print content of field `field`
|
||||||
|
BEGIN { FS = ":"; regex = "^" field; }
|
||||||
|
/^BEGIN:VEVENT$/ { inside = 1 }
|
||||||
|
/^END:VEVENT/ && inside { exit }
|
||||||
|
$0 ~ field { content = $0; next; }
|
||||||
|
/^ / && content { content = content substr($0, 2); next; }
|
||||||
|
/^[^ ]/ && content { exit }
|
||||||
|
END {
|
||||||
|
if (!type) { exit }
|
||||||
|
# Process content line
|
||||||
|
content = substr(content, index(content, ":") + 1);
|
||||||
|
gsub("\\\\n", "\n", content);
|
||||||
|
gsub("\\\\N", "\n", content);
|
||||||
|
gsub("\\\\,", ",", content);
|
||||||
|
gsub("\\\\;", ";", content);
|
||||||
|
gsub("\\\\\\\\", "\\", content);
|
||||||
|
print content;
|
||||||
|
}
|
68
src/main.sh
68
src/main.sh
@ -83,6 +83,13 @@ EOF
|
|||||||
AWK_DAYVIEW=$(
|
AWK_DAYVIEW=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include src/awk/dayview.awk
|
@@include src/awk/dayview.awk
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
export AWK_DAYVIEW
|
||||||
|
|
||||||
|
AWK_PREVIEW=$(
|
||||||
|
cat <<'EOF'
|
||||||
|
@@include src/awk/preview.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_DAYVIEW
|
export AWK_DAYVIEW
|
||||||
@ -129,38 +136,38 @@ __show_day() {
|
|||||||
shift
|
shift
|
||||||
endtime="$1"
|
endtime="$1"
|
||||||
shift
|
shift
|
||||||
fpath="$1"
|
fpath="$(echo "$1" | sed 's/|/ /g')" # we will use | as delimiter (need to convert back!)
|
||||||
shift
|
shift
|
||||||
description=$(echo "$*" | sed 's/|/:/g') # we will use | as delimiter
|
description="$(echo "$*" | sed 's/|/:/g')" # we will use | as delimiter
|
||||||
#
|
#
|
||||||
daystart=$(date -d "$today 00:00:00" +"%s")
|
daystart=$(date -d "$today 00:00:00" +"%s")
|
||||||
dayend=$(date -d "$today 23:59:59" +"%s")
|
dayend=$(date -d "$today 23:59:59" +"%s")
|
||||||
line=""
|
line=""
|
||||||
if [ "$starttime" -gt "$daystart" ] && [ "$starttime" -lt "$dayend" ]; then
|
if [ "$starttime" -gt "$daystart" ] && [ "$starttime" -lt "$dayend" ]; then
|
||||||
s=$(date -d "@$starttime" +"%H:%M")
|
s=$(date -d "@$starttime" +"%R")
|
||||||
elif [ "$starttime" -le "$daystart" ] && [ "$endtime" -gt "$daystart" ]; then
|
elif [ "$starttime" -le "$daystart" ] && [ "$endtime" -gt "$daystart" ]; then
|
||||||
s="00:00"
|
s="00:00"
|
||||||
else
|
else
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [ "$endtime" -gt "$daystart" ] && [ "$endtime" -lt "$dayend" ]; then
|
if [ "$endtime" -gt "$daystart" ] && [ "$endtime" -lt "$dayend" ]; then
|
||||||
e=$(date -d "@$endtime" +"%H:%M")
|
e=$(date -d "@$endtime" +"%R")
|
||||||
elif [ "$endtime" -ge "$dayend" ] && [ "$starttime" -lt "$dayend" ]; then
|
elif [ "$endtime" -ge "$dayend" ] && [ "$starttime" -lt "$dayend" ]; then
|
||||||
e="00:00"
|
e="00:00"
|
||||||
else
|
else
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "$s|$e|$fpath|$description"
|
echo "$s|$e|$starttime|$endtime|$fpath|$description"
|
||||||
done)
|
done)
|
||||||
fi
|
fi
|
||||||
GREEN="\033[1;32m"
|
GREEN="\033[1;32m"
|
||||||
OFF="\033[m"
|
OFF="\033[m"
|
||||||
echo "|🗓️ $GREEN $(date -d "$DISPLAY_DATE" +"%a %e %b %Y")$OFF"
|
echo "||||🗓️ $GREEN $(date -d "$DISPLAY_DATE" +"%a %e %b %Y")$OFF"
|
||||||
echo ""
|
echo ""
|
||||||
(
|
(
|
||||||
echo "$sef"
|
echo "$sef"
|
||||||
seq 8 18 | sort -n
|
seq 8 18
|
||||||
) | awk "$AWK_DAYVIEW"
|
) | sort -n | awk "$AWK_DAYVIEW"
|
||||||
}
|
}
|
||||||
|
|
||||||
__list() {
|
__list() {
|
||||||
@ -233,6 +240,32 @@ if [ -z "${WEEKLY_DATA_FILE:-}" ]; then
|
|||||||
export WEEKLY_DATA_FILE
|
export WEEKLY_DATA_FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${1:-}" = "--preview" ]; then
|
||||||
|
hour=$(echo "$2" | cut -d '|' -f 1)
|
||||||
|
start=$(echo "$2" | cut -d '|' -f 2)
|
||||||
|
end=$(echo "$2" | cut -d '|' -f 3)
|
||||||
|
fpath=$(echo "$2" | cut -d '|' -f 4 | sed "s/ /|/g")
|
||||||
|
if [ -n "$hour" ] && [ -n "$fpath" ]; then
|
||||||
|
fpath="$ROOT/$fpath"
|
||||||
|
timestart=$(date -d "@$start" +"%R")
|
||||||
|
timeend=$(date -d "@$end" +"%R")
|
||||||
|
dfmt="%a %e %b %Y"
|
||||||
|
if [ "$timestart" != "00:00" ]; then
|
||||||
|
dfmt="$dfmt %Y %R %Z"
|
||||||
|
fi
|
||||||
|
start=$(date -d "@$start" +"$dfmt")
|
||||||
|
dfmt="%a %e %b %Y"
|
||||||
|
if [ "$timeend" != "00:00" ]; then
|
||||||
|
dfmt="$dfmt %Y %R %Z"
|
||||||
|
fi
|
||||||
|
end=$(date -d "@$end" +"$dfmt")
|
||||||
|
echo "START @ $start, END @ $end"
|
||||||
|
fi
|
||||||
|
#awk -v field="DESCRIPTION" "$AWK_PREVIEW" "$fpath" |
|
||||||
|
# $CAT
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${1:-}" = "--day" ]; then
|
if [ "${1:-}" = "--day" ]; then
|
||||||
DISPLAY_DATE="$2"
|
DISPLAY_DATE="$2"
|
||||||
echo "Jumping to day $DISPLAY_DATE!"
|
echo "Jumping to day $DISPLAY_DATE!"
|
||||||
@ -244,13 +277,22 @@ if [ "${1:-}" = "--day" ]; then
|
|||||||
--no-sort \
|
--no-sort \
|
||||||
--no-input \
|
--no-input \
|
||||||
--delimiter='|' \
|
--delimiter='|' \
|
||||||
--with-nth='{2}' \
|
--with-nth='{5}' \
|
||||||
--accept-nth='{1}' \
|
--accept-nth='1,2,3,4' \
|
||||||
|
--preview="$0 --preview {}" \
|
||||||
--bind="backspace:first+accept"
|
--bind="backspace:first+accept"
|
||||||
)
|
)
|
||||||
if [ -n "$selection" ]; then
|
hour=$(echo "$selection" | cut -d '|' -f 1)
|
||||||
fpath="$ROOT/$selection"
|
start=$(echo "$selection" | cut -d '|' -f 2)
|
||||||
fi
|
end=$(echo "$selection" | cut -d '|' -f 3)
|
||||||
|
fpath=$(echo "$selection" | cut -d '|' -f 4 | sed "s/ /|/g")
|
||||||
|
if [ -n "$fpath" ]; then
|
||||||
|
fpath="$ROOT/$fpath"
|
||||||
|
# TODO: Go on edit file
|
||||||
|
elif [ -n "$hour" ]; then
|
||||||
|
# TODO Go on add entry for hour
|
||||||
|
echo "Add entry for hour $hour"
|
||||||
|
fi # Else: continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${1:-}" = "--date" ]; then
|
if [ "${1:-}" = "--date" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user