(define-module (catbird line-editor) #:use-module (catbird mode) #:use-module (catbird node) #:use-module (catbird node-2d) #:use-module (catbird observer) #:use-module (catbird region) #:use-module (catbird ring-buffer) #:use-module (catbird scene) #:use-module (chickadee) #:use-module (chickadee graphics color) #:use-module (chickadee graphics path) #:use-module (chickadee graphics text) #:use-module (chickadee math vector) #:use-module (chickadee scripting) #:use-module (ice-9 match) #:use-module (oop goops) #:use-module (srfi srfi-1) #:export ( backward-char backward-delete-char forward-delete-char backward-history beginning-of-line clear-line end-of-line forward-char forward-history get-line history-enabled? insert-char invert-color kill-line overwrite prompt save-to-history) #:re-export (color font)) ;; TODO: Matching paren/quote highlighting. (define-class () (chars-before #:accessor chars-before #:init-value '()) (chars-after #:accessor chars-after #:init-value '()) (cached-line #:accessor cached-line #:init-value #f) (prompt #:accessor prompt #:init-keyword #:prompt #:init-value "" #:observe? #t) ;; TODO: Allow customizable history length. (history #:accessor history #:init-form (make-ring-buffer 128)) (history-enabled? #:accessor history-enabled? #:init-keyword #:history-enabled? #:init-value #t) (history-index #:accessor history-index #:init-value 0) (font #:accessor font #:init-keyword #:font #:init-thunk default-font #:asset? #t) (color #:accessor color #:init-keyword #:color #:init-value white) (invert-color #:accessor invert-color #:init-keyword #:invert-color #:init-value black) (accepting-input? #:accessor accepting-input? #:init-value #t)) (define-method (on-change (editor ) slot old new) (update-visual editor)) (define-method (on-boot (editor )) (attach-to editor (make