Skip to content

Commit

Permalink
feat: remove termion dependency in order to support windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nanov committed Nov 13, 2024
1 parent 66b80df commit e50f5fa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 38 deletions.
35 changes: 5 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
16 changes: 9 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use reqwest::{self, StatusCode};
use html2text;
use html2text::config;
use html2text::render::RichAnnotation;
use termion::color::*;

use std::cell::LazyCell;

Expand Down Expand Up @@ -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(_) => {
}
Expand All @@ -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)?;
Expand Down

0 comments on commit e50f5fa

Please sign in to comment.