Skip to content

Commit

Permalink
Add PAUSED icon
Browse files Browse the repository at this point in the history
  • Loading branch information
azat committed Nov 30, 2023
1 parent a5b81b9 commit 8bceed5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/interpreter/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ impl Worker {
);
}

pub fn is_paused(&self) -> bool {
return self.paused;
}

pub fn send(&mut self, event: Event) {
if self.paused {
return;
Expand Down
26 changes: 21 additions & 5 deletions src/view/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,22 @@ impl Navigation for Cursive {
}

fn toggle_pause_updates(&mut self) {
let mut context = self.user_data::<ContextArc>().unwrap().lock().unwrap();
// NOTE: though it will be better to stop sending any message completelly, instead of
// simply ignoring them
context.worker.toggle_pause();
let is_paused;
{
let mut context = self.user_data::<ContextArc>().unwrap().lock().unwrap();
// NOTE: though it will be better to stop sending any message completelly, instead of
// simply ignoring them
context.worker.toggle_pause();
is_paused = context.worker.is_paused();
}

self.call_on_name("is_paused", |v: &mut TextView| {
let mut text = StyledString::new();
if is_paused {
text.append_styled(" PAUSED", Effect::Bold);
}
v.set_content(text);
});
}

fn refresh_view(&mut self) {
Expand Down Expand Up @@ -152,7 +164,11 @@ impl Navigation for Cursive {
.child(
LinearLayout::vertical()
// FIXME: there is one extra line on top
.child(TextView::new(make_menu_text()))
.child(
LinearLayout::horizontal()
.child(TextView::new(make_menu_text()))
.child(TextView::new("").with_name("is_paused")),
)
.child(view::SummaryView::new(context.clone()).with_name("summary"))
.with_name("main"),
),
Expand Down

0 comments on commit 8bceed5

Please sign in to comment.