Setup initial architecture for testing
This commit is contained in:
parent
ae990b4784
commit
878eadd075
|
@ -33,7 +33,8 @@
|
||||||
(arguments
|
(arguments
|
||||||
(list
|
(list
|
||||||
(argument (name 'file)
|
(argument (name 'file)
|
||||||
(test file-exists?)
|
(default "")
|
||||||
|
(test string?)
|
||||||
(synopsis "The file to open")
|
(synopsis "The file to open")
|
||||||
(example "./file.txt"))))
|
(example "./file.txt"))))
|
||||||
(directory (in-home ".config/"))
|
(directory (in-home ".config/"))
|
||||||
|
@ -44,27 +45,7 @@
|
||||||
"(Listof String) -> Int
|
"(Listof String) -> Int
|
||||||
program entrypoint; handle commandline args and call appropriate procedures"
|
program entrypoint; handle commandline args and call appropriate procedures"
|
||||||
(define options (getopt-config-auto args %configuration))
|
(define options (getopt-config-auto args %configuration))
|
||||||
(display (full-command options))
|
(core-loop))
|
||||||
(newline)
|
|
||||||
(init-screen)
|
|
||||||
(let test-loop ()
|
|
||||||
(let ((ch (getch screen))
|
|
||||||
(yx (getyx screen)))
|
|
||||||
(cond
|
|
||||||
((eq? #\backspace ch) (begin
|
|
||||||
(delch screen)))
|
|
||||||
((eq? KEY_LEFT ch) (move screen (car yx) (- (cadr yx) 1)))
|
|
||||||
((eq? KEY_RIGHT ch) (move screen (car yx) (+ (cadr yx) 1)))
|
|
||||||
((eq? KEY_UP ch) (move screen (- (car yx) 1) (cadr yx)))
|
|
||||||
((eq? KEY_DOWN ch) (move screen (+ (car yx) 1) (cadr yx)))
|
|
||||||
((char? ch) (insert-char ch))))
|
|
||||||
(test-loop))
|
|
||||||
#;
|
|
||||||
(match (full-command options) ;
|
|
||||||
((_ file) ;
|
|
||||||
(open file)) ;
|
|
||||||
((_) ;
|
|
||||||
(new-instance))))
|
|
||||||
|
|
||||||
;;; Local Variables:
|
;;; Local Variables:
|
||||||
;;; mode: scheme
|
;;; mode: scheme
|
||||||
|
|
|
@ -1,9 +1,28 @@
|
||||||
(define-module (sloth editor)
|
(define-module (sloth editor)
|
||||||
|
#:use-module (sloth interface)
|
||||||
#:use-module (ncurses curses)
|
#:use-module (ncurses curses)
|
||||||
#:use-module (ts)
|
#:use-module (ts)
|
||||||
#:use-module (sloth interface)
|
#:export (core-loop))
|
||||||
#:export (insert-char))
|
|
||||||
|
|
||||||
(define (insert-char c)
|
(define* (core-loop #:optional (win (init-win)))
|
||||||
(addch screen (normal c))
|
(define y (getcury win))
|
||||||
(refresh screen))
|
(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))
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
(define-module (sloth interface)
|
(define-module (sloth interface)
|
||||||
#:use-module (ncurses curses)
|
#:use-module (ncurses curses)
|
||||||
#:export (screen
|
#:export (init-win))
|
||||||
init-screen))
|
|
||||||
|
|
||||||
(define screen '())
|
(define (init-win)
|
||||||
|
(define win (initscr))
|
||||||
(define (init-screen)
|
|
||||||
(set! screen (initscr))
|
|
||||||
(raw!)
|
(raw!)
|
||||||
(noecho!)
|
(noecho!)
|
||||||
(keypad! screen #t))
|
(keypad! win #t)
|
||||||
|
win)
|
||||||
|
|
Loading…
Reference in New Issue