Skip to content

Commit

Permalink
fix: add shutting down dialog to TUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Goulden committed Oct 27, 2019
1 parent 9bb14b4 commit c6cde8e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/bin/tui/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use cursive::theme::{BaseColor, BorderStyle, Color, Theme};
use cursive::traits::Boxable;
use cursive::traits::Identifiable;
use cursive::utils::markup::StyledString;
use cursive::views::{LinearLayout, Panel, StackView, TextView, ViewBox};
use cursive::views::{CircularFocus, Dialog, LinearLayout, Panel, StackView, TextView, ViewBox};
use cursive::Cursive;
use std::sync::mpsc;

Expand Down Expand Up @@ -108,7 +108,10 @@ impl UI {

// Configure a callback (shutdown, for the first test)
let controller_tx_clone = grin_ui.controller_tx.clone();
grin_ui.cursive.add_global_callback('q', move |_| {
grin_ui.cursive.add_global_callback('q', move |c| {
c.add_layer(CircularFocus::wrap_tab(Dialog::around(TextView::new(
"Shutting down...",
))));
controller_tx_clone
.send(ControllerMessage::Shutdown)
.unwrap();
Expand Down Expand Up @@ -174,7 +177,6 @@ impl Controller {
match message {
ControllerMessage::Shutdown => {
self.ui.stop();
println!("Shutdown in progress, please wait");
server.stop();
return;
}
Expand Down

0 comments on commit c6cde8e

Please sign in to comment.