Correcting interactions, pause/unpause

master
Brady McDonough 2 years ago
parent c0ac4a551b
commit 4d7a451a3c

@ -49,7 +49,8 @@
;;; Code: ;;; Code:
;; TODOS: ;; TODOS: Buffer kill hook not triggered on exit?
;;
;; ;;
;; ERROR: timer shutdown seems to leave things in a wrong state and buffer doesn't die properly ;; ERROR: timer shutdown seems to leave things in a wrong state and buffer doesn't die properly
;; Check on the logic of push-current, needs predicates rather than lazy if conditions ;; Check on the logic of push-current, needs predicates rather than lazy if conditions
@ -379,30 +380,37 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
(time-add start-ts (time-add start-ts
(if (eq state 'work) (if (eq state 'work)
(tacc-work-period cycle) (tacc-work-period cycle)
(tacc-break-period cycle))))) (if (eq state 'break)
(tacc-break-period cycle))
0))))
;; 05.3 State manipulation ;; 05.3 State manipulation
(defun tacc-tick () (defun tacc-draw-buffer (now state)
"Time marches on. Called every second while a tacc timer is running" "Redraws the timer buffer and returns the calculated countdown seconds"
(let* ((now (current-time)) (let* ((cycle (alist-get 'cycle tacc-info))
(state (alist-get 'state tacc-info))
(cycle (alist-get 'cycle tacc-info))
(work-ts (alist-get 'work-ts tacc-info)) (work-ts (alist-get 'work-ts tacc-info))
(break-ts (alist-get 'break-ts tacc-info)) (break-ts (alist-gete 'break-ts tacc-info))
(est (tacc-est-ts state cycle work-ts break-ts)) (est (tacc-est-ts state cycle work-ts break-ts))
(countdown (time-subtract est now))) (countdown (time-subtract est now)))
(tacc-timer-buffer-update state est countdown now) (tacc-timer-buffer-update state est countdown now)
countdown))
(defun tacc-tick ()
"Time marches on. Called every second while a tacc timer is running"
(let* ((now (current-time))
(state (alist-get 'state tacc-info))
(countdown (tacc-draw-buffer now state)))
(if (functionp tacc-play-sound-file) (if (functionp tacc-play-sound-file)
(cond ((tacc-chime-p countdown) (cond ((tacc-chime-p countdown)
(funcall tacc-play-sound-file tacc-sound-chime)) (funcall tacc-play-sound-file tacc-sound-chime))
(t (funcall tacc-play-sound-file tacc-sound-tick)))))) (t (funcall tacc-play-sound-file tacc-sound-tick))))))
(defun tacc-timer-buffer-redraw () (defun tacc-timer-buffer-redraw ()
"Force a redraw of the timer buffer"
(let ((now (current-time)) (let ((now (current-time))
(state (alist-get 'state tacc-info))) (state (alist-get 'state tacc-info)))
(tacc-timer-buffer-update state))) (tacc-draw-buffer now state)))
;; TODO
(defun tacc-schedule () (defun tacc-schedule ()
"Note the time and schedule the first tick" "Note the time and schedule the first tick"
@ -737,8 +745,9 @@ Returns the current tag if no prompt is made"
(tacc-deschedule) (tacc-deschedule)
(tacc-push-current) (tacc-push-current)
(tacc-save-record (assoc 'history tacc-info)) (tacc-save-record (assoc 'history tacc-info))
(setcdr (assoc 'state tacc-info) 'stop) (setq tacc-info (tacc-info-initial))
(kill-buffer (tacc-buffer))))) (kill-buffer (tacc-buffer))
(tacc-cleanup-invariant))))
;; 09 Hooks setup ;; 09 Hooks setup
(add-hook 'after-init-hook 'tacc-load-tag-history) (add-hook 'after-init-hook 'tacc-load-tag-history)

Loading…
Cancel
Save