diff --git a/Cargo.toml b/Cargo.toml index 2a76283..ef068da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,5 @@ dotenvy = "0.15.*" log = "0.4.*" clap = { version = "4.1.*", features = ["derive"] } image = { version = "0.24.*", features = ["webp-encoder"] } -termion = "2.0.*" \ No newline at end of file +#termion = "2.0.*" +crossterm = "0.26.*" diff --git a/src/image_manipulation.rs b/src/image_manipulation.rs index db2b151..3fa751b 100644 --- a/src/image_manipulation.rs +++ b/src/image_manipulation.rs @@ -1,5 +1,5 @@ //! This module contains all functions related to image manipulation. -use termion::terminal_size; +use crossterm::terminal; use log::{debug, error}; use std::process::exit; use std::path::PathBuf; @@ -11,7 +11,7 @@ use image::imageops::FilterType; /// returns: /// (u32, u32) representing the (width, length) of stdout fn get_terminal_size() -> (u32, u32) { - let size = terminal_size(); + let size = terminal::size(); match size { Ok(size) => { (size.0 as u32, size.1 as u32) diff --git a/src/output.rs b/src/output.rs index db73cd9..1e14975 100644 --- a/src/output.rs +++ b/src/output.rs @@ -1,10 +1,11 @@ //! This module contains functions related to output. use std::fs::File; -use std::io::Write; +use std::io::{stdout, Write}; use std::path::PathBuf; use std::process::exit; +use crossterm::execute; +use crossterm::style::{Color, SetForegroundColor, Print, ResetColor}; use log::error; -use termion::{color, style}; use crate::model_rgb_ascii::Ascii; /// This function prints ASCII art to stdout. @@ -16,12 +17,15 @@ pub fn print_terminal(art: Vec>, in_colour: bool) { for line in art { for ascii in line { if in_colour { - print!("{}{}", color::Fg(color::Rgb(ascii.rgb[0], ascii.rgb[1], ascii.rgb[2])), ascii.char); + let _ = execute!(stdout(), + SetForegroundColor(Color::Rgb {r: ascii.rgb[0], g: ascii.rgb[1], b: ascii.rgb[2]}), + Print(ascii.char), + ResetColor); } else { print!("{}", ascii.char); } } - println!("{}", style::Reset); + println!(); } }