From d3f1e04bd759b7c3f75c7f14a3d700c1ee87f799 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 13 Aug 2018 09:32:01 +0100 Subject: [PATCH] Tweak guard; small demo --- ansi/lcd-terminal.rkt | 3 ++- ansi/test-screen-size.rkt | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 ansi/test-screen-size.rkt diff --git a/ansi/lcd-terminal.rkt b/ansi/lcd-terminal.rkt index 53dfeee..6442f09 100644 --- a/ansi/lcd-terminal.rkt +++ b/ansi/lcd-terminal.rkt @@ -126,7 +126,8 @@ ["c" (S- 'right)] ["d" (S- 'left)] ["h" #:when (equal? params '(4)) (simple-key 'insert)] ;; st, http://st.suckless.org/ - ["t" #:when (equal? (car params) 8) (apply screen-size-report (cdr params))] + ["t" #:when (and (= (length params) 3) (= (car params) 8)) + (apply screen-size-report (cdr params))] [_ (simple-key (unknown-escape-sequence lexeme))])) (define (analyze-vt-O-mainchar lexeme mainchar) diff --git a/ansi/test-screen-size.rkt b/ansi/test-screen-size.rkt new file mode 100644 index 0000000..c925426 --- /dev/null +++ b/ansi/test-screen-size.rkt @@ -0,0 +1,24 @@ +#lang racket/base + +(require "main.rkt") + +(define (display* . things) + (for-each display things) + (flush-output)) + +(define (main) + (tty-raw!) + + (display* (dec-soft-terminal-reset) + (device-request-screen-size)) + + (define report (lex-lcd-input (current-input-port))) + (printf "The reported screen size is ~a columns and ~a rows.\r\n" + (screen-size-report-columns report) + (screen-size-report-rows report)) + (printf "The raw report value itself is ~v.\r\n" report) + + (display* (dec-soft-terminal-reset))) + +(module+ main + (main))