[TUI] Properly handle Esc in Peers and Mining, add Esc to the legend (#2371)

This commit is contained in:
eupn 2019-01-16 21:49:04 +03:00 committed by Ignotus Peverell
parent 4743286713
commit 85fcfd8b64
3 changed files with 14 additions and 6 deletions

View file

@ -83,6 +83,7 @@ pub fn create() -> Box<dyn View> {
.child(TextView::new("------------------"))
.child(TextView::new("Tab/Arrow : Cycle "))
.child(TextView::new("Enter : Select"))
.child(TextView::new("Esc : Back "))
.child(TextView::new("Q : Quit "));
Box::new(main_menu)
}

View file

@ -184,10 +184,6 @@ impl TUIStatusListener for TUIMiningView {
.child(Panel::new(devices_button))
.child(Panel::new(difficulty_button));
let mining_submenu = OnEventView::new(mining_submenu).on_pre_event(Key::Esc, move |c| {
let _ = c.focus_id(MAIN_MENU);
});
let table_view = TableView::<WorkerStats, StratumWorkerColumn>::new()
.column(StratumWorkerColumn::Id, "Worker ID", |c| c.width_percent(8))
.column(StratumWorkerColumn::IsConnected, "Connected", |c| {
@ -306,6 +302,10 @@ impl TUIStatusListener for TUIMiningView {
.child(mining_submenu)
.child(view_stack);
let mining_view = OnEventView::new(mining_view).on_pre_event(Key::Esc, move |c| {
let _ = c.focus_id(MAIN_MENU);
});
Box::new(mining_view.with_id(VIEW_MINING))
}

View file

@ -22,12 +22,13 @@ use crate::tui::humansize::{file_size_opts::CONVENTIONAL, FileSize};
use chrono::prelude::*;
use cursive::direction::Orientation;
use cursive::event::Key;
use cursive::traits::{Boxable, Identifiable};
use cursive::view::View;
use cursive::views::{BoxView, Dialog, LinearLayout, TextView};
use cursive::views::{BoxView, Dialog, LinearLayout, OnEventView, TextView};
use cursive::Cursive;
use crate::tui::constants::{TABLE_PEER_STATUS, VIEW_PEER_SYNC};
use crate::tui::constants::{MAIN_MENU, TABLE_PEER_STATUS, VIEW_PEER_SYNC};
use crate::tui::table::{TableView, TableViewItem};
use crate::tui::types::TUIStatusListener;
@ -149,6 +150,12 @@ impl TUIStatusListener for TUIPeerView {
),
)
.with_id(VIEW_PEER_SYNC);
let peer_status_view =
OnEventView::new(peer_status_view).on_pre_event(Key::Esc, move |c| {
let _ = c.focus_id(MAIN_MENU);
});
Box::new(peer_status_view)
}