nabijaczleweli / termimage

Display images in your terminal, kind of
MIT License
209 stars 4 forks source link

Screws up terminal #10

Closed sevagh closed 7 years ago

sevagh commented 7 years ago

Hello,

I'm trying to use this in a crate where I have my own shell, and I want to output text and images side by side.

After calling write_ansi_truecolor once, an image successfully displays (and I can print more images), my terminal goes all wonky and writing to stdout/typing input from my keyboard does nothing until I type reset or exit the terminal.

Example:

writeln!(out, "Hello")
ops::write_ansi_truecolor(img1)
writeln!(out, "World")
ops::write_ansi_truecolor(img2)

=>

Hello
*img1*
*img2*
// can't type anymore

Any way to reset the terminal after outputting an image? Or any idea what's going on?

Thanks.

sevagh commented 7 years ago

Same behavior observed in alacritty and gnome-terminal (with or without tmux).

nabijaczleweli commented 7 years ago

any idea what

Nay, besides the fact that your term might not support ANSI truecolour escapes.

reset the terminal

I mean I don't use Linux much but reset probably works right

sevagh commented 7 years ago

Yeah, reset works. The termimage binary (cargo install termimage) has the same behavior, so it's not me incorrectly using the library. I'll do some poking around regarding truecolor support, thanks.

nabijaczleweli commented 7 years ago

Well I mean yeah the exec is just an iface to the library, it'd be weird if it didn't happen there. Oh and please do report back when you have some data about truecolourness.

sevagh commented 7 years ago

selection_013 So the image displays. Just mangles everything afterwards until I reset.

nabijaczleweli commented 7 years ago

Define "mangles"?

sevagh commented 7 years ago

Everything I type subsequently, or that my program outputs to stdout, is hidden. Here I typed ls and enter a few times and it magically "recovered" (but my program exit):

selection_015

sevagh commented 7 years ago

I just checked with a friend and it works fine for him. Closing this as a bug with my own setup.

Thanks for the help, cool library!

nabijaczleweli commented 7 years ago

Cheers, mate

sevagh commented 7 years ago

Actually figured it out. Adding this helps:

ops::write_ansi_truecolor(out, &resized);
writeln!(out, "\x1b[0m").expect("Couldn't write to stdout");

\x1b[0m is Rust's equivalent of \033[0m.

nabijaczleweli commented 7 years ago

Reset ANSI attr printed in v0.3.2.