diff options
author | Tom Willemsen | 2012-10-01 00:35:05 +0200 |
---|---|---|
committer | Tom Willemsen | 2012-10-01 00:35:05 +0200 |
commit | ffcd87e06fd830aef5bbd9a2bd8877db8b98501d (patch) | |
tree | 7c406ca69eee234fa3e44e26a4b914b2f901938c | |
parent | dcd44d1e9379ffa181cc925d68a5951bc0fb2188 (diff) | |
download | undone-ffcd87e06fd830aef5bbd9a2bd8877db8b98501d.tar.gz undone-ffcd87e06fd830aef5bbd9a2bd8877db8b98501d.zip |
Make the <view> class do its work
I still need to rewrite the macros to work with this new style of
view.
-rw-r--r-- | undone/main.scm | 20 | ||||
-rw-r--r-- | undone/view.scm | 6 |
2 files changed, 11 insertions, 15 deletions
diff --git a/undone/main.scm b/undone/main.scm index 117e2c6..508a8f2 100644 --- a/undone/main.scm +++ b/undone/main.scm @@ -109,8 +109,6 @@ result) '())) -(define view-list '()) - (define (mkdirs path) (let ((parent (dirname path))) (if (not (file-exists? parent)) @@ -177,19 +175,17 @@ (cdr (assq 'state item)) (cdr (assq 'content item)))) -(define-view default - "Default todo-list view, show only the title." - "~2d ~a~%" id content) - (define (view args) "Show a list of todo items." (let* ((view-name (or (and (pair? args) (car args)) - "default")) + "view")) (view-symbol (string->symbol view-name)) (view-cons (assq view-symbol view-list)) - (view-func (if view-cons (cdr view-cons) '()))) - (if (procedure? view-func) - (apply view-func '())))) + (view-class (if view-cons (cdr view-cons) '()))) + (if (or (eq? <view> view-class) + (memq view-class (class-subclasses <view>))) + (print-view (make view-class #:todo-list todo-list)) + (format #t "Unknown view: ~a~%" view-name)))) (define (load-rc-file) "Load the RC file containing custom views and such." @@ -220,6 +216,4 @@ (lambda (view) (format #t "~a~20t~a~%" (car view) (procedure-documentation (cdr view)))) - view-list)))) - - (print-view (make <todo-view> #:todo-list todo-list))) + view-list))))) diff --git a/undone/view.scm b/undone/view.scm index dcd694a..ce1ef23 100644 --- a/undone/view.scm +++ b/undone/view.scm @@ -1,7 +1,7 @@ (define-module (undone view) #:use-module (oop goops) - #:export (<view> sort-view filter-view print-item get-list-for - print-view)) + #:export (<view> view-list sort-view filter-view print-item + get-list-for print-view)) (define-generic sort-view) (define-generic filter-view) @@ -12,6 +12,8 @@ (define-class <view> () (todo-list #:init-value '() #:init-keyword #:todo-list)) +(define view-list `((view . ,<view>))) + (define-method (sort-view (v <view>) l) l) (define-method (print-item (v <view>) item) |