| 1 |
;; |
| 2 |
;; Sample of text.line-edit |
| 3 |
;; |
| 4 |
|
| 5 |
;; Just reads a line at a time and echoes back. |
| 6 |
|
| 7 |
(use text.console) |
| 8 |
(use text.line-edit) |
| 9 |
(use gauche.listener :only (complete-sexp?)) |
| 10 |
|
| 11 |
(define (main args) |
| 12 |
(let* ([con (guard (e [else (exit 1 (condition-message e))]) |
| 13 |
(make-default-console))] |
| 14 |
[count 0] |
| 15 |
[ctx (make <line-edit-context> |
| 16 |
:console con |
| 17 |
:prompt (^[] (format #t "[~d]$ " count)) |
| 18 |
:input-continues (^s (not (complete-sexp? s))))]) |
| 19 |
(let loop () |
| 20 |
(let1 line (read-line/edit ctx) |
| 21 |
(unless (eof-object? line) |
| 22 |
(print line) |
| 23 |
(inc! count) |
| 24 |
(loop)))))) |