aboutsummaryrefslogtreecommitdiff
path: root/module/output/terminal.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2020-01-22 00:00:10 +0100
committerHugo Hörnquist <hugo@hornquist.se>2020-01-22 00:06:36 +0100
commitcc4bf12c19003cc06824c34eb96aaae8df368a0b (patch)
treef7ad9ba4603c3051a918f11f8ef8459f6917e5af /module/output/terminal.scm
parentAdd normilze-date/tz. (diff)
downloadcalp-cc4bf12c19003cc06824c34eb96aaae8df368a0b.tar.gz
calp-cc4bf12c19003cc06824c34eb96aaae8df368a0b.tar.xz
Fix basic ability to edit events.
Diffstat (limited to 'module/output/terminal.scm')
-rw-r--r--module/output/terminal.scm56
1 files changed, 31 insertions, 25 deletions
diff --git a/module/output/terminal.scm b/module/output/terminal.scm
index 5ab70aa8..8b113c82 100644
--- a/module/output/terminal.scm
+++ b/module/output/terminal.scm
@@ -38,17 +38,25 @@
(location-width 20))
(for-each
(lambda (ev i)
- (format #t "~a │ ~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)) summary-width)
- STR-RESET
- (if (attr ev 'LOCATION) "" "\x1b[1;30m")
- (trim-to-width
- (or (attr ev 'LOCATION) "INGEN LOKAL") location-width)
- STR-RESET))
+ (display
+ (string-append
+ (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
+ (let ((dirty (attr ev 'X-HNH-DIRTY)))
+ (string-append
+ (if dirty "* " "")
+ (trim-to-width ((summary-filter) ev (attr ev 'SUMMARY)) (- summary-width
+ (if dirty 2 0)))))
+ STR-RESET
+ " │ "
+ (if (attr ev 'LOCATION) "" "\x1b[1;30m")
+ (trim-to-width
+ (or (attr ev 'LOCATION) "INGEN LOKAL") location-width)
+ STR-RESET
+ "\n")))
events
(iota (length events))))
@@ -126,20 +134,18 @@
(with-output-to-file fname
(lambda () (serialize-vcomponent (list-ref events cur-event))))
(open-in-editor fname)
- (with-input-from-file fname
- (lambda ()
- ;; TODO readinig back this partal vcomponent somehow fails.
- ;; TODO Create a "display-in-parent" procedure, which takes a vcomponent
- ;; and displays it within the context of it's parents, N steps up.
- ;; This is different that display on parent since that would also
- ;; display all our siblings, which is not always wanted.
- (let ((ev ((@ (vcomponent primitive) %vcomponent-make) fname)))
- (serialize-vcomponent ev (current-error-port))
-
- (add-child! (parent (list-ref events cur-event)) ev)
- (format (current-error-port) "Children: ~a~%start: ~a~%" (children ev)
- (attr ev 'DTSTART))
- (set! event-stream (stream-insert ev-time<? ev event-stream)))))))
+ (let ((ev (parse-cal-path fname)))
+ (serialize-vcomponent ev (current-error-port))
+
+ ;; TODO remove child
+
+ (add-child! (parent (list-ref events cur-event)) ev)
+ (format (current-error-port) "Children: ~a~%start: ~a~%" (children ev)
+ (attr ev 'DTSTART))
+ (set! (attr ev 'X-HNH-DIRTY) #t)
+ (set! event-stream (stream-insert ev-time<? ev event-stream))
+ (set! grouped-stream (group-stream event-stream))
+ )))
((#\g) (set! cur-event 0))
((#\G) (set! cur-event (1- (length events)))))