did some progress
This commit is contained in:
parent
9300750af1
commit
a1f49ee90e
10 changed files with 3938 additions and 2 deletions
61
src/im_gonna_try_better.rs
Normal file
61
src/im_gonna_try_better.rs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
use std::{env, fs, path};
|
||||
|
||||
use crossterm::event::{self, Event, KeyCode};
|
||||
use ratatui::{
|
||||
style::{Color, Style, Stylize},
|
||||
widgets::{Block, Borders, List, ListState, Padding},
|
||||
};
|
||||
|
||||
fn list_dir(path: &str) -> Vec<String> {
|
||||
let paths = fs::read_dir(path).unwrap();
|
||||
let mut array_of_dirs: Vec<String> = Vec::new();
|
||||
|
||||
for path in paths {
|
||||
array_of_dirs.push(path.unwrap().path().display().to_string());
|
||||
}
|
||||
|
||||
array_of_dirs
|
||||
}
|
||||
|
||||
fn create_list<'a>(ls_result: Vec<String>) -> List<'a> {
|
||||
let block = Block::new()
|
||||
.borders(Borders::ALL)
|
||||
.padding(Padding::symmetric(1, 1))
|
||||
.fg(Color::Blue);
|
||||
|
||||
List::new(ls_result)
|
||||
.block(block)
|
||||
.highlight_style(Style::new().reversed())
|
||||
}
|
||||
|
||||
fn get_events(state: ListState) {
|
||||
match event::read().expect("failed to read event") {
|
||||
Event::Key(key_event) => match key_event.code {
|
||||
KeyCode::Esc => {
|
||||
break;
|
||||
}
|
||||
|
||||
KeyCode::Down => {
|
||||
state.select_next();
|
||||
}
|
||||
|
||||
KeyCode::Up => {
|
||||
state.select_previous();
|
||||
}
|
||||
|
||||
KeyCode::Left => (),
|
||||
|
||||
KeyCode::Right => (),
|
||||
|
||||
_ => (),
|
||||
},
|
||||
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut path = env::current_dir().unwrap();
|
||||
let mut terminal = ratatui::init();
|
||||
let mut state = ListState::default();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue