From d04147e1fcc425c031b402b4c50d31dc8f27e365 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 25 Oct 2022 09:03:39 -0600 Subject: [PATCH] Reduce framerate of orbclient example --- examples/editor-orbclient/src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/editor-orbclient/src/main.rs b/examples/editor-orbclient/src/main.rs index 8bf23cd..b5daad5 100644 --- a/examples/editor-orbclient/src/main.rs +++ b/examples/editor-orbclient/src/main.rs @@ -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)); + } } }