]>
git.proxmox.com Git - rustc.git/blob - src/vendor/termion/examples/keys.rs
3 use termion
::event
::Key
;
4 use termion
::input
::TermRead
;
5 use termion
::raw
::IntoRawMode
;
6 use std
::io
::{Write, stdout, stdin}
;
10 let mut stdout
= stdout().into_raw_mode().unwrap();
13 "{}{}q to exit. Type stuff, use alt, and so on.{}",
15 termion
::cursor
::Goto(1, 1),
16 termion
::cursor
::Hide
)
18 stdout
.flush().unwrap();
20 for c
in stdin
.keys() {
23 termion
::cursor
::Goto(1, 1),
24 termion
::clear
::CurrentLine
)
28 Key
::Char('q'
) => break,
29 Key
::Char(c
) => println
!("{}", c
),
30 Key
::Alt(c
) => println
!("^{}", c
),
31 Key
::Ctrl(c
) => println
!("*{}", c
),
32 Key
::Esc
=> println
!("ESC"),
33 Key
::Left
=> println
!("←"),
34 Key
::Right
=> println
!("→"),
35 Key
::Up
=> println
!("↑"),
36 Key
::Down
=> println
!("↓"),
37 Key
::Backspace
=> println
!("×"),
40 stdout
.flush().unwrap();
43 write
!(stdout
, "{}", termion
::cursor
::Show
).unwrap();