Moved preview_content to floating_text and merged

This commit is contained in:
afonsofrancof 2024-08-08 23:37:19 +01:00
parent ab2cc1340f
commit da7f078063
No known key found for this signature in database
4 changed files with 8 additions and 12 deletions

View File

@ -1,8 +1,6 @@
use crossterm::event::{KeyCode, KeyEvent}; use crossterm::event::{KeyCode, KeyEvent};
use ratatui::{ use ratatui::{
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
style::{Color, Style, Stylize},
widgets::Block,
Frame, Frame,
}; };

View File

@ -1,6 +1,4 @@
use crate::{ use crate::{float::Float, floating_text::FloatingText, running_command::Command, state::AppState};
float::Float, preview_content::FloatingText, running_command::Command, state::AppState,
};
use crossterm::event::{KeyCode, KeyEvent, KeyEventKind}; use crossterm::event::{KeyCode, KeyEvent, KeyEventKind};
use ego_tree::{tree, NodeId}; use ego_tree::{tree, NodeId};
use ratatui::{ use ratatui::{

View File

@ -1,6 +1,6 @@
mod float; mod float;
mod floating_text;
mod list; mod list;
mod preview_content;
mod running_command; mod running_command;
pub mod state; pub mod state;
mod theme; mod theme;
@ -140,11 +140,11 @@ fn run<B: Backend>(terminal: &mut Terminal<B>, state: &AppState) -> io::Result<(
if key.kind != KeyEventKind::Press && key.kind != KeyEventKind::Repeat { if key.kind != KeyEventKind::Press && key.kind != KeyEventKind::Repeat {
continue; continue;
} }
if let Some(ref mut command) = command_opt {
if command.handle_key_event(&key) { //Send the key to the float
command_opt = None; //If we receive true, then the float processed the input
} //If that's the case, don't propagate input to other widgets
} else { if !command_float.handle_key_event(&key) {
//Insert user input into the search bar //Insert user input into the search bar
if in_search_mode { if in_search_mode {
match key.code { match key.code {
@ -168,7 +168,7 @@ fn run<B: Backend>(terminal: &mut Terminal<B>, state: &AppState) -> io::Result<(
_ => {} _ => {}
} }
} else if let Some(cmd) = custom_list.handle_key(key, state) { } else if let Some(cmd) = custom_list.handle_key(key, state) {
command_opt = Some(RunningCommand::new(cmd, state)); command_float.set_content(Some(RunningCommand::new(cmd, state)));
} else { } else {
// Handle keys while not in search mode // Handle keys while not in search mode
match key.code { match key.code {