[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/indent-bars 213033e60e 100/431: Allow :blend by itself
From: |
ELPA Syncer |
Subject: |
[elpa] externals/indent-bars 213033e60e 100/431: Allow :blend by itself for current depth |
Date: |
Mon, 16 Sep 2024 12:59:18 -0400 (EDT) |
branch: externals/indent-bars
commit 213033e60e567d1fc455fcd9fcd01d5c372c585c
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
Allow :blend by itself for current depth
Re-blends main or depth-based colors
---
indent-bars.el | 101 ++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 60 insertions(+), 41 deletions(-)
diff --git a/indent-bars.el b/indent-bars.el
index ab63129eea..4a9f825591 100644
--- a/indent-bars.el
+++ b/indent-bars.el
@@ -250,22 +250,30 @@ Format:
If nil, no highlighting will be applied to bars at the current
depth of the line at point. Otherwise, a plist describes what
highlighting to apply, which can include changes to color and/or
-bar pattern. At least one of :color, :face, :width, :pad,
-:pattern, or :zigzag must be set and non-nil for this setting to
-take effect.
-
-With COLOR or FACE set, all bars at the current depth will be
-highlighted in the appropriate color, either COLOR, or, if FACE
-is set, FACE's foreground or background color (the latter if
-FACE-BG is non-nil). If BACKGROUND is set to a color, this will
-be used for the background color of the current bar (i.e. not the
-stipple color).
+bar pattern. At least one of :blend, :color, :face, :width,
+:pad, :pattern, or :zigzag must be set and non-nil for this
+setting to take effect.
+
+By default, the highlight color will be the same as the
+underlying color. With COLOR or FACE set, all bars at the current
+depth will be highlighted in the appropriate color, either COLOR,
+or, if FACE is set, FACE's foreground or background color (the
+latter if FACE-BG is non-nil). If BACKGROUND is set to a color,
+this will be used for the background color of the current
+bar (i.e. not the stipple color).
If BLEND is provided, it is a blend fraction between 0 and 1 for
-blending the highlight color with the existing (depth-based or
-main) bar color; see `indent-bars-colors' for its meaning.
-BLEND=1 indicates using the full, unblended highlight
-color (i.e., the same as omitting BLEND).
+blending the specified highlight color with the
+existing (depth-based or main) bar color; see `indent-bars-color'
+for its meaning. BLEND=1 indicates using the full, unblended
+highlight color (i.e., the same as omitting BLEND).
+
+As a special case, if BLEND is provided, but neither COLOR nor
+FACE is, this indicates using for the current depth highlight
+a (presumably distinct) blend factor with the frame background of
+the original colors specified in `indent-bars-color-by-depth' or
+`indent-bars-color'. In this manner the current-depth highlight
+can be made a more or less visible version of the same color.
If any of WIDTH, PAD, PATTERN, or ZIGZAG are set, the bar pattern
at the current level will be altered as well. Note that
@@ -357,28 +365,31 @@ float FAC, with 1.0 matching C1 and 0.0 C2."
(+ (* a fac) (* b (- 1.0 fac))))
(color-name-to-rgb c1) (color-name-to-rgb c2))))
-(defun indent-bars--main-color (&optional tint tint-blend)
+(defun indent-bars--main-color (&optional tint tint-blend blend-override)
"Calculate the main bar color.
Uses `indent-bars-color' for color and background blend config.
If TINT and TINT-BLEND are passed, first blend the TINT color
into the main color with the requested blend, prior to blending
-into the background color."
+into the background color. If BLEND-OVERRIDE is set, use it
+instead of the :blend factor in `indent-bars-color'."
(cl-destructuring-bind (main &key face-bg blend) indent-bars-color
(let ((col (cond ((facep main)
(funcall (if face-bg #'face-background #'face-foreground)
main))
- ((color-defined-p main) main))))
- (if (and tint tint-blend (color-defined-p tint))
+ ((color-defined-p main) main)))
+ (blend (or blend-override blend)))
+ (if (and tint tint-blend (color-defined-p tint)) ;tint main color
(setq col (indent-bars--blend-colors tint col tint-blend)))
- (if blend
- (setq col
- (indent-bars--blend-colors
- col (indent-bars--frame-background-color) blend)))
+ (if blend ;now blend into BG
+ (setq col (indent-bars--blend-colors
+ col (indent-bars--frame-background-color) blend)))
col)))
-(defun indent-bars--depth-palette ()
+(defun indent-bars--depth-palette (&optional blend-override)
"Calculate the palette of depth-based colors (a vector).
-See `indent-bars-color-by-depth'."
+If BLEND-OVERRIDE is set, the main color's :blend will be ignored
+and this value will be used instead, for blending into the frame
+background color. See `indent-bars-color-by-depth'."
(when indent-bars-color-by-depth
(cl-destructuring-bind (&key regexp face-bg palette blend)
indent-bars-color-by-depth
@@ -397,8 +408,10 @@ See `indent-bars-color-by-depth'."
((color-defined-p el) el)
(t nil))))))))
(vconcat
- (if blend
- (mapcar (lambda (c) (indent-bars--main-color c blend)) colors)
+ (if (or blend blend-override)
+ (mapcar (lambda (c)
+ (indent-bars--main-color c blend blend-override))
+ colors)
colors))))))
(defun indent-bars--current-depth-palette ()
@@ -410,21 +423,27 @@ configuration."
(when indent-bars-highlight-current-depth
(cl-destructuring-bind (&key color face face-bg blend &allow-other-keys)
indent-bars-highlight-current-depth
- (when-let ((color
- (cond
- ((facep face)
- (funcall (if face-bg #'face-background #'face-foreground)
- face))
- ((and color (color-defined-p color)) color))))
- (if (string= color "unspecified-fg")
- (setq color indent-bars-unspecified-fg-color))
- (if blend
- (if indent-bars--depth-palette ; blend into normal depth palette
- (vconcat (mapcar (lambda (c)
- (indent-bars--blend-colors color c blend))
- indent-bars--depth-palette))
- (indent-bars--blend-colors color indent-bars--main-color blend))
- color)))))
+ (let ((color
+ (cond
+ ((facep face)
+ (funcall (if face-bg #'face-background #'face-foreground)
+ face))
+ ((and color (color-defined-p color)) color))))
+
+ (if (and blend (not color)) ; special case: re-blend originals with BG
+ (or (indent-bars--depth-palette blend)
+ (indent-bars--main-color nil nil blend))
+ ;; Normal case
+ (when color
+ (if (string= color "unspecified-fg")
+ (setq color indent-bars-unspecified-fg-color))
+ (if blend
+ (if indent-bars--depth-palette ; blend into normal depth palette
+ (vconcat (mapcar (lambda (c)
+ (indent-bars--blend-colors color c
blend))
+ indent-bars--depth-palette))
+ (indent-bars--blend-colors color indent-bars--main-color
blend))
+ color)))))))
- [elpa] externals/indent-bars f8d5e25527 030/431: bug fix for long patterns, (continued)
- [elpa] externals/indent-bars f8d5e25527 030/431: bug fix for long patterns, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars eab376d061 041/431: Allow background color on current depth highlight, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 253cf0d9bc 042/431: Improve spacing-override customize, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 71472e3cce 040/431: sub-headings, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars f608dce7a6 046/431: Convert examples from org to md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars b4995ad103 058/431: README: add hl-indent-scope, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars f109140fcb 047/431: examples.md: added images, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 0500330d87 070/431: README: mention after-make-frame-hook, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 6e33272206 086/431: Ensure daemon-mode deferred setup runs in current buffer, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 21b84f400d 079/431: README: improvments and describe new non-stipple display options, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 213033e60e 100/431: Allow :blend by itself for current depth,
ELPA Syncer <=
- [elpa] externals/indent-bars be6a67cda4 093/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 4501c7e884 119/431: ts-lang -> ts-parser: cache parser instead of lang, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 026ee80a27 028/431: commentary: improve, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars ca9b1a630f 035/431: setup: slight re-org, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 1215185bfb 033/431: draw: return object (if any), ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 00c4e12bbd 036/431: allow highlighting single blank lines, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 1a5f016740 032/431: blank line bars: correctly mark final line bars, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 5f5dd86810 034/431: always resize stipple on setup, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 931bf08cb2 045/431: Examples: add default, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars c534bb5b5d 056/431: Minor README tweak, ELPA Syncer, 2024/09/16