mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-11 07:30:34 +01:00
- allowed switching off abbreviations on the command-window.
This commit is contained in:
parent
5c8e1d5828
commit
8d086ba6c4
@ -32,23 +32,49 @@ will replace 'foo' with 'bar'.
|
|||||||
|
|
||||||
So the whole list is like: '((\"foo\" \"bar\") (\"old\" \"new\") ...)")
|
So the whole list is like: '((\"foo\" \"bar\") (\"old\" \"new\") ...)")
|
||||||
|
|
||||||
(defun abbrev-re (abbrev)
|
|
||||||
|
(defun expand-abbrev-abbrev-re (abbrev)
|
||||||
(first abbrev))
|
(first abbrev))
|
||||||
|
|
||||||
(defun abbrev-replace (abbrev)
|
(defun expand-abbrev-abbrev-replace (abbrev)
|
||||||
(second abbrev))
|
(second abbrev))
|
||||||
|
|
||||||
|
(defparameter *expand-abbrev-actual-rewriting-rules*
|
||||||
|
(mapcar (lambda (a) (list (create-scanner (expand-abbrev-abbrev-re a))
|
||||||
|
(expand-abbrev-abbrev-replace a)))
|
||||||
|
*expand-abbrev-rewriting-rules*))
|
||||||
|
|
||||||
|
(defparameter *expand-abbrev-stop-rewrite* nil)
|
||||||
|
|
||||||
(defun expand-abbrev-command-hook-fn (command-window)
|
(defun expand-abbrev-command-hook-fn (command-window)
|
||||||
(let ((expanded (command-window:command-line command-window)))
|
(let ((expanded (command-window:command-line command-window)))
|
||||||
(loop for expansion in *expand-abbrev-rewriting-rules*
|
(when (null *expand-abbrev-stop-rewrite*)
|
||||||
when (scan (abbrev-re expansion) expanded)
|
(if (scan "^\\\\." expanded)
|
||||||
do
|
(progn
|
||||||
(setf expanded (regex-replace (abbrev-re expansion)
|
(setf *expand-abbrev-stop-rewrite* t)
|
||||||
expanded
|
(setf expanded (subseq expanded 1)))
|
||||||
(abbrev-replace expansion))))
|
(loop for expansion in *expand-abbrev-actual-rewriting-rules*
|
||||||
(setf (command-window:command-line command-window) expanded)
|
when (scan (expand-abbrev-abbrev-re expansion) expanded)
|
||||||
(point-tracker:move-point-to-end command-window expanded))
|
do
|
||||||
|
(setf expanded (regex-replace (expand-abbrev-abbrev-re expansion)
|
||||||
|
expanded
|
||||||
|
(expand-abbrev-abbrev-replace expansion)))))
|
||||||
|
(setf (command-window:command-line command-window) expanded)
|
||||||
|
(point-tracker:move-point-to-end command-window expanded)))
|
||||||
command-window)
|
command-window)
|
||||||
|
|
||||||
|
(defun expand-abbrev-command-fire-hook (x)
|
||||||
|
(declare (ignore x))
|
||||||
|
(setf *expand-abbrev-stop-rewrite* nil))
|
||||||
|
|
||||||
|
(defun expand-abbrev-command-delete-hook (x)
|
||||||
|
(expand-abbrev-command-fire-hook x))
|
||||||
|
|
||||||
(hooks:add-hook 'hooks:*after-char-to-command-window*
|
(hooks:add-hook 'hooks:*after-char-to-command-window*
|
||||||
#'expand-abbrev-command-hook-fn)
|
#'expand-abbrev-command-hook-fn)
|
||||||
|
|
||||||
|
(hooks:add-hook 'hooks:*before-fire-string-event-command-window*
|
||||||
|
#'expand-abbrev-command-fire-hook)
|
||||||
|
|
||||||
|
(hooks:add-hook 'hooks:*after-delete-char-from-command-window*
|
||||||
|
#'expand-abbrev-command-delete-hook)
|
||||||
|
@ -498,9 +498,13 @@ command line."
|
|||||||
(move-suggestion-page-right command-window))
|
(move-suggestion-page-right command-window))
|
||||||
((eq :backspace event)
|
((eq :backspace event)
|
||||||
(setf command-line (delete-at-point command-window command-line :direction :left))
|
(setf command-line (delete-at-point command-window command-line :direction :left))
|
||||||
|
(when 'hooks:*after-char-to-command-window*
|
||||||
|
(hooks:run-hook 'hooks:*after-delete-char-from-command-window* command-window))
|
||||||
(show-candidate-completion command-window))
|
(show-candidate-completion command-window))
|
||||||
((eq :dc event)
|
((eq :dc event)
|
||||||
(setf command-line (delete-at-point command-window command-line :direction :right))
|
(setf command-line (delete-at-point command-window command-line :direction :right))
|
||||||
|
(when 'hooks:*after-char-to-command-window*
|
||||||
|
(hooks:run-hook 'hooks:*after-delete-char-from-command-window* command-window))
|
||||||
(show-candidate-completion command-window))
|
(show-candidate-completion command-window))
|
||||||
((eq :left event)
|
((eq :left event)
|
||||||
(move-point-left command-window))
|
(move-point-left command-window))
|
||||||
@ -525,6 +529,9 @@ command line."
|
|||||||
((characterp event)
|
((characterp event)
|
||||||
(cond
|
(cond
|
||||||
((char= #\Newline event)
|
((char= #\Newline event)
|
||||||
|
(when 'hooks:*before-fire-string-event-command-window*
|
||||||
|
(hooks:run-hook 'hooks:*before-fire-string-event-command-window*
|
||||||
|
command-window))
|
||||||
(insert-in-history prompt command-line)
|
(insert-in-history prompt command-line)
|
||||||
(fire-user-input-event command-window)
|
(fire-user-input-event command-window)
|
||||||
(setf command-line nil)
|
(setf command-line nil)
|
||||||
|
@ -111,3 +111,9 @@ open the links")
|
|||||||
|
|
||||||
(defparameter *after-char-to-command-window* '()
|
(defparameter *after-char-to-command-window* '()
|
||||||
"Run this hooks after a character has been typed by the user on the command window.")
|
"Run this hooks after a character has been typed by the user on the command window.")
|
||||||
|
|
||||||
|
(defparameter *before-fire-string-event-command-window* '()
|
||||||
|
"Run this hooks before sending user input to the program (command window only).")
|
||||||
|
|
||||||
|
(defparameter *after-delete-char-from-command-window* '()
|
||||||
|
"Run this hooks after deleting a character from the input of the command-window.")
|
||||||
|
@ -1555,7 +1555,9 @@
|
|||||||
:*skip-message-hook*
|
:*skip-message-hook*
|
||||||
:*after-saving-message*
|
:*after-saving-message*
|
||||||
:*before-displaying-links-hook*
|
:*before-displaying-links-hook*
|
||||||
:*after-char-to-command-window*))
|
:*after-char-to-command-window*
|
||||||
|
:*before-fire-string-event-command-window*
|
||||||
|
:*after-delete-char-from-command-window*))
|
||||||
|
|
||||||
(defpackage :keybindings
|
(defpackage :keybindings
|
||||||
(:use
|
(:use
|
||||||
|
Loading…
x
Reference in New Issue
Block a user