Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: supoort Windows Terminal #40

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 204 additions & 10 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ base64 = { version = "^0.22.1" }
rand = { version = "0.8.5" }
ratatui = { version = ">=0.23", default-features = false, features = [] }

[target.'cfg(windows)'.dependencies]
semver = "1.0"
pelite = "0.10.0"
sysinfo = { version = "0.31.4", default-features = false, features = ["system"] }

[[bin]]
name = "ratatui-image"
path = "./src/bin/ratatui-image/main.rs" # cargo readme needs this for some reason
Expand Down
6 changes: 6 additions & 0 deletions examples/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let backend = CrosstermBackend::new(stdout);
let mut terminal = Terminal::new(backend)?;

#[cfg(all(feature = "rustix", unix))]
let mut picker = Picker::from_termios()?;
#[cfg(not(all(feature = "rustix", unix)))]
let mut picker = {
let font_size = (8, 16);
Picker::new(font_size)
};
Comment on lines +48 to +51
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is used to calculate the amount of space an image will occupy in character cells, it should be 10x20 for Windows Terminal (that's the cell size of the original VT340 hardware terminal).

You can also query the cell size with the CSI 16 t escape sequence.

picker.guess_protocol();
picker.background_color = Some(Rgb::<u8>([255, 0, 255]));
let dyn_img = image::io::Reader::open("./assets/Ada.png")?.decode()?;
Expand Down
6 changes: 6 additions & 0 deletions examples/demo/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ impl<'a> App<'a> {
let ada = "./assets/Ada.png";
let dyn_img = image::io::Reader::open(ada).unwrap().decode().unwrap();

#[cfg(all(feature = "rustix", unix))]
let mut picker = Picker::from_termios().unwrap();
#[cfg(not(all(feature = "rustix", unix)))]
let mut picker = {
let font_size = (8, 16);
Picker::new(font_size)
};
picker.guess_protocol();

let image_static = picker
Expand Down
Loading
Loading