Create a basic ncurses buffer that can be edited
This commit is contained in:
parent
3d1d63d050
commit
1db39c1348
3 changed files with 39 additions and 2 deletions
|
@ -13,7 +13,10 @@
|
|||
(use-modules (config)
|
||||
(config api)
|
||||
(config licenses)
|
||||
(config parser sexp))
|
||||
(config parser sexp)
|
||||
(sloth interface)
|
||||
(sloth editor)
|
||||
(ncurses curses))
|
||||
|
||||
;; Commandline handling
|
||||
|
||||
|
@ -30,7 +33,7 @@
|
|||
(arguments
|
||||
(list
|
||||
(argument (name 'file)
|
||||
(handle file-exists?)
|
||||
(test file-exists?)
|
||||
(synopsis "The file to open")
|
||||
(example "./file.txt"))))
|
||||
(directory (in-home ".config/"))
|
||||
|
@ -43,6 +46,19 @@ program entrypoint; handle commandline args and call appropriate procedures"
|
|||
(define options (getopt-config-auto args %configuration))
|
||||
(display (full-command options))
|
||||
(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) ;
|
||||
|
|
9
sloth/editor.scm
Normal file
9
sloth/editor.scm
Normal file
|
@ -0,0 +1,9 @@
|
|||
(define-module (sloth editor)
|
||||
#:use-module (ncurses curses)
|
||||
#:use-module (ts)
|
||||
#:use-module (sloth interface)
|
||||
#:export (insert-char))
|
||||
|
||||
(define (insert-char c)
|
||||
(addch screen (normal c))
|
||||
(refresh screen))
|
12
sloth/interface.scm
Normal file
12
sloth/interface.scm
Normal file
|
@ -0,0 +1,12 @@
|
|||
(define-module (sloth interface)
|
||||
#:use-module (ncurses curses)
|
||||
#:export (screen
|
||||
init-screen))
|
||||
|
||||
(define screen '())
|
||||
|
||||
(define (init-screen)
|
||||
(set! screen (initscr))
|
||||
(raw!)
|
||||
(noecho!)
|
||||
(keypad! screen #t))
|
Loading…
Reference in a new issue