Skip to content

Commit

Permalink
fix: add shutting down dialog to TUI (#3101)
Browse files Browse the repository at this point in the history
* fix: add shutting down dialog to the TUI
  • Loading branch information
Joseph Goulden authored and hashmap committed Oct 28, 2019
1 parent 1f5de6b commit 67057ab
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/bin/tui/ui.rs
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,11 @@ 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| {
let content = StyledString::styled("Shutting down...", Color::Light(BaseColor::Yellow));
c.add_layer(CircularFocus::wrap_tab(Dialog::around(TextView::new(
content,
))));
controller_tx_clone
.send(ControllerMessage::Shutdown)
.unwrap();
Expand Down Expand Up @@ -174,7 +178,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 67057ab

Please sign in to comment.