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

iterm2 terminal size not detected #44

Open
hackerb9 opened this issue Jul 12, 2021 · 8 comments
Open

iterm2 terminal size not detected #44

hackerb9 opened this issue Jul 12, 2021 · 8 comments

Comments

@hackerb9
Copy link
Owner

iterm2 does not detect terminal size, tiles are too small and too few per row.

@hackerb9
Copy link
Owner Author

hackerb9 commented Jul 12, 2021

Example of iterm2 build 3.4.8:

Screen Shot 2021-07-12 at 1 09 59 PM

The tiles seems strangely shrunken and the font is illegible. (DPI issue?) Even so, there should be more tiles because there is more space available.

Note that the images also appear to have been shifted up by six pixels, truncating them at the top edge and adding extra space at the bottom. This appears to be a bug in iterm2 as it occurs when using convert as well.

@tk512
Copy link

tk512 commented May 18, 2023

Is there a workaround for this?

@hackerb9
Copy link
Owner Author

Thanks for the reminder. I don't have a Mac, so it is tricky for me to figure out what is going wrong. My current guess is that iTerm2 is doing something funky with the DPI setting. Would you be willing to try setting tilesize=256 (instead of 120) at the top of the file and posting a screenshot?

@NathanielHill
Copy link

Thanks for the reminder. I don't have a Mac, so it is tricky for me to figure out what is going wrong. My current guess is that iTerm2 is doing something funky with the DPI setting. Would you be willing to try setting tilesize=256 (instead of 120) at the top of the file and posting a screenshot?

Where do you want that to be set? As an environment variable?

@hackerb9
Copy link
Owner Author

hackerb9 commented Jul 8, 2023

At the top of the lsix file.

@jquast
Copy link

jquast commented Apr 7, 2024

Problem is due to using a retina display and lsix is using \e[14t to determine pixel size instead of TIOCGWINSZ. A temporary workaround Under Preferences->Advanced Preferences, change option "Show inline images at Retina resolution" to "no":

image

With this preference set to "no" (defaults to "yes"), when given a sixel image, iTerm2 should show images from lsix at correct size.

I have a Mac mini with no retina display so I cannot test it myself, but it may be possible to detect whether the display is retina using the following sequence (from https://iterm2.com/documentation-escape-codes.html):

printf "\e]1337;ReportCellSize\a"

A non-retina display has output,

1337;ReportCellSize=33.0;14.0;1.0

I expect the final attribute, "1.0" becomes "2.0" with a retina display. lsix can check for this and scale accordingly (assuming the user leaves this experimental feature to its default value of "yes").

@hackerb9
Copy link
Owner Author

hackerb9 commented Apr 8, 2024

Thanks for the detailed explanation. "Show inline images at retina resolutions" seems like a bad solution as it would mean sixel images would be larger but lower resolution for no good reason, right? The real problem is that I hardcoded the width of the tiles in lsix for simplicity. (For comparison, see the baroque image viewer, vv, which scales the image based on the resolution of the character cells.)

It doesn't make sense to me that iTerm is returning "points" instead of pixels ever. I looked at the linked bug report, but it sounds like the issue got fixed for TIOCGWINSZ but not other methods. But then, I don't have a Macintosh, so there is probably something I don't know.

I do know that TIOCGWINSZ is nice when available, which, unfortunately, is not always. It depends upon OS support. And, even for OSes that support it, can be filtered out depending upon how you are connecting to the machine. And, finally, being an ioctl, it cannot be used in a simple shell script, like lsix.

It is true that XTWINOPS 14 (CSI 1 4 t, window size) is not well defined and can include margins. That is why lsix always first checks XTSMGRAPHICS (CSI ? 2 ; 1 S) which returns the exact size of the sixel graphics geometry. It is unfortunate that iTerm doesn't support it.

Does XTWINOPS 16 (CSI 1 6 t, character cell size) return points or pixels in iTerm?

And, final question, if you don't have a Retina display Mac, then does that mean lsix is giving you some other problem with the image sizes?

@jquast
Copy link

jquast commented Apr 8, 2024

It doesn't make sense to me that iTerm is returning "points" instead of pixels ever.

I'm not sure it makes sense either, maybe we should file a bug report with iTerm2, to change this to pixels, George Nachman seems like a pretty nice guy. There are situations where TIOCGWINSZ is not available other than being a shell script.

Does XTWINOPS 16 (CSI 1 6 t, character cell size) return points or pixels in iTerm?

iTerm2 does not support XTWINOPS \x1b[16t, only 14t.

And, final question, if you don't have a Retina display Mac, then does that mean lsix is giving you some other problem with the image sizes?

Happy to report that it is working fine on non-retina display! :) it has the same behavior whether the option is enabled or not, so I am very sure the users in this thread who report the issue are using a retina display like a macbook, or maybe a 4 or 5k display.

I just stumbled onto this issue and looked into it a bit :) glad to help

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

4 participants