[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dslide 0af6dac584 076/230: contents highlight line
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dslide 0af6dac584 076/230: contents highlight line |
Date: |
Sun, 7 Jul 2024 19:00:17 -0400 (EDT) |
branch: elpa/dslide
commit 0af6dac584a122a8aa1ca24081a454b3b13c7b04
Author: Psionik K <73710933+psionic-k@users.noreply.github.com>
Commit: Psionik K <73710933+psionic-k@users.noreply.github.com>
contents highlight line
Re-using the users existing hl-line without at least a new face would be
annoying.
This implementation is better suited to the folding situation in org docs,
which
screws up display of :extend
Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com>
---
macro-slides.el | 52 +++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 49 insertions(+), 3 deletions(-)
diff --git a/macro-slides.el b/macro-slides.el
index 0c1c7d765f..668b1e53e2 100644
--- a/macro-slides.el
+++ b/macro-slides.el
@@ -354,6 +354,20 @@ an SLIDE_FILTER keyword."
:type 'function
:group 'macro-slides)
+(defcustom ms-contents-selection-highlight t
+ "Show a highlight on the selected headline.
+This is useful if you have some subtle cursor feature enabled for
+your presentation and wouldn't otherwise know what line you are
+on in the contents view. The default is also just a way more
+obvious display style."
+ :type 'boolean
+ :group 'macro-slides)
+
+(defface ms-contents-selection-face
+ '((t :inherit org-level-1 :inverse-video t :extend t))
+ "Face for highlighting the current slide root."
+ :group 'macro-slides)
+
(defvar ms--debug nil
"Set to t for logging slides and actions.")
@@ -375,6 +389,10 @@ coordinate with it.")
(defvar-local ms--header-overlay nil
"Flag to check the status of overlay for a slide header.")
+;; Shouldn't need one per buffer
+(defvar ms--contents-hl-line-overlay nil
+ "Highlights selected heading in contents view.")
+
;; * Classes
;; This generic functions below are the most important interfaces for all
@@ -2210,8 +2228,9 @@ and the value of `point-max' should contain a newline
somewhere."
(defun ms--cleanup-state ()
"Clean up states between contents and slides."
(ms--delete-header)
- (ms--delete-overlays)
- (ms--animation-cleanup))
+ (ms--delete-overlays)
+ (ms--animation-cleanup)
+ (remove-hook 'post-command-hook #'ms--contents-hl-line t))
(defun ms--ensure-deck ()
"Prepare for starting the minor mode.
@@ -2296,8 +2315,11 @@ hooks must occur in the deck's :slide-buffer."
(cancel-timer ms--animation-timer))
(when ms--animation-overlay
(delete-overlay ms--animation-overlay))
+ (when ms--contents-hl-line-overlay
+ (delete-overlay ms--contents-hl-line-overlay))
(setq ms--animation-overlay nil
- ms--animation-timer nil))
+ ms--animation-timer nil
+ ms--contents-hl-line-overlay nil))
(defun ms--ensure-slide-buffer (&optional display-action)
"Run in commands that must run in the slide buffer."
@@ -2414,6 +2436,27 @@ Optional ERROR if you want to process
`wrong-type-argument'."
(format "Class name not a class: %s" class-name))
nil))))
+;; * Contents Highlight Line
+
+;; Basically we need to use the post-command hook to update a line with our
+;; handy-dandy face. This is basically just a less feature-ful
re-implementation
+;; of hl-line. hl-line is kind of subtle and works across all buffers. This
is
+;; safer and defaults to the face attribute, :inverse-video, which is super
high
+;; contrast, good when navigating slide headlines like a menu.
+(defun ms--contents-hl-line ()
+ (unless ms--contents-hl-line-overlay
+ (setq ms--contents-hl-line-overlay
+ (make-overlay (point) (point)))
+ (overlay-put ms--contents-hl-line-overlay
+ 'face 'ms-contents-selection-face)
+ (overlay-put ms--contents-hl-line-overlay
+ 'priority 10))
+ (when-let ((element (org-element-at-point)))
+ (setf (overlay-start ms--contents-hl-line-overlay)
+ (1+ (org-element-property :begin element)))
+ (setf (overlay-end ms--contents-hl-line-overlay)
+ (org-element-property :end element))))
+
;; * Lifecycle
(defvar-keymap ms-mode-map
@@ -2478,6 +2521,9 @@ each slide show from the contents view."
(point-max)))
(ms--make-header t))
+ (when ms-contents-selection-highlight
+ (add-hook 'post-command-hook #'ms--contents-hl-line nil t))
+
;; TODO walk all headings with the filter and add overlays on the hidden
stuff
;; TODO filter slides that don't have a display action?
- [nongnu] elpa/dslide 7fbe8db983 005/230: compiler warning, unused variable, (continued)
- [nongnu] elpa/dslide 7fbe8db983 005/230: compiler warning, unused variable, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide cb31e38633 041/230: push-restriction uses markers, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 1766661399 037/230: comments & whitespace, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 14e4d670f3 045/230: !ugly Support arguments from heading properties =D, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 645c555272 036/230: minor fixes and no-effect changes, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 57838970e8 059/230: Debug feedback when slides change, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 23cbefa7b8 053/230: clean up begin marker during slide finalization, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide ca778812bf 077/230: Start at beginning of heading to implement end, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 1fb1a599b7 074/230: Ensure buffer before running forward and backward commands, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 4dcdb243b0 055/230: Copy EIEIO style from transient, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 0af6dac584 076/230: contents highlight line,
ELPA Syncer <=
- [nongnu] elpa/dslide 1a6fe7f61c 068/230: Just some readme and comment updates, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 198a80255b 072/230: move lifecycle & commands to end of package, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide f130bedeab 078/230: Update readme, rearrange some demo headlines, bump minor version, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 0a59731410 075/230: Navigation from contents to same heading, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide dc5d0b965e 119/230: disinformation cleanup, a few lingering ms symbols, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide a8f7174ef3 095/230: dead expression, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide f24e5b8538 088/230: Rename argument, display-action -> display, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 18e079c83f 113/230: Clean up misinformation & propagate naming, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 4af6955e23 090/230: missing feedback on last slide, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 8bc5783536 051/230: Sorry taka. It's been a good 13 years of org-tree-slide, ELPA Syncer, 2024/07/07