Browse code

Add some extra movement keybindings

Jenga Phoenix authored on 2019-03-27 18:14:48
Showing 3 changed files
... ...
@@ -78,6 +78,12 @@
78 78
 (defparameter *key-asdf-load* "<Control-p>" "Load an ASDF system")
79 79
 (defparameter *key-reset-listener* "<Control-0>" "Reset the listener")
80 80
 
81
+(defparameter *key-line-start* "<Alt-s>" "Goto start of line")
82
+(defparameter *key-line-end* "<Alt-e>" "Goto end of line")
83
+(defparameter *key-forward* "<Alt-f>" "Move forward a character")
84
+(defparameter *key-backward* "<Alt-b>" "Move backward a character")
85
+
86
+
81 87
 (defparameter *indentation-rules*  '(("if" . 4)
82 88
                                      ("cond" . 6)
83 89
                                      ("and" . 5)
... ...
@@ -36,6 +36,19 @@
36 36
   (format-wish "~a mark set insert \"insert ~a~ac\""
37 37
     (widget-path text) (if (plusp count) #\+ #\-) (abs count)))
38 38
 
39
+(defgeneric set-to-start-current-line (object)
40
+  (:documentation "Move the cursor to the start of it's current line."))
41
+
42
+(defmethod set-to-start-current-line ((text text))
43
+    (set-cursor-pos text "\"insert linestart\""))
44
+
45
+(defgeneric set-to-end-current-line (object)
46
+  (:documentation "Move the cursor to the end of it's current line."))
47
+
48
+(defmethod set-to-end-current-line ((text text))
49
+  (set-cursor-pos text "\"insert lineend\""))
50
+
51
+
39 52
 (defmethod scroll-to ((txt text) pos)
40 53
   (format-wish "~a see ~a" (widget-path txt) pos))
41 54
 
... ...
@@ -497,6 +497,10 @@
497 497
      (list *key-cut* 'on-cut t)
498 498
      (list *key-copy* 'on-copy)
499 499
      (list *key-paste* 'on-paste)
500
+     (list *key-line-start* 'on-cursor-line-start)
501
+     (list *key-line-end* 'on-cursor-line-end)
502
+     (list *key-forward* 'on-cursor-forward)
503
+     (list *key-backward* 'on-cursor-backward)
500 504
      (list *key-select-all* 'on-select-all t)
501 505
      (list *key-reformat* 'on-re-indent t)
502 506
      (list *key-macro-expand* 'on-macro-expand t)
... ...
@@ -1364,6 +1368,18 @@
1364 1368
   (indent-block txt)
1365 1369
   (match-paren txt))
1366 1370
 
1371
+(defmethod on-cursor-line-start ((txt ltk:text))
1372
+    (ltk::set-to-start-current-line txt))
1373
+
1374
+(defmethod on-cursor-line-end ((txt ltk:text))
1375
+    (ltk::set-to-end-current-line txt))
1376
+
1377
+(defmethod on-cursor-forward ((txt ltk:text))
1378
+    (ltk::move-cursor-pos txt 1))
1379
+
1380
+(defmethod on-cursor-backward ((txt ltk:text))
1381
+    (ltk::move-cursor-pos txt -1))
1382
+
1367 1383
 (defun focus-editor ()
1368 1384
   (ltk:focus (get-current-text-ctrl *buffer-manager*)))
1369 1385