aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-17 18:13:58 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-17 18:13:58 +0200
commitc1cbef6611df9c8918fee8699b5867d8a54ac810 (patch)
tree46ab04d457eda5e7c0873efe3480d5c68ef1d4c2
parentGot type files out of output. (diff)
downloadcalp-c1cbef6611df9c8918fee8699b5867d8a54ac810.tar.gz
calp-c1cbef6611df9c8918fee8699b5867d8a54ac810.tar.xz
even more.
-rw-r--r--module/output/common.scm32
-rw-r--r--module/output/general.scm22
-rw-r--r--module/util.scm7
-rw-r--r--module/vcomponent/base.scm5
-rw-r--r--module/vcomponent/ical/output.scm9
-rw-r--r--module/vcomponent/recurrence/internal.scm6
6 files changed, 21 insertions, 60 deletions
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)