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

How to clear the image printed? #28

Open
tramhao opened this issue Jun 19, 2021 · 5 comments
Open

How to clear the image printed? #28

tramhao opened this issue Jun 19, 2021 · 5 comments

Comments

@tramhao
Copy link

tramhao commented Jun 19, 2021

Firstly, thanks for your work and it provides very good display result in kitty.
I'm using it in my repo(https://github.com/tramhao/termusic) to display the album photo.
The display works without problems. However, i need to clear the printed image if the song doesn't have an album photo.
I cannot figure out how to do it.
Thanks so much.

@tramhao
Copy link
Author

tramhao commented Jun 19, 2021

I solve it by sending control sequence to terminal directly

    pub fn clear_image(&mut self) {
        write!(self.context.backend_mut(), "\x1b_Ga=d\x1b\\").expect("error delete image");
        self.context
            .backend_mut()
            .flush()
            .expect("error flush delete image");
    }

@tramhao
Copy link
Author

tramhao commented Jun 19, 2021

If this is the correct way, please close this issue. Thanks.

@atanunq
Copy link
Owner

atanunq commented Jun 19, 2021

Thank you for using viuer. This is a really good point, I think viuer could use a clear/delete_image method. I will leave this issue open as a reminder :)

@tramhao
Copy link
Author

tramhao commented Feb 25, 2022

I met this problem again but for iterm2 protocol. I'm using same code to clear picture in iterm2, but not working. I'm using wezterm. Do you know if there is a way to clear image in iterm2? I didn't find related information in their website. Thanks so much.

@kyoheiu
Copy link

kyoheiu commented May 14, 2022

I faced the same problem: By using termion, for example, clearing the image goes like this:

for i in 0..terminal_row {
    print!("{}", cursor::Goto(BEGINNING_COLUMN, BEGINNING_ROW + i as u16));
    print!("{}", clear::UntilNewline);
}

Both cursor::Goto and clear::UntilNewline in termion write escape sequences. This works fine when using alacritty, which does not support sixel.
However, with kitty, the above code does not work.
Is there any solution to this, or do I miss something? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants