some initial previewk lots ofs fixes
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
# 11:00|13:00|1748422800|1748430000|fpath|desc...
|
||||
# 00:00|00:00|1748296800|1748383200|fpath|desc...
|
||||
function allday() {
|
||||
return ITALIC FAINT " (allday) " OFF $4
|
||||
return ITALIC FAINT " (allday) " OFF $6
|
||||
}
|
||||
function endstoday() {
|
||||
return CYAN " -- " $2 OFF ": " $4
|
||||
return CYAN " -- " $2 OFF ": " $6
|
||||
}
|
||||
function slice() {
|
||||
if ($2 == "00:00")
|
||||
return CYAN $1 " -- " OFF ": " $4
|
||||
return CYAN $1 " -- " OFF ": " $6
|
||||
else
|
||||
return CYAN $1 OFF " -- " CYAN $2 OFF ": " $4
|
||||
return CYAN $1 OFF " -- " CYAN $2 OFF ": " $6
|
||||
}
|
||||
BEGIN {
|
||||
FS = "|";
|
||||
@@ -21,8 +23,8 @@ BEGIN {
|
||||
OFF = "\033[m";
|
||||
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 }
|
||||
$1 == hour":00" { print $3, slice(); unset hour; next }
|
||||
$1 == "00:00" && $2 == "00:00" { print $3, allday(); next }
|
||||
$1 == "00:00" { print $3, endstoday();next }
|
||||
$1 == hour":00" { print $1, $3, $4, $5, slice(); unset hour; next }
|
||||
$1 == "00:00" && $2 == "00:00" { print $1, $3, $4, $5, allday(); 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;
|
||||
}
|
Reference in New Issue
Block a user