switched from termion to crossterm for windows support
This commit is contained in:
parent
d93e147914
commit
21d740cf70
|
|
@ -11,4 +11,5 @@ dotenvy = "0.15.*"
|
||||||
log = "0.4.*"
|
log = "0.4.*"
|
||||||
clap = { version = "4.1.*", features = ["derive"] }
|
clap = { version = "4.1.*", features = ["derive"] }
|
||||||
image = { version = "0.24.*", features = ["webp-encoder"] }
|
image = { version = "0.24.*", features = ["webp-encoder"] }
|
||||||
termion = "2.0.*"
|
#termion = "2.0.*"
|
||||||
|
crossterm = "0.26.*"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
//! This module contains all functions related to image manipulation.
|
//! This module contains all functions related to image manipulation.
|
||||||
use termion::terminal_size;
|
use crossterm::terminal;
|
||||||
use log::{debug, error};
|
use log::{debug, error};
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
@ -11,7 +11,7 @@ use image::imageops::FilterType;
|
||||||
/// returns:
|
/// returns:
|
||||||
/// (u32, u32) representing the (width, length) of stdout
|
/// (u32, u32) representing the (width, length) of stdout
|
||||||
fn get_terminal_size() -> (u32, u32) {
|
fn get_terminal_size() -> (u32, u32) {
|
||||||
let size = terminal_size();
|
let size = terminal::size();
|
||||||
match size {
|
match size {
|
||||||
Ok(size) => {
|
Ok(size) => {
|
||||||
(size.0 as u32, size.1 as u32)
|
(size.0 as u32, size.1 as u32)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
//! This module contains functions related to output.
|
//! This module contains functions related to output.
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::{stdout, Write};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
use crossterm::execute;
|
||||||
|
use crossterm::style::{Color, SetForegroundColor, Print, ResetColor};
|
||||||
use log::error;
|
use log::error;
|
||||||
use termion::{color, style};
|
|
||||||
use crate::model_rgb_ascii::Ascii;
|
use crate::model_rgb_ascii::Ascii;
|
||||||
|
|
||||||
/// This function prints ASCII art to stdout.
|
/// This function prints ASCII art to stdout.
|
||||||
|
|
@ -16,12 +17,15 @@ pub fn print_terminal(art: Vec<Vec<Ascii>>, in_colour: bool) {
|
||||||
for line in art {
|
for line in art {
|
||||||
for ascii in line {
|
for ascii in line {
|
||||||
if in_colour {
|
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 {
|
} else {
|
||||||
print!("{}", ascii.char);
|
print!("{}", ascii.char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("{}", style::Reset);
|
println!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue