site-josuah

/usr/josuah
Log | Files | Refs

commit 9137196a137e1d58e7abd3116e80dd05e103c38b
parent 224ef40cd14ca6a5ef3d94a4ed713da7911d6db4
Author: Josuah Demangeon <me@josuah.net>
Date:   Thu, 25 Jun 2020 00:15:41 +0200

update jj-log

Diffstat:
Mwiki/jj/jj-log | 46+++++++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/wiki/jj/jj-log b/wiki/jj/jj-log @@ -7,7 +7,7 @@ function isleap(year) function mdays(mon, year) { - return (mon == 2) ? (28 + isleap(year)) : (30 + (mon + (mon > 7)) % 2) + return (mon == 2 ? 28 + isleap(year) : 30 + (mon + (mon > 7)) % 2) } function gmtime(sec, tm) @@ -17,31 +17,26 @@ function gmtime(sec, tm) tm["year"]++ sec -= s } - tm["mon"] = 1 while (sec >= (s = 86400 * mdays(tm["mon"], tm["year"]))) { tm["mon"]++ sec -= s } - tm["mday"] = 1 while (sec >= (s = 86400)) { tm["mday"]++ sec -= s } - tm["hour"] = 0 while (sec >= 3600) { tm["hour"]++ sec -= 3600 } - tm["min"] = 0 while (sec >= 60) { tm["min"]++ sec -= 60 } - tm["sec"] = sec } @@ -84,15 +79,15 @@ BEGIN { } $1 == "==>" { - sub(".log <==", "") - sub("/channels/", " ") - sub("/server$", " server") - sub(".*/", "") - sub(" ", "/") - printf("\n\n%s", $0) - fflush() - prev["nick"] = "" - next + sub(".log$", "", $2) + sub("/channels/", " ", $2) + sub("/server$", " server", $2) + sub(".*/", "", $2) + sub(" ", "/", $2) + if (prev["nick"]) + msg["chan"] = $2 + delete prev["nick"] + next } NF < 2 { @@ -121,28 +116,37 @@ index(msg["type"], "a") { msg["nick"] = "*" } +prev["chan"] != msg["chan"] { + printf("\n\nā”€ā”€ %s ", msg["chan"]) + for (i = length(msg["chan"]) + 4; i < 80; i++) + printf("ā”€") + fflush() +} + msg["nick"] == prev["nick"] { - nick = (msg["nick"] == "-") ? ("-") : ("") + nick = "" } msg["nick"] != prev["nick"] { - nick = msg["nick"] + nick = msg["nick"] ":" print "" } +msg["nick"] == "-" { + nick = "- " +} + prev["date"] != msg["date"] { printf("\n%s", msg["date"]) } { fold = fold_line(msg["text"], 66) - sp = (length(nick) > 10) ? ("") : (" ") - printf("\n\033[%sm%5s\033[m %10s %s%s", - color, msg["time"], nick, sp, fold) + printf("\n\033[%sm%5s\033[m %10s %s", color, msg["time"], nick, fold) color = "" while (msg["text"] = substr(msg["text"], length(fold) + 2)) { fold = fold_line(msg["text"], 66) - printf("\n%5s %10s %s", "", "", fold) + printf("\n%5s %10s %s", "", "", fold) } fflush()