Make the <view> class do its work
I still need to rewrite the macros to work with this new style of view.
This commit is contained in:
parent
dcd44d1e93
commit
ffcd87e06f
2 changed files with 11 additions and 15 deletions
|
@ -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)))))
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue