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/html/html.scm | 2 +- module/main.scm | 36 +++++++++++++++++++----------------- module/srfi/srfi-19/util.scm | 7 ++++--- 3 files changed, 24 insertions(+), 21 deletions(-) (limited to 'module') diff --git a/module/html/html.scm b/module/html/html.scm index 93977106..d81faaaf 100644 --- a/module/html/html.scm +++ b/module/html/html.scm @@ -38,7 +38,7 @@ #f (let* ((pred? (lambda (next) (timestring (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) ) diff --git a/module/srfi/srfi-19/util.scm b/module/srfi/srfi-19/util.scm index f9453820..551f5a12 100644 --- a/module/srfi/srfi-19/util.scm +++ b/module/srfi/srfi-19/util.scm @@ -54,6 +54,8 @@ attribute set to 0. Can also be seen as \"Start of day\"" (define* (time->string time #:optional (format "~1 ~3")) (date->string (time-utc->date time) format)) +;; TODO these ({add,remove}-day} might have problem moving between timezones. + (define (add-day time) (add-duration time (make-duration (* 60 60 24)))) @@ -99,14 +101,13 @@ attribute set to 0. Can also be seen as \"Start of day\"" (lambda (d) (set! (day d) (1+ (day d))) (normalize-date d)) - start-day)) + (#; drop-time identity start-day + ))) (define-public (in-date-range? start-date end-date) (format (current-error-port) "Start: ~a~%End: ~a~%" (date->string start-date) (date->string end-date)) (lambda (date) - (format (current-error-port) "Date: ~a~%" - (date->string date "~1")) (let ((time (date->time-utc date))) (timespan-overlaps? (date->time-utc start-date) (date->time-utc end-date) -- cgit v1.2.3