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

Incorrect cursor position after drawing image (iTerm inline image protocol) #317

Closed
o2sh opened this issue Nov 2, 2020 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@o2sh
Copy link

o2sh commented Nov 2, 2020

Describe the bug

While adding support for iTerm inline image protocol to onefetch, we stumbled upon an inconsistent behavior between iTerm2 and WezTerm.

iTerm2:

97804886-eefa0680-1c95-11eb-9bb3-b1c85a1c2e78

WezTerm:

97865633-db11db80-1d4d-11eb-8b08-c8434ac5b490

The cursor position after drawing the image is at the bottom left hand corner (WezTerm) instead of near the lower right corner (iTerm2).

Indeed - after drawing the image -, if we do this

image_data.extend(format!("\x1B[{}A", image_rows as u32).as_bytes()); // move cursor to top-left corner
image_data.extend(format!("\x1B[{}C", image_columns as u32 + 1).as_bytes()); // move cursor to top-right corner of image

instead of that

image_data.extend(format!("\x1B[{}A", image_rows as u32 - 1).as_bytes()); // move cursor to start of image`

We get the correct output:

iterm

However, this obviously breaks the output on iTerm2...

Environment (please complete the following information):

  • OS: macOS
  • Version: wezterm 20200909-002054-4c9af461

Expected behavior

Consistent behavior with iTerm2 which is the de-facto standard.

@o2sh o2sh added the bug Something isn't working label Nov 2, 2020
wez added a commit that referenced this issue Nov 3, 2020
I've had a FIXME in here for a while to check the positioning,
but never got around to it.

The onefetch folks have an app that does care about this,
so it's time to resolve it!

This commit adjusts the cursor position for the iterm case
(not the sixel case), and results in both:

running in xterm:

```
onefetch --image ~/Downloads/squirrel.png
```

running in wezterm:

```
TERM_PROGRAM=iTerm.app onefetch --image ~/Downloads/squirrel.png --image-backend=iterm
```

```
onefetch --image ~/Downloads/squirrel.png --image-backend=sixel
```

showing consistent positioning.

refs: #317
refs: o2sh/onefetch#305
@wez
Copy link
Owner

wez commented Nov 3, 2020

Thanks for reporting this! I've pushed a fix that seems to make the onefetch sixel and iterm2 backend behavior consistent with each other within wezterm, and consistently with sixel in xterm.

That'll be available in the "nightly" downloads within about an hour.

@o2sh
Copy link
Author

o2sh commented Nov 3, 2020

Well done!

wez

@o2sh o2sh closed this as completed Nov 3, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants