From e50f5fad8e3f05d6faf039e61d68eba818d2576a Mon Sep 17 00:00:00 2001 From: nanov Date: Wed, 13 Nov 2024 06:50:45 +0200 Subject: [PATCH] feat: remove termion dependency in order to support windows --- Cargo.lock | 35 +++++------------------------------ Cargo.toml | 2 +- src/main.rs | 16 +++++++++------- 3 files changed, 15 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bdd77c1..146f5ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -738,17 +738,6 @@ version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" -[[package]] -name = "libredox" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" -dependencies = [ - "bitflags 2.6.0", - "libc", - "redox_syscall", -] - [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -898,12 +887,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "numtoa" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f" - [[package]] name = "object" version = "0.36.5" @@ -1144,7 +1127,7 @@ dependencies = [ "reqwest", "scraper", "terminal-menu", - "termion", + "termsize", ] [[package]] @@ -1186,12 +1169,6 @@ dependencies = [ "bitflags 2.6.0", ] -[[package]] -name = "redox_termios" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20145670ba436b55d91fc92d25e71160fbfbdd57831631c8d7d36377a476f1cb" - [[package]] name = "reqwest" version = "0.12.8" @@ -1634,15 +1611,13 @@ dependencies = [ ] [[package]] -name = "termion" -version = "4.0.3" +name = "termsize" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eaa98560e51a2cf4f0bb884d8b2098a9ea11ecf3b7078e9c68242c74cc923a7" +checksum = "6f11ff5c25c172608d5b85e2fb43ee9a6d683a7f4ab7f96ae07b3d8b590368fd" dependencies = [ "libc", - "libredox", - "numtoa", - "redox_termios", + "winapi", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 18332a9..195252b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,4 @@ inquire = "0.7.5" reqwest = { version = "0.12.8", features = ["blocking"] } scraper = "0.20.0" terminal-menu = "3.0.0" -termion = "4.0.3" +termsize = "0.1.9" diff --git a/src/main.rs b/src/main.rs index 0cc4f9c..2cb2d05 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,6 @@ use reqwest::{self, StatusCode}; use html2text; use html2text::config; use html2text::render::RichAnnotation; -use termion::color::*; use std::cell::LazyCell; @@ -96,12 +95,12 @@ fn default_colour_map( match annotation { Default => {} Link(_) => { - start.push(format!("{}", termion::style::Underline)); - finish.push(format!("{}", termion::style::Reset)); + start.push(""); + finish.push(""); } - Colour(c) => { - start.push(format!("{}", termion::color::Fg(Rgb(c.r, c.g, c.b)))); - finish.push(format!("{}", Fg(Reset))); + Colour(_) => { + start.push(""); + finish.push(""); } BgColour(_) => { } @@ -120,7 +119,10 @@ fn default_colour_map( fn imprimir_palabra(definicion_html: ElementRef) -> RaeResult { - let (width, _) = termion::terminal_size().unwrap(); + let width = match termsize::get() { + Some(s) => s.rows, + _ => 80 + }; let co = config::rich(); let mut redader = std::io::Cursor::new(definicion_html.inner_html()); let d = co.coloured(&mut redader, usize::from(width), default_colour_map)?;