[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/svg-tag-mode 558ac3d3bd 54/63: Added edit mode (tag is
From: |
ELPA Syncer |
Subject: |
[elpa] externals/svg-tag-mode 558ac3d3bd 54/63: Added edit mode (tag is hidden) when pointer is over a tag. |
Date: |
Mon, 27 Dec 2021 15:58:01 -0500 (EST) |
branch: externals/svg-tag-mode
commit 558ac3d3bd286a26eb01907f0109fd6728227852
Author: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Commit: Nicolas P. Rougier <Nicolas.Rougier@inria.fr>
Added edit mode (tag is hidden) when pointer is over a tag.
---
svg-tag-mode.el | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/svg-tag-mode.el b/svg-tag-mode.el
index 12774ef168..2cedd1ae97 100644
--- a/svg-tag-mode.el
+++ b/svg-tag-mode.el
@@ -184,6 +184,22 @@ allows to create dynamic tags."
:background (face-background face nil 'default)
args))))
+(defun svg-tag--cursor-function (win position direction)
+ "This function hides the tag when cursor is over it. This
+allows to edit the tag."
+ (let* ((extents (cond ((and (eq direction 'left) (< (point) position))
+ `(,position . ,(next-property-change position)))
+ ((and (eq direction 'left) (> (point) position))
+ `(,(previous-property-change position) . ,(point)))
+ ((and (eq direction 'entered) (> (point) position))
+ `(,(point) . ,(next-property-change (point))))
+ ((and (eq direction 'entered) (< (point) position))
+ `(,(previous-property-change (point)) . ,position)))))
+ (if (eq direction 'left)
+ (font-lock-flush (car extents) (cdr extents))
+ (font-lock-unfontify-region (car extents) (cdr extents)))))
+
+
(defun svg-tag--build-keywords (item)
"Process an item in order to install it as a new keyword."
@@ -197,6 +213,7 @@ allows to create dynamic tags."
(setq tag `(,tag (match-string 1))))
(setq tag ``(face nil
display ,,tag
+ cursor-sensor-functions ,'(svg-tag--cursor-function)
,@(if ,callback '(pointer hand))
,@(if ,help `(help-echo ,,help))
,@(if ,callback `(keymap (keymap (mouse-1 . ,,callback))))))
@@ -237,12 +254,13 @@ allows to create dynamic tags."
;; is a hack to prevent org mode from removing SVG tags that use the
;; 'display property
(advice-add 'org-fontify-meta-lines-and-blocks
- :before #'notebook--remove-text-properties-on)
+ :before #'svg-tag--remove-text-properties-on)
(advice-add 'org-fontify-meta-lines-and-blocks
- :after #'notebook--remove-text-properties-off)
+ :after #'svg-tag--remove-text-properties-off)
;; Redisplay everything to show tags
(message "SVG tag mode on")
+ (cursor-sensor-mode 1)
(font-lock-flush))
(defun svg-tag-mode-off ()
@@ -263,6 +281,7 @@ allows to create dynamic tags."
;; Redisplay everything to hide tags
(message "SVG tag mode off")
+ (cursor-sensor-mode -1)
(font-lock-flush))
(define-minor-mode svg-tag-mode
- [elpa] externals/svg-tag-mode 40d7820143 28/63: Moved examples into a directory, (continued)
- [elpa] externals/svg-tag-mode 40d7820143 28/63: Moved examples into a directory, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode c0492f9046 30/63: Fixed links, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 78a343f0f3 34/63: Cleanup whitespace, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 29ca63cdbb 36/63: Rewrote the mode using svg-lib, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode f6adc4b772 39/63: Make sure to remove space from tag., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode a5098267c9 41/63: Updated example 2 to new tags format., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode e9a6256dee 44/63: Added org-mode screenshot, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 525901723f 47/63: Fixed requirements., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 8d9dd283fb 45/63: Updated screenshot, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode aca351185b 52/63: Fixed documentation., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 558ac3d3bd 54/63: Added edit mode (tag is hidden) when pointer is over a tag.,
ELPA Syncer <=
- [elpa] externals/svg-tag-mode 72068052ff 19/63: Fixed default height, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 9ddf0e4f13 38/63: Rename screenshot, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode b865793671 53/63: Updated copyright notices., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 95b5404997 35/63: Merge pull request #13 from tarsiiformes/cleanup, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 861c68af89 40/63: Updated example 1 to new tags format., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode ee16277655 42/63: Added examples from documentation, ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 8533c6c174 50/63: Added progress bar example., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode d9a803a92e 49/63: Added date without time format example., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 3e49ddcee2 57/63: Cancel tag editing in read-only or view mode., ELPA Syncer, 2021/12/27
- [elpa] externals/svg-tag-mode 7266de9f9c 61/63: Simplified advice on org fontify blocks., ELPA Syncer, 2021/12/27