bounds/
bounds.rs

1
2#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
3
4extern crate easycurses;
5
6use easycurses::*;
7
8fn main() {
9    // Common startup
10    let mut easy = EasyCurses::initialize_system().unwrap();
11    easy.set_cursor_visibility(CursorVisibility::Invisible);
12    easy.set_echo(false);
13    easy.set_keypad_enabled(true);
14
15    // Check the size of the window.
16    let (row_count, col_count) = easy.get_row_col_count();
17
18    // A message using RC coordinates.
19    easy.move_rc(0, 0);
20    assert_eq!(easy.get_cursor_rc(), (0, 0));
21    easy.print("Hello from RC 0,0.");
22
23    // A message using XY coordinates.
24    easy.move_xy(1, 1);
25    assert_eq!(easy.get_cursor_xy(), (1, 1));
26    easy.print("Hello from XY 1,1.");
27
28    // Upper right corner has a '+'
29    easy.move_rc(0, col_count - 1);
30    easy.print_char('+');
31
32    // Lower left corner has a '-', note that the col_count based argument is
33    // the first argument now because we're using the xy coordinate system.
34    easy.move_xy(col_count - 1, 0);
35    easy.print_char('-');
36
37    // Middle of the screen (ish) has a '*'
38    easy.move_xy(col_count / 2, row_count / 2);
39    easy.print_char('*');
40
41    // Ensure that the user has the latest view of things.
42    easy.refresh();
43
44    // Get one input from the user. This is just so that they have a chance to
45    // see the message and press a key, otherwise the program would end faster
46    // than they could read it.
47    easy.get_input();
48}