[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/eglot-inactive-regions 65fbd7a7a1 08/66: Support for diffe
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/eglot-inactive-regions 65fbd7a7a1 08/66: Support for different shading methods to render inactive regions |
Date: |
Fri, 6 Dec 2024 06:59:50 -0500 (EST) |
branch: elpa/eglot-inactive-regions
commit 65fbd7a7a103cf5a43d135ec902e083af123024f
Author: Filippo Argiolas <filippo.argiolas@gmail.com>
Commit: Filippo Argiolas <filippo.argiolas@gmail.com>
Support for different shading methods to render inactive regions
Add support for shading the background of inactive regions (e.g. like
eclipse does by default) and one to apply a shadow face (or any other
face) to an overlay covering each region.
---
eglot-clangd-inactive-regions.el | 61 ++++++++++++++++++++++++++++++++--------
1 file changed, 50 insertions(+), 11 deletions(-)
diff --git a/eglot-clangd-inactive-regions.el b/eglot-clangd-inactive-regions.el
index 09ed85889b..d549b66d84 100644
--- a/eglot-clangd-inactive-regions.el
+++ b/eglot-clangd-inactive-regions.el
@@ -34,14 +34,35 @@
(require 'eglot)
(require 'cl-lib)
-(defvar eglot-clangd-inactive-regions-opacity 0.3
- "Blending factor to mix foreground and background color of current
-region. The lower the blending factor the more text will look
-dim.")
+(defvar eglot-clangd-inactive-regions-opacity 0.55
+ "Blending factor for the `darken-foreground' method. Used to mix
+foreground and background color and apply to the foreground of
+the inactive region. The lower the blending factor the more text
+will look dim.")
+
+(defvar eglot-clangd-inactive-regions-shading 0.9
+ "Blending factor for the `shade-background' method. Used to mix
+background and foreground and shade inactive region
+background. The higher the less visible the shading will be.")
+
+(defvar eglot-clangd-inactive-regions-method "darken-foreground"
+ "Shading method to apply to the inactive code regions.
+Allowed methods:
+- darken-foreground: dim foreground color
+- shade-background: shade background color
+- shadow: apply shadow face.")
(defvar-local eglot-clangd-inactive-regions-overlays '())
(defvar-local eglot-clangd-inactive-regions-ranges '())
+(defface eglot-clangd-inactive-regions-shadow-face
+ '((t (:inherit shadow)))
+ "Face used to inactive code with shadow method.")
+
+(defface eglot-clangd-inactive-regions-shade-face
+ '((t (:extend t)))
+ "Face used to inactive code with shade-background method.")
+
(define-minor-mode eglot-clangd-inactive-regions-mode
""
:global nil
@@ -67,11 +88,10 @@ dim.")
(defun eglot-clangd-inactive-regions-cleanup ()
"Clean up inactive regions."
- (message "CLEANUP")
+ (mapc #'delete-overlay eglot-clangd-inactive-regions-overlays)
(with-silent-modifications
(remove-text-properties (point-min) (point-max) '(ecir-inactive nil)))
- (mapc #'delete-overlay eglot-clangd-inactive-regions-overlays)
- (font-lock-update))
+ (font-lock-flush))
(defun eglot-clangd-inactive-regions--get-face (pos)
(or (get-text-property pos 'face)
@@ -149,13 +169,33 @@ dim.")
"Force a refresh of known inactive regions without waiting for a
new notification from the server. Useful to update colors after a
face or theme change."
+ (eglot-clangd-inactive-regions-cleanup)
+ (when (string= eglot-clangd-inactive-regions-method "shade-background")
+ (set-face-background
+ 'eglot-clangd-inactive-regions-shade-face
+ (eglot-clangd-inactive-regions--color-blend
+ (face-background 'default)
+ (face-foreground 'default)
+ eglot-clangd-inactive-regions-shading)))
(let ((ranges (copy-tree eglot-clangd-inactive-regions-ranges)))
(dolist (range ranges)
(let ((beg (car range))
(end (cdr range)))
- (with-silent-modifications
- (put-text-property beg end 'ecir-inactive t))
- (font-lock-flush beg end)))))
+ (cond
+ ((string= eglot-clangd-inactive-regions-method "darken-foreground")
+ (with-silent-modifications
+ (put-text-property beg end 'ecir-inactive t))
+ (font-lock-flush beg end))
+ ((string= eglot-clangd-inactive-regions-method "shadow")
+ (let ((ov (make-overlay beg end)))
+ (overlay-put ov 'face 'eglot-clangd-inactive-regions-shadow-face)
+ (push ov eglot-clangd-inactive-regions-overlays)))
+ ((string= eglot-clangd-inactive-regions-method "shade-background")
+ (let ((ov (make-overlay beg (1+ end))))
+ (overlay-put ov 'face 'eglot-clangd-inactive-regions-shade-face)
+ (push ov eglot-clangd-inactive-regions-overlays)))
+ )
+ ))))
(cl-defmethod eglot-client-capabilities :around (server)
@@ -175,7 +215,6 @@ dim.")
(buffer (find-buffer-visiting path)))
(with-current-buffer buffer
(when eglot-clangd-inactive-regions-mode
- (eglot-clangd-inactive-regions-cleanup)
(setq eglot-clangd-inactive-regions-ranges '())
(cl-loop
for r across regions
- [nongnu] branch elpa/eglot-inactive-regions created (now 2c83a3230d), ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions f47d728c65 11/66: Stage basic README, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 65fbd7a7a1 08/66: Support for different shading methods to render inactive regions,
ELPA Syncer <=
- [nongnu] elpa/eglot-inactive-regions ea8da46342 01/66: Initial commit, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 9dba1b222d 14/66: Check for valid ranges when setting parameters, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 4f5ab3203c 17/66: No need to copy-tree ranges, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 5528f4d3e1 03/66: fix gpl preamble, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 4fc6480bed 18/66: Move forward if forward-same-syntax does not, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 2e52c1a10a 19/66: Use my own forward function, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 3876101626 31/66: Update README., ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions b0ade8c12e 21/66: Handle face list properties, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 3d3280c415 48/66: rename to eglot-inactive-regions.el, ELPA Syncer, 2024/12/06
- [nongnu] elpa/eglot-inactive-regions 475864a1a3 65/66: exclude screenshots from the tarball, ELPA Syncer, 2024/12/06