[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/indent-bars b913264e5a 167/431: highlight-current-depth
From: |
ELPA Syncer |
Subject: |
[elpa] externals/indent-bars b913264e5a 167/431: highlight-current-depth: add palette (no blending) |
Date: |
Mon, 16 Sep 2024 12:59:24 -0400 (EDT) |
branch: externals/indent-bars
commit b913264e5a91cd81ed094c1442bec0afdc07cf87
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
highlight-current-depth: add palette (no blending)
---
indent-bars.el | 102 +++++++++++++++++++++++++++++++++++----------------------
1 file changed, 62 insertions(+), 40 deletions(-)
diff --git a/indent-bars.el b/indent-bars.el
index 34f9efaabf..8ce140ba9d 100644
--- a/indent-bars.el
+++ b/indent-bars.el
@@ -246,22 +246,25 @@ current line's indentation depth level.
Format:
- nil | (:color :face :face-bg :background :blend
+ nil | (:color :face :face-bg :background :blend :palette
:width :pad :pattern :zigzag)
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 :blend, :color, :face, :width,
-:pad, :pattern, or :zigzag must be set and non-nil for this
-setting to take effect.
+bar pattern. At least one of :blend, :color, :palette, :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
+underlying color. With PALETTE, COLOR or FACE set, all bars at
+the current depth will be highlighted in the appropriate color,
+either from an explicit PALETTE list (see
+`indent-bars-color-by-depth'), a COLOR, or, if FACE is set,
+FACE's foreground or background color (the latter if FACE-BG is
+non-nil). If PALETTE is provided, it overrides any other
+foreground color setting. 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
@@ -272,11 +275,12 @@ highlight color (and is the same as omitting BLEND).
As a special case, if BLEND is provided, but neither COLOR nor
FACE is, this indicates using a (presumably distinct) blend
-factor between the default color and the frame background for the
-current depth highlight. The original colors are 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)
-prominent version of the default coloring.
+factor between the usual color for that bar and the frame
+background for the current depth highlight. The original colors
+are 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) prominent version of the default
+coloring.
If any of WIDTH, PAD, PATTERN, or ZIGZAG are set, the bar pattern
at the current level will be altered as well. Note that
@@ -298,6 +302,14 @@ non-nil, any stipple appearance parameters will be
ignored."
:value 0.5
:match (lambda (_ val) (and (<= val 1) (>= val 0)))
:type-error "Factor must be between 0 and 1")
+ (:palette
+ (repeat :tag "Explicit Color/Face List"
+ (choice (color :tag "Color")
+ (face :tag "Foreground from Face")
+ (cons :tag "Background from Face"
+ :format "Background from %v"
+ face
+ (const :format "\n" :value bg)))))
(:width (float :tag "Bar Width"))
(:pad (float :tag "Bar Padding (from left)"))
(:pattern (string :tag "Fill Pattern"))
@@ -437,6 +449,18 @@ instead of the :blend factor in `indent-bars-color'."
col (indent-bars--frame-background-color) blend)))
col)))
+(defun indent-bars--unpack-palette (palette)
+ "Process a face or color-based PALETTE."
+ (delq nil
+ (cl-loop for el in palette
+ collect (cond
+ ((and (consp el) (facep (car el)))
+ (face-background (car el)))
+ ((facep el)
+ (face-foreground el))
+ ((color-defined-p el) el)
+ (t nil)))))
+
(defun indent-bars--depth-palette (&optional blend-override)
"Calculate the palette of depth-based colors (a vector).
If BLEND-OVERRIDE is set, the main color's :blend will be ignored
@@ -450,15 +474,7 @@ background color. See `indent-bars-color-by-depth'."
(regexp
(indent-bars--depth-colors-from-regexp regexp face-bg))
(palette
- (delq nil
- (cl-loop for el in palette
- collect (cond
- ((and (consp el) (facep (car el)))
- (face-background (car el)))
- ((facep el)
- (face-foreground el))
- ((color-defined-p el) el)
- (t nil))))))))
+ (indent-bars--unpack-palette palette)))))
(vconcat
(if (or blend blend-override)
(mapcar (lambda (c)
@@ -473,7 +489,7 @@ nil, in which case no special current depth-coloring is
used.
See `indent-bars-highlight-current-depth' for
configuration."
(when indent-bars-highlight-current-depth
- (cl-destructuring-bind (&key color face face-bg blend &allow-other-keys)
+ (cl-destructuring-bind (&key color face face-bg blend palette
&allow-other-keys)
indent-bars-highlight-current-depth
(let ((color
(cond
@@ -482,22 +498,28 @@ configuration."
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)))))))
-
-
+ (cond
+ ;; An explicit palette
+ (palette
+ (vconcat (indent-bars--unpack-palette palette)))
+
+ ;; A specified color (possibly to blend in)
+ (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))
+ ;; Just blend into main color
+ (indent-bars--blend-colors color indent-bars--main-color blend))
+ color))
+
+ ;; blend-only without a specified color: re-blend originals with BG
+ (blend
+ (or (indent-bars--depth-palette blend)
+ (indent-bars--main-color nil nil blend))))))))
(defun indent-bars--depth-colors-from-regexp (regexp &optional face-bg)
"Return a list of depth colors (strings) for faces matching REGEXP.
- [elpa] externals/indent-bars a0d78b2c3d 065/431: Merge pull request #2 from BrunodaSilvaBelo/patch-1, (continued)
- [elpa] externals/indent-bars a0d78b2c3d 065/431: Merge pull request #2 from BrunodaSilvaBelo/patch-1, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars e8cc5c4a77 094/431: Make default highlight bolder, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars d8ee83c12d 063/431: Fix footnote, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars acb992d370 103/431: Mention ┋, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 3a971623af 102/431: Tweak README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars a3083e769d 061/431: Merge pull request #1 from ideasman42/patch-2, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars d23ab840ec 062/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 4a7f9c7528 059/431: README: more compatibility detail, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 25e3624ec1 108/431: initial support for treesitter + no string/comment descend, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars b3297d6739 118/431: indent-at-node: move point (guard at top level with save-excursion), ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars b913264e5a 167/431: highlight-current-depth: add palette (no blending),
ELPA Syncer <=
- [elpa] externals/indent-bars 5bce1c1324 005/431: Notes on updates :stipple usage given gutter offsets, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars ee18d37d12 006/431: Greatly simplify row-data, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 3fef0ab598 007/431: improve stipple description comment, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 14dad9430e 011/431: spacing: use override and default to 4 chars, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 563328e19e 009/431: resize-stipple: let faces extend, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars fde60a178f 013/431: tint the main color with depth-based color first, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 257b723c72 014/431: Use stipple-rot for rotating stipple, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 2452b96761 021/431: Simplify create-faces, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 00a26de005 020/431: rename indentation->depth, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars fa1d59893f 026/431: Some custom doc improvements, ELPA Syncer, 2024/09/16