mirror of
https://github.com/itsjunetime/tdf.git
synced 2026-06-02 08:01:47 -04:00
Fix a few more small clippy issues
This commit is contained in:
@@ -8,7 +8,6 @@ readme = "README.md"
|
|||||||
homepage = "https://github.com/itsjunetime/tdf"
|
homepage = "https://github.com/itsjunetime/tdf"
|
||||||
repository = "https://github.com/itsjunetime/tdf"
|
repository = "https://github.com/itsjunetime/tdf"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
license-file = "LICENSE"
|
|
||||||
keywords = ["pdf", "tui", "cli", "terminal"]
|
keywords = ["pdf", "tui", "cli", "terminal"]
|
||||||
categories = ["command-line-utilities", "text-processing", "visualization"]
|
categories = ["command-line-utilities", "text-processing", "visualization"]
|
||||||
default-run = "tdf"
|
default-run = "tdf"
|
||||||
|
|||||||
+2
-2
@@ -75,7 +75,7 @@ pub fn start_rendering_loop(
|
|||||||
width: columns * FONT_SIZE.0
|
width: columns * FONT_SIZE.0
|
||||||
};
|
};
|
||||||
|
|
||||||
std::thread::spawn(move || start_rendering(str_path, to_main_tx, from_main_rx, size));
|
std::thread::spawn(move || start_rendering(&str_path, to_main_tx, from_main_rx, size));
|
||||||
|
|
||||||
let main_area = Rect {
|
let main_area = Rect {
|
||||||
x: 0,
|
x: 0,
|
||||||
@@ -136,7 +136,7 @@ pub async fn render_doc(path: impl AsRef<Path>) {
|
|||||||
to_render_tx
|
to_render_tx
|
||||||
} = start_all_rendering(path);
|
} = start_all_rendering(path);
|
||||||
|
|
||||||
while pages.is_empty() || pages.iter().any(|p| p.is_none()) {
|
while pages.is_empty() || pages.iter().any(Option::is_none) {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
Some(renderer_msg) = from_render_rx.next() => {
|
Some(renderer_msg) = from_render_rx.next() => {
|
||||||
handle_renderer_msg(renderer_msg, &mut pages, &mut to_converter_tx);
|
handle_renderer_msg(renderer_msg, &mut pages, &mut to_converter_tx);
|
||||||
|
|||||||
+6
-7
@@ -96,7 +96,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// read in the returned size until we hit a 't' (which indicates to us it's done)
|
// read in the returned size until we hit a 't' (which indicates to us it's done)
|
||||||
let input_vec = std::io::stdin()
|
let input_vec = std::io::stdin()
|
||||||
.bytes()
|
.bytes()
|
||||||
.flat_map(|b| b.ok())
|
.filter_map(Result::ok)
|
||||||
.take_while(|b| *b != b't')
|
.take_while(|b| *b != b't')
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// We need to use the thread::spawn API so that this exists in a thread not owned by tokio,
|
// We need to use the thread::spawn API so that this exists in a thread not owned by tokio,
|
||||||
// since the methods we call in `start_rendering` will panic if called in an async context
|
// since the methods we call in `start_rendering` will panic if called in an async context
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
renderer::start_rendering(file_path, render_tx, render_rx, window_size)
|
renderer::start_rendering(&file_path, render_tx, render_rx, window_size)
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut ev_stream = crossterm::event::EventStream::new();
|
let mut ev_stream = crossterm::event::EventStream::new();
|
||||||
@@ -154,11 +154,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
tokio::spawn(run_conversion_loop(to_main, from_main, picker, 20));
|
tokio::spawn(run_conversion_loop(to_main, from_main, picker, 20));
|
||||||
|
|
||||||
let file_name = path
|
let file_name = path.file_name().map_or_else(
|
||||||
.file_name()
|
|| "Unknown file".into(),
|
||||||
.map(|n| n.to_string_lossy())
|
|n| n.to_string_lossy().to_string()
|
||||||
.unwrap_or_else(|| "Unknown file".into())
|
);
|
||||||
.to_string();
|
|
||||||
let mut tui = tui::Tui::new(file_name);
|
let mut tui = tui::Tui::new(file_name);
|
||||||
|
|
||||||
let backend = CrosstermBackend::new(std::io::stdout());
|
let backend = CrosstermBackend::new(std::io::stdout());
|
||||||
|
|||||||
+4
-4
@@ -65,7 +65,7 @@ pub fn fill_default<T: Default>(vec: &mut Vec<T>, size: usize) {
|
|||||||
// means the other side's disconnected, which means that the main thread has panicked, which means
|
// means the other side's disconnected, which means that the main thread has panicked, which means
|
||||||
// we're done.
|
// we're done.
|
||||||
pub fn start_rendering(
|
pub fn start_rendering(
|
||||||
path: String,
|
path: &str,
|
||||||
mut sender: Sender<Result<RenderInfo, RenderError>>,
|
mut sender: Sender<Result<RenderInfo, RenderError>>,
|
||||||
receiver: Receiver<RenderNotif>,
|
receiver: Receiver<RenderNotif>,
|
||||||
size: WindowSize
|
size: WindowSize
|
||||||
@@ -90,7 +90,7 @@ pub fn start_rendering(
|
|||||||
let col_h = size.height / size.rows;
|
let col_h = size.height / size.rows;
|
||||||
|
|
||||||
'reload: loop {
|
'reload: loop {
|
||||||
let doc = match Document::from_file(&path, None) {
|
let doc = match Document::from_file(path, None) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// if there's an error, tell the main loop
|
// if there's an error, tell the main loop
|
||||||
sender.send(Err(RenderError::Doc(e)))?;
|
sender.send(Err(RenderError::Doc(e)))?;
|
||||||
@@ -189,8 +189,8 @@ pub fn start_rendering(
|
|||||||
.map(|(idx, p)| (start_point - (idx + 1), p))
|
.map(|(idx, p)| (start_point - (idx + 1), p))
|
||||||
);
|
);
|
||||||
|
|
||||||
let area_w = area.width as f64 * col_w as f64;
|
let area_w = f64::from(area.width) * f64::from(col_w);
|
||||||
let area_h = area.height as f64 * col_h as f64;
|
let area_h = f64::from(area.height) * f64::from(col_h);
|
||||||
|
|
||||||
// we go through each page
|
// we go through each page
|
||||||
for (num, rendered) in page_iter {
|
for (num, rendered) in page_iter {
|
||||||
|
|||||||
+1
-1
@@ -204,7 +204,7 @@ impl Tui {
|
|||||||
// and only take as many as are ready to be rendered
|
// and only take as many as are ready to be rendered
|
||||||
.take_while(|(_, page)| page.img.is_some())
|
.take_while(|(_, page)| page.img.is_some())
|
||||||
// and map it to their width (in cells on the terminal, not pixels)
|
// and map it to their width (in cells on the terminal, not pixels)
|
||||||
.flat_map(|(idx, page)| page.img.as_ref().map(|img| (idx, img.rect().width)))
|
.filter_map(|(idx, page)| page.img.as_ref().map(|img| (idx, img.rect().width)))
|
||||||
// and then take them as long as they won't overflow the available area.
|
// and then take them as long as they won't overflow the available area.
|
||||||
.take_while(|(_, width)| match test_area_w.checked_sub(*width) {
|
.take_while(|(_, width)| match test_area_w.checked_sub(*width) {
|
||||||
Some(new_val) => {
|
Some(new_val) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user