From c1cbef6611df9c8918fee8699b5867d8a54ac810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 17 Aug 2020 18:13:58 +0200 Subject: even more. --- module/output/common.scm | 32 ------------------------------- module/output/general.scm | 22 --------------------- module/util.scm | 7 +++++++ module/vcomponent/base.scm | 5 +++++ module/vcomponent/ical/output.scm | 9 +++++++++ module/vcomponent/recurrence/internal.scm | 6 ------ 6 files changed, 21 insertions(+), 60 deletions(-) delete mode 100644 module/output/common.scm delete mode 100644 module/output/general.scm diff --git a/module/output/common.scm b/module/output/common.scm deleted file mode 100644 index 84a2f77e..00000000 --- a/module/output/common.scm +++ /dev/null @@ -1,32 +0,0 @@ -;;; Commentary: -;; Common code between all serializers. -;; (ical and xcal). Not for graphical output stuff. -;;; Code: - -(define-module (output common) - :use-module (util) - :use-module (srfi srfi-1) - :use-module (vcomponent) - ) - - -(define*-public (internal-field? symbol optional: (prefix "-")) - (string=? prefix - (string-take-to (symbol->string symbol) - (string-length prefix)))) - -(define-public (get-tz-names events) - (lset-difference - equal? (lset-union - equal? '("dummy") - (filter-map - (lambda (vline) (and=> (param vline 'TZID) car)) - (filter-map (extract* 'DTSTART) - events))) - '("dummy" "local"))) - -(define-public (downcase-symbol symb) - (-> symb - symbol->string - string-downcase - string->symbol)) diff --git a/module/output/general.scm b/module/output/general.scm deleted file mode 100644 index 2e0e77c6..00000000 --- a/module/output/general.scm +++ /dev/null @@ -1,22 +0,0 @@ -(define-module (output general) - ) - -;; Returns a color with good contrast to the given background color. -;; https://stackoverflow.com/questions/1855884/determine-font-color-based-on-background-color/1855903#1855903 -(define-public (calculate-fg-color c) - (catch #t - (lambda () - (define (str->num c n) (string->number (substring/shared c n (+ n 2)) 16)) - ;; (format (current-error-port) "COLOR = ~s~%" c) - (let ((r (str->num c 1)) - (g (str->num c 3)) - (b (str->num c 5))) - (if (< 1/2 (/ (+ (* 0.299 r) - (* 0.587 g) - (* 0.114 b)) - #xFF)) - "#000000" "#FFFFFF"))) - (lambda args - (format (current-error-port) "Error calculating foreground color?~%~s~%" args) - "#FF0000" - ))) diff --git a/module/util.scm b/module/util.scm index 17400c3b..e2acd551 100644 --- a/module/util.scm +++ b/module/util.scm @@ -309,6 +309,13 @@ (define-public (as-symb s) (if (string? s) (string->symbol s) s)) +(define-public (downcase-symbol symb) + (-> symb + symbol->string + string-downcase + string->symbol)) + + (define-public (enumerate lst) (zip (iota (length lst)) lst)) diff --git a/module/vcomponent/base.scm b/module/vcomponent/base.scm index 7b81fb05..47815a0e 100644 --- a/module/vcomponent/base.scm +++ b/module/vcomponent/base.scm @@ -189,3 +189,8 @@ (define-public (x-property? symb) (string=? "X-" (string-take (symbol->string symb) 2))) + +(define*-public (internal-field? symbol optional: (prefix "-")) + (string=? prefix + (string-take-to (symbol->string symbol) + (string-length prefix)))) diff --git a/module/vcomponent/ical/output.scm b/module/vcomponent/ical/output.scm index eead035b..ff5465c6 100644 --- a/module/vcomponent/ical/output.scm +++ b/module/vcomponent/ical/output.scm @@ -199,6 +199,15 @@ CALSCALE:GREGORIAN\r (define (print-footer) (format #t "END:VCALENDAR\r\n")) +(define (get-tz-names events) + (lset-difference + equal? (lset-union + equal? '("dummy") + (filter-map + (lambda (vline) (and=> (param vline 'TZID) car)) + (filter-map (extract* 'DTSTART) + events))) + '("dummy" "local"))) (define-public (print-components-with-fake-parent events) diff --git a/module/vcomponent/recurrence/internal.scm b/module/vcomponent/recurrence/internal.scm index aab65959..502f588f 100644 --- a/module/vcomponent/recurrence/internal.scm +++ b/module/vcomponent/recurrence/internal.scm @@ -116,12 +116,6 @@ rrule) ";")) -(define (downcase-symbol symb) - (-> symb - symbol->string - string-downcase - string->symbol)) - (define-public (recur-rule->rrule-sxml rrule) (map-fields (lambda (field value) -- cgit v1.2.3