some initial previewk lots ofs fixes

This commit is contained in:
2025-06-06 10:44:21 +02:00
parent 19c65d7ce1
commit 1fd35de475
3 changed files with 83 additions and 21 deletions

View File

@@ -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
View 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;
}