Compare commits
4 Commits
4d32d4d403
...
63e35a4120
Author | SHA1 | Date | |
---|---|---|---|
63e35a4120 | |||
71a7d9029c | |||
79abbd566d | |||
fc50b78637 |
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-eye"
|
||||
version = "0.2.0"
|
||||
version = "0.2.2"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
@ -27,6 +27,8 @@
|
||||
"normal_title_style": "blue",
|
||||
"hover_title_style": "",
|
||||
"highlight_style": "yellow bold",
|
||||
"popup_style": "blue",
|
||||
"popup_title_style": "blue",
|
||||
}
|
||||
},
|
||||
"keybindings": {
|
||||
|
@ -178,13 +178,12 @@ impl Accounts {
|
||||
let pair_signer = PairSigner::<CasperConfig, Pair>::new(pair);
|
||||
|
||||
self.wallet_keys.push((wallet_name.to_string(), address, wallet_key.to_string(), pair_signer));
|
||||
|
||||
if let Some(action_tx) = &self.action_tx {
|
||||
let _ = action_tx.send(Action::WalletLog(
|
||||
format!("read {} wallets from disk", self.wallet_keys.len()),
|
||||
ActionLevel::Info,
|
||||
));
|
||||
}
|
||||
}
|
||||
if let Some(action_tx) = &self.action_tx {
|
||||
let _ = action_tx.send(Action::WalletLog(
|
||||
format!("read {} wallets from disk", self.wallet_keys.len()),
|
||||
ActionLevel::Info,
|
||||
));
|
||||
}
|
||||
},
|
||||
Err(_) => {
|
||||
@ -307,7 +306,7 @@ impl Component for Accounts {
|
||||
}
|
||||
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_hover_style(style.get("hover_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
|
@ -83,10 +83,12 @@ impl Component for AddAccount {
|
||||
}
|
||||
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
self.palette.with_normal_title_style(style.get("normal_title_style").copied());
|
||||
self.palette.with_popup_style(style.get("popup_style").copied());
|
||||
self.palette.with_popup_title_style(style.get("popup_title_style").copied());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -108,8 +110,15 @@ impl Component for AddAccount {
|
||||
|
||||
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
||||
if self.is_active {
|
||||
let size = area.as_size();
|
||||
let area = Rect::new(size.width / 2, size.height / 2, 50, 3);
|
||||
let (border_style, border_type) = self.palette.create_popup_style();
|
||||
|
||||
let input = Paragraph::new(self.name.value())
|
||||
.block(Block::bordered()
|
||||
.border_style(border_style)
|
||||
.border_type(border_type)
|
||||
.title_style(self.palette.create_popup_title_style())
|
||||
.title_alignment(Alignment::Right)
|
||||
.title("New wallet name"));
|
||||
let v = Layout::vertical([Constraint::Max(3)]).flex(Flex::Center);
|
||||
|
@ -128,10 +128,12 @@ impl Component for AddAddressBookRecord {
|
||||
}
|
||||
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
self.palette.with_normal_title_style(style.get("normal_title_style").copied());
|
||||
self.palette.with_popup_style(style.get("popup_style").copied());
|
||||
self.palette.with_popup_title_style(style.get("popup_title_style").copied());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -158,14 +160,21 @@ impl Component for AddAddressBookRecord {
|
||||
let size = area.as_size();
|
||||
let name_area = Rect::new(size.width / 2, size.height / 2, 50, 3);
|
||||
let address_area = Rect::new(size.width / 2, size.height / 2 + 3, 50, 3);
|
||||
let (border_style, border_type) = self.palette.create_popup_style();
|
||||
|
||||
let input_name = Paragraph::new(self.name.value())
|
||||
.block(Block::bordered()
|
||||
.border_style(border_style)
|
||||
.border_type(border_type)
|
||||
.title_style(self.palette.create_popup_title_style())
|
||||
.title_alignment(Alignment::Right)
|
||||
.title("New name in Address Book"));
|
||||
|
||||
let input_address = Paragraph::new(self.address.value())
|
||||
.block(Block::bordered()
|
||||
.border_style(border_style)
|
||||
.border_type(border_type)
|
||||
.title_style(self.palette.create_popup_title_style())
|
||||
.title_alignment(Alignment::Right)
|
||||
.title("Address for new name"));
|
||||
|
||||
|
@ -277,7 +277,7 @@ impl PartialComponent for AddressBook {
|
||||
|
||||
impl Component for AddressBook {
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_hover_style(style.get("hover_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
|
@ -60,7 +60,7 @@ impl PartialComponent for Balance {
|
||||
|
||||
impl Component for Balance {
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_hover_style(style.get("hover_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
|
@ -64,7 +64,7 @@ impl PartialComponent for EventLogs {
|
||||
|
||||
impl Component for EventLogs {
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_hover_style(style.get("hover_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
|
@ -102,10 +102,8 @@ impl Component for Wallet {
|
||||
}
|
||||
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(_) = config.styles.get(&crate::app::Mode::Explorer) {
|
||||
for component in self.components.iter_mut() {
|
||||
component.register_config_handler(config.clone())?;
|
||||
}
|
||||
for component in self.components.iter_mut() {
|
||||
component.register_config_handler(config.clone())?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ impl PartialComponent for Overview {
|
||||
|
||||
impl Component for Overview {
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_hover_style(style.get("hover_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
|
@ -86,10 +86,12 @@ impl Component for RenameAccount {
|
||||
}
|
||||
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
self.palette.with_normal_title_style(style.get("normal_title_style").copied());
|
||||
self.palette.with_popup_style(style.get("popup_style").copied());
|
||||
self.palette.with_popup_title_style(style.get("popup_title_style").copied());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -119,8 +121,12 @@ impl Component for RenameAccount {
|
||||
|
||||
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
||||
if self.is_active {
|
||||
let (border_style, border_type) = self.palette.create_popup_style();
|
||||
let input = Paragraph::new(self.name.value())
|
||||
.block(Block::bordered()
|
||||
.border_style(border_style)
|
||||
.border_type(border_type)
|
||||
.title_style(self.palette.create_popup_title_style())
|
||||
.title_alignment(Alignment::Right)
|
||||
.title(format!("New name for '{}'", self.old_name)));
|
||||
let v = Layout::vertical([Constraint::Max(3)]).flex(Flex::Center);
|
||||
|
@ -91,6 +91,8 @@ impl Component for RenameAddressBookRecord {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
self.palette.with_normal_title_style(style.get("normal_title_style").copied());
|
||||
self.palette.with_popup_style(style.get("popup_style").copied());
|
||||
self.palette.with_popup_title_style(style.get("popup_title_style").copied());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -120,8 +122,12 @@ impl Component for RenameAddressBookRecord {
|
||||
|
||||
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
||||
if self.is_active {
|
||||
let (border_style, border_type) = self.palette.create_popup_style();
|
||||
let input = Paragraph::new(self.name.value())
|
||||
.block(Block::bordered()
|
||||
.border_style(border_style)
|
||||
.border_type(border_type)
|
||||
.title_style(self.palette.create_popup_title_style())
|
||||
.title_alignment(Alignment::Right)
|
||||
.title(format!("New name for '{}'", self.old_name)));
|
||||
let v = Layout::vertical([Constraint::Max(3)]).flex(Flex::Center);
|
||||
|
@ -41,13 +41,12 @@ impl PartialComponent for Transfer {
|
||||
|
||||
impl Component for Transfer {
|
||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
|
||||
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
|
||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
||||
self.palette.with_hover_style(style.get("hover_style").copied());
|
||||
self.palette.with_normal_border_style(style.get("normal_border_style").copied());
|
||||
self.palette.with_hover_border_style(style.get("hover_border_style").copied());
|
||||
self.palette.with_normal_title_style(style.get("normal_title_style").copied());
|
||||
self.palette.with_hover_title_style(style.get("hover_title_style").copied());
|
||||
self.palette.with_popup_style(style.get("popup_style").copied());
|
||||
self.palette.with_popup_title_style(style.get("popup_title_style").copied());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -15,8 +15,12 @@ pub struct StylePalette {
|
||||
highlight_style: Option<Style>,
|
||||
scrollbar_style: Option<Style>,
|
||||
|
||||
popup_style: Option<Style>,
|
||||
popup_title_style: Option<Style>,
|
||||
|
||||
normal_border_type: BorderType,
|
||||
hover_border_type: BorderType,
|
||||
popup_border_type: BorderType,
|
||||
}
|
||||
|
||||
impl Default for StylePalette {
|
||||
@ -36,9 +40,12 @@ impl StylePalette {
|
||||
hover_title_style: None,
|
||||
highlight_style: None,
|
||||
scrollbar_style: None,
|
||||
popup_style: None,
|
||||
popup_title_style: None,
|
||||
|
||||
normal_border_type: BorderType::Plain,
|
||||
hover_border_type: BorderType::Double,
|
||||
popup_border_type: BorderType::Thick,
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,6 +81,14 @@ impl StylePalette {
|
||||
self.scrollbar_style = scrollbar_style;
|
||||
}
|
||||
|
||||
pub fn with_popup_style(&mut self, popup_style: Option<Style>) {
|
||||
self.popup_style = popup_style;
|
||||
}
|
||||
|
||||
pub fn with_popup_title_style(&mut self, popup_title_style: Option<Style>) {
|
||||
self.popup_title_style = popup_title_style;
|
||||
}
|
||||
|
||||
pub fn create_scrollbar_style(&mut self) -> Style {
|
||||
self.scrollbar_style.unwrap_or_default()
|
||||
}
|
||||
@ -111,4 +126,15 @@ impl StylePalette {
|
||||
self.hover_title_style.unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_popup_style(&self) -> (Color, BorderType) {
|
||||
(
|
||||
self.popup_style.map(|style| style.fg).flatten().unwrap_or_default(),
|
||||
self.popup_border_type,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn create_popup_title_style(&self) -> Style {
|
||||
self.popup_title_style.unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user