From 153305f5e45bbccd9083f8228fe436729f0eba34 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 27 Jul 2022 10:21:50 -0700 Subject: [PATCH] Finished long-lock style rendering. Need to dynamically adjust the notification rate to handle high throughput scenarios --- crates/terminal/src/terminal.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index 802d3e59be8a321bb2b685218dfe561fa0dfaca2..f1fd0d961b46aa910544c159d75b29289897059e 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -345,11 +345,14 @@ impl TerminalBuilder { }) } + //TODO: Adaptive framerate mechanism for high throughput times? + //Probably nescessary... + pub fn subscribe(mut self, cx: &mut ModelContext) -> Terminal { cx.spawn_weak(|this, mut cx| async move { 'outer: loop { //TODO: Pending GPUI updates, sync this to some higher, smarter system. - let delay = cx.background().timer(Duration::from_secs_f32(1.0 / 60.)); + let delay = cx.background().timer(Duration::from_secs_f32(1.0 / 30.)); let mut events = vec![]; @@ -365,8 +368,9 @@ impl TerminalBuilder { } match this.upgrade(&cx) { Some(this) => { - this.update(&mut cx, |this, _cx| { + this.update(&mut cx, |this, cx| { this.push_events(events); + cx.notify(); }); } None => break 'outer, @@ -402,7 +406,6 @@ impl Terminal { term: &mut Term, cx: &mut ModelContext, ) { - dbg!(event); // TODO: Handle is_self_focused in subscription on terminal view match event { InternalEvent::TermEvent(term_event) => match term_event { @@ -463,7 +466,6 @@ impl Terminal { term.clear_screen(ClearMode::Saved); } InternalEvent::Keystroke(keystroke) => { - println!("Trying keystroke: {}", keystroke); let esc = to_esc_str(keystroke, term.mode()); if let Some(esc) = esc { self.notify_pty(esc); @@ -537,7 +539,6 @@ impl Terminal { where F: FnOnce(RenderableContent, char) -> T, { - println!("RENDER LOCK!"); let m = self.term.clone(); //Arc clone let mut term = m.lock();