dot

packages and services management
Log | Files | Refs | README

commit 7a1e6882889ce25dcbc11f4a4abebb77c704222f
parent fcd0efa42f116e5ed4ee5fcfed825fd966a00aa7
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sun, 11 Mar 2018 20:37:17 +0100

VIEW converted

Diffstat:
Mbin/agenda | 24++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/bin/agenda b/bin/agenda @@ -90,13 +90,12 @@ function sort(array, beg, end) function view(line, nb, off) { sort(line, 1, nb); - for (i = 1; i < nb; i++) { + for (i = 1; i <= nb; i++) { sub("([^\t]*\t){" length(SORT) + 1 "}", "", line[i]); - print(line[i]); - cat = line[substr(line[i], 1, 1)]; + cat = substr(line[i], 1, 1); - if (cat ~ /^[BESCLD]:/) { + if (cat ~ /^[BESCLD]$/) { if (line[1] == "") line[cat] = substr(line[i], 3); else @@ -105,7 +104,7 @@ function view(line, nb, off) line["B"] = line["E"] = line["S"] = ""; line["C"] = line["L"] = line["D"] = ""; - } else if (cat == "") { + } else if (cat == ":") { display(last, line, off); } } @@ -194,6 +193,7 @@ BEGIN { } else if (system("test -f '" AGENDA "/" ARGV[1] "'") == 0) { VIEW = 1; FS = ":"; + NB = 1; SORT = ARGV[2] ? ARGV[2] : "BECLS"; ARGV[1] = AGENDA "/" ARGV[1] } else if (ARGV[1] == "-a") { @@ -236,26 +236,26 @@ IMPORT && /END:VEVENT/ { } VIEW && /^B:/ { - prev = nb + 1; + prev = NB; line["B"] = line["E"] = line["S"] = ""; line["C"] = line["L"] = line["D"] = ""; } VIEW && /^[BESCLD]:/ { - line[++nb] = sprintf("%08d\t%s", NR, $0); + line[NB++] = sprintf("%08d\t%s", NR, $0); line[$1] = substr($0, 3); } VIEW && /^:$/ { prefix = ""; - line[++nb] = sprintf("%08d\t:", NR); - for (i = length(SORT); i > 0; i--) - prefix = line[substr(SORT, i, 1)] "\t" prefix; - for (i = prev; i <= nb; i++) + line[NB++] = sprintf("%08d\t:", NR); + for (n = length(SORT); n > 0; n--) + prefix = line[substr(SORT, n, 1)] "\t" prefix; + for (i = prev; i < NB; i++) line[i] = sprintf("%s%s", prefix, line[i]); } END { if (VIEW) - view(line, nb, OFF); + view(line, NB, OFF); }