summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJeff Zhao <jeff.no.zhao@gmail.com>2022-08-31 11:11:06 -0400
committerGitHub <noreply@github.com>2022-08-31 11:11:06 -0400
commit0ca4ffd657f1a2884ca8422be8a78baa42f00de4 (patch)
tree408c91b138707942b4c7736893e4ecbefbe9a544 /src/ui
parentcd838711107303e4c6076df5bc38b2b74c819480 (diff)
use hashmap and uuid to store tabs (#194)
This is preliminary changes in order to track preview threads and progress. The current setup is we just kick off a new thread to load the given directory whenever we see the directory content does not exist in history. We don't track these threads or which tab these requests came from. When the result is returned, we just assign it to the current tab, instead of the tab that actually initiated the request. By adding uuid, we can now track which tab requested the preview and assign it accordingly. This will also allow us to track the status of the preview, so we can display to the user a loading state, when a directory is taking longer than usual to load. This will also solve the problem of kicking off multiple threads to read the same directory for the same tab. Now these threads can be stored and tracked. - side: fix reload not honouring tab sort options - use tab specific options whenever we need to reload stuff
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/views/tui_folder_view.rs9
-rw-r--r--src/ui/views/tui_hsplit_view.rs8
2 files changed, 8 insertions, 9 deletions
diff --git a/src/ui/views/tui_folder_view.rs b/src/ui/views/tui_folder_view.rs
index f19336e..dd5e2e7 100644
--- a/src/ui/views/tui_folder_view.rs
+++ b/src/ui/views/tui_folder_view.rs
@@ -33,6 +33,7 @@ impl<'a> Widget for TuiFolderView<'a> {
fn render(self, area: Rect, buf: &mut Buffer) {
let preview_context = self.context.preview_context_ref();
let curr_tab = self.context.tab_context_ref().curr_tab_ref();
+ let curr_tab_id = self.context.tab_context_ref().curr_tab_id();
let curr_list = curr_tab.curr_list_ref();
let child_list = curr_tab.child_list_ref();
@@ -180,13 +181,9 @@ impl<'a> Widget for TuiFolderView<'a> {
width: TAB_VIEW_WIDTH,
height: 1,
};
- let name = if let Some(ostr) = curr_tab.cwd().file_name() {
- ostr.to_str().unwrap_or("")
- } else {
- ""
- };
+ let name = curr_tab_id.to_string();
TuiTabBar::new(
- name,
+ &name[..5],
self.context.tab_context_ref().index,
self.context.tab_context_ref().len(),
)
diff --git a/src/ui/views/tui_hsplit_view.rs b/src/ui/views/tui_hsplit_view.rs
index 015ca5a..2c26bd6 100644
--- a/src/ui/views/tui_hsplit_view.rs
+++ b/src/ui/views/tui_hsplit_view.rs
@@ -26,7 +26,6 @@ impl<'a> TuiHSplitView<'a> {
impl<'a> Widget for TuiHSplitView<'a> {
fn render(self, area: Rect, buf: &mut Buffer) {
let tab_context = self.context.tab_context_ref();
- let tab_index = tab_context.index;
let config = self.context.config_ref();
let display_options = config.display_options_ref();
@@ -66,7 +65,9 @@ impl<'a> Widget for TuiHSplitView<'a> {
calculate_layout(area, constraints)
};
- if let Some(curr_tab) = tab_context.tab_ref(tab_index) {
+ let tab_id = tab_context.curr_tab_id();
+ let tab_index = tab_context.index;
+ if let Some(curr_tab) = tab_context.tab_ref(&tab_id) {
let curr_list = curr_tab.curr_list_ref();
let layout_rect = if tab_index % 2 == 0 {
@@ -143,7 +144,8 @@ impl<'a> Widget for TuiHSplitView<'a> {
tab_index - 1
};
- if let Some(curr_tab) = tab_context.tab_ref(other_tab_index) {
+ let other_tab_id = tab_context.tab_order[other_tab_index];
+ if let Some(curr_tab) = tab_context.tab_ref(&other_tab_id) {
let curr_list = curr_tab.curr_list_ref();
let layout_rect = if other_tab_index % 2 == 0 {