diff --git a/src/components/wallet/event_logs.rs b/src/components/wallet/event_logs.rs
index 1f14a60..d772f12 100644
--- a/src/components/wallet/event_logs.rs
+++ b/src/components/wallet/event_logs.rs
@@ -1,4 +1,5 @@
use color_eyre::Result;
+use crossterm::event::{KeyCode, KeyEvent};
use ratatui::{
layout::{Alignment, Constraint, Margin, Rect},
style::{Color, Style},
@@ -51,13 +52,62 @@ impl EventLogs {
self.table_state.select(Some(self.logs.len() - 1));
self.scroll_state = self.scroll_state.content_length(self.logs.len());
}
+
+ fn first_row(&mut self) {
+ if self.logs.len() > 0 {
+ self.table_state.select(Some(0));
+ self.scroll_state = self.scroll_state.position(0);
+ }
+ }
+
+ fn next_row(&mut self) {
+ let i = match self.table_state.selected() {
+ Some(i) => {
+ if i >= self.logs.len() - 1 {
+ i
+ } else {
+ i + 1
+ }
+ },
+ None => 0,
+ };
+ self.table_state.select(Some(i));
+ self.scroll_state = self.scroll_state.position(i);
+ }
+
+ fn last_row(&mut self) {
+ if self.logs.len() > 0 {
+ let last = self.logs.len() - 1;
+ self.table_state.select(Some(last));
+ self.scroll_state = self.scroll_state.position(last);
+ }
+ }
+
+ fn previous_row(&mut self) {
+ let i = match self.table_state.selected() {
+ Some(i) => {
+ if i == 0 {
+ 0
+ } else {
+ i - 1
+ }
+ },
+ None => 0
+ };
+ self.table_state.select(Some(i));
+ self.scroll_state = self.scroll_state.position(i);
+ }
}
impl PartialComponent for EventLogs {
fn set_active(&mut self, current_tab: CurrentTab) {
match current_tab {
CurrentTab::EventLogs => self.is_active = true,
- _ => self.is_active = false,
+ _ => {
+ self.is_active = false;
+ self.table_state.select(None);
+ self.scroll_state = self.scroll_state.position(0);
+ }
}
}
}
@@ -71,10 +121,23 @@ impl Component for EventLogs {
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_highlight_style(style.get("highlight_style").copied());
+ self.palette.with_scrollbar_style(style.get("scrollbar_style").copied());
}
Ok(())
}
+ fn handle_key_event(&mut self, key: KeyEvent) -> Result