Made show/hide cursor in the demo more resilient

Keeping track of state is hard!
This commit is contained in:
Howard Abrams 2024-10-30 22:04:06 -07:00
parent 9101e07990
commit 029a714bd7

View file

@ -175,8 +175,8 @@ Ive used [[https://github.com/takaxp/org-tree-slide][org-tree-slide]] for yea
(demo-it--presentation-display-restore) ; Restore previous changes (demo-it--presentation-display-restore) ; Restore previous changes
(setq org-hide-emphasis-markers t) (setq org-hide-emphasis-markers t)
(ha-demo-show-mode-line) (ha-demo-show-mode-line)
(ha-demo-normalize-frame)
(ha-demo-show-cursor) (ha-demo-show-cursor)
(ha-demo-normalize-frame)
(git-gutter-mode) (git-gutter-mode)
(text-scale-set 0) (text-scale-set 0)
(flycheck-mode) (flycheck-mode)
@ -348,44 +348,47 @@ The typical presentation software has an issue for hiding the cursor when workin
(defun ha-demo-hide-cursor () (defun ha-demo-hide-cursor ()
"Hide the cursor for the current frame." "Hide the cursor for the current frame."
(interactive) (interactive)
(setq ha-demo-cursor (unless ha-demo-cursor
(list cursor-type (setq ha-demo-cursor
t ; (when (boundp 'evil-default-cursor) evil-default-cursor) (list cursor-type
(when (boundp 'evil-emacs-state-cursor) evil-emacs-state-cursor) t ; (when (boundp 'evil-default-cursor) evil-default-cursor)
(when (boundp 'evil-normal-state-cursor) evil-normal-state-cursor) (when (boundp 'evil-emacs-state-cursor) evil-emacs-state-cursor)
(default-value blink-cursor-mode) (when (boundp 'evil-normal-state-cursor) evil-normal-state-cursor)
(when (display-graphic-p) (default-value blink-cursor-mode)
(frame-parameter (selected-frame) 'cursor-type)))) (when (display-graphic-p)
(frame-parameter (selected-frame) 'cursor-type))))
;; Turn off the cursor blinking minor mode: ;; Turn off the cursor blinking minor mode:
(blink-cursor-mode -1) (blink-cursor-mode -1)
;; Change the cursor types for normal and Evil states: ;; Change the cursor types for normal and Evil states:
(setq-local cursor-type nil) (setq-local cursor-type nil)
(when (boundp 'evil-default-cursor) (when (boundp 'evil-default-cursor)
(setq-local (setq-local
evil-default-cursor nil evil-default-cursor nil
evil-emacs-state-cursor nil evil-emacs-state-cursor nil
evil-normal-state-cursor nil)) evil-normal-state-cursor nil))
;; And most importantly, turn off the cursor for the selected frame: ;; And most importantly, turn off the cursor for the selected frame:
(set-frame-parameter (selected-frame) 'cursor-type nil)) (set-frame-parameter (selected-frame) 'cursor-type nil)))
(defun ha-demo-show-cursor () (defun ha-demo-show-cursor ()
"Restore cursor properties turned off by `ha-demo-hide-cursor'." "Restore cursor properties turned off by `ha-demo-hide-cursor'."
(interactive) (interactive)
(setq cursor-type (car ha-demo-cursor)) (when ha-demo-cursor
(setq cursor-type (car ha-demo-cursor))
(when (boundp 'evil-default-cursor) (when (boundp 'evil-default-cursor)
(setq-local (setq-local
evil-default-cursor (nth 1 ha-demo-cursor) evil-default-cursor (nth 1 ha-demo-cursor)
evil-emacs-state-cursor (nth 2 ha-demo-cursor) evil-emacs-state-cursor (nth 2 ha-demo-cursor)
evil-normal-state-cursor (nth 3 ha-demo-cursor))) evil-normal-state-cursor (nth 3 ha-demo-cursor)))
(when (nth 4 ha-demo-cursor) (blink-cursor-mode 1)) (when (nth 4 ha-demo-cursor) (blink-cursor-mode 1))
(set-frame-parameter (selected-frame) (set-frame-parameter (selected-frame)
'cursor-type (nth 5 ha-demo-cursor))) 'cursor-type (nth 5 ha-demo-cursor))
(setq ha-demo-cursor nil)))
#+END_SRC #+END_SRC
** Hide and Show the Modeline ** Hide and Show the Modeline