Skip to content

Commit e50f5fa

Browse files
committed
feat: remove termion dependency in order to support windows
1 parent 66b80df commit e50f5fa

File tree

3 files changed

+15
-38
lines changed

3 files changed

+15
-38
lines changed

Cargo.lock

+5-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ inquire = "0.7.5"
1111
reqwest = { version = "0.12.8", features = ["blocking"] }
1212
scraper = "0.20.0"
1313
terminal-menu = "3.0.0"
14-
termion = "4.0.3"
14+
termsize = "0.1.9"

src/main.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use reqwest::{self, StatusCode};
1212
use html2text;
1313
use html2text::config;
1414
use html2text::render::RichAnnotation;
15-
use termion::color::*;
1615

1716
use std::cell::LazyCell;
1817

@@ -96,12 +95,12 @@ fn default_colour_map(
9695
match annotation {
9796
Default => {}
9897
Link(_) => {
99-
start.push(format!("{}", termion::style::Underline));
100-
finish.push(format!("{}", termion::style::Reset));
98+
start.push("");
99+
finish.push("");
101100
}
102-
Colour(c) => {
103-
start.push(format!("{}", termion::color::Fg(Rgb(c.r, c.g, c.b))));
104-
finish.push(format!("{}", Fg(Reset)));
101+
Colour(_) => {
102+
start.push("");
103+
finish.push("");
105104
}
106105
BgColour(_) => {
107106
}
@@ -120,7 +119,10 @@ fn default_colour_map(
120119

121120

122121
fn imprimir_palabra(definicion_html: ElementRef) -> RaeResult {
123-
let (width, _) = termion::terminal_size().unwrap();
122+
let width = match termsize::get() {
123+
Some(s) => s.rows,
124+
_ => 80
125+
};
124126
let co = config::rich();
125127
let mut redader = std::io::Cursor::new(definicion_html.inner_html());
126128
let d = co.coloured(&mut redader, usize::from(width), default_colour_map)?;

0 commit comments

Comments
 (0)