-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
224 additions
and
191 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use std::path::PathBuf; | ||
use ratatui::{ | ||
crossterm::event::{KeyCode}, | ||
Frame, | ||
}; | ||
use binsider::prelude::*; | ||
|
||
fn main() -> Result<()> { | ||
let mut path = PathBuf::from("ls"); | ||
if !path.exists() { | ||
let resolved_path = which::which(path.to_string_lossy().to_string())?; | ||
path = resolved_path; | ||
} | ||
|
||
let file_data = std::fs::read(&path)?; | ||
let bytes = file_data.as_slice(); | ||
let file_info = FileInfo::new(path.to_str().expect("should be valid string"), Some(vec![]), bytes)?; | ||
let analyzer = | ||
Analyzer::new(file_info, 15, vec![])?; | ||
|
||
// Create an application. | ||
let mut state = State::new(analyzer)?; | ||
let events = EventHandler::new(250); | ||
state.analyzer.extract_strings(events.sender.clone()); | ||
|
||
let mut terminal = ratatui::init(); | ||
loop { | ||
terminal | ||
.draw(|frame: &mut Frame| { | ||
render(&mut state, frame); | ||
}) | ||
.expect("failed to draw frame"); | ||
|
||
let event = events.next()?; | ||
match event { | ||
Event::Key(key_event) => { | ||
if key_event.code == KeyCode::Char('q') { | ||
break; | ||
} | ||
handle_event(Event::Key(key_event), &events, &mut state)?; | ||
} | ||
Event::Restart(None) => { | ||
break; | ||
} | ||
Event::Restart(Some(path)) => { | ||
let file_data = std::fs::read(&path)?; | ||
let bytes = file_data.as_slice(); | ||
let file_info = FileInfo::new(path.to_str().expect("should be valid string"), Some(vec![]), bytes)?; | ||
let analyzer = | ||
Analyzer::new(file_info, 15, vec![])?; | ||
state.analyzer = analyzer; | ||
state.handle_tab()?; | ||
state.analyzer.extract_strings(events.sender.clone()); | ||
} | ||
_ => { | ||
handle_event(event, &events, &mut state)?; | ||
} | ||
} | ||
} | ||
events.stop(); | ||
ratatui::restore(); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.