Skip to content

Commit

Permalink
some code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
c committed Nov 22, 2024
1 parent f4593f9 commit 2cc8e5f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 21 deletions.
13 changes: 13 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,19 @@ Set the current brush with:

- =<return>= move without drawing anything

The current bush and the current text direction (see below) are
reflected in the mode-line (at the bottom of the Emacs screen). It
looks like this:

#+begin_example
╭─current brush
→Uniline┼
╰──current text direction

#+end_example

* The =<insert>= key
The =<insert>= key is a prefix for other keys:
- for drawing arrows, squares, crosses, o-shapes glyphs,
Expand Down
47 changes: 26 additions & 21 deletions uniline.el
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,31 @@ It is a list containing:
- `truncate-lines'
- `cursor-type'")

(defun uniline--welcome-message ()
"Display a message giving the main key-bindings of the minor mode."
(interactive)
(let ((message-log-max))
(message
(replace-regexp-in-string
"\\^.*?\\^"
(lambda (x)
(setq x (substring x 1 (1- (length x))))
(add-face-text-property
0 (length x)
'hydra-face-red
nil x)
x)
"\
╭─^^────────────╴Uniline╶╴mode╶────────────────────────╮
│ ^→ ↓ ← ↑^ draw lines with current brush│
│^Ctrl → ↓ ← ↑^ overwrite │
│^Shift → ↓ ← ↑^ extend selection │
│^- + = # DEL RET^ change brush style │
│^INS^ without selection insert glyphs, change font │
│^INS^ with selection handle rectangles │
╰─^^───────────────────────────────────────────────────╯"
t))))

(defun uniline--mode-pre ()
"Change settings when entering uniline mode.
And backup previous settings."
Expand All @@ -2130,27 +2155,7 @@ And backup previous settings."
'post-self-insert-hook
#'uniline--post-self-insert
nil 'local)
(let ((message-log-max))
(message
(replace-regexp-in-string
"([^)]*)"
(lambda (x)
(setq x (substring x 1 (1- (length x))))
(add-face-text-property
0 (length x)
'hydra-face-red
nil x)
x)
"\
╭─()────────────╴Uniline╶╴mode╶────────────────────────╮
│ (→ ↓ ← ↑) draw lines with current brush│
│(Ctrl → ↓ ← ↑) overwrite │
│(Shift → ↓ ← ↑) extend selection │
│(- + = # DEL RET) change brush style │
│(INS) without selection insert glyphs, change font │
│(INS) with selection handle rectangles │
╰─()───────────────────────────────────────────────────╯"
t))))
(uniline--welcome-message))

(defun uniline--mode-post ()
"Restore settings when exiting uniline mode."
Expand Down

0 comments on commit 2cc8e5f

Please sign in to comment.