Reduce framerate of orbclient example

This commit is contained in:
Jeremy Soller 2022-10-25 09:03:39 -06:00
parent 079778cbf9
commit d04147e1fc
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE

View file

@ -2,7 +2,7 @@
use cosmic_text::{FontSystem, TextAction, TextBuffer, TextCursor, TextLineIndex, TextMetrics};
use orbclient::{Color, EventOption, Renderer, Window, WindowFlag};
use std::{env, fs, time::Instant};
use std::{env, fs, thread, time::{Duration, Instant}};
fn main() {
env_logger::init();
@ -166,7 +166,9 @@ fn main() {
log::debug!("redraw: {:?}", duration);
}
let mut found_event = false;
for event in window.events() {
found_event = true;
match event.to_option() {
EventOption::Key(event) => match event.scancode {
orbclient::K_CTRL => ctrl_pressed = event.pressed,
@ -271,5 +273,9 @@ fn main() {
buffer.action(TextAction::Scroll { lines: 3 });
}
}
if ! found_event {
thread::sleep(Duration::from_millis(5));
}
}
}