Support loading files
This commit is contained in:
parent
4f112832a7
commit
8f0e46ee5d
2 changed files with 14 additions and 3 deletions
|
@ -45,7 +45,7 @@
|
|||
"(Listof String) -> Int
|
||||
program entrypoint; handle commandline args and call appropriate procedures"
|
||||
(define options (getopt-config-auto args %configuration))
|
||||
(core-loop))
|
||||
(start-loop #:file (option-ref options '(file) #f)))
|
||||
|
||||
;;; Local Variables:
|
||||
;;; mode: scheme
|
||||
|
|
|
@ -2,11 +2,17 @@
|
|||
#:use-module (sloth interface)
|
||||
#:use-module (ncurses curses)
|
||||
#:use-module (ts)
|
||||
#:export (core-loop))
|
||||
#:use-module (ice-9 textual-ports)
|
||||
#:export (start-loop))
|
||||
|
||||
(define modes '(#:normal-mode #:insert-mode))
|
||||
|
||||
(define* (core-loop #:optional (win (init-win)) (mode #:normal-mode))
|
||||
(define* (start-loop #:key (win (init-win))
|
||||
(file #f))
|
||||
(if file (find-file win file))
|
||||
(core-loop win))
|
||||
|
||||
(define* (core-loop win #:optional (mode #:normal-mode))
|
||||
(define process-result
|
||||
(case mode
|
||||
((#:normal-mode) (normal-mode-process-input win (getch win)))
|
||||
|
@ -50,3 +56,8 @@
|
|||
((eqv? key #\q)
|
||||
(endwin)
|
||||
(quit))))
|
||||
|
||||
(define (find-file win file)
|
||||
(when (file-exists? file)
|
||||
(addstr win (call-with-input-file file get-string-all))
|
||||
(refresh win)))
|
||||
|
|
Loading…
Reference in a new issue