improvement: Calendar preview: weeks start on Mondays
This commit is contained in:
19
src/awk/calshift.awk
Normal file
19
src/awk/calshift.awk
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
BEGIN {
|
||||||
|
ORS = ""
|
||||||
|
W3 = " "
|
||||||
|
W17 = W3 W3 W3 W3 W3 " "
|
||||||
|
}
|
||||||
|
NR == 1 { i++; print $0 "\n"; next }
|
||||||
|
NR == 2 { i++; print substr($0, 4, 17) " " substr($0, 1, 3) " \n"; next }
|
||||||
|
NR == 3 && /^ 1/ { print W17; }
|
||||||
|
NR == 3 && /^ / { print substr($0, 4, 17); next }
|
||||||
|
/[0-9]/ {
|
||||||
|
i++
|
||||||
|
print " " substr($0, 1, 3) " \n" substr($0, 4, 17)
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
i++
|
||||||
|
print " " W3 " \n"
|
||||||
|
for (i; i<8; i++)
|
||||||
|
print " " W17 W3 " \n"
|
||||||
|
}
|
30
src/main.sh
30
src/main.sh
@@ -137,7 +137,8 @@ fi
|
|||||||
# Print preview of week.
|
# Print preview of week.
|
||||||
#
|
#
|
||||||
# @input $2: Line from week view
|
# @input $2: Line from week view
|
||||||
# @req $AWK_CAL: Awk script to annotate calendar
|
# @req $AWK_CALSHIFT: Awk script to make `cal` output to start on Mondays
|
||||||
|
# @req $AWK_CALANNOT: Awk script to annotate calendar
|
||||||
if [ "${1:-}" = "--preview-week" ]; then
|
if [ "${1:-}" = "--preview-week" ]; then
|
||||||
sign=$(echo "$2" | cut -d '|' -f 1)
|
sign=$(echo "$2" | cut -d '|' -f 1)
|
||||||
if [ "$sign" = "+" ]; then
|
if [ "$sign" = "+" ]; then
|
||||||
@@ -188,12 +189,12 @@ if [ "${1:-}" = "--preview-week" ]; then
|
|||||||
fi
|
fi
|
||||||
# show
|
# show
|
||||||
(
|
(
|
||||||
cal "$month_pre2" "$year_pre2" | awk -v cur="${var_pre2:-}" "$AWK_CAL"
|
cal "$month_pre2" "$year_pre2" | awk "$AWK_CALSHIFT" | awk -v cur="${var_pre2:-}" "$AWK_CALANNOT"
|
||||||
cal "$month_pre" "$year_pre" | awk -v cur="${var_pre:-}" "$AWK_CAL"
|
cal "$month_pre" "$year_pre" | awk "$AWK_CALSHIFT" | awk -v cur="${var_pre:-}" "$AWK_CALANNOT"
|
||||||
cal "$month" "$year" | awk -v cur="${var:-}" -v day="$day" "$AWK_CAL"
|
cal "$month" "$year" | awk "$AWK_CALSHIFT" | awk -v cur="${var:-}" -v day="$day" "$AWK_CALANNOT"
|
||||||
cal "$month_nex" "$year_nex" | awk -v cur="${var_nex:-}" "$AWK_CAL"
|
cal "$month_nex" "$year_nex" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex:-}" "$AWK_CALANNOT"
|
||||||
cal "$month_nex2" "$year_nex2" | awk -v cur="${var_nex2:-}" "$AWK_CAL"
|
cal "$month_nex2" "$year_nex2" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex2:-}" "$AWK_CALANNOT"
|
||||||
cal "$month_nex3" "$year_nex3" | awk -v cur="${var_nex3:-}" "$AWK_CAL"
|
cal "$month_nex3" "$year_nex3" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex3:-}" "$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
|
||||||
@@ -448,7 +449,8 @@ fi
|
|||||||
###
|
###
|
||||||
### AWK scripts
|
### AWK scripts
|
||||||
### AWK_APPROX: Generate approximate data of all files
|
### AWK_APPROX: Generate approximate data of all files
|
||||||
### AWK_CAL: Annotate output of `cal`
|
### AWK_CALSHIFT: Shift calendar to start weeks on Mondays
|
||||||
|
### AWK_CALANNOT: Annotate calendar
|
||||||
### AWK_DAYVIEW: Generate view of the day
|
### AWK_DAYVIEW: Generate view of the day
|
||||||
### AWK_GET: Print field of iCalendar file
|
### AWK_GET: Print field of iCalendar file
|
||||||
### AWK_MERGE: Generate list of weeks with associated iCalendar files
|
### AWK_MERGE: Generate list of weeks with associated iCalendar files
|
||||||
@@ -507,9 +509,15 @@ AWK_NEW=$(
|
|||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
AWK_CAL=$(
|
AWK_CALSHIFT=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include src/awk/cal.awk
|
@@include src/awk/calshift.awk
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
AWK_CALANNOT=$(
|
||||||
|
cat <<'EOF'
|
||||||
|
@@include src/awk/calannot.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -882,7 +890,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_CAL CYAN WHITE ITALIC OFF
|
export ROOT CAT AWK_GET AWK_CALSHIFT AWK_CALANNOT CYAN WHITE ITALIC OFF
|
||||||
# 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
|
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
|
||||||
|
Reference in New Issue
Block a user