updated tui logic to allow for history recall, and ctrl of selected

project.
This commit is contained in:
2026-05-20 14:01:53 -05:00
parent e3cb4628f8
commit 2c78f26dd2
2 changed files with 34 additions and 4 deletions
+33 -3
View File
@@ -68,6 +68,7 @@ pub fn run_tui(
if !state.projects.is_empty() {
project_list_state.select(Some(0));
}
let mut history_index = state.history.len();
loop {
terminal.draw(|f| {
let main_chunks = Layout::default()
@@ -84,7 +85,11 @@ pub fn run_tui(
.map(|p| ListItem::new(format!(" {} | {}", p.org_name, p.name)))
.collect();
let projects_list = List::new(projects)
.block(Block::default().borders(Borders::ALL).title(" Projects "))
.block(
Block::default()
.borders(Borders::ALL)
.title(" Projects (ctrl + arrow keys to select) "),
)
.highlight_style(
Style::default()
.bg(Color::Blue)
@@ -185,6 +190,7 @@ pub fn run_tui(
}
state.curent_intput.clear();
}
history_index = state.history.len();
}
KeyCode::Char(c) => {
state.curent_intput.push(c);
@@ -192,14 +198,38 @@ pub fn run_tui(
KeyCode::Backspace => {
state.curent_intput.pop();
}
KeyCode::Up => {
KeyCode::Up if key.modifiers.is_empty() => {
if !state.history.is_empty() && history_index > 0 {
history_index -= 1;
state.curent_intput = state.history[history_index].clone();
}
}
KeyCode::Down if key.modifiers.is_empty() => {
if history_index < state.history.len() {
history_index += 1;
if history_index == state.history.len() {
state.curent_intput.clear(); // Clear back to a fresh prompt
} else {
state.curent_intput = state.history[history_index].clone();
}
}
}
KeyCode::Up
if key
.modifiers
.contains(crossterm::event::KeyModifiers::CONTROL) =>
{
if let Some(selected) = project_list_state.selected() {
if selected > 0 {
project_list_state.select(Some(selected - 1));
}
}
}
KeyCode::Down => {
KeyCode::Down
if key
.modifiers
.contains(crossterm::event::KeyModifiers::CONTROL) =>
{
if let Some(selected) = project_list_state.selected() {
if selected + 1 < state.projects.len() {
project_list_state.select(Some(selected + 1));