feat: STATUS support
This commit is contained in:
@@ -10,37 +10,54 @@
|
||||
|
||||
# Functions
|
||||
|
||||
# Set event color based on status
|
||||
|
||||
# @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 line for all-day event.
|
||||
#
|
||||
# @local variables: color
|
||||
# @input collection: Collection symbol
|
||||
# @input desc: Event description
|
||||
# @input status: Event status, one of TENTATIVE, CONFIRMED, CANCELLED
|
||||
# @return: Single-line string
|
||||
function allday(collection, desc) {
|
||||
return collection " " LIGHT_CYAN ITALIC FAINT " (allday) " OFF CYAN desc OFF
|
||||
function allday(collection, desc, status, color) {
|
||||
color = color_from_status(status)
|
||||
return collection " " LIGHT_CYAN ITALIC FAINT " (allday) " OFF color desc OFF
|
||||
}
|
||||
|
||||
# Return line for multi-day event, or event that starts at midnight, which ends today.
|
||||
#
|
||||
# @local variables: color
|
||||
# @input stop: Time at which the event ends
|
||||
# @input collection: Collection symbol
|
||||
# @input desc: Event description
|
||||
# @input status: Event status, one of TENTATIVE, CONFIRMED, CANCELLED
|
||||
# @return: Single-line string
|
||||
function endstoday(stop, collection, desc) {
|
||||
return collection " " LIGHT_CYAN " -- " stop OFF ": " CYAN desc OFF
|
||||
function endstoday(stop, collection, desc, status) {
|
||||
color = color_from_status(status)
|
||||
return collection " " LIGHT_CYAN " -- " stop OFF ": " color desc OFF
|
||||
}
|
||||
|
||||
# Return line for event that starts sometime today.
|
||||
#
|
||||
# @local variables: color
|
||||
# @input start: Time at which the event starts
|
||||
# @input stop: Time at which the event ends
|
||||
# @input collection: Collection symbol
|
||||
# @input desc: Event description
|
||||
# @input status: Event status, one of TENTATIVE, CONFIRMED, CANCELLED
|
||||
# @return: Single-line string
|
||||
function slice(start, stop, collection, desc) {
|
||||
function slice(start, stop, collection, desc, status) {
|
||||
color = color_from_status(status)
|
||||
if (stop == "00:00")
|
||||
return collection " " LIGHT_CYAN start " -- " OFF ": " CYAN desc OFF
|
||||
return collection " " LIGHT_CYAN start " -- " OFF ": " color desc OFF
|
||||
else
|
||||
return collection " " LIGHT_CYAN start OFF " -- " LIGHT_CYAN stop OFF ": " CYAN desc OFF
|
||||
return collection " " LIGHT_CYAN start OFF " -- " LIGHT_CYAN stop OFF ": " color desc OFF
|
||||
}
|
||||
|
||||
# Print line for a single hour entry.
|
||||
@@ -79,13 +96,14 @@ BEGIN {
|
||||
CYAN = "\033[1;36m"
|
||||
ITALIC = "\033[3m"
|
||||
FAINT = "\033[2m"
|
||||
STRIKE = "\033[9m"
|
||||
OFF = "\033[m"
|
||||
OFS = "|"
|
||||
}
|
||||
$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 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6, $7, $8); next }
|
||||
$1 == "00:00" { print today, $1, $3, $4, $5, endstoday($2, $6, $7, $8); next }
|
||||
$1 ~ /^[0-9]{2}:[0-9]{2}$/ {
|
||||
daystart = hrlines($1, $2, daystart)
|
||||
print today, $1, $3, $4, $5, slice($1, $2, $6, $7)
|
||||
print today, $1, $3, $4, $5, slice($1, $2, $6, $7, $8)
|
||||
}
|
||||
END { hrlines(dayend":00", 0, daystart) }
|
||||
|
Reference in New Issue
Block a user