Struct ascii_forge::window::Supports
source · pub struct Supports { /* private fields */ }
Expand description
Struct that helps report what the terminal supports for you without you having to work with it yourself.
Implementations§
source§impl Supports
impl Supports
sourcepub fn keyboard(&self) -> bool
pub fn keyboard(&self) -> bool
Examples found in repository?
examples/event_visualizer.rs (line 9)
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
fn main() -> Result<(), Box<dyn Error>> {
let mut event = Event::FocusGained;
let mut window = Window::init()?;
if !window.supports().keyboard() {
window.restore()?;
eprintln!("This game does not support this terminal.\nIf Curious, look up terminals that support the kitty keyboard protocol");
return Err("Terminal Unsupported".into());
}
loop {
window.update(Duration::ZERO)?;
if let Some(new_event) = window.event() {
event = new_event.clone();
}
render!(
window, [
vec2(0, 20) => "To Quit, Press Ctrl + C".red(),
vec2(0, 0) => format!("{:#?}", event).replace('\t', " "),
]
);
if window.key(KeyEvent::new(KeyCode::Char('c'), KeyModifiers::CONTROL)) {
break;
}
}
Ok(())
}
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Supports
impl Send for Supports
impl Sync for Supports
impl Unpin for Supports
impl UnwindSafe for Supports
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more