implement Toggle-Insert
authorNikodemus Siivola <nikodemus@random-state.net>
Sat, 23 Jun 2012 13:05:33 +0000 (16:05 +0300)
committerNikodemus Siivola <nikodemus@random-state.net>
Sat, 23 Jun 2012 13:05:33 +0000 (16:05 +0300)
  The function got lost in a reshuffle way back when, but looks like it never
  did anything useful. Huh.

command-functions.lisp
editor.lisp

index 2d3cb2d..6aa4c55 100644 (file)
 
 (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)
   (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))))
index ca3fd72..64e7234 100644 (file)
@@ -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