| 1 | module main |
| 2 | |
| 3 | import readline |
| 4 | |
| 5 | fn main() { |
| 6 | run() or { panic('${err}') } |
| 7 | } |
| 8 | |
| 9 | fn run() ! { |
| 10 | $if windows { |
| 11 | eprintln('skipping on Windows, since raw mode and read_char are not yet implemented.') |
| 12 | return |
| 13 | } $else { |
| 14 | // Explicit comptime block for other OSes than Windows is required to not break compilation on Windows. |
| 15 | mut r := readline.Readline{} |
| 16 | r.enable_raw_mode_nosig() |
| 17 | defer { |
| 18 | r.disable_raw_mode() |
| 19 | } |
| 20 | |
| 21 | for { |
| 22 | entered := r.read_char()! |
| 23 | if entered == `q` { |
| 24 | break |
| 25 | } |
| 26 | println('got ${entered}') |
| 27 | } |
| 28 | println('Goodbye.') |
| 29 | } |
| 30 | } |
| 31 | |