[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dslide 2ec658ec9e 162/230: reverse-in-place for children
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dslide 2ec658ec9e 162/230: reverse-in-place for children |
Date: |
Sun, 7 Jul 2024 19:00:31 -0400 (EDT) |
branch: elpa/dslide
commit 2ec658ec9eea8e577699b430a802fb3e73788323
Author: Psionik K <73710933+psionic-k@users.noreply.github.com>
Commit: Psionik K <73710933+psionic-k@users.noreply.github.com>
reverse-in-place for children
Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com>
---
dslide.el | 54 +++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 41 insertions(+), 13 deletions(-)
diff --git a/dslide.el b/dslide.el
index 789cc972b2..b8f80c305d 100644
--- a/dslide.el
+++ b/dslide.el
@@ -1607,10 +1607,23 @@ stateful-sequence class methods. METHOD-NAME is a
string."
"Base class for child actions."
:abstract t)
-(cl-defmethod dslide-deck-forward-child ((obj dslide-action))
- "Advance OBJ's marker while returning next child heading.
-Marker is moved to the end of OBJ's heading if no matching
-child is found."
+(cl-defmethod dslide-child-next ((obj dslide-action)
+ &optional reverse-in-place)
+ "Return the next direct child heading element.
+Only matches headings beginning after the marker stored in the
+action OBJ. Moves the marker forward to the beginning of the
+matched heading or to the end of heading.
+
+Optional REVERSE-IN-PLACE is used when changing directions should
+return the same heading, meaning your action reverses in-place.
+Hiding and revealing list items works this way. When non-nil,
+matches can include headings starting at the action's marker, and
+the marker is moved to the end rather than beginning of an
+heading.
+
+The action's marker is moved to the end of the heading if no
+matching heading is found. This allows a subsequent backwards
+step to process the last heading."
(if-let* ((marker (dslide-marker obj))
(heading (dslide-heading obj))
(target-level (1+ (org-element-property :level heading)))
@@ -1618,18 +1631,31 @@ child is found."
heading 'headline
(lambda (child)
(and (= target-level (org-element-property :level child))
- (> (org-element-property :begin child) marker)
+ (funcall (if reverse-in-place #'>= #'>)
+ (org-element-property :begin child) marker)
child))
nil t)))
(prog1 next
- (dslide-marker obj (org-element-property :begin next)))
+ (dslide-marker obj (org-element-property
+ (if reverse-in-place :end :begin) next)))
(dslide-marker obj (org-element-property :end (dslide-heading obj)))
nil))
-(cl-defmethod dslide-deck-backward-child ((obj dslide-action))
- "Advance OBJ's marker backward while returning previous child.
-Marker is moved to the beginning of OBJ's heading if no matching
-child is found."
+(cl-defmethod dslide-child-previous ((obj dslide-action)
+ &optional reverse-in-place)
+ "Return the previous direct child heading element.
+Only matches child headings beginning before the marker stored in
+the action, OBJ. Moves the marker backward to the beginning of
+the returned heading or the beginning of OBJ's heading.
+
+Optional REVERSE-IN-PLACE is used when changing directions should
+return the same heading, meaning your action reverses in-place.
+hiding and revealing list items works this way. When non-nil,
+matches can include headings starting at the action's marker.
+
+Marker is moved to the beginning of the heading if no matching
+heading is found. This allows actions to differentiate the begin
+state from being at the first child heading."
(if-let* ((marker (dslide-marker obj))
(heading (dslide-heading obj))
(target-level (1+ (org-element-property :level heading)))
@@ -1640,7 +1666,9 @@ child is found."
heading 'headline
(lambda (child)
(and (= target-level (org-element-property :level
child))
- (< (org-element-property :begin child) marker)
+ (funcall
+ (if reverse-in-place #'<= #'<)
+ (org-element-property :begin child) marker)
child)))))))
(prog1 next
(dslide-marker obj (org-element-property :begin next)))
@@ -1664,7 +1692,7 @@ child is found."
(dslide-final child)
(oset obj child nil)))
(unless progress
- (when-let ((child (dslide-deck-forward-child obj)))
+ (when-let ((child (dslide-child-next obj)))
;; TODO transitive action customization
(let ((child (dslide--make-slide child (oref dslide--deck slide))))
(dslide-begin child)
@@ -1682,7 +1710,7 @@ child is found."
(dslide-final child)
(oset obj child nil)))
(unless progress
- (when-let ((child (dslide-deck-backward-child obj)))
+ (when-let ((child (dslide-child-previous obj)))
;; TODO transitive action customization
(let ((child (dslide--make-slide child (oref dslide--deck slide))))
(dslide-end child)
- [nongnu] elpa/dslide 5956b98172 132/230: :results none in babel. really wish I could let-bind this, (continued)
- [nongnu] elpa/dslide 5956b98172 132/230: :results none in babel. really wish I could let-bind this, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide fe63ace5ca 144/230: empty presentation for test suite, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 92b39b410f 131/230: interesting bug in custom action, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 7f578b605a 130/230: old name left over, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 40b4bfe353 147/230: multiple animation overlays, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 91b8fcaf92 153/230: introducing dslide-deck-develop, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 64dc89cd0f 156/230: allow explicit 'none for slide action class, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 93585c9173 158/230: slide composition order change (soon to refactor), ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 00597b9770 155/230: customization reminders in the demo, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 77126167a3 159/230: remove extraneous method qualifiers, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 2ec658ec9e 162/230: reverse-in-place for children,
ELPA Syncer <=
- [nongnu] elpa/dslide a58a915104 163/230: understand progress from org elements, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 586082e591 165/230: set overlay initial height, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 6cf49d2625 181/230: Oh yeah, seq-find doesn't return the result, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 935224a638 182/230: ! introducing peel animation, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 217ddbe03e 185/230: a bit better display behavior, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 3a77163b15 188/230: ! hide markup action, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 04b2888a52 192/230: Hide markup action hides affiliated keywords, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide 7ae80ecdca 194/230: cleaning up light misinformation, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide df98f4e5c2 197/230: remove babel results, ELPA Syncer, 2024/07/07
- [nongnu] elpa/dslide cdf8d97eb6 198/230: hide non-exporting babel, ELPA Syncer, 2024/07/07