#[repr(C)]pub struct Curses { /* private fields */ }
Expand description
Handle to the terminal’s curses interface.
Implementations§
Source§impl Curses
impl Curses
Sourcepub fn init() -> Self
pub fn init() -> Self
Initializes curses.
- Automatically enables color, if available.
- Automatically enables keypad keys (arrow keys, function keys, etc).
§Panics
- If you double-initialize curses this will panic.
- If your previous curses handle has been dropped it is legal to init another one. Curses mode will resume just fine.
§Other
- If this fails on the curses side, curses will “helpfully” print an error and abort the process for you.
- This installs a custom panic hook that ends curses mode before printing
the panic message. Otherwise your panic messages get eaten. The normal
panic hook is restored when
Curses
drops.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn refresh(&mut self) -> Result<(), &'static str>
pub fn refresh(&mut self) -> Result<(), &'static str>
Pushes all updates out to the physical screen, refreshing the display.
Sourcepub fn set_echo(&mut self, echoing: bool) -> Result<(), &'static str>
pub fn set_echo(&mut self, echoing: bool) -> Result<(), &'static str>
Sets if user inputs should automatically echo to the screen or not.
- Initially this is enabled.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn get_cursor_position(&self) -> Position
pub fn get_cursor_position(&self) -> Position
Get the cursor’s current row and column.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn get_terminal_size(&self) -> TerminalSize
pub fn get_terminal_size(&self) -> TerminalSize
Get the size of the terminal.
Cursor positions can range in 0..COUNT
in each dimension.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn move_cursor(&mut self, p: Position) -> Result<(), &'static str>
pub fn move_cursor(&mut self, p: Position) -> Result<(), &'static str>
Move the cursor to the position given.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn print_ch<C: Into<CursesGlyph>>(
&mut self,
c: C,
) -> Result<(), &'static str>
pub fn print_ch<C: Into<CursesGlyph>>( &mut self, c: C, ) -> Result<(), &'static str>
Prints the character given, advancing the cursor.
- Wraps to the next line if in the final col.
- Will scroll the terminal if in the final row, if scrolling is enabled.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn print_str(&mut self, s: &str) -> Result<(), &'static str>
pub fn print_str(&mut self, s: &str) -> Result<(), &'static str>
Prints the str given, advancing the cursor.
This is identical to calling print_ch
on every byte
in s
. If your &str
has non-ascii data you’ll get garbage on the
screen.
- Wraps to the next line if in the final col.
- Will scroll the terminal if in the final row, if scrolling is enabled.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn insert_ch<C: Into<CursesGlyph>>(
&mut self,
c: C,
) -> Result<(), &'static str>
pub fn insert_ch<C: Into<CursesGlyph>>( &mut self, c: C, ) -> Result<(), &'static str>
Inserts the given character under the cursor.
- The cursor doesn’t move.
- Other characters to the right get pushed 1 cell forward.
- The last character of the line gets pushed off the screen.
Sourcepub fn delete_ch(&mut self) -> Result<(), &'static str>
pub fn delete_ch(&mut self) -> Result<(), &'static str>
Deleted character under the cursor.
- The cursor doesn’t move.
- Other characters to the right get pulled 1 cell backward.
- The last character of the line is now blank.
Sourcepub fn copy_glyphs(&mut self, s: &[CursesGlyph]) -> Result<(), &'static str>
pub fn copy_glyphs(&mut self, s: &[CursesGlyph]) -> Result<(), &'static str>
Copies the slice of glyphs starting from the cursor position.
- Does not advance the cursor.
- Does not wrap the content to the next line.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn clear(&mut self) -> Result<(), &'static str>
pub fn clear(&mut self) -> Result<(), &'static str>
Clears the entire screen and moves the cursor to (0,0)
.
This can have somewhat poor performance. If you’re just going to overwrite the entire screen with new content anyway, you shouldn’t use this.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn set_attributes(
&mut self,
attr: Attributes,
on: bool,
) -> Result<(), &'static str>
pub fn set_attributes( &mut self, attr: Attributes, on: bool, ) -> Result<(), &'static str>
Set the given attribute bits to be on or off.
Sourcepub fn set_terminal_size(
&mut self,
size: TerminalSize,
) -> Result<(), &'static str>
pub fn set_terminal_size( &mut self, size: TerminalSize, ) -> Result<(), &'static str>
Attempts to change the terminal size to a new size.
In many contexts the terminal size cannot change. Your program should tolerate that this will fail under reasonable conditions.
Sourcepub fn set_timeout(&mut self, time: i32)
pub fn set_timeout(&mut self, time: i32)
Assigns the timeout to use with poll_events
.
- Negative: infinite time,
poll_events
is blocking. - Zero: No timeout,
poll_events
returnsNone
immediately if no input is ready. - Positive: wait up to this many milliseconds before returning
None
.
The default is to have blocking input.
Sourcepub fn poll_events(&mut self) -> Option<CursesKey>
pub fn poll_events(&mut self) -> Option<CursesKey>
Gets an input event.
- Ascii keys are returned as their ascii value.
- Special keys each have an enum variant of their own.
- If the terminal is resized, that shows up as a type of “key”.
- If you have a timeout set and the time expires, you get
None
back.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn un_get_event(
&mut self,
event: Option<CursesKey>,
) -> Result<(), &'static str>
pub fn un_get_event( &mut self, event: Option<CursesKey>, ) -> Result<(), &'static str>
Pushes this event to the front of the event queue so that the next
poll_events
returns this value.
Sourcepub fn flush_events(&mut self) -> Result<(), &'static str>
pub fn flush_events(&mut self) -> Result<(), &'static str>
Flushes all pending key events.
Sourcepub fn shell_mode<'a>(&'a mut self) -> Result<CursesShell<'a>, &'static str>
pub fn shell_mode<'a>(&'a mut self) -> Result<CursesShell<'a>, &'static str>
Return the terminal to shell mode temporarily.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn can_change_colors(&self) -> bool
pub fn can_change_colors(&self) -> bool
If the terminal is able to change the RGB values of a given ColorID
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn get_max_color_id_inclusive(&self) -> Option<ColorID>
pub fn get_max_color_id_inclusive(&self) -> Option<ColorID>
Gets the highest allowed color id for this terminal.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn get_max_color_pair_inclusive(&self) -> Option<ColorPair>
pub fn get_max_color_pair_inclusive(&self) -> Option<ColorPair>
Gets the highest allowed color pair for this terminal.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn set_color_id_rgb(
&mut self,
c: ColorID,
[r, g, b]: [f32; 3],
) -> Result<(), &'static str>
pub fn set_color_id_rgb( &mut self, c: ColorID, [r, g, b]: [f32; 3], ) -> Result<(), &'static str>
Sets the color id to use the RGB values given, or closest approximation available.
Inputs are clamped to the range 0.0 ..= 1.0
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn get_color_id_rgb(&self, c: ColorID) -> Result<[f32; 3], &'static str>
pub fn get_color_id_rgb(&self, c: ColorID) -> Result<[f32; 3], &'static str>
Gets the RGB values of the given color id.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn set_color_pair_content(
&mut self,
pair: ColorPair,
fg: ColorID,
bg: ColorID,
) -> Result<(), &'static str>
pub fn set_color_pair_content( &mut self, pair: ColorPair, fg: ColorID, bg: ColorID, ) -> Result<(), &'static str>
Assigns the selected color pair to use the foreground and background specified.
A character cell is associated to a given color pair, so changing any color pair will immediately change all character cells displaying the color pair.
Sourcepub fn get_color_pair_content(
&self,
c: ColorID,
) -> Result<(ColorID, ColorID), &'static str>
pub fn get_color_pair_content( &self, c: ColorID, ) -> Result<(ColorID, ColorID), &'static str>
Gets the RGB values of the given color id.
Sourcepub fn set_active_color_pair(
&mut self,
opt_pair: Option<ColorPair>,
) -> Result<(), &'static str>
pub fn set_active_color_pair( &mut self, opt_pair: Option<ColorPair>, ) -> Result<(), &'static str>
Sets the default coloring for all newly printed glyphs.
Sourcepub fn set_scrollable(&mut self, yes: bool) -> Result<(), &'static str>
pub fn set_scrollable(&mut self, yes: bool) -> Result<(), &'static str>
Set if the window can be scrolled or not.
- Off by default.
Sourcepub fn set_scroll_region(
&mut self,
top: u32,
bottom: u32,
) -> Result<(), &'static str>
pub fn set_scroll_region( &mut self, top: u32, bottom: u32, ) -> Result<(), &'static str>
Sets the top line and bottom line that mark the edges of the scrollable region.
Lines 0..=top
and bottom..
will stay static when the window is
scrolled. All other lines will move 1 row upward.
- By default the scroll region is the entire terminal.
Sourcepub fn scroll(&mut self, n: i32) -> Result<(), &'static str>
pub fn scroll(&mut self, n: i32) -> Result<(), &'static str>
Scrolls the window by the given number of lines.
- Negative: text moves down the page.
- Positive: text moves up the page.
- Zero: text doesn’t move.
Sourcepub fn set_cursor_visibility(
&mut self,
vis: CursorVisibility,
) -> Result<CursorVisibility, &'static str>
pub fn set_cursor_visibility( &mut self, vis: CursorVisibility, ) -> Result<CursorVisibility, &'static str>
Sets the cursor visibility.
Returns the old visibility, or Err if it can’t be set.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn set_background<C: Into<CursesGlyph>>(
&mut self,
c: C,
) -> Result<(), &'static str>
pub fn set_background<C: Into<CursesGlyph>>( &mut self, c: C, ) -> Result<(), &'static str>
Sets the background glyph.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn get_background(&self) -> CursesGlyph
pub fn get_background(&self) -> CursesGlyph
Gets the background glyph.
Source§impl Curses
impl Curses
Sourcepub fn acs_block(&self) -> CursesGlyph
pub fn acs_block(&self) -> CursesGlyph
Solid square block, but sometimes a hash.
Sourcepub fn acs_board(&self) -> CursesGlyph
pub fn acs_board(&self) -> CursesGlyph
Board of squares, often just a hash.
Sourcepub fn acs_btee(&self) -> CursesGlyph
pub fn acs_btee(&self) -> CursesGlyph
Bottom T
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_bullet(&self) -> CursesGlyph
pub fn acs_bullet(&self) -> CursesGlyph
Bullet point
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_ckboard(&self) -> CursesGlyph
pub fn acs_ckboard(&self) -> CursesGlyph
Checkerboard, usually like a 50% stipple
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_darrow(&self) -> CursesGlyph
pub fn acs_darrow(&self) -> CursesGlyph
Down arrow
Sourcepub fn acs_degree(&self) -> CursesGlyph
pub fn acs_degree(&self) -> CursesGlyph
Degree symbol (like with an angle)
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_diamond(&self) -> CursesGlyph
pub fn acs_diamond(&self) -> CursesGlyph
Diamond
Sourcepub fn acs_gequal(&self) -> CursesGlyph
pub fn acs_gequal(&self) -> CursesGlyph
Greater-than or equal to.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_hline(&self) -> CursesGlyph
pub fn acs_hline(&self) -> CursesGlyph
Horizontal line
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_lantern(&self) -> CursesGlyph
pub fn acs_lantern(&self) -> CursesGlyph
Lantern symbol
Sourcepub fn acs_larrow(&self) -> CursesGlyph
pub fn acs_larrow(&self) -> CursesGlyph
Left arrow
Sourcepub fn acs_lequal(&self) -> CursesGlyph
pub fn acs_lequal(&self) -> CursesGlyph
Less-than or equal to.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_llcorner(&self) -> CursesGlyph
pub fn acs_llcorner(&self) -> CursesGlyph
Lower left corner of a box.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_lrcorner(&self) -> CursesGlyph
pub fn acs_lrcorner(&self) -> CursesGlyph
Lower right corner of a box.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_ltee(&self) -> CursesGlyph
pub fn acs_ltee(&self) -> CursesGlyph
Left T
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_nequal(&self) -> CursesGlyph
pub fn acs_nequal(&self) -> CursesGlyph
Not-equal to.
Sourcepub fn acs_pi(&self) -> CursesGlyph
pub fn acs_pi(&self) -> CursesGlyph
Pi
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_plminus(&self) -> CursesGlyph
pub fn acs_plminus(&self) -> CursesGlyph
Plus/Minus
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_plus(&self) -> CursesGlyph
pub fn acs_plus(&self) -> CursesGlyph
Plus shaped “line” in all four directions
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_rarrow(&self) -> CursesGlyph
pub fn acs_rarrow(&self) -> CursesGlyph
Right arrow
Sourcepub fn acs_rtee(&self) -> CursesGlyph
pub fn acs_rtee(&self) -> CursesGlyph
Right T
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_s1(&self) -> CursesGlyph
pub fn acs_s1(&self) -> CursesGlyph
Horizontal Scanline 1
Sourcepub fn acs_s3(&self) -> CursesGlyph
pub fn acs_s3(&self) -> CursesGlyph
Horizontal Scanline 3
Sourcepub fn acs_s7(&self) -> CursesGlyph
pub fn acs_s7(&self) -> CursesGlyph
Horizontal Scanline 7
Sourcepub fn acs_s9(&self) -> CursesGlyph
pub fn acs_s9(&self) -> CursesGlyph
Horizontal Scanline 9
Sourcepub fn acs_sterling(&self) -> CursesGlyph
pub fn acs_sterling(&self) -> CursesGlyph
British pounds sterling.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_ttee(&self) -> CursesGlyph
pub fn acs_ttee(&self) -> CursesGlyph
Top T
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_uarrow(&self) -> CursesGlyph
pub fn acs_uarrow(&self) -> CursesGlyph
Up arrow
Sourcepub fn acs_ulcorner(&self) -> CursesGlyph
pub fn acs_ulcorner(&self) -> CursesGlyph
Upper left corner of a box.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_urcorner(&self) -> CursesGlyph
pub fn acs_urcorner(&self) -> CursesGlyph
Upper right corner of a box.
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}
Sourcepub fn acs_vline(&self) -> CursesGlyph
pub fn acs_vline(&self) -> CursesGlyph
Vertical line
Examples found in repository?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
fn main() {
// This will rust-panic on double-init, and on failure in the C layer the C
// code will "helpfully" print the error message and abort the process.
// Otherwise, this "always succeeds".
let mut win = Curses::init();
win.set_echo(false);
win.set_cursor_visibility(CursorVisibility::Invisible);
if win.can_change_colors() {
win.set_color_id_rgb(ColorID::WHITE, [1.0, 1.0, 1.0]).unwrap();
} else {
win.print_str("This terminal cannot change colors :(");
}
win.move_cursor(Position { x: 75, y: 1 });
let ascii = b'@';
let opt_color_pair = None;
win.print_ch(CursesGlyph {
ascii,
opt_color_pair,
attributes: Attributes(0),
});
for n in 0..16 {
let attributes = Attributes(1 << n);
win.print_ch(CursesGlyph { ascii, opt_color_pair, attributes });
}
win.move_cursor(Position { x: 75, y: 5 });
win.print_str("Hello there, General Kenobi!");
win.poll_events().unwrap();
//
win.set_background('!');
win.clear();
win.print_str("ACS:");
// These are the ACS characters that are most likely to be consistent-enough
// across terminals:
for ch in [
win.acs_sterling(),
win.acs_degree(),
win.acs_plminus(),
win.acs_bullet(),
win.acs_pi(),
win.acs_lequal(),
win.acs_gequal(),
win.acs_hline(),
win.acs_vline(),
win.acs_ulcorner(),
win.acs_urcorner(),
win.acs_llcorner(),
win.acs_lrcorner(),
win.acs_ltee(),
win.acs_rtee(),
win.acs_ttee(),
win.acs_btee(),
win.acs_plus(),
win.acs_ckboard(),
]
.iter()
.copied()
{
win.print_ch(ch);
}
win.move_cursor(Position { x: 75, y: 8 });
win.copy_glyphs(&[CursesGlyph::from(ascii); 10]);
const Q: CursesKey = CursesKey::from_ascii(b'q');
const P: CursesKey = CursesKey::from_ascii(b'p');
const BANG: CursesKey = CursesKey::from_ascii(b'!');
loop {
match win.poll_events() {
Some(Q) => break,
Some(BANG) => panic!("test panic"),
Some(P) => {
let sh = win.shell_mode().unwrap();
for cid in 0..8 {
let [r, g, b] = sh.get_color_id_rgb(ColorID(cid)).unwrap();
eprintln!("CID({}): [{},{},{}]", cid, r, g, b);
}
eprintln!("{:?}", sh.get_cursor_position());
eprintln!("{:?}", sh.get_terminal_size());
eprintln!("{:?}", sh.get_max_color_id_inclusive());
eprintln!("{:?}", sh.get_max_color_pair_inclusive());
let mut str_buf = String::with_capacity(1024);
std::io::stdin().read_line(&mut str_buf).unwrap();
println!("got line: {}", str_buf);
}
Some(CursesKey::UnknownKey(u)) => {
let sh = win.shell_mode().unwrap();
panic!("Unknown Key: {}", u);
}
_ => continue,
}
}
println!("Demo over.");
}