Add indent and unindent commands
This commit is contained in:
parent
13715859ef
commit
4415bb3d55
1 changed files with 31 additions and 0 deletions
|
@ -812,6 +812,35 @@ Additionally ensures correct line numbers on the way, as a bonus."
|
|||
(read-char *eio*)
|
||||
(com-help))
|
||||
|
||||
(defparameter *indent-width* 4)
|
||||
|
||||
(defun com-indent-line ()
|
||||
;; TODO: Proper logical indentation
|
||||
(with-editor-accessors *editor* (:current-line line
|
||||
:current-column column)
|
||||
(cond ((< (+ (line-length line) *indent-width*) +screen-width+)
|
||||
(loop :repeat *indent-width*
|
||||
:do (insert-character-into-line line 0 #\Space
|
||||
:try-redisplay-p nil))
|
||||
(incf column *indent-width*)
|
||||
(redisplay-line line))
|
||||
(t
|
||||
(feep)))))
|
||||
|
||||
(defun com-unindent-line ()
|
||||
;; TODO: Remove when auto-indenting works
|
||||
(with-editor-accessors *editor* (:current-line line
|
||||
:current-column column)
|
||||
(cond ((and (>= (line-length line) *indent-width*)
|
||||
(>= (- (line-length line) *indent-width*) 0)
|
||||
(string= (make-string *indent-width* :initial-element #\Space)
|
||||
(subseq (line-content line) 0 *indent-width*)))
|
||||
(loop :repeat *indent-width*
|
||||
:do (delete-character-in-line line 0))
|
||||
(redisplay-line line)
|
||||
(decf column 4))
|
||||
(t
|
||||
(feep)))))
|
||||
|
||||
|
||||
(defun compile-fail-prompt (text line col)
|
||||
|
@ -930,6 +959,8 @@ Additionally ensures correct line numbers on the way, as a bonus."
|
|||
(#\Del com-backward-delete)
|
||||
(:help com-help)
|
||||
((:m . #\o) com-f1-help)
|
||||
((:c . #\i) com-indent-line)
|
||||
((:c . #\u) com-unindent-line)
|
||||
((:c . #\d) com-forward-delete)
|
||||
((:c . #\k) com-kill-line)
|
||||
((:c . #\j) com-newline)
|
||||
|
|
Loading…
Add table
Reference in a new issue