Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions src/view/table_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ impl TableListView {
UserEvent::CopyToClipboard => {
self.copy_table_name_to_clipboard();
}
UserEvent::Reload => {
self.reload_table_list();
}
UserEvent::Help => {
self.open_help();
}
Expand Down Expand Up @@ -237,6 +240,9 @@ impl TableListView {
UserEvent::CopyToClipboard => {
self.copy_table_descriptions_to_clipboard();
}
UserEvent::Reload => {
self.reload_table_description();
}
UserEvent::Help => {
self.open_help();
}
Expand Down Expand Up @@ -284,6 +290,7 @@ fn build_helps(
BuildHelpsItem::new(UserEvent::NextPreview, "Switch to next preview"),
BuildHelpsItem::new(UserEvent::PrevPreview, "Switch to prev preview"),
BuildHelpsItem::new(UserEvent::CopyToClipboard, "Copy table name"),
BuildHelpsItem::new(UserEvent::Reload, "Reload table list"),
];
#[rustfmt::skip]
let list_filtered_helps = vec![
Expand All @@ -298,6 +305,7 @@ fn build_helps(
BuildHelpsItem::new(UserEvent::NextPreview, "Switch to next preview"),
BuildHelpsItem::new(UserEvent::PrevPreview, "Switch to prev preview"),
BuildHelpsItem::new(UserEvent::CopyToClipboard, "Copy table name"),
BuildHelpsItem::new(UserEvent::Reload, "Reload table list"),
];
#[rustfmt::skip]
let detail_helps = vec![
Expand All @@ -316,6 +324,7 @@ fn build_helps(
BuildHelpsItem::new(UserEvent::ToggleWrap, "Toggle wrap"),
BuildHelpsItem::new(UserEvent::ToggleNumber, "Toggle number"),
BuildHelpsItem::new(UserEvent::CopyToClipboard, "Copy table descriptions"),
BuildHelpsItem::new(UserEvent::Reload, "Reload table details"),
];
(
build_help_spans(list_helps, mapper, theme),
Expand All @@ -335,34 +344,37 @@ fn build_short_helps(
let list_helps = vec![
BuildShortHelpsItem::single(UserEvent::Quit, "Quit", 0),
BuildShortHelpsItem::group(vec![UserEvent::Down, UserEvent::Up], "Select", 2),
BuildShortHelpsItem::group(vec![UserEvent::GoToTop, UserEvent::GoToBottom], "Top/Bottom", 7),
BuildShortHelpsItem::group(vec![UserEvent::GoToTop, UserEvent::GoToBottom], "Top/Bottom", 8),
BuildShortHelpsItem::single(UserEvent::Confirm, "Open", 1),
BuildShortHelpsItem::single(UserEvent::QuickFilter, "Filter", 3),
BuildShortHelpsItem::single(UserEvent::NextPane, "Switch pane", 4),
BuildShortHelpsItem::single(UserEvent::NextPreview, "Switch preview", 6),
BuildShortHelpsItem::single(UserEvent::NextPreview, "Switch preview", 7),
BuildShortHelpsItem::single(UserEvent::CopyToClipboard, "Copy", 5),
BuildShortHelpsItem::single(UserEvent::Reload, "Reload", 6),
BuildShortHelpsItem::single(UserEvent::Help, "Help", 0),
];
#[rustfmt::skip]
let list_filtered_helps = vec![
BuildShortHelpsItem::single(UserEvent::Quit, "Quit", 0),
BuildShortHelpsItem::group(vec![UserEvent::Down, UserEvent::Up], "Select", 2),
BuildShortHelpsItem::group(vec![UserEvent::GoToTop, UserEvent::GoToBottom], "Top/Bottom", 7),
BuildShortHelpsItem::group(vec![UserEvent::GoToTop, UserEvent::GoToBottom], "Top/Bottom", 8),
BuildShortHelpsItem::single(UserEvent::Confirm, "Open", 1),
BuildShortHelpsItem::single(UserEvent::Reset, "Clear filter", 3),
BuildShortHelpsItem::single(UserEvent::NextPane, "Switch pane", 4),
BuildShortHelpsItem::single(UserEvent::NextPreview, "Switch preview", 6),
BuildShortHelpsItem::single(UserEvent::NextPreview, "Switch preview", 7),
BuildShortHelpsItem::single(UserEvent::CopyToClipboard, "Copy", 5),
BuildShortHelpsItem::single(UserEvent::Reload, "Reload", 6),
BuildShortHelpsItem::single(UserEvent::Help, "Help", 0),
];
#[rustfmt::skip]
let detail_helps = vec![
BuildShortHelpsItem::single(UserEvent::Quit, "Quit", 0),
BuildShortHelpsItem::group(vec![UserEvent::Down, UserEvent::Up], "Scroll", 1),
BuildShortHelpsItem::group(vec![UserEvent::GoToTop, UserEvent::GoToBottom], "Top/Bottom", 5),
BuildShortHelpsItem::group(vec![UserEvent::GoToTop, UserEvent::GoToBottom], "Top/Bottom", 6),
BuildShortHelpsItem::single(UserEvent::NextPane, "Switch pane", 2),
BuildShortHelpsItem::single(UserEvent::NextPreview, "Switch preview", 4),
BuildShortHelpsItem::group(vec![UserEvent::ToggleWrap, UserEvent::ToggleNumber], "Toggle wrap/number", 6),
BuildShortHelpsItem::single(UserEvent::NextPreview, "Switch preview", 5),
BuildShortHelpsItem::group(vec![UserEvent::ToggleWrap, UserEvent::ToggleNumber], "Toggle wrap/number", 7),
BuildShortHelpsItem::single(UserEvent::Reload, "Reload", 4),
BuildShortHelpsItem::single(UserEvent::CopyToClipboard, "Copy", 3),
BuildShortHelpsItem::single(UserEvent::Help, "Help", 0),
];
Expand Down Expand Up @@ -441,6 +453,13 @@ impl TableListView {
if self.table_descriptions.contains_key(name) {
return;
}

self.tx.send(AppEvent::LoadTableDescription(name.into()));
}
}

fn reload_table_description(&self) {
if let Some(name) = self.current_selected_table_name() {
self.tx.send(AppEvent::LoadTableDescription(name.into()));
}
}
Expand Down Expand Up @@ -584,6 +603,10 @@ impl TableListView {
));
}

fn reload_table_list(&self) {
self.tx.send(AppEvent::Initialize);
}

fn open_help(&self) {
match self.focused {
Focused::List => match self.filter_state {
Expand Down