diff --git a/command-functions.lisp b/command-functions.lisp index 8449b10..9a01873 100644 --- a/command-functions.lisp +++ b/command-functions.lisp @@ -80,6 +80,20 @@ (declare (ignore chord editor)) (throw 'linedit-done t)) +(defun new-sexp (chord editor) + (declare (ignore chord editor)) + (with-editor-point-and-string ((point string) editor) + (move-to-eol chord editor) + (add-char #\( editor) + (incf (get-point editor)) + (move-to-eol chord editor) + (add-char #\) editor) + (decf (get-point editor)))) + +(defun clear-screen (chord editor) + (declare (ignore chord)) + (terminal-clear-screen)) + ;;; CASE CHANGES (flet ((frob-case (frob editor) diff --git a/command-keys.lisp b/command-keys.lisp index d53dc1c..0825e33 100644 --- a/command-keys.lisp +++ b/command-keys.lisp @@ -36,7 +36,7 @@ (defcommand "C-G") (defcommand "C-J") (defcommand "C-K" 'kill-to-eol) -(defcommand "C-L") +(defcommand "C-L" 'clear-screen) (defcommand "C-N" 'history-next) (defcommand "C-O" 'close-all-sexp) (defcommand "C-P" 'history-previous) @@ -65,7 +65,7 @@ (defcommand "M-K") (defcommand "M-L" 'downcase-word) (defcommand "M-M") -(defcommand "M-N") +(defcommand "M-N" 'new-sexp) (defcommand "M-O") (defcommand "M-P") (defcommand "M-Q") @@ -113,3 +113,6 @@ (defcommand "Page-down") (defcommand "Home" 'move-to-bol) (defcommand "End" 'move-to-eol) + +(defcommand "C-Right-arrow" 'forward-sexp) +(defcommand "C-Left-arrow" 'backward-sexp) diff --git a/smart-terminal.lisp b/smart-terminal.lisp index f30d937..3778d02 100644 --- a/smart-terminal.lisp +++ b/smart-terminal.lisp @@ -41,6 +41,10 @@ (or ti:column-address (and ti:cursor-left ti:cursor-right)) (or ti:auto-right-margin ti:enter-am-mode))) +(defun terminal-clear-screen () + (when ti:clear-screen + (format t "~A~A" ti:clear-screen (editor-prompt *editor*)))) + (defmethod backend-init ((backend smart-terminal)) (call-next-method) (when ti:enter-am-mode diff --git a/terminal-translations.lisp b/terminal-translations.lisp index 7357a85..c8ebbab 100644 --- a/terminal-translations.lisp +++ b/terminal-translations.lisp @@ -112,3 +112,6 @@ (deftrans "Page-down" (#\Esc #\[ #\6 #\~)) (deftrans "Home" (#\Esc #\[ #\7 #\~) (#\Esc #\[ #\1 #\~) (#\Esc #\[ #\H)) (deftrans "End" (#\Esc #\[ #\8 #\~) (#\Esc #\[ #\4 #\~) (#\Esc #\[ #\F)) + +(deftrans "C-Right-arrow" (#\Esc #\[ #\1 #\; #\5 #\C)) +(deftrans "C-Left-arrow" (#\Esc #\[ #\1 #\; #\5 #\D)) diff --git a/terminal.lisp b/terminal.lisp index 8169aac..dc8bce0 100644 --- a/terminal.lisp +++ b/terminal.lisp @@ -51,8 +51,21 @@ (flet ((read-open-chord () (do ((chars nil) (c #1=(read-char) #1#)) - ((member c '(#\- #\~ #\$)) (nconc (nreverse chars) (list c))) - (push c chars)))) + ((or (member c '(#\- #\~ #\$)) + (if (char-equal c #\;) + (let ((c1 (read-char)) + (c2 (read-char))) + (push #\; chars) + (push c1 chars) + (push c2 chars) + ;; (format t "add (~A,~A,~A): chars:~A~%" + ;; c c1 c2 chars) + t))) + (nconc (nreverse chars) + (if (char-not-equal c #\;) + (list c)))) + (when (char-not-equal c #\;) + (push c chars))))) (let ((chord (acase (read-char) (#\Esc @@ -63,7 +76,8 @@ (if (digit-char-p char) (cons char (read-open-chord)) - (list char))))) + (when (char-not-equal char #\;) + (list char)))))) (t (list it))))) (t (if (graphic-char-p it) it