2011-12-19 20:47:58 +00:00
|
|
|
#lang racket/base
|
|
|
|
|
2014-12-17 17:01:40 +00:00
|
|
|
(require "main.rkt")
|
|
|
|
|
|
|
|
(require racket/set)
|
|
|
|
(require racket/match)
|
2011-12-19 20:47:58 +00:00
|
|
|
|
|
|
|
(define (main)
|
|
|
|
(tty-raw!)
|
2011-12-19 21:28:22 +00:00
|
|
|
|
2014-12-27 20:23:46 +00:00
|
|
|
(define utf-8?
|
|
|
|
(match (current-command-line-arguments)
|
|
|
|
[(or '#() '#("--utf-8")) #t]
|
|
|
|
['#("--no-utf-8") #f]
|
|
|
|
[_ (error 'main "Usage: test-raw [ --utf-8 / --no-utf-8 ]")]))
|
|
|
|
|
2014-12-17 17:14:00 +00:00
|
|
|
(plumber-add-flush! (current-plumber)
|
|
|
|
(lambda (handle)
|
2015-05-08 18:10:17 +00:00
|
|
|
(for-each display
|
|
|
|
(list
|
|
|
|
(reset-mode x11-extended-mouse-tracking-mode)
|
|
|
|
(reset-mode x11-any-event-mouse-tracking-mode)
|
|
|
|
(reset-mode x11-focus-event-mode)
|
|
|
|
))))
|
|
|
|
|
|
|
|
(for-each display (list
|
|
|
|
(set-mode x11-focus-event-mode)
|
|
|
|
(set-mode x11-any-event-mouse-tracking-mode)
|
|
|
|
(set-mode x11-extended-mouse-tracking-mode)
|
|
|
|
))
|
2011-12-19 21:28:22 +00:00
|
|
|
|
2014-12-17 17:01:40 +00:00
|
|
|
(display "Type keys. Press control-D to exit.\r\n")
|
2011-12-19 20:47:58 +00:00
|
|
|
(let loop ()
|
2014-12-17 17:01:40 +00:00
|
|
|
(flush-output)
|
2014-12-27 20:23:46 +00:00
|
|
|
(match (lex-lcd-input (current-input-port) #:utf-8? utf-8?)
|
2014-12-17 17:01:40 +00:00
|
|
|
[(? eof-object?) (void)]
|
|
|
|
[(== (key #\D (set 'control))) (void)]
|
|
|
|
[key
|
|
|
|
(printf "Key: ~v\r\n" key)
|
|
|
|
(loop)])))
|
2011-12-19 20:47:58 +00:00
|
|
|
|
|
|
|
(main)
|