Skip to content

Commit

Permalink
Fixed issues with runner terminal not updating
Browse files Browse the repository at this point in the history
  • Loading branch information
curlpipe committed Dec 21, 2024
1 parent ac9f01a commit 279bbb0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
29 changes: 17 additions & 12 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@ pub fn mm_active(editor: &AnyUserData) -> bool {
ged!(mut &editor).macro_man.playing
}

pub fn hold_event(editor: &AnyUserData) -> bool {
matches!(
(
mm_active(editor),
term_force(editor),
poll(Duration::from_millis(50))
/// (should hold event, triggered by term force?)
pub fn hold_event(editor: &AnyUserData) -> (bool, bool) {
let tf = term_force(editor);
(
matches!(
(mm_active(editor), tf, poll(Duration::from_millis(50))),
(false, false, Ok(false))
),
(false, false, Ok(false))
!tf,
)
}

pub fn wait_for_event(editor: &AnyUserData, lua: &Lua) -> Result<CEvent> {
loop {
// While waiting for an event to come along, service the task manager
if !mm_active(editor) {
while hold_event(editor) {
while let (true, was_term) = hold_event(editor) {
let exec = ged!(mut &editor)
.config
.task_manager
Expand All @@ -47,7 +48,7 @@ pub fn wait_for_event(editor: &AnyUserData, lua: &Lua) -> Result<CEvent> {
}
// If a terminal dictates, force a rerender
#[cfg(not(target_os = "windows"))]
if term_force(editor) {
if was_term {
ged!(mut &editor).needs_rerender = true;
ged!(mut &editor).render(lua)?;
}
Expand Down Expand Up @@ -100,9 +101,13 @@ pub fn get_event(editor: &mut Editor) -> Option<CEvent> {
if let Some(ev) = editor.macro_man.next() {
// Take from macro man
Some(ev)
} else if let Ok(ev) = read() {
// Use standard crossterm event
Some(ev)
} else if let Ok(true) = poll(Duration::from_millis(50)) {
if let Ok(ev) = read() {
// Use standard crossterm event
Some(ev)
} else {
None
}
} else {
None
}
Expand Down
2 changes: 0 additions & 2 deletions src/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ impl Pty {
}
// println!("Adding (aftercmd) \"{:?}\"", output);
self.output += &output;
self.force_rerender = true;
Ok(())
}

Expand All @@ -127,7 +126,6 @@ impl Pty {
if self.output.starts_with(cmd) {
self.output = self.output.chars().skip(cmd.chars().count()).collect();
}
self.force_rerender = true;
Ok(())
}

Expand Down

0 comments on commit 279bbb0

Please sign in to comment.