Display tasks as presentation types

This commit is contained in:
contrapunctus 2022-04-11 22:42:47 +05:30
parent b9417d6a25
commit 0831ae82d5
1 changed files with 63 additions and 22 deletions

View File

@ -2396,40 +2396,81 @@ s-expressions in a text column.")
**** chronometrist :application:frame:
#+BEGIN_SRC lisp
(define-application-frame chronometrist ()
((%table :initform nil
:initarg :table
:accessor table)
(%total :initform nil
:initarg :total
:accessor total))
(define-application-frame chronometrist () ()
(:pointer-documentation t)
(:panes (app :application
:height (graft-height (find-graft))
:width (graft-width (find-graft))
:display-function 'display
:background +black+
:foreground +white+)
(:panes (task-duration :application
:height (graft-height (find-graft))
:width (graft-width (find-graft))
:display-function 'display
:background +black+
:foreground +white+)
(int :interactor
:background +black+
:foreground +white+))
(:layouts (default (vertically () app int))))
(:layouts (default (vertically () task-duration int))))
#+END_SRC
**** display :function:
**** *table-specification* :custom:variable:
1. column name (unique symbol)
2. column label (string)
3. (optional) functions - called with row data as a list
#+BEGIN_SRC lisp
(defun display (frame pane)
(defvar *table-specification*
'((index "#")
(task "Task")
(duration "Time")
(activity-indicator "Active")))
#+END_SRC
**** table-function :function:
#+BEGIN_SRC lisp
#+(or)
(defun table-function (table-specification)
(loop for col-spec in *table-specification*
for (sym str) in *table-specification*
for index from 1
collect (cond ((eq sym 'index) index)
(()))))
#+END_SRC
**** display
***** display :function:
#+BEGIN_SRC lisp
(defun display (frame stream)
(display-pane frame stream (pane-name stream)))
#+END_SRC
***** task-name :class:
#+BEGIN_SRC lisp
(defclass task-name () ())
#+END_SRC
***** display-pane :generic:function:
#+BEGIN_SRC lisp
(defgeneric display-pane (frame stream pane-name)
(:documentation "Display Chronometrist application panes."))
#+END_SRC
***** display-pane :method:
#+BEGIN_SRC lisp
(defmethod display-pane (frame pane (pane-name (eql 'task-duration)))
(declare (ignorable frame pane pane-name))
;; (format *debug-io* "*application-frame*: ~a~%" *application-frame*)
(let ((stream *standard-output*)
(task-list (chronometrist:task-list)))
(formatting-table (stream)
(loop for task in task-list
for index from 1
do (formatting-row (stream)
(formatting-cell (stream)
(format stream "~2@A" index))
(formatting-cell (stream)
(format stream "~A" task)))))))
for index from 1 do
(formatting-row (stream)
(formatting-cell (stream)
(format t "~2@A" index))
(formatting-cell (stream)
(with-output-as-presentation (pane task 'task-name)
(format t "~A" task)))
;; (formatting-cell (stream)
;; )
)))))
#+END_SRC
**** refresh :command: