[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/valign cf3a794 099/198: Fix: cursor disappears on bars
From: |
Stefan Monnier |
Subject: |
[elpa] externals/valign cf3a794 099/198: Fix: cursor disappears on bars when fancy-bar is t |
Date: |
Tue, 1 Dec 2020 18:19:25 -0500 (EST) |
branch: externals/valign
commit cf3a794ebe269e743102dc42aca1357722d344fc
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Fix: cursor disappears on bars when fancy-bar is t
* valign.el (valign--fancy-bar-cursor-fn): New function
(valign--render-bar): Add new text property.
(valign--clean-text-property): Remove new text property.
(valign-fancy-bar): Change docstring.
(valign-mode): Enable/disable supporting minor mode.
---
valign.el | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/valign.el b/valign.el
index 99392ae..37dee1e 100644
--- a/valign.el
+++ b/valign.el
@@ -335,11 +335,30 @@ But only if `valign-fancy-bar' is non-nil."
(when valign-fancy-bar
(valign--render-bar point)))
+(defun valign--fancy-bar-cursor-fn (window prev-pos action)
+ "Run when point enters or left a fancy bar.
+Because the bar is so thin, the cursor disappears in it. We
+expands the bar so the cursor is visible. 'cusor-intangible
+doesn’t work because it prohibits you to put the cursor at BOL.
+
+WINDOW is just window, PREV-POS is the previous point of cursor
+before event, ACTION is either 'entered or 'left."
+ (ignore window)
+ (with-silent-modifications
+ (pcase action
+ ('entered (put-text-property (point) (1+ (point))
+ 'display " "))
+ ('left (put-text-property prev-pos (1+ prev-pos)
+ 'display '(space :width (1)))))))
+
(defun valign--render-bar (point)
"Make the character at POINT a full hegiht bar."
(with-silent-modifications
(put-text-property
point (1+ point) 'display '(space :width (1)))
+ (put-text-property point (1+ point)
+ 'cursor-sensor-functions
+ '(valign--fancy-bar-cursor-fn))
;; We can’t just use :inverse-video because people
;; uses different color for their tables, fine.
(let* ((inherit (valign--table-face))
@@ -351,6 +370,7 @@ But only if `valign-fancy-bar' is non-nil."
(defun valign--clean-text-property (beg end)
"Clean up the display text property between BEG and END."
+ (put-text-property beg end 'cursor-sensor-functions nil)
;; TODO ‘text-property-search-forward’ is Emacs 27 feature.
(if (boundp 'text-property-search-forward)
(save-excursion
@@ -481,8 +501,7 @@ setting to take effect."
(defcustom valign-fancy-bar nil
"Non-nil means to render bar as a full-height line.
-You need to restart valign mode or realign tables for this
-setting to take effect."
+You need to restart valign mode for this setting to take effect."
:type '(choice
(const :tag "Enable fancy bar" t)
(const :tag "Disable fancy bar" nil))
@@ -702,9 +721,11 @@ FLAG is the same as in ‘org-flag-region’."
(advice-add fn :after #'valign--buffer-advice))
(dolist (fn '(org-flag-region outline-flag-region))
(advice-add fn :after #'valign--flag-region-advice))
+ (if valign-fancy-bar (cursor-sensor-mode))
(jit-lock-refontify))
(remove-hook 'jit-lock-functions #'valign-region t)
- (valign-reset-buffer)))
+ (valign-reset-buffer)
+ (cursor-sensor-mode -1)))
(provide 'valign)
- [elpa] externals/valign 9daeab8 071/198: * valign.el (valign-table-quite): Really ignore errors., (continued)
- [elpa] externals/valign 9daeab8 071/198: * valign.el (valign-table-quite): Really ignore errors., Stefan Monnier, 2020/12/01
- [elpa] externals/valign 09e89aa 105/198: * valign.el (valign--at-table-p): Don’t align org blocks., Stefan Monnier, 2020/12/01
- [elpa] externals/valign e91abf2 112/198: Extract out boilerplate from valign-table, Stefan Monnier, 2020/12/01
- [elpa] externals/valign d799e31 181/198: ; * valign.el (valign--cell-content-config): Fix typo., Stefan Monnier, 2020/12/01
- [elpa] externals/valign 9fc0c11 149/198: Use new function to calculate space and bar width, Stefan Monnier, 2020/12/01
- [elpa] externals/valign d18aea8 183/198: Improve error handling, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 62766e7 184/198: Add custom group, Stefan Monnier, 2020/12/01
- [elpa] externals/valign bf68d39 171/198: Remove single-column style, Stefan Monnier, 2020/12/01
- [elpa] externals/valign ce1a53c 188/198: ; * test.org: Update., Stefan Monnier, 2020/12/01
- [elpa] externals/valign 82be45d 198/198: Bug fix, Stefan Monnier, 2020/12/01
- [elpa] externals/valign cf3a794 099/198: Fix: cursor disappears on bars when fancy-bar is t,
Stefan Monnier <=
- [elpa] externals/valign 0e77a02 164/198: Add some commands that suppresses auto alignment, Stefan Monnier, 2020/12/01
- [elpa] externals/valign 7afe578 182/198: Improve documentation, Stefan Monnier, 2020/12/01
- [elpa] externals/valign e0362c0 156/198: * valign.el (valign-region): Report to jit-lock the actual end of fontified region., Stefan Monnier, 2020/12/01
- [elpa] externals/valign 841925f 189/198: Remove all advice when they are not needed, Stefan Monnier, 2020/12/01
- [elpa] externals/valign e438083 103/198: Change text property to overlay, Stefan Monnier, 2020/12/01
- [elpa] externals/valign cd2b563 191/198: * valign.el: Bump version to 3.0.0., Stefan Monnier, 2020/12/01