From 79f7122a66ea7f02c5d0ba128363f0ea35983ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 22 Apr 2019 18:33:12 +0200 Subject: General cleanup. --- module/main.scm | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'module/main.scm') diff --git a/module/main.scm b/module/main.scm index a83f651f..1b38e6e2 100755 --- a/module/main.scm +++ b/module/main.scm @@ -51,6 +51,22 @@ (define (displayln a) (display a) (newline)) +(define (display-event-table events) + (for-each + (lambda (ev i) + (format #t "~a │ ~a~a~a~a │ ~a~a~%" + (time->string (attr ev 'DTSTART) "~1 ~3") ; TODO show truncated string + (if (= i cur-event) "\x1b[7m" "") + (color-escape (attr (parent ev) 'COLOR)) + ;; Summary filter is a hook for the user + (trim-to-width (summary-filter ev (attr ev 'SUMMARY)) 30) + STR-RESET + (trim-to-width + (or (attr ev 'LOCATION) "\x1b[1;30mINGEN LOKAL") 20) + STR-RESET)) + events + (iota (length events)))) + (define (summary-filter _ str) str) (define (main-loop event-stream) @@ -65,24 +81,9 @@ (cls) (display-calendar-header! (time-utc->date time)) - ;; (line) - (displayln (box-top #\┬ #\─ 20 32 10)) - - (for-each - (lambda (ev i) - (format #t "~a │ ~a~a~a~a │ ~a~a~%" - (time->string (attr ev 'DTSTART) "~1 ~3") ; TODO show truncated string - (if (= i cur-event) "\x1b[7m" "") - (color-escape (attr (parent ev) 'COLOR)) - ;; Summary filter is a hook for the user - (trim-to-width (summary-filter ev (attr ev 'SUMMARY)) 30) - STR-RESET - (trim-to-width - (or (attr ev 'LOCATION) "\x1b[1;30mINGEN LOKAL") 20) - STR-RESET)) - events - (iota (length events))) + (displayln (box-top #\┬ #\─ 20 32 10)) + (display-event-table events) (displayln (box-top #\┴ #\─ 20 32 10)) (unless (null? events) @@ -160,4 +161,5 @@ ;; (with-vulgar ;; (lambda () (main-loop events))))) ((@ (sxml simple) sxml->xml) (init html-main)) + (newline) ) -- cgit v1.2.3