hackerb9 / lsix

Like "ls", but for images. Shows thumbnails in terminal using sixel graphics.
GNU General Public License v3.0
3.99k stars 129 forks source link

fix typo #22

Closed srlehn closed 5 years ago

srlehn commented 5 years ago

MinTTY is written as mintty since 2009 (https://groups.google.com/forum/#!msg/mintty-discuss/Qb_88RMRy-o/NUfct8j9dl8J).

hackerb9 commented 5 years ago

Thanks. Can you confirm that lsix works with MinTTY?

srlehn commented 5 years ago

Hi. The positioning seems to be off:

image

The image appeared near the top and the next prompt was printed over it.

hackerb9 commented 5 years ago

Yeesh. That's the third terminal that copied the sixel scroll bug. I can work around it. What does MinTTY set the TERM environment variable to?

srlehn commented 5 years ago

mintty and WSLTty (based on mintty) are from the same author - I am not aware of terminal specific differences. Both of them can probably be handled the same.

mintty has TERM set to xterm... When it is run as the Cygwin Terminal it has an icon set and the environment variable MINTTY_SHORTCUT is set and can be checked in this case.

srlehn commented 5 years ago

It probably is better to check if the terminal is an actual xterm based on if the variable XTERM_VERSION is set not if TERM == xterm.

srlehn commented 5 years ago

Yeesh. That's the third terminal that copied the sixel scroll bug. I can work around it. What does MinTTY set the TERM environment variable to?

I think xterm has the buggy behaviour here (https://github.com/mintty/mintty/issues/572#issuecomment-236396598) (I didn't read the whole PR):

Still not like xterm (which moves to the horizontal beginning of the line, not of the image), but note http://vt100.net/docs/vt3xx-gp/chapter14.html :

When sixel display mode is enabled, the sixel active position begins at the upper-left corner of the ANSI text active position. Scrolling occurs when the sixel active position reaches the bottom margin of the graphics page. When sixel mode is exited, the text cursor is set to the current sixel cursor position.

So actually your previous approach was the original one and xterm does not implement it correctly. I guess we should follow DEC here rather than xterm. This applies to "Sixel Scrolling Mode Enabled"; "Sixel Scrolling Mode Disabled" does not seem very useful to me.


https://github.com/mintty/mintty/issues/572#issuecomment-236438360

Tera Term maintainer @ttdoda, also known as VT collector, reported real behavior of SIXEL terminal VT382 and VT330.

He says, (summary)

In VT382, the cursor returns to left automatically, in spite of lacking sixel next line charactor(-) at the end of SIXEL dump. (twitter) A SIXEL line has only 6-dot height, and the text line is higher than it. Because SIXEL active position is converted into text cursor position, it might not be at next line of bottom, but at the bottom-left corner of image. (twitter)

SIXEL active position

I think we should follow Xterm's behavior because it is too complicated to emulate.

hackerb9 commented 5 years ago

It is a bug in MinTTY if it sets the TERM variable to xterm and is not bug-for-bug compatible with xterm. MinTTY should add their entry to the TERMINFO database instead of pretending to be something else.

As for the positioning of the text after showing an image, I'm pretty sure what you quoted actually shows that Xterm is doing the right thing (putting the text after the image instead of on top of it). What MinTTY and mlterm appear to be emulating is a VT125 or VT240, a behavior specifically deprecated in the DEC literature as deviant. Please see DEC STD 070, chapter 9, section 12.1, Deviations.

srlehn commented 5 years ago

There are so many terminals pretending to be xterm - I think all libvte based ones use xterm or xterm-256color, alacritty uses xterm-256color. tmux pretends to be screen with the TERM variable. It doesn't matter what TERM should be practically all terminal emulators I know of abuse it. You can't use TERM to decide what terminal you are using. It reminds me of the User Agent Mozilla/5.0.

I can't say much about the expected terminal behaviour for sixel graphics. Most of what I know was found by testing when making sixel output work for a specific terminal emulator/multiplexer. I am more interested in having my program work than fulfilling all those slightly antique standards. If possible and I know how it should behave and the supposed bahaviour doesn't conflict with the real behaviour of terminals I of cause will follow the rules.

Thanks for the pdf link. Here the excerpt: https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n929 page: 930-931

12.1 Deviations

12.1.1 .VT125

  1. Initialization - The VT125 does not reset the Sixel writing color to contrast to the background.
  2. Relation to ANSI text position - The VT125 does not start the Sixel position at the ANSI text position but rather at the upper left corner of the display. It does not update the ANSI text vertical position at the termination of a Sixel image.
  3. Color numbers - The VT125 accepts color numbers 0, 1, 2, 3 but does not allow color specifiers.
  4. Background select - The VT125 does not accept this parameter. It always uses the background color for unwritten sixe1s by erasing the screen to background (i.e. extent is the entire screen).
  5. Scrolling - The VT125 does not scroll when the bottom margin is reached.
  6. Raster attributes - The only raster attributes accepted by the VT125 is defined by Macro Parameter value of 1. Thus all other combinations of raster attributes fall back . to this selection.

12.1.2 VT240

  1. Initialization - The VT240 does not reset the Sixel writing color to contrast to the background. It retains the colors from the previous Sixel transmission.
  2. Relation to ANSI text position - The VT240 does not start the Sixel position at the ANSI text position but rather at the upper left corner of the display. It does not update the ANSI text vertical position at the termination of a Sixel image.
  3. Horizontal and Vertical Extent - The VT240 assumes that the extent of the image is the entire screen when Background Select is specified to fill in the background; thus the VT240 erases the screen to background in this case.
  4. Scrolling - The VT240 does not scroll when the bottom margin is reached.
  5. Raster attributes - The only raster attributes accepted by the VT240 is defined. by Macro Parameter value of 1. Thus all other combinations of raster attributes fall back to this selection.
  6. Horizontal Grid Size parameter - The VT240 interprets this parameter as a different function. The effect of specifying this parameter has very limited effects.
hackerb9 commented 5 years ago

It is precisely the USER AGENT problem which MinTTY is contributing to by not using its right name. UNIX has had a solution to this for a long time: using Terminfo, a terminal can use its own name but simply declare that it is compatible with some other terminal.