Skip to content

Commit

Permalink
Rendering optimizations and function refactors
Browse files Browse the repository at this point in the history
Handle `find_command` inside state itself -> `get_command_by_name`. Move tips to a seperate file for modularity. Pass the whole args to state instead of seperate args. Use const for float and confirmation prompt float sizes. Add the `longest_tab_length` to appstate struct so that it will not be calculated for each frame render use static str instead String for tips. Use function for spawning confirmprompt. Merge command list and task items list rendering a single widget instead of two. Remove redundant keys in handle_key. Optimize scrolling logic. Rename `toggle_task_list_guide` -> `enable_task_list_guide`
  • Loading branch information
jeevithakannan2 committed Nov 12, 2024
1 parent df81642 commit 4ee7fa3
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 295 deletions.
13 changes: 0 additions & 13 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,3 @@ pub struct ListNode {
pub task_list: String,
pub multi_select: bool,
}

impl Tab {
pub fn find_command(&self, name: &str) -> Option<Rc<ListNode>> {
self.tree.root().descendants().find_map(|node| {
let value = node.value();
if value.name == name && !node.has_children() {
Some(value.clone())
} else {
None
}
})
}
}
13 changes: 5 additions & 8 deletions tui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ mod running_command;
pub mod state;
mod theme;

#[cfg(feature = "tips")]
mod tips;

use crate::theme::Theme;
use clap::Parser;
use ratatui::{
Expand All @@ -29,7 +32,7 @@ use std::{

// Linux utility toolbox
#[derive(Debug, Parser)]
struct Args {
pub struct Args {
#[arg(short, long, help = "Path to the configuration file")]
config: Option<PathBuf>,
#[arg(short, long, value_enum)]
Expand All @@ -53,13 +56,7 @@ struct Args {
fn main() -> io::Result<()> {
let args = Args::parse();

let mut state = AppState::new(
args.config,
args.theme,
args.override_validation,
args.size_bypass,
args.skip_confirmation,
);
let mut state = AppState::new(args);

stdout().execute(EnterAlternateScreen)?;
stdout().execute(EnableMouseCapture)?;
Expand Down
Loading

0 comments on commit 4ee7fa3

Please sign in to comment.