29 lines
705 B
Scheme
29 lines
705 B
Scheme
(define-module (sloth editor)
|
|
#:use-module (sloth interface)
|
|
#:use-module (ncurses curses)
|
|
#:use-module (ts)
|
|
#:export (core-loop))
|
|
|
|
(define* (core-loop #:optional (win (init-win)))
|
|
(define y (getcury win))
|
|
(define x (getcurx win))
|
|
(define ch (getch win))
|
|
(cond
|
|
((eqv? ch KEY_BACKSPACE)
|
|
(delch win #:y y #:x (- x 1)))
|
|
((eqv? ch KEY_DC)
|
|
(delch win))
|
|
((eqv? ch KEY_LEFT)
|
|
(move win y (- x 1)))
|
|
((eqv? ch KEY_RIGHT)
|
|
(move win y (+ x 1)))
|
|
((eqv? ch KEY_UP)
|
|
(move win (- y 1) x))
|
|
((eqv? ch KEY_DOWN)
|
|
(move win (+ y 1) x))
|
|
((eqv? ch #\q)
|
|
(endwin)
|
|
(quit))
|
|
(else (echochar win (normal ch))))
|
|
(core-loop win))
|