Repurpose test-raw.

This commit is contained in:
Tony Garnock-Jones 2014-12-17 12:01:40 -05:00
parent 7c3b3f3c6c
commit 7ef6d4fe9a
2 changed files with 12 additions and 23 deletions

View File

@ -147,15 +147,3 @@
[(:: "\eO" any-char) (analyze-vt-O-key lexeme)] [(:: "\eO" any-char) (analyze-vt-O-key lexeme)]
[(:: "\eO" numeric any-char) (analyze-vt-O-key lexeme)] [(:: "\eO" numeric any-char) (analyze-vt-O-key lexeme)]
)) ))
(module+ main
(require "private/tty-raw-extension")
(tty-raw!)
(let loop ()
(match (lex-lcd-input (current-input-port))
[(? eof-object?) (void)]
[(== (C- #\D)) (void)]
[key
(printf "Key: ~v\r\n" key)
(loop)]))
(tty-restore!))

View File

@ -1,7 +1,10 @@
#lang racket/base #lang racket/base
(require "private/tty-raw-extension") (require "private/tty-raw-extension")
(require "ansi.rkt") (require "main.rkt")
(require racket/set)
(require racket/match)
(define (main) (define (main)
(tty-raw!) (tty-raw!)
@ -12,17 +15,15 @@
(old-exit-handler v))) (old-exit-handler v)))
(for-each display (list (set-mode x11-any-event-mouse-tracking-mode))) (for-each display (list (set-mode x11-any-event-mouse-tracking-mode)))
(flush-output)
(display "Type keys. Press control-D to exit.\r\n")
(let loop () (let loop ()
(define ch (read-byte)) (flush-output)
(display (select-graphic-rendition ch)) (match (lex-lcd-input (current-input-port))
(display (clear-to-eol)) [(? eof-object?) (void)]
(printf "Byte: ~v ~s\015\012" ch (integer->char ch)) [(== (key #\D (set 'control))) (void)]
(display (select-graphic-rendition)) [key
;;(flush-output) (printf "Key: ~v\r\n" key)
(if (member ch '(4 8 127)) ;; EOF, C-h, DEL (loop)])))
(exit)
(loop))))
(main) (main)