[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/why-this 340194b6d2 24/59: Calculate background for messag
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/why-this 340194b6d2 24/59: Calculate background for message |
Date: |
Sun, 27 Nov 2022 16:02:50 -0500 (EST) |
branch: elpa/why-this
commit 340194b6d2013c4b4488ba29124fa3667f314ccc
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>
Calculate background for message
---
images/blame-region.png | Bin 182406 -> 173866 bytes
images/blame.png | Bin 136015 -> 159057 bytes
why-this.el | 58 ++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/images/blame-region.png b/images/blame-region.png
index abd2663631..804e817cd2 100644
Binary files a/images/blame-region.png and b/images/blame-region.png differ
diff --git a/images/blame.png b/images/blame.png
index c1693824aa..038de12e09 100644
Binary files a/images/blame.png and b/images/blame.png differ
diff --git a/why-this.el b/why-this.el
index e707e11536..5fe971d04d 100644
--- a/why-this.el
+++ b/why-this.el
@@ -132,6 +132,12 @@ NICK."
:package-version '(why-this "1.0")
:group 'why-this)
+(defcustom why-this-calculate-background t
+ "Non-nil means calculate background for message."
+ :type 'boolean
+ :package-version '(why-this "1.0")
+ :group 'why-this)
+
(defface why-this-face
'((t :foreground "#82b0ec"
:background nil
@@ -225,6 +231,41 @@ When EXACT is non-nil, be as exact as possible."
str)))))
format t t))))
+(defun why-this--overlay-bg-type (pos)
+ "Return the background type for overlay at POS."
+ (cond
+ ((and (use-region-p)
+ (>= pos (region-beginning))
+ (< pos (region-end)))
+ 'region)
+ ((eq (line-number-at-pos)
+ (line-number-at-pos pos))
+ 'line)
+ (t
+ nil)))
+
+(defun why-this--get-face (type)
+ "Return face for showing message with background type TYPE."
+ (if (not why-this-calculate-background)
+ 'why-this-face
+ `(:background
+ ,(face-background
+ (pcase type
+ ('region
+ (if (bound-and-true-p solaire-mode)
+ 'solaire-region-face
+ 'region))
+ ('line
+ (if (bound-and-true-p hl-line-mode)
+ (if (bound-and-true-p solaire-mode)
+ 'solaire-hl-line-face
+ 'hl-line)
+ 'why-this-face))
+ (_
+ 'why-this-face))
+ nil t)
+ :inherit why-this-face)))
+
(defvar why-this-mode)
(defun why-this--render ()
@@ -244,13 +285,15 @@ When EXACT is non-nil, be as exact as possible."
(let ((pos (save-excursion
(goto-char (point-min))
(line-end-position (+ begin i)))))
- (let ((ov (make-overlay pos pos)))
+ (let ((ov (make-overlay pos pos))
+ (type (why-this--overlay-bg-type pos)))
(overlay-put ov 'after-string
(propertize (why-this-format-data
why-this-message-format
(append `(:backend ,backend)
(nth i data)))
- 'cursor t 'face 'why-this-face
+ 'cursor t
+ 'face (why-this--get-face type)
'help-echo
(when why-this-enable-tooltip
(why-this-format-data
@@ -258,6 +301,7 @@ When EXACT is non-nil, be as exact as possible."
(append `(:backend ,backend)
(nth i data))))))
(overlay-put ov 'why-this-line (+ begin i))
+ (overlay-put ov 'why-this-bg-type type)
(push (cons ov (current-buffer)) why-this--overlays)))))))
(defun why-this--render-non-blocking ()
@@ -292,6 +336,16 @@ When EXACT is non-nil, be as exact as possible."
(line-end-position))))
(unless (eq ov-start pos)
(move-overlay (car ov) pos pos)))
+ (when why-this-calculate-background
+ (let ((type (why-this--overlay-bg-type
+ (overlay-start (car ov)))))
+ (unless (eq (overlay-get (car ov) 'why-this-bg-type)
+ type)
+ (overlay-put (car ov) 'after-string
+ (propertize
+ (overlay-get (car ov) 'after-string)
+ 'face (why-this--get-face type)))
+ (overlay-put (car ov) 'why-this-bg-type type))))
ov)
(delete-overlay (car ov))
nil))
- [nongnu] branch elpa/why-this created (now c914584833), ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this e89aabc765 02/59: (provide 'why-this), ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 961f84afc6 08/59: Fixed typo in the value of why-this-echo-format, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 2f714a9820 05/59: Add Git backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 82397f6a45 03/59: Add support for nick names, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 3c252a6621 07/59: Allow showing last change manually, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this f62dccdd90 10/59: Add annonation support, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 340194b6d2 24/59: Calculate background for message,
ELPA Syncer <=
- [nongnu] elpa/why-this 167397e7ad 25/59: Fix copyright year, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 9c0daa799c 28/59: Rename a variable, change backend API and update docs, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 53b2b803f0 22/59: Update commentary, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this d47f547250 39/59: Allow customization of executable paths, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 7f1ae28159 36/59: Fix Git backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 9f656b59dd 33/59: Change package summary, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 3497115c2b 35/59: Don't store unnecessary data, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 7a2e4af450 19/59: Rewrite Git backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 41fe21da73 15/59: Fontify before annotate, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 006ea3864a 13/59: Fix Git backend 'supported-p command, ELPA Syncer, 2022/11/27