[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/company 15bd239 4/6: company-text-icons-margin: Always
From: |
ELPA Syncer |
Subject: |
[elpa] externals/company 15bd239 4/6: company-text-icons-margin: Always adjust bg on select |
Date: |
Wed, 5 May 2021 15:57:09 -0400 (EDT) |
branch: externals/company
commit 15bd239a1c611e39613188e4c3a1789f74c0de8e
Author: Mohsin Kaleem <mohkale@kisara.moe>
Commit: Mohsin Kaleem <mohkale@kisara.moe>
company-text-icons-margin: Always adjust bg on select
Before when users specified a BG entry in `company-text-icons-mapping`
it either had to be a face, a string or a CONS of the above to indicate
variants for when the item was selected and when it wasn't. If the CONS
wasn't given then the same background color was used both for selected
and unselected items. With this patch the BG is now always adjusted in
this case. If for example you add `(array "a" fg-face "red")` to
`company-text-icons-mapping` then when the tooltip selects an array
entry the foreground will now change slightly to indicate it's selected.
If you want to maintain the previous behaviour you can set the BG entry
to a cons of the same color (eg: `(array "a" fg-face ("red" . "red"))`).
---
company.el | 52 +++++++++++++++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 21 deletions(-)
diff --git a/company.el b/company.el
index e80afb2..e4ebe85 100644
--- a/company.el
+++ b/company.el
@@ -1557,32 +1557,42 @@ See `company-text-icons-mapping'."
(declare-function color-gradient "color")
(defun company-text-icons--face (fg bg selected)
- ;; Narrow to specific bg used for current candidate when a CONS cell.
- (when (consp bg)
- (setq bg (if selected (cdr bg) (car bg))))
- (let ((bg-color (if (facep bg) (face-attribute bg :background) bg))
- (fg-color (if (facep fg) (face-attribute fg :foreground) fg)))
+ (let ((fg-color (if (facep fg) (face-attribute fg :foreground) fg)))
`(,@company-text-face-extra-attributes
- ,@(cond
- ;; When bg is given, but the bg face has no color then don't set a
- ;; bg color. Leave it as the default from `company-tooltip'.
- (bg (and bg-color
- (list :background bg-color)))
- ;; Otherwise try to generate a decent background from the foreground.
- ((and fg-color
- company-text-icons-add-background)
- (when-let ((tooltip-bg-color (face-attribute
- (if selected
- 'company-tooltip-selection
- 'company-tooltip)
- :background)))
+ ,@(and fg-color
+ (list :foreground fg-color))
+ ,@(let* ((bg-is-cons (consp bg))
+ (bg (if bg-is-cons (if selected (cdr bg) (car bg)) bg))
+ (bg-color (if (facep bg) (face-attribute bg :background) bg))
+ (bg-color (unless (eq bg-color 'unspecified)
+ bg-color))
+ (tooltip-bg-color (face-attribute
+ (if selected
+ 'company-tooltip-selection
+ 'company-tooltip)
+ :background)))
+ (cond
+ ((and company-text-icons-add-background selected
+ (not bg-is-cons) bg-color tooltip-bg-color)
+ ;; Adjust the coloring of the background when *selected* but user
hasn't
+ ;; specified an alternate background color for selected item icons.
+ (list :background
+ (apply #'color-rgb-to-hex
+ (nth 0 (color-gradient (color-name-to-rgb
tooltip-bg-color)
+ (color-name-to-rgb bg-color)
+ 2)))))
+ (bg
+ ;; When background is configured we use it as is, even if it
doesn't
+ ;; constrast well with other candidates when selected.
+ (and bg-color
+ (list :background bg-color)))
+ ((and company-text-icons-add-background fg-color tooltip-bg-color)
+ ;; Lastly attempt to generate a background from the foreground.
(list :background
(apply #'color-rgb-to-hex
(nth 0 (color-gradient (color-name-to-rgb
tooltip-bg-color)
(color-name-to-rgb fg-color)
- 10)))))))
- ,@(and fg-color
- (list :foreground fg-color)))))
+ 10))))))))))
(defcustom company-dot-icons-format "●"
"Format string for `company-dot-icons-margin'."
- [elpa] externals/company updated (9074b71 -> b1b51b5), ELPA Syncer, 2021/05/05
- [elpa] externals/company 38d7542 3/6: company-text-icons-margin: Swap order of BG cons, ELPA Syncer, 2021/05/05
- [elpa] externals/company 3d7110b 1/6: company-text-icons-mapping: Merge faces/colors into format, ELPA Syncer, 2021/05/05
- [elpa] externals/company 1657962 2/6: company-text-icons-mapping: Allow either FG/BG to be face or string, ELPA Syncer, 2021/05/05
- [elpa] externals/company 15bd239 4/6: company-text-icons-margin: Always adjust bg on select,
ELPA Syncer <=
- [elpa] externals/company b1b51b5 6/6: Merge pull request #1099 from mohkale/color-text-icons, ELPA Syncer, 2021/05/05
- [elpa] externals/company 59bbbbc 5/6: company-text-icons-margin: Better handling of unspecified colors, ELPA Syncer, 2021/05/05