[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/sketch-mode 8e98379 3/3: Merge branch 'develop'
From: |
ELPA Syncer |
Subject: |
[elpa] externals/sketch-mode 8e98379 3/3: Merge branch 'develop' |
Date: |
Fri, 22 Oct 2021 16:57:35 -0400 (EDT) |
branch: externals/sketch-mode
commit 8e9837993533ad4d917d0989349d16eed7db035c
Merge: d973f2d 77ed467
Author: Daniel Nicolai <dalanicolai@gmail.com>
Commit: Daniel Nicolai <dalanicolai@gmail.com>
Merge branch 'develop'
---
README.org | 36 ++++++++++++-----------
sketch-mode.el | 92 +++++++++++++++++++++++++++-------------------------------
2 files changed, 62 insertions(+), 66 deletions(-)
diff --git a/README.org b/README.org
index 90bc13f..578930b 100644
--- a/README.org
+++ b/README.org
@@ -6,13 +6,17 @@
* Prepreliminary comment
The initial version with the transient can be found in the
'transient-version'
- branch. This version introduced a toolbar which made the transient
- unnecessary. Also removing the transient frees up drawing space. It has been
- replaced by a hydra which is togglable. Also an earlier version showed the
- mouse coordinate position in the mode-line. However, this functionality
- hinders the 'interactive' drawing (which might be due to an emacs 'bug').
- Anyway, you can toggle showing the coordinates by pressing =t c= (maybe it
- works more fluently on your system).
+ branch. A second version using a hydra can be found in the 'hydra version'.
+ This version has a toolbar which made the transient unnecessary. Which makes
+ the transient unnecessary, while removing the transient frees up drawing
+ space. Initially this version used a hydra. But using a hydra just
complicates
+ things if its purpose is to show keybindings only. So finally this version
+ simply uses a side buffer to show keybindings.
+
+ Also an earlier version showed the mouse coordinates in the mode-line.
+ However, this functionality hinders the 'interactive' drawing (which might be
+ due to an emacs 'bug'). Anyway, you can toggle showing the coordinates by
+ pressing =t c= (maybe it works more fluently on your system).
* Preliminary comment
This is a new package that is still in development. It has been on ELPA-devel
@@ -36,7 +40,8 @@
the =sketch.el= file and additionally in the
[[https://github.com/dalanicolai/sketch-mode/wiki/vision][wiki]] section.
** Included features
- - mnemonic shortcuts + hydra and (alternatively) a toolbar
+ - mnemonic shortcuts
+ - toolbar
- quickly insert image definition into new type (image) org-block with the
image rendered as overlay (no external file required)
- snap to grid (on minor-grid, however major and minor grid are fully
@@ -77,9 +82,6 @@
in other words, this means it must have been build with cairo support, but I
still have to find out)
- Also the hydra package is recommended for informing/reminding about the
- keybindings.
-
* Installation
The package is available from
[[https://elpa.gnu.org/packages/sketch-mode.html][GNU ELPA]], so it can simply
get installed as
usual. However, the publishing 'cycle' on ELPA is somewhat slow, while
@@ -126,9 +128,9 @@
* Usage
Start a sketch with =M-x sketch= and enter values at the prompts (or prefix
- with =C-u= to use default values). Although, thanks to the =hydra=
- package, the usage is more or less self explanatory, it is wise to take note
- of the following comments:
+ with =C-u= to use default values). Although, thanks to the key help buffer,
+ the usage is more or less self explanatory, it is wise to take note of the
+ following comments:
- use =C-c C-c= to quickly insert the xml-definition into the (org-mode)
buffer from which sketch-mode was called and create the image as an
overlay.
@@ -146,9 +148,9 @@
- to remove an object (without using undo), you should press =d=, and then
the
label of the object you want removed.
- You can also modify the drawing by changing the object definition (i.e.
- elisp). For that press =d= to open the definition in a side-window, then
- press =.= to hide (deactivate the) hydra (keymap). Now modify the code
- and press =C-c C=c=, to load it and update the =\*sketch\*= buffer.
+ elisp). For that press =D= to open the definition in a side-window, then
+ press =.= to toggle the key help buffer. Now modify the code and press =C-c
+ C=c=, to load it and update the =\*sketch\*= buffer.
* Bugs
Currently when undoing all (drawing of) objects, sketch-mode gets confused
and
diff --git a/sketch-mode.el b/sketch-mode.el
index 54d5b30..38908da 100644
--- a/sketch-mode.el
+++ b/sketch-mode.el
@@ -4,7 +4,7 @@
;; Author: D.L. Nicolai <dalanicolai@gmail.com>
;; Created: 17 Jul 2021
-;; Version: 1.0.2
+;; Version: 1.0.3
;; Keywords: multimedia
;; URL: https://github.com/dalanicolai/sketch-mode
@@ -56,7 +56,6 @@
;;;; Code
(require 'svg)
-;; (require 'seq)
(require 'shr-color)
(require 'sgml-mode)
(require 'org-element)
@@ -442,7 +441,7 @@ transient."
([sketch down-mouse-1] . sketch-interactively)
([sketch mouse-3] . sketch-text-interactively)
([sketch C-S-drag-mouse-1] . sketch-crop)
- ;; ([sketch S-down-mouse-1] . sketch-select)
+ ([sketch S-down-mouse-1] . sketch-select)
("a" . sketch-set-action)
("c" . sketch-set-colors)
("w" . sketch-set-width)
@@ -456,6 +455,7 @@ transient."
("tg" . sketch-toggle-grid)
("ts" . sketch-toggle-snap)
("tt" . sketch-toggle-toolbar)
+ ("." . sketch-toggle-key-hints)
("tc" . sketch-toggle-coords)
("l" . sketch-cycle-labels)
("D" . sketch-show-definition)
@@ -465,7 +465,7 @@ transient."
(,(kbd "C-c C-c") . sketch-quick-insert-image)
("?" . sketch-help)
("Q" . sketch-quit))
- ;; (,(kbd "C-c C-s") . sketch-transient))
+ ;; (,(kbd "C-c C-s") . sketch-transient))
(with-no-warnings
(if (boundp 'undo-tree-mode)
(undo-tree-mode))
@@ -473,48 +473,37 @@ transient."
(setq-local global-hl-line-mode nil)
(blink-cursor-mode 0))
-(when (eval-when-compile
- (require 'hydra nil t))
- (defhydra sketch-hydra (:hint nil)
- "
-^Stroke/Fill^ ^Font^ ^Edit^ ^Toggle^
-^^^^^^^^-------------------------------------------------------------
-_a_ : action _fw_: font _v_ : select _tg_: grid
-_c_ : color _fs_: sont-size _m_ : modify _ts_: snap
-_w_ : width ^ ^ _d_ : delete _tt_: toolbar
-_sd_: dasharray ^ ^ _u_/_U_: undo/redo _tc_: coords
-"
- ("a" sketch-set-action)
- ("c" sketch-set-colors)
- ("w" sketch-set-width)
- ("sd" sketch-set-dasharray)
- ("fw" sketch-set-font-with-keyboard)
- ("fs" sketch-set-font-size-by-keyboard)
- ("v" sketch-keyboard-select)
- ("m" sketch-modify-object)
- ("d" sketch-remove-object)
- ("tg" sketch-toggle-grid)
- ("ts" sketch-toggle-snap)
- ("l" sketch-cycle-labels)
- ("D" sketch-show-definition)
- ("u" sketch-undo)
- ("U" sketch-redo)
- ("S" image-save)
- ("tt" sketch-toggle-toolbar)
- ("tc" sketch-toggle-coords)
- ("?" sketch-help "help" :color blue)
- ("." nil "exit hydra" :color blue)
- ("q" sketch-quit-window "quit-restore")
- ("Q" sketch-quit "quit")))
-
-(with-no-warnings
- (defun sketch-hydra ()
- (interactive)
- (if (featurep 'hydra)
- (sketch-hydra/body)
- (user-error "This feature requires the hydra package to be installed"))))
-
-(define-key sketch-mode-map "." 'sketch-hydra)
+;; TODO format/propertize key hints
+(defun sketch-toggle-key-hints ()
+ (interactive)
+ (let ((win (get-buffer-window "*sketch-key-hints*")))
+ (if win
+ (delete-window win)
+ (let ((window-sides-vertical t)
+ (buffer (get-buffer-create "*sketch-key-hints*")))
+ (set-window-dedicated-p
+ (display-buffer-in-side-window (get-buffer-create
"*sketch-key-hints*")
+ `((side . bottom)
+ (slot . -1)
+ (window-height . 10)))
+ t)
+ (with-current-buffer buffer
+ (insert
+ "Stroke/Fill Font Edit Toggle
Definition
+-----------------------------------------------------------------------------------------------
+[a] : action [fw]: font [v] : select [tg]: grid
[D] Show definition
+[(C-u) c]: color [fs]: font-size [m] : modify [ts]: snap
+[w] : width [fc]: font-color [d] : delete [tt]: toolbar
+[sd] : dasharray [u/U]: undo/redo [tc]: coords
+
+[down-mouse-1] main action, [down-mouse-3] add text")
+ (setq cursor-type nil)
+ (special-mode))))))
+
+(defun sketch-kill-key-hints ()
+ (let ((key-hints (get-buffer "*sketch-key-hints*")))
+ (when key-hints
+ (kill-buffer key-hints))))
;;;###autoload
(defun sketch (arg)
@@ -525,7 +514,10 @@ values"
(let ((buffer (get-buffer "*sketch*")))
(cond (buffer
(switch-to-buffer buffer)
- (sketch-toggle-toolbar))
+ ;; TODO maybe immprove, i.e. always show on visit
+ (sketch-toggle-toolbar)
+ (sketch-toggle-key-hints)
+ )
(t
(let ((call-buffer (current-buffer))
(width (if arg (car sketch-size) (read-number "Enter width:
") ))
@@ -558,7 +550,9 @@ values"
(goto-char (point-min)) ; cursor over image looks better
(setq sketch-im-x-offset (car (window-absolute-pixel-position)))
(sketch-toggle-toolbar)
+ (sketch-toggle-key-hints)
(add-hook 'kill-buffer-hook 'sketch-kill-toolbar nil t)
+ (add-hook 'kill-buffer-hook 'sketch-kill-key-hints nil t)
(special-mode)
(sketch-mode))
@@ -798,7 +792,6 @@ VEC should be a cons or a list containing only number
elements."
;; (if sketch-include-end-marker
;; "url(#arrow)"
;; "none"))))
-
(apply #'svg-text
(nth sketch-active-layer sketch-layers-list)
text
@@ -1415,7 +1408,7 @@ then insert the image at the end"
(with-current-buffer (get-buffer "*sketch-toolbar*")
(let ((inhibit-read-only t))
(erase-buffer)
- (insert (propertize "Press . for hydra or press ? for help\n\n" 'face
'bold))
+ (insert (propertize "Press . for key hints or press ? for help\n\n"
'face 'bold))
(sketch-toolbar-colors)
(insert "\n\n")
(sketch-toolbar-widths)
@@ -1427,6 +1420,7 @@ then insert the image at the end"
(sketch-toolbar-font)
(goto-char (point-min)))))
+
(defun sketch-toggle-toolbar ()
(interactive)
(let ((win (get-buffer-window "*sketch-toolbar*")))