From 7ef6d4fe9a61b0777daf42288cece97e070c93f9 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 17 Dec 2014 12:01:40 -0500 Subject: [PATCH] Repurpose test-raw. --- ansi/lcd-terminal.rkt | 12 ------------ ansi/test-raw.rkt | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/ansi/lcd-terminal.rkt b/ansi/lcd-terminal.rkt index 473554a..92396c1 100644 --- a/ansi/lcd-terminal.rkt +++ b/ansi/lcd-terminal.rkt @@ -147,15 +147,3 @@ [(:: "\eO" 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!)) diff --git a/ansi/test-raw.rkt b/ansi/test-raw.rkt index ff78afd..e4355e6 100644 --- a/ansi/test-raw.rkt +++ b/ansi/test-raw.rkt @@ -1,7 +1,10 @@ #lang racket/base (require "private/tty-raw-extension") -(require "ansi.rkt") +(require "main.rkt") + +(require racket/set) +(require racket/match) (define (main) (tty-raw!) @@ -12,17 +15,15 @@ (old-exit-handler v))) (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 () - (define ch (read-byte)) - (display (select-graphic-rendition ch)) - (display (clear-to-eol)) - (printf "Byte: ~v ~s\015\012" ch (integer->char ch)) - (display (select-graphic-rendition)) - ;;(flush-output) - (if (member ch '(4 8 127)) ;; EOF, C-h, DEL - (exit) - (loop)))) + (flush-output) + (match (lex-lcd-input (current-input-port)) + [(? eof-object?) (void)] + [(== (key #\D (set 'control))) (void)] + [key + (printf "Key: ~v\r\n" key) + (loop)]))) (main)