Compare commits

..

No commits in common. "63e35a4120265f4dd2b1c839654852f4752b8797" and "4d32d4d403b72e6e55a3258ef8bc16d4dcdece51" have entirely different histories.

14 changed files with 24 additions and 78 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "ghost-eye"
version = "0.2.2"
version = "0.2.0"
edition = "2021"
[dependencies]

View File

@ -27,8 +27,6 @@
"normal_title_style": "blue",
"hover_title_style": "",
"highlight_style": "yellow bold",
"popup_style": "blue",
"popup_title_style": "blue",
}
},
"keybindings": {

View File

@ -178,12 +178,13 @@ 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(_) => {
@ -306,7 +307,7 @@ impl Component for Accounts {
}
fn register_config_handler(&mut self, config: Config) -> Result<()> {
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
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());

View File

@ -83,12 +83,10 @@ impl Component for AddAccount {
}
fn register_config_handler(&mut self, config: Config) -> Result<()> {
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
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(())
}
@ -110,15 +108,8 @@ 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);

View File

@ -128,12 +128,10 @@ impl Component for AddAddressBookRecord {
}
fn register_config_handler(&mut self, config: Config) -> Result<()> {
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
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(())
}
@ -160,21 +158,14 @@ 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"));

View File

@ -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::Wallet) {
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
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());

View File

@ -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::Wallet) {
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
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());

View File

@ -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::Wallet) {
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
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());

View File

@ -102,8 +102,10 @@ impl Component for Wallet {
}
fn register_config_handler(&mut self, config: Config) -> Result<()> {
for component in self.components.iter_mut() {
component.register_config_handler(config.clone())?;
if let Some(_) = config.styles.get(&crate::app::Mode::Explorer) {
for component in self.components.iter_mut() {
component.register_config_handler(config.clone())?;
}
}
Ok(())
}

View File

@ -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::Wallet) {
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
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());

View File

@ -86,12 +86,10 @@ impl Component for RenameAccount {
}
fn register_config_handler(&mut self, config: Config) -> Result<()> {
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
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(())
}
@ -121,12 +119,8 @@ 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);

View File

@ -91,8 +91,6 @@ 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(())
}
@ -122,12 +120,8 @@ 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);

View File

@ -41,12 +41,13 @@ 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::Wallet) {
if let Some(style) = config.styles.get(&crate::app::Mode::Explorer) {
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_popup_style(style.get("popup_style").copied());
self.palette.with_popup_title_style(style.get("popup_title_style").copied());
self.palette.with_hover_title_style(style.get("hover_title_style").copied());
}
Ok(())
}

View File

@ -15,12 +15,8 @@ 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 {
@ -40,12 +36,9 @@ 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,
}
}
@ -81,14 +74,6 @@ 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()
}
@ -126,15 +111,4 @@ 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()
}
}