Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input bar at the top if we are in inline mode #866

Merged
merged 5 commits into from May 21, 2023
Merged

Conversation

ellie
Copy link
Member

@ellie ellie commented Apr 11, 2023

After merging this, I'm working on configurable UI before v15

The idea there is that we can control much more than just compact etc, and toggle each part of the UI to preference. Including where the input bar is

Thanks @pdecat for most of the work here! Based this off of #808

This does feel kinda weird with the up arrow binding

@vercel
Copy link

vercel bot commented Apr 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
atuin ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 18, 2023 9:49am

@ellie ellie enabled auto-merge (squash) April 11, 2023 21:28
@pdecat
Copy link
Contributor

pdecat commented Apr 12, 2023

This does feel kinda weird with the up arrow binding

It feels like the exit at most recent behavior is quite biting when trying to get used to the new direction. That probably should be made optional, or require two consecutive presses to actually exit.

I've commented it out to test how it goes:

diff --git a/src/command/client/search/interactive.rs b/src/command/client/search/interactive.rs
index 3e9dd122..a8e15583 100644
--- a/src/command/client/search/interactive.rs
+++ b/src/command/client/search/interactive.rs
@@ -180,18 +180,18 @@ impl State {
                 self.search_mode = self.search_mode.next(settings);
                 self.engine = engines::engine(self.search_mode);
             }
-            KeyCode::Down if self.results_state.selected() == 0 && !invert => {
-                return Some(match settings.exit_mode {
-                    ExitMode::ReturnOriginal => RETURN_ORIGINAL,
-                    ExitMode::ReturnQuery => RETURN_QUERY,
-                })
-            }
-            KeyCode::Up if self.results_state.selected() == 0 && invert => {
-                return Some(match settings.exit_mode {
-                    ExitMode::ReturnOriginal => RETURN_ORIGINAL,
-                    ExitMode::ReturnQuery => RETURN_QUERY,
-                })
-            }
+            // KeyCode::Down if self.results_state.selected() == 0 && !invert => {
+                // return Some(match settings.exit_mode {
+                    // ExitMode::ReturnOriginal => RETURN_ORIGINAL,
+                    // ExitMode::ReturnQuery => RETURN_QUERY,
+                // })
+            // }
+            // KeyCode::Up if self.results_state.selected() == 0 && invert => {
+                // return Some(match settings.exit_mode {
+                    // ExitMode::ReturnOriginal => RETURN_ORIGINAL,
+                    // ExitMode::ReturnQuery => RETURN_QUERY,
+                // })
+            // }
             KeyCode::Down if !invert => {
                 let i = self.results_state.selected().saturating_sub(1);
                 self.results_state.select(i);

I guess the main issue with it is that you cannot tell if you are on the most recent command.

@@ -13,6 +13,7 @@ use super::format_duration;
pub struct HistoryList<'a> {
history: &'a [History],
block: Option<Block<'a>>,
inverted: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny, we almost got to the same solution, here's what I had in stash:

diff --git a/src/command/client/search/history_list.rs b/src/command/client/search/history_list.rs
index eedab1a5..a7af8777 100644
--- a/src/command/client/search/history_list.rs
+++ b/src/command/client/search/history_list.rs
@@ -13,6 +13,7 @@ use super::format_duration;
 pub struct HistoryList<'a> {
     history: &'a [History],
     block: Option<Block<'a>>,
+    reversed: bool,
 }

 #[derive(Default)]
@@ -59,8 +60,9 @@ impl<'a> StatefulWidget for HistoryList<'a> {
             buf,
             list_area,
             x: 0,
-            y: 0,
+            y: if self.reversed { list_area.height } else { 0 },
             state,
+            reversed: self.reversed,
         };

         for item in self.history.iter().skip(state.offset).take(end - start) {
@@ -70,17 +72,18 @@ impl<'a> StatefulWidget for HistoryList<'a> {
             s.command(item);

             // reset line
-            s.y += 1;
+            s.y = if self.reversed { s.y - 1 } else { s.y + 1 };
             s.x = 0;
         }
     }
 }

 impl<'a> HistoryList<'a> {
-    pub fn new(history: &'a [History]) -> Self {
+    pub fn new(history: &'a [History], reversed: bool) -> Self {
         Self {
             history,
             block: None,
+            reversed,
         }
     }

@@ -110,6 +113,7 @@ struct DrawState<'a> {
     x: u16,
     y: u16,
     state: &'a ListState,
+    reversed: bool,
 }

 // longest line prefix I could come up with
diff --git a/src/command/client/search/interactive.rs b/src/command/client/search/interactive.rs
index 21ffb800..20aa3848 100644
--- a/src/command/client/search/interactive.rs
+++ b/src/command/client/search/interactive.rs
@@ -294,7 +294,7 @@ impl State {
         let stats = self.build_stats();
         f.render_widget(stats, header_chunks[2]);

-        let results_list = Self::build_results_list(compact, results);
+        let results_list = Self::build_results_list(compact, results, inline_mode);
         f.render_stateful_widget(results_list, results_list_chunk, &mut self.results_state);

         let input = self.build_input(compact, input_chunk.width.into());
@@ -352,11 +352,11 @@ impl State {
         stats
     }

-    fn build_results_list(compact: bool, results: &[History]) -> HistoryList {
+    fn build_results_list(compact: bool, results: &[History], reversed: bool) -> HistoryList {
         let results_list = if compact {
-            HistoryList::new(results)
+            HistoryList::new(results, reversed)
         } else {
-            HistoryList::new(results).block(
+            HistoryList::new(results, reversed).block(
                 Block::default()
                     .borders(Borders::TOP | Borders::LEFT | Borders::RIGHT)
                     .border_type(BorderType::Rounded),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha nice! very similar :D

@pdecat
Copy link
Contributor

pdecat commented Apr 12, 2023

I'm loving it so far :)

@ellie
Copy link
Member Author

ellie commented Apr 12, 2023

I'm loving it so far :)

awesome! I'll probably get it merged and gated behind some config soon then

@ellie ellie disabled auto-merge May 21, 2023 16:42
@ellie ellie merged commit 5b5e4ea into main May 21, 2023
9 checks passed
@ellie ellie deleted the ellie/search-at-top branch May 21, 2023 16:42
@lazywei
Copy link

lazywei commented May 22, 2023

I'm using the HEAD build which should include this commit, but when using

atuin search -i --inline-height 10

the search box is still at the bottom

image

Is this expected behavior?

@lawrencegripper
Copy link

Love this change ❤️ Thanks for adding it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants