[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt d9da365a0f 320/323: Rework rainbow overlays t
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt d9da365a0f 320/323: Rework rainbow overlays to make them slightly more useful |
Date: |
Thu, 9 Mar 2023 10:59:00 -0500 (EST) |
branch: externals/beardbolt
commit d9da365a0fae008a725d42fd0c6947d66a544114
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Rework rainbow overlays to make them slightly more useful
* beardbolt.el (pulse): Require it.
(bb--rainbowize): Make a muted color.
(bb--recenter-maybe): Recenter to overlay.
(bb--synch-relation-overlays): Rework.
---
beardbolt.el | 92 +++++++++++++++++++++++++++++++++++++++---------------------
1 file changed, 60 insertions(+), 32 deletions(-)
diff --git a/beardbolt.el b/beardbolt.el
index 39833d3be1..0e87ac733f 100644
--- a/beardbolt.el
+++ b/beardbolt.el
@@ -36,6 +36,7 @@
(require 'disass)
(require 'json)
(require 'color)
+(require 'pulse)
;;; Code:
(defgroup beardbolt nil
@@ -464,17 +465,20 @@ some parts of the buffer and setup a buffer-local value of
(lambda (src-line asm-pos-regions)
(when (not (zerop src-line))
(cl-loop
- with color =
- (apply #'color-rgb-to-hex
- (color-hsl-to-rgb (mod (+ (cl-first background-hsl)
- (/ (cl-incf idx) (float total)))
- 1)
- (min (max (cl-second background-hsl)
- 0.25)
- 0.8)
- (min (max (cl-third background-hsl)
- 0.25)
- 0.8)))
+ with bright-hsl =(list (mod (+ (cl-first background-hsl)
+ (/ (cl-incf idx) (float total)))
+ 1)
+ (min (max (cl-second background-hsl)
+ 0.25)
+ 0.8)
+ (min (max (cl-third background-hsl)
+ 0.25)
+ 0.8))
+ with muted-hsl = (list (car bright-hsl)
+ (/ (cadr bright-hsl) 2.0)
+ (caddr bright-hsl))
+ with color = (apply #'color-rgb-to-hex (apply #'color-hsl-to-rgb
bright-hsl))
+ with muted-color = (apply #'color-rgb-to-hex (apply
#'color-hsl-to-rgb muted-hsl))
for (beg . end) in asm-pos-regions
for asm-ov = (make-overlay beg end)
do
@@ -482,7 +486,8 @@ some parts of the buffer and setup a buffer-local value of
(push asm-ov all-ovs)
(overlay-put asm-ov 'face `(:background ,color))
(overlay-put asm-ov 'beardbolt-rainbow-face `(:background ,color))
- (overlay-put asm-ov 'beardbolt t)
+ (overlay-put asm-ov 'beardbolt-muted-face `(:background
,muted-color))
+ (overlay-put asm-ov 'beardbolt 'asm)
collect asm-ov into this-lines-asm-overlays
finally
(with-current-buffer src-buffer
@@ -497,6 +502,7 @@ some parts of the buffer and setup a buffer-local value of
(overlay-put o 'beardbolt-related-overlays group))
(overlay-put ov 'face `(:background ,color))
(overlay-put ov 'beardbolt-rainbow-face `(:background ,color))
+ (overlay-put ov 'beardbolt-muted-face `(:background
,muted-color))
(overlay-put ov 'beardbolt t)
(push ov all-ovs)))))))
ht)
@@ -666,37 +672,59 @@ With prefix argument, choose from starter files in
`bb-starter-files'."
(find-file sandbox-file)
(bb-mode 1))))
-(defun bb--recenter-maybe (pos)
- (cl-loop for w in (cl-remove-if (lambda (w)
- (and (>= pos (* 1.1 (window-start w)))
- (<= pos (* 0.9 (window-end w)))))
- (get-buffer-window-list))
- unless (eq w (selected-window))
- do (set-window-point w pos)
- (with-selected-window w (recenter))))
+(defun bb--recenter-maybe (ov)
+ (bb--when-live-buffer (overlay-buffer ov)
+ (cl-loop with pos = (overlay-start ov)
+ for w in (cl-remove-if (lambda (w)
+ (and (>= pos (* 1.1 (window-start w)))
+ (<= pos (* 0.9 (window-end w)))))
+ (get-buffer-window-list))
+ unless (eq w (selected-window))
+ do (set-window-point w pos)
+ (with-selected-window w (recenter)))))
(defvar bb--currently-synched-overlays nil)
(defun bb--synch-relation-overlays ()
(let* ((at-point (overlays-at (point)))
- has-recentered
+ (all-ovs (if (eq major-mode 'bb--asm-mode)
+ bb--rainbow-overlays
+ (buffer-local-value 'bb--rainbow-overlays bb--asm-buffer)))
(ov (cl-find-if (lambda (ov) (overlay-get ov 'beardbolt-rainbow-face))
at-point)))
(cond ((and ov (not (member ov bb--currently-synched-overlays)))
- (dolist (oov bb--currently-synched-overlays)
- (overlay-put oov 'face (overlay-get ov 'beardbolt-rainbow-face)))
+ (dolist (o all-ovs)
+ (overlay-put o 'face (overlay-get o 'beardbolt-muted-face)))
(setq bb--currently-synched-overlays
(overlay-get ov 'beardbolt-related-overlays))
- (dolist (oov bb--currently-synched-overlays)
- (unless (or has-recentered
- (eq (overlay-buffer oov) (overlay-buffer ov)))
- (bb--when-live-buffer (overlay-buffer oov)
- (bb--recenter-maybe (overlay-start oov))
- (setq has-recentered t)))
- (overlay-put oov 'face 'bb-current-line-face)))
+ (setq bb--currently-synched-overlays
+ (cl-sort bb--currently-synched-overlays #'< :key
#'overlay-start))
+ (dolist (o bb--currently-synched-overlays)
+ (overlay-put o 'face 'bb-current-line-face))
+ (let* ((other-buffer-overlays
+ (cl-remove (current-buffer)
+ bb--currently-synched-overlays
+ :key #'overlay-buffer))
+ (recenter-target (car other-buffer-overlays))
+ (pulse-delay 0.01)
+ (asm-overlays
+ (cl-remove-if-not (lambda (ov)
+ (eq 'asm (overlay-get ov 'beardbolt)))
+ bb--currently-synched-overlays)))
+ (if (memq recenter-target asm-overlays)
+ (message "[beardbolt] maps to %s asm regions."
+ (length asm-overlays))
+ (message "[beardbolt] asm region %s/%s for source line %s."
+ (1+ (cl-position ov asm-overlays))
+ (length asm-overlays)
+ (with-current-buffer (overlay-buffer recenter-target)
+ (line-number-at-pos (overlay-start
recenter-target)))))
+ (bb--recenter-maybe recenter-target)
+ (pulse-momentary-highlight-overlay recenter-target
+ 'bb-current-line-face)))
((not ov)
- (dolist (ov bb--currently-synched-overlays)
- (overlay-put ov 'face (overlay-get ov 'beardbolt-rainbow-face)))
+ (dolist (o all-ovs)
+ (overlay-put o 'face (overlay-get o 'beardbolt-rainbow-face)))
(setq bb--currently-synched-overlays nil)))))
(defvar bb--change-timer nil)
- [elpa] externals/beardbolt 3b7a5bc85a 288/323: Simplify M-x beardbolt-starter. Less tmp directory cruft., (continued)
- [elpa] externals/beardbolt 3b7a5bc85a 288/323: Simplify M-x beardbolt-starter. Less tmp directory cruft., ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 2e9abdbcbf 293/323: fixup README tweak, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 93778d8391 298/323: Don't try any window scrolling heroics on recompile, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 12e926f66b 300/323: Correct local variable section of benchmark file, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 782febee77 307/323: Add new option bb-execute and simplify more code, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 13c51a99e0 309/323: Rework window management again. Not more like godbolt, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 27f10327f3 308/323: Rework window management. Not a bad alternative., ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt f260a62397 312/323: Refactor some behaviour for easier language definition, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 3b88b18029 316/323: Update README.md, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 08227684f5 317/323: Provide better local variable defaults for starter examples, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt d9da365a0f 320/323: Rework rainbow overlays to make them slightly more useful,
ELPA Syncer <=
- [elpa] externals/beardbolt 06fd5a1eee 323/323: * beardbolt.el (bb--guess-from-ccj): Don't mess with -O flags, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt e97b71e808 171/323: Re-work method to replace asm contents, ELPA Syncer, 2023/03/09