Skip to content

Commit

Permalink
fix: address input (#321)
Browse files Browse the repository at this point in the history
* Use key modifiers to prevent undesired actions

* Capitalize the screen name

* Fix typo Crtl -> Ctrl
  • Loading branch information
brianp committed Mar 1, 2024
1 parent 52031dc commit e4c8a5c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
14 changes: 7 additions & 7 deletions cli/src/component/normal/legend_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ impl<B: Backend> Component<B> for LegendWidget {
f.render_widget(block, rect);

let command_items = [
["Crtl-Q", "Quit"],
["Crtl-B", "Start Tari node"],
["Crtl-H", "Switch to home"],
["Crtl-L", "Switch to logs"],
["Crtl-S", "Switch to settings"],
["Ctrl-Q", "Quit"],
["Ctrl-B", "Start Tari node"],
["Ctrl-H", "Switch to Home"],
["Ctrl-L", "Switch to Logs"],
["Ctrl-S", "Switch to Settings"],
["Enter ", "Edit/stop editing field"],
["M ", "Merge mine"],
["T ", "Sha mine"],
["Ctrl-M", "Merge mine"],
["Ctrl-T", "Sha mine"],
["Left-Arrow ", "Move left"],
["Right-Arrow", "Move right"],
["Up-Arrow ", "Move up"],
Expand Down
8 changes: 4 additions & 4 deletions cli/src/component/normal/mining/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ pub struct MergeMiningStatus;
impl StatusGetter for MergeMiningStatus {
fn get_status(&self, state: &AppState) -> (&str, Color) {
if state.state.config.session.merge_layer_active {
("⚒️ Press [M] to stop Merge Mining", Color::Green)
("⚒️ Press [Ctrl-M] to stop Merge Mining", Color::Green)
} else {
("Press [M] to start Merge mining ", Color::Gray)
("Press [Ctrl-M] to start Merge mining ", Color::Gray)
}
}
}
Expand All @@ -22,9 +22,9 @@ pub struct ShaMiningStatus;
impl StatusGetter for ShaMiningStatus {
fn get_status(&self, state: &AppState) -> (&str, Color) {
if state.state.config.session.sha3x_layer_active {
("⚒️ Press [T] to stop SHA3X mining", Color::Yellow)
("⚒️ Press [Ctrl-T] to stop SHA3X mining", Color::Yellow)
} else {
("Press [T] to start SHA3X mining ", Color::Gray)
("Press [Ctrl-T] to start SHA3X mining ", Color::Gray)
}
}
}
10 changes: 7 additions & 3 deletions cli/src/component/normal/mining/mining_panel.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023. The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

use crossterm::event::KeyCode;
use crossterm::event::{KeyCode, KeyModifiers};
use log::warn;
use ratatui::prelude::*;
use tari_launchpad_protocol::settings::LaunchpadSettings;
Expand Down Expand Up @@ -142,7 +142,9 @@ impl Input for MiningPanel {
self.check_for_updated_settings(state);

if let KeyEvent(key) = event {
if key.code == KeyCode::Char('m') || key.code == KeyCode::Char('M') {
if (key.code == KeyCode::Char('m') || key.code == KeyCode::Char('M'))
&& key.modifiers.contains(KeyModifiers::CONTROL)
{
if let Some(settings) = &state.state.config.settings {
if let Some(conf) = &settings.saved_settings.sha3_miner {
if conf.wallet_payment_address.is_none() {
Expand All @@ -164,7 +166,9 @@ impl Input for MiningPanel {
Self::toggle_merge_mining(state);
return Some(());
}
if key.code == KeyCode::Char('t') || key.code == KeyCode::Char('T') {
if (key.code == KeyCode::Char('t') || key.code == KeyCode::Char('T'))
&& key.modifiers.contains(KeyModifiers::CONTROL)
{
if let Some(settings) = &state.state.config.settings {
if let Some(conf) = &settings.saved_settings.sha3_miner {
if conf.wallet_payment_address.is_none() {
Expand Down

0 comments on commit e4c8a5c

Please sign in to comment.