improvement: styles in theme file, and new exports
This commit is contained in:
		@@ -10,6 +10,7 @@
 | 
				
			|||||||
## 5. filename (collection/name)
 | 
					## 5. filename (collection/name)
 | 
				
			||||||
##
 | 
					##
 | 
				
			||||||
## @assign collection_labels: See configuration of the current program.
 | 
					## @assign collection_labels: See configuration of the current program.
 | 
				
			||||||
 | 
					## @assign style_line: Style for each line
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@include "lib/awk/icalendar.awk"
 | 
					@include "lib/awk/icalendar.awk"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -38,7 +39,7 @@ function title(start, summary) {
 | 
				
			|||||||
  depth = split(FILENAME, path, "/")
 | 
					  depth = split(FILENAME, path, "/")
 | 
				
			||||||
  collection = depth > 1 ? path[depth-1] : ""
 | 
					  collection = depth > 1 ? path[depth-1] : ""
 | 
				
			||||||
  collection = collection in collection2label ? collection2label[collection] : collection
 | 
					  collection = collection in collection2label ? collection2label[collection] : collection
 | 
				
			||||||
  return FAINT "~ " collection " " gensub(/^[^0-9]*([0-9]{4})([0-9]{2}).*$/, "\\1-\\2", "1", start) " " summary OFF
 | 
					  return style_line "~ " collection " " gensub(/^[^0-9]*([0-9]{4})([0-9]{2}).*$/, "\\1-\\2", "1", start) " " summary OFF
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# AWK program
 | 
					# AWK program
 | 
				
			||||||
@@ -52,7 +53,6 @@ BEGIN {
 | 
				
			|||||||
    collection2label[m[1]] = m[2]
 | 
					    collection2label[m[1]] = m[2]
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  # Colors
 | 
					  # Colors
 | 
				
			||||||
  FAINT = "\033[2m"
 | 
					 | 
				
			||||||
  OFF = "\033[m"
 | 
					  OFF = "\033[m"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
BEGINFILE             { inside = 0; rs = 0; dur = 0; summary = ""; start = "ERROR"; end = "ERROR" }
 | 
					BEGINFILE             { inside = 0; rs = 0; dur = 0; summary = ""; start = "ERROR"; end = "ERROR" }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,22 +3,20 @@
 | 
				
			|||||||
##
 | 
					##
 | 
				
			||||||
## @assign cur: Day-of-month to mark as `today`
 | 
					## @assign cur: Day-of-month to mark as `today`
 | 
				
			||||||
## @assign day: Day-of-month to highlight
 | 
					## @assign day: Day-of-month to highlight
 | 
				
			||||||
 | 
					## @assign style_month: Theme to use for month
 | 
				
			||||||
 | 
					## @assign style_weekdays: Theme to use for weekdays
 | 
				
			||||||
 | 
					## @assign style_cur: Theme to use for current day 
 | 
				
			||||||
 | 
					## @assign style_highlight: Theme to use for highlighted day
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BEGIN {
 | 
					BEGIN {
 | 
				
			||||||
  BLACK = "\033[1;30m"
 | 
					 | 
				
			||||||
  GREEN = "\033[1;32m"
 | 
					 | 
				
			||||||
  RED = "\033[1;31m"
 | 
					 | 
				
			||||||
  FAINT = "\033[2m"
 | 
					 | 
				
			||||||
  BOLD = "\033[1m"
 | 
					 | 
				
			||||||
  BG = "\033[41m"
 | 
					 | 
				
			||||||
  OFF = "\033[m"
 | 
					  OFF = "\033[m"
 | 
				
			||||||
  day = day + 0
 | 
					  day = day + 0
 | 
				
			||||||
  cur = cur + 0
 | 
					  cur = cur + 0
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
NR == 1 { print GREEN $0 OFF; next }
 | 
					NR == 1 { print style_month $0 OFF; next }
 | 
				
			||||||
NR == 2 { print FAINT $0 OFF; next }
 | 
					NR == 2 { print style_weekdays $0 OFF; next }
 | 
				
			||||||
{ 
 | 
					{ 
 | 
				
			||||||
  sub("\\y"cur"\\y", BG BLACK BOLD cur OFF)
 | 
					  sub("\\y"cur"\\y", style_cur cur OFF)
 | 
				
			||||||
  sub("\\y"day"\\y", RED BOLD day OFF)
 | 
					  sub("\\y"day"\\y", style_highlight day OFF)
 | 
				
			||||||
  print
 | 
					  print
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,13 @@
 | 
				
			|||||||
## @assign today: Date of `today` in the format %D (%m/%d/%y)
 | 
					## @assign today: Date of `today` in the format %D (%m/%d/%y)
 | 
				
			||||||
## @assign daystart: Hour of start of the day
 | 
					## @assign daystart: Hour of start of the day
 | 
				
			||||||
## @assign dayend: Hour of end 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
 | 
					# Functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -29,7 +36,7 @@
 | 
				
			|||||||
# @input status: Event status, one of TENTATIVE, CONFIRMED, CANCELLED
 | 
					# @input status: Event status, one of TENTATIVE, CONFIRMED, CANCELLED
 | 
				
			||||||
# @return: Color modifier
 | 
					# @return: Color modifier
 | 
				
			||||||
function color_from_status(status) {
 | 
					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.
 | 
					# Return line for all-day event.
 | 
				
			||||||
@@ -41,7 +48,7 @@ function color_from_status(status) {
 | 
				
			|||||||
# @return: Single-line string
 | 
					# @return: Single-line string
 | 
				
			||||||
function allday(collection, desc, status,    color) {
 | 
					function allday(collection, desc, status,    color) {
 | 
				
			||||||
  color = color_from_status(status)
 | 
					  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.
 | 
					# 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
 | 
					# @return: Single-line string
 | 
				
			||||||
function endstoday(stop, collection, desc, status) {
 | 
					function endstoday(stop, collection, desc, status) {
 | 
				
			||||||
  color = color_from_status(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.
 | 
					# 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) {
 | 
					function slice(start, stop, collection, desc, status) {
 | 
				
			||||||
  color = color_from_status(status)
 | 
					  color = color_from_status(status)
 | 
				
			||||||
  if (stop == "00:00")
 | 
					  if (stop == "00:00")
 | 
				
			||||||
    return collection " " LIGHT_CYAN start " →      " ": " OFF color desc OFF
 | 
					    return collection " " style_timerange start " →      " ": " OFF color desc OFF
 | 
				
			||||||
   else
 | 
					   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.
 | 
					# Print line for a single hour entry.
 | 
				
			||||||
@@ -79,7 +86,7 @@ function slice(start, stop, collection, desc, status) {
 | 
				
			|||||||
# @input hour: Hour of the entry
 | 
					# @input hour: Hour of the entry
 | 
				
			||||||
function hrline(hour) {
 | 
					function hrline(hour) {
 | 
				
			||||||
  hour = hour < 10 ? "0"hour : 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
 | 
					# 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 {
 | 
					BEGIN {
 | 
				
			||||||
  FS = "\t"
 | 
					  FS = "\t"
 | 
				
			||||||
  OFS = "\t"
 | 
					  OFS = "\t"
 | 
				
			||||||
  LIGHT_CYAN = "\033[1;36m"
 | 
					 | 
				
			||||||
  CYAN = "\033[1;36m"
 | 
					 | 
				
			||||||
  ITALIC = "\033[3m"
 | 
					 | 
				
			||||||
  FAINT = "\033[2m"
 | 
					 | 
				
			||||||
  STRIKE = "\033[9m"
 | 
					 | 
				
			||||||
  OFF = "\033[m"
 | 
					  OFF = "\033[m"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
$1 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6, $7, $8);        next }
 | 
					$1 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6, $7, $8);        next }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,10 @@
 | 
				
			|||||||
##   printf "%s\t%s\t%s\t%s\n" "$i" "$s" "$e" "$description"
 | 
					##   printf "%s\t%s\t%s\t%s\n" "$i" "$s" "$e" "$description"
 | 
				
			||||||
##
 | 
					##
 | 
				
			||||||
## @assign startofweek: Date of first day in the week
 | 
					## @assign startofweek: Date of first day in the week
 | 
				
			||||||
 | 
					## @assign style_day: Style for dates
 | 
				
			||||||
 | 
					## @assign style_event_delim: Event delimiter
 | 
				
			||||||
 | 
					## @assign style_summary: Style for summary lines
 | 
				
			||||||
 | 
					## @assign style_time: Style for times
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Functions
 | 
					# Functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -12,7 +16,7 @@
 | 
				
			|||||||
# @input desc: String with a description of the event
 | 
					# @input desc: String with a description of the event
 | 
				
			||||||
# @return: Single-line string
 | 
					# @return: Single-line string
 | 
				
			||||||
function c(desc) {
 | 
					function c(desc) {
 | 
				
			||||||
  return CYAN desc OFF "  " RED "/" OFF
 | 
					  return style_summary desc OFF "  " style_event_delim
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# AWK program
 | 
					# AWK program
 | 
				
			||||||
@@ -20,19 +24,16 @@ function c(desc) {
 | 
				
			|||||||
BEGIN {
 | 
					BEGIN {
 | 
				
			||||||
  FS = "\t"
 | 
					  FS = "\t"
 | 
				
			||||||
  OFS = "\t"
 | 
					  OFS = "\t"
 | 
				
			||||||
  GREEN = "\033[1;32m"
 | 
					 | 
				
			||||||
  RED = "\033[1;31m"
 | 
					 | 
				
			||||||
  CYAN = "\033[1;36m"
 | 
					 | 
				
			||||||
  OFF = "\033[m"
 | 
					  OFF = "\033[m"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
$2 == "00:00" && $3 == "00:00" { dayline = dayline " " c($4); next }
 | 
					$2 == "00:00" && $3 == "00:00" { dayline = dayline " " c($4); next }
 | 
				
			||||||
$2 == "00:00"                  { dayline = dayline " → " $3 " " c($4); next }
 | 
					$2 == "00:00"                  { dayline = dayline style_time " → " $3 OFF " " c($4); next }
 | 
				
			||||||
$3 == "00:00"                  { dayline = dayline " " $2 " → " c($4); next }
 | 
					$3 == "00:00"                  { dayline = dayline style_time " " $2 " → " OFF c($4); next }
 | 
				
			||||||
NF == 4                        { dayline = dayline " " $2 " – " $3 " " c($4); next }
 | 
					NF == 4                        { dayline = dayline style_time " " $2 " – " $3 OFF " " c($4); next }
 | 
				
			||||||
NF == 1 && dayline             { print "+", startofweek " +" $1-1 " days", "", dayline }
 | 
					NF == 1 && dayline             { print "+", startofweek " +" $1-1 " days", "", dayline }
 | 
				
			||||||
NF == 1 {
 | 
					NF == 1 {
 | 
				
			||||||
  cmd = "date -d '" startofweek " +" $1 " days' +\"%a %e %b %Y\""
 | 
					  cmd = "date -d '" startofweek " +" $1 " days' +\"%a %e %b %Y\""
 | 
				
			||||||
  cmd | getline dayline
 | 
					  cmd | getline dayline
 | 
				
			||||||
  close(cmd)
 | 
					  close(cmd)
 | 
				
			||||||
  dayline = GREEN dayline ":   " OFF
 | 
					  dayline = style_day dayline ":   " OFF
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -70,9 +70,7 @@ __refresh_data
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
### Exports
 | 
					### Exports
 | 
				
			||||||
# The preview calls run in subprocesses. These require the following variables:
 | 
					# The preview calls run in subprocesses. These require the following variables:
 | 
				
			||||||
export ROOT CAT AWK_GET AWK_CALSHIFT AWK_CALANNOT CYAN STRIKE FAINT WHITE ITALIC OFF AWK_ATTACHLS
 | 
					 | 
				
			||||||
# The reload commands also run in subprocesses, and use in addition
 | 
					# The reload commands also run in subprocesses, and use in addition
 | 
				
			||||||
export COLLECTION_LABELS DAY_START DAY_END AWK_DAYVIEW AWK_WEEKVIEW AWK_PARSE
 | 
					 | 
				
			||||||
# as well as the following variables that will be dynamically specified. So, we
 | 
					# as well as the following variables that will be dynamically specified. So, we
 | 
				
			||||||
# export them in the main loop using the following function.
 | 
					# export them in the main loop using the following function.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,87 +20,102 @@ AWK_APPROX=$(
 | 
				
			|||||||
@@include awk/approx.awk
 | 
					@@include awk/approx.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_APPROX
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_MERGE=$(
 | 
					AWK_MERGE=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/merge.awk
 | 
					@@include awk/merge.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_MERGE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_PARSE=$(
 | 
					AWK_PARSE=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/parse.awk
 | 
					@@include awk/parse.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_PARSE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_WEEKVIEW=$(
 | 
					AWK_WEEKVIEW=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/weekview.awk
 | 
					@@include awk/weekview.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_WEEKVIEW
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_DAYVIEW=$(
 | 
					AWK_DAYVIEW=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/dayview.awk
 | 
					@@include awk/dayview.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_DAYVIEW
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_GET=$(
 | 
					AWK_GET=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/get.awk
 | 
					@@include awk/get.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_GET
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_UPDATE=$(
 | 
					AWK_UPDATE=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/update.awk
 | 
					@@include awk/update.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_UPDATE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_NEW=$(
 | 
					AWK_NEW=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/new.awk
 | 
					@@include awk/new.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_NEW
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_CALSHIFT=$(
 | 
					AWK_CALSHIFT=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/calshift.awk
 | 
					@@include awk/calshift.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_CALSHIFT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_CALANNOT=$(
 | 
					AWK_CALANNOT=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/calannot.awk
 | 
					@@include awk/calannot.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_CALANNOT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_SET=$(
 | 
					AWK_SET=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/set.awk
 | 
					@@include awk/set.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_SET
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_ATTACHLS=$(
 | 
					AWK_ATTACHLS=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/attachls.awk
 | 
					@@include awk/attachls.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_ATTACHLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_ATTACHDD=$(
 | 
					AWK_ATTACHDD=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/attachdd.awk
 | 
					@@include awk/attachdd.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_ATTACHDD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_ATTACHRM=$(
 | 
					AWK_ATTACHRM=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/attachrm.awk
 | 
					@@include awk/attachrm.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_ATTACHRM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AWK_ATTACH=$(
 | 
					AWK_ATTACH=$(
 | 
				
			||||||
  cat <<'EOF'
 | 
					  cat <<'EOF'
 | 
				
			||||||
@@include awk/attach.awk
 | 
					@@include awk/attach.awk
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					export AWK_ATTACH
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,9 +21,9 @@ if [ "${1:-}" = "--preview-event" ]; then
 | 
				
			|||||||
    elif [ "$status" = "CANCELLED" ]; then
 | 
					    elif [ "$status" = "CANCELLED" ]; then
 | 
				
			||||||
      symb="❌"
 | 
					      symb="❌"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    echo "📅${symb:-} ${CYAN}$start${OFF} → ${CYAN}$end${OFF}"
 | 
					    echo "📅${symb:-} ${STYLE_EPV_DATETIME}$start${OFF} → ${STYLE_EPV_DATETIME}$end${OFF}"
 | 
				
			||||||
    if [ -n "${location:-}" ]; then
 | 
					    if [ -n "${location:-}" ]; then
 | 
				
			||||||
      echo "📍 ${CYAN}$location${OFF}"
 | 
					      echo "📍 ${STYLE_EPV_LOCATION}$location${OFF}"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    attcnt=$(awk "$AWK_ATTACHLS" "$fpath" | wc -l)
 | 
					    attcnt=$(awk "$AWK_ATTACHLS" "$fpath" | wc -l)
 | 
				
			||||||
    if [ "$attcnt" -gt 0 ]; then
 | 
					    if [ "$attcnt" -gt 0 ]; then
 | 
				
			||||||
@@ -88,12 +88,12 @@ if [ "${1:-}" = "--preview-week" ]; then
 | 
				
			|||||||
    fi
 | 
					    fi
 | 
				
			||||||
    # show
 | 
					    # show
 | 
				
			||||||
    (
 | 
					    (
 | 
				
			||||||
      cal "$month_pre2" "$year_pre2" | awk "$AWK_CALSHIFT" | awk -v cur="${var_pre2:-}" "$AWK_CALANNOT"
 | 
					      cal "$month_pre2" "$year_pre2" | awk "$AWK_CALSHIFT" | awk -v cur="${var_pre2:-}" -v style_month="$STYLE_CALENDAR_MONTH" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT"
 | 
				
			||||||
      cal "$month_pre" "$year_pre" | awk "$AWK_CALSHIFT" | awk -v cur="${var_pre:-}" "$AWK_CALANNOT"
 | 
					      cal "$month_pre" "$year_pre" | awk "$AWK_CALSHIFT" | awk -v cur="${var_pre:-}" -v style_month="$STYLE_CALENDAR_MONTH" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT"
 | 
				
			||||||
      cal "$month" "$year" | awk "$AWK_CALSHIFT" | awk -v cur="${var:-}" -v day="$day" "$AWK_CALANNOT"
 | 
					      cal "$month" "$year" | awk "$AWK_CALSHIFT" | awk -v cur="${var:-}" -v day="$day" -v style_month="$STYLE_CALENDAR_MONTH" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT"
 | 
				
			||||||
      cal "$month_nex" "$year_nex" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex:-}" "$AWK_CALANNOT"
 | 
					      cal "$month_nex" "$year_nex" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex:-}" -v style_month="$STYLE_CALENDAR_MONTH" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT"
 | 
				
			||||||
      cal "$month_nex2" "$year_nex2" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex2:-}" "$AWK_CALANNOT"
 | 
					      cal "$month_nex2" "$year_nex2" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex2:-}" -v style_month="$STYLE_CALENDAR_MONTH" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT"
 | 
				
			||||||
      cal "$month_nex3" "$year_nex3" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex3:-}" "$AWK_CALANNOT"
 | 
					      cal "$month_nex3" "$year_nex3" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex3:-}" -v style_month="$STYLE_CALENDAR_MONTH" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT"
 | 
				
			||||||
    ) | awk '{ l[NR%8] = l[NR%8] "    " $0 } END {for (i in l) if (i>0) print l[i] }'
 | 
					    ) | awk '{ l[NR%8] = l[NR%8] "    " $0 } END {for (i in l) if (i>0) print l[i] }'
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  exit
 | 
					  exit
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,15 +20,16 @@ if [ -z "${ROOT:-}" ] || [ -z "${COLLECTION_LABELS:-}" ]; then
 | 
				
			|||||||
  err "Configuration is incomplete."
 | 
					  err "Configuration is incomplete."
 | 
				
			||||||
  exit 1
 | 
					  exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
SYNC_CMD=${SYNC_CMD:-echo 'Synchronization disabled'}
 | 
					export ROOT COLLECTION_LABELS
 | 
				
			||||||
DAY_START=${DAY_START:-8}
 | 
					export SYNC_CMD=${SYNC_CMD:-echo 'Synchronization disabled'}
 | 
				
			||||||
DAY_END=${DAY_END:-18}
 | 
					export DAY_START=${DAY_START:-8}
 | 
				
			||||||
ZI_DIR=${ZI_DIR:-/usr/share/zoneinfo/posix}
 | 
					export DAY_END=${DAY_END:-18}
 | 
				
			||||||
 | 
					export ZI_DIR=${ZI_DIR:-/usr/share/zoneinfo/posix}
 | 
				
			||||||
if [ ! -d "$ZI_DIR" ]; then
 | 
					if [ ! -d "$ZI_DIR" ]; then
 | 
				
			||||||
  err "Could not determine time-zone information"
 | 
					  err "Could not determine time-zone information"
 | 
				
			||||||
  exit 1
 | 
					  exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
OPEN=${OPEN:-open}
 | 
					export OPEN=${OPEN:-open}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Check and load required tools
 | 
					# Check and load required tools
 | 
				
			||||||
# - FZF:     Fuzzy finder `fzf``
 | 
					# - FZF:     Fuzzy finder `fzf``
 | 
				
			||||||
@@ -39,14 +40,14 @@ OPEN=${OPEN:-open}
 | 
				
			|||||||
# The presence of POSIX tools is not checked.
 | 
					# The presence of POSIX tools is not checked.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if command -v "fzf" >/dev/null; then
 | 
					if command -v "fzf" >/dev/null; then
 | 
				
			||||||
  FZF="fzf --black"
 | 
					  export FZF="fzf --black"
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
  err "Did not find the command-line fuzzy finder fzf."
 | 
					  err "Did not find the command-line fuzzy finder fzf."
 | 
				
			||||||
  exit 1
 | 
					  exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if command -v "uuidgen" >/dev/null; then
 | 
					if command -v "uuidgen" >/dev/null; then
 | 
				
			||||||
  UUIDGEN="uuidgen"
 | 
					  export UUIDGEN="uuidgen"
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
  err "Did not find the uuidgen command."
 | 
					  err "Did not find the uuidgen command."
 | 
				
			||||||
  exit 1
 | 
					  exit 1
 | 
				
			||||||
@@ -58,8 +59,8 @@ elif command -v "batcat" >/dev/null; then
 | 
				
			|||||||
  CAT="batcat"
 | 
					  CAT="batcat"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
CAT=${CAT:+$CAT --color=always --style=numbers --language=md}
 | 
					CAT=${CAT:+$CAT --color=always --style=numbers --language=md}
 | 
				
			||||||
CAT=${CAT:-cat}
 | 
					export CAT=${CAT:-cat}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if command -v "git" >/dev/null && [ -d "$ROOT/.git" ]; then
 | 
					if command -v "git" >/dev/null && [ -d "$ROOT/.git" ]; then
 | 
				
			||||||
  GIT="git -C $ROOT"
 | 
					  export GIT="git -C $ROOT"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,7 @@ __load_approx_data() {
 | 
				
			|||||||
    xargs -0 -P0 \
 | 
					    xargs -0 -P0 \
 | 
				
			||||||
      awk \
 | 
					      awk \
 | 
				
			||||||
      -v collection_labels="$COLLECTION_LABELS" \
 | 
					      -v collection_labels="$COLLECTION_LABELS" \
 | 
				
			||||||
 | 
					      -v style_line="$STYLE_LV" \
 | 
				
			||||||
      "$AWK_APPROX"
 | 
					      "$AWK_APPROX"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,42 @@
 | 
				
			|||||||
 | 
					# Colors
 | 
				
			||||||
GREEN="\033[1;32m"
 | 
					GREEN="\033[1;32m"
 | 
				
			||||||
 | 
					BLACK="\033[1;30m"
 | 
				
			||||||
RED="\033[1;31m"
 | 
					RED="\033[1;31m"
 | 
				
			||||||
WHITE="\033[1;97m"
 | 
					WHITE="\033[1;97m"
 | 
				
			||||||
CYAN="\033[1;36m"
 | 
					CYAN="\033[1;36m"
 | 
				
			||||||
 | 
					LIGHT_CYAN="\033[1;36m"
 | 
				
			||||||
STRIKE="\033[9m"
 | 
					STRIKE="\033[9m"
 | 
				
			||||||
ITALIC="\033[3m"
 | 
					ITALIC="\033[3m"
 | 
				
			||||||
FAINT="\033[2m"
 | 
					FAINT="\033[2m"
 | 
				
			||||||
 | 
					BOLD="\033[1m"
 | 
				
			||||||
 | 
					BG="\033[41m"
 | 
				
			||||||
OFF="\033[m"
 | 
					OFF="\033[m"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Style
 | 
				
			||||||
 | 
					# Calendar
 | 
				
			||||||
 | 
					export STYLE_CALENDAR_MONTH="$GREEN"
 | 
				
			||||||
 | 
					export STYLE_CALENDAR_WEEKDAYS="$FAINT"
 | 
				
			||||||
 | 
					export STYLE_CALENDAR_CURRENT_DAY="$BLACK$BG"
 | 
				
			||||||
 | 
					export STYLE_CALENDAR_HL_DAY="$BOLD$RED"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Week view
 | 
				
			||||||
 | 
					export STYLE_WV_DAY="$GREEN"
 | 
				
			||||||
 | 
					export STYLE_WV_EVENT_DELIM="$RED / $OFF"
 | 
				
			||||||
 | 
					export STYLE_WV_SUMMARY="$CYAN"
 | 
				
			||||||
 | 
					export STYLE_WV_TIME="$WHITE"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# List view
 | 
				
			||||||
 | 
					export STYLE_LV="$FAINT"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Day view
 | 
				
			||||||
 | 
					export STYLE_DV_ALLDAY="$LIGHT_CYAN$ITALIC$FAINT    (allday)   $OFF"
 | 
				
			||||||
 | 
					export STYLE_DV_TIME="$LIGHT_CYAN"
 | 
				
			||||||
 | 
					export STYLE_DV_CONFIRMED="$CYAN"
 | 
				
			||||||
 | 
					export STYLE_DV_TENTATIVE="$FAINT$CYAN"
 | 
				
			||||||
 | 
					export STYLE_DV_CANCELLED="$STRIKE$CYAN"
 | 
				
			||||||
 | 
					export STYLE_DV_HOUR="$FAINT"
 | 
				
			||||||
 | 
					export STYLE_DV_EMPTYHOUR="$FAINT----------------------$OFF"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Event preview
 | 
				
			||||||
 | 
					export STYLE_EPV_DATETIME="$CYAN"
 | 
				
			||||||
 | 
					export STYLE_EPV_LOCATION="$GREEN"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -61,7 +61,18 @@ __view_day() {
 | 
				
			|||||||
      printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" "$s" "$e" "$starttime" "$endtime" "$fpath" "$collection" "$description" "$status"
 | 
					      printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" "$s" "$e" "$starttime" "$endtime" "$fpath" "$collection" "$description" "$status"
 | 
				
			||||||
    done)
 | 
					    done)
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  echo "$sef" | sort -n | awk -v today="$today" -v daystart="$DAY_START" -v dayend="$DAY_END" "$AWK_DAYVIEW"
 | 
					  echo "$sef" | sort -n | awk \
 | 
				
			||||||
 | 
					    -v today="$today" \
 | 
				
			||||||
 | 
					    -v daystart="$DAY_START" \
 | 
				
			||||||
 | 
					    -v dayend="$DAY_END" \
 | 
				
			||||||
 | 
					    -v style_allday="$STYLE_DV_ALLDAY" \
 | 
				
			||||||
 | 
					    -v style_timerange="$STYLE_DV_TIME" \
 | 
				
			||||||
 | 
					    -v style_confirmed="$STYLE_DV_CONFIRMED" \
 | 
				
			||||||
 | 
					    -v style_tentative="$STYLE_DV_TENTATIVE" \
 | 
				
			||||||
 | 
					    -v style_cancelled="$STYLE_DV_CANCELLED" \
 | 
				
			||||||
 | 
					    -v style_hour="$STYLE_DV_HOUR" \
 | 
				
			||||||
 | 
					    -v style_emptyhour="$STYLE_DV_EMPTYHOUR" \
 | 
				
			||||||
 | 
					    "$AWK_DAYVIEW"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This function prints the view for the week that contains the day specified in `$DISPLAY_DATE`.
 | 
					# This function prints the view for the week that contains the day specified in `$DISPLAY_DATE`.
 | 
				
			||||||
@@ -127,7 +138,13 @@ __view_week() {
 | 
				
			|||||||
    echo "$sef"
 | 
					    echo "$sef"
 | 
				
			||||||
    seq 0 7
 | 
					    seq 0 7
 | 
				
			||||||
  } | sort -n)
 | 
					  } | sort -n)
 | 
				
			||||||
  echo "$sef" | awk -v startofweek="$startofweek" "$AWK_WEEKVIEW"
 | 
					  echo "$sef" | awk \
 | 
				
			||||||
 | 
					    -v startofweek="$startofweek" \
 | 
				
			||||||
 | 
					    -v style_day="$STYLE_WV_DAY" \
 | 
				
			||||||
 | 
					    -v style_event_delim="$STYLE_WV_EVENT_DELIM" \
 | 
				
			||||||
 | 
					    -v style_summary="$STYLE_WV_SUMMARY" \
 | 
				
			||||||
 | 
					    -v style_time="$STYLE_WV_TIME" \
 | 
				
			||||||
 | 
					    "$AWK_WEEKVIEW"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This function prints all entries.
 | 
					# This function prints all entries.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user