Allow merging lines by backspacing at the beginning of a line

This commit is contained in:
Skylar Hill 2023-11-08 11:58:12 -06:00
parent cd851bffc7
commit 55a251642f
1 changed files with 12 additions and 2 deletions

View File

@ -99,12 +99,22 @@
(string-take s k)
(string-drop s (1+ k))))
;;; merges k and k+1
(define (merge-lines buffer k)
(append (list-head buffer k)
(list
(string-append (list-ref buffer k)
(list-ref buffer (1+ k))))
(list-tail buffer (+ k 2))))
(define (backward-delete-char state)
(define buf (buffer state))
(define x (curx state))
(define y (cury state))
(list-set! buf y
(string-delete-kth (list-ref buf y) (1- x)))
(if (> x 0)
(list-set! buf y
(string-delete-kth (list-ref buf y) (1- x)))
(set! (buffer state) (merge-lines buf (1- y))))
(move-cursor state #:x -1 #:relative? #t))
(define (delete-char state)