diff --git a/command-functions.lisp b/command-functions.lisp index 2d3cb2df1717bde440a800ac4a702cab791b2b59..6aa4c55e4efdf1cb26c9c94c00cbd7f04100ddd0 100644 --- a/command-functions.lisp +++ b/command-functions.lisp @@ -31,9 +31,13 @@ (defun add-char (char editor) (with-editor-point-and-string ((point string) editor) - (setf (get-string editor) (concat (subseq string 0 point) - (string char) - (subseq string point))) + (setf (get-string editor) + (concat (subseq string 0 point) + (string char) + (if (editor-insert-mode editor) + (subseq string point) + (when (> (length string) (1+ point)) + (subseq string (1+ point)))))) (incf (get-point editor)))) (defun delete-char-backwards (chord editor) @@ -351,3 +355,7 @@ (print-in-lines editor (with-output-to-string (s) (describe (read-from-string (editor-word editor)) s)))) + +(defun toggle-insert (chord editor) + (declare (ignore chord)) + (setf (editor-insert-mode editor) (not (editor-insert-mode editor)))) diff --git a/editor.lisp b/editor.lisp index ca3fd727347b356fcb8288d3285fa903b056d363..64e7234e315a7891ce11d4c669287faac7956f50 100644 --- a/editor.lisp +++ b/editor.lisp @@ -35,7 +35,7 @@ :initarg :complete) (history :accessor editor-history) (killring :accessor editor-killring) - (insert :reader editor-insert-mode + (insert :accessor editor-insert-mode :initform t :initarg :insert-mode) (mark :accessor editor-mark