improvement: styles in theme file, and new exports

This commit is contained in:
2025-06-18 16:35:26 +02:00
parent 3b8c412885
commit a79dfc575e
11 changed files with 119 additions and 52 deletions

View File

@@ -21,6 +21,13 @@
## @assign today: Date of `today` in the format %D (%m/%d/%y)
## @assign daystart: Hour of start of the day
## @assign dayend: Hour of end of the day
## @assign style_allday
## @assign style_timerange
## @assign style_confirmed
## @assign style_tentative
## @assign style_cancelled
## @assign style_hour
## @assign style_emptyhour
# Functions
@@ -29,7 +36,7 @@
# @input status: Event status, one of TENTATIVE, CONFIRMED, CANCELLED
# @return: Color modifier
function color_from_status(status) {
return status == "CANCELLED" ? STRIKE CYAN : status == "TENTATIVE" ? FAINT CYAN : CYAN
return status == "CANCELLED" ? style_cancelled : status == "TENTATIVE" ? style_tentative : style_confirmed
}
# Return line for all-day event.
@@ -41,7 +48,7 @@ function color_from_status(status) {
# @return: Single-line string
function allday(collection, desc, status, color) {
color = color_from_status(status)
return collection " " LIGHT_CYAN ITALIC FAINT " (allday) " OFF color desc OFF
return collection " " style_allday
}
# Return line for multi-day event, or event that starts at midnight, which ends today.
@@ -54,7 +61,7 @@ function allday(collection, desc, status, color) {
# @return: Single-line string
function endstoday(stop, collection, desc, status) {
color = color_from_status(status)
return collection " " LIGHT_CYAN " → " stop ": " OFF color desc OFF
return collection " " style_timerange " → " stop ": " OFF color desc OFF
}
# Return line for event that starts sometime today.
@@ -69,9 +76,9 @@ function endstoday(stop, collection, desc, status) {
function slice(start, stop, collection, desc, status) {
color = color_from_status(status)
if (stop == "00:00")
return collection " " LIGHT_CYAN start " → " ": " OFF color desc OFF
return collection " " style_timerange start " → " ": " OFF color desc OFF
else
return collection " " LIGHT_CYAN start " " stop ": " OFF color desc OFF
return collection " " style_timerange start " " stop ": " OFF color desc OFF
}
# Print line for a single hour entry.
@@ -79,7 +86,7 @@ function slice(start, stop, collection, desc, status) {
# @input hour: Hour of the entry
function hrline(hour) {
hour = hour < 10 ? "0"hour : hour
print today, hour, "", "", "", " " FAINT hour ":00 ----------------------" OFF
print today, hour, "", "", "", " " style_hou hour ":00" OFF " " style_emptyhour
}
# Print lines for hour entries before an event that starts at `start` and stops
@@ -107,11 +114,6 @@ function hrlines(start, stop, h, starth, stoph, tmp, i) {
BEGIN {
FS = "\t"
OFS = "\t"
LIGHT_CYAN = "\033[1;36m"
CYAN = "\033[1;36m"
ITALIC = "\033[3m"
FAINT = "\033[2m"
STRIKE = "\033[9m"
OFF = "\033[m"
}
$1 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6, $7, $8); next }