dankamongmen / notcurses

blingful character graphics/TUI library. definitely not curses.
https://nick-black.com/dankwiki/index.php/Notcurses
Other
3.43k stars 113 forks source link

ncplayer sixel output may cause undesired scrolling #2709

Closed PerBothner closed 1 year ago

PerBothner commented 1 year ago

I am working on improving the Sixel support in DomTerm, and I found a problem with sixel scrolling. (It is quite possible I'm misunderstanding something.)

Running ncplayer will output a sixel bitmap ending in - (graphics new line), then move to the home position and write some text. The problem is that as I read the specification the final - may scroll the window, which is undesirable.

For example, consider a window containing 10 lines, with each line 20 pixels high. To fill the window requires floor(200/6) or 33 sixel rows. The final ~ moves the sixel cursor to sixel row 33 (0-origin) which is pixel lines 198-203 (again 0-origin). This is more than window height, so the window is scrolled. (Assuming DECSDM is not set - I've read some of the discussion about that.) This scrolling could cause glitches or inefficiency.

Note the VT340 manual says: When sixel mode is exited, the text cursor is set to the current sixel cursor position.

A fix might be to emit $ (graphics carriage return) instead of - at the end.

I'm using ncplayer built from github master.

PerBothner commented 1 year ago

I noticed that ncplayer sets the 8452 setting - xterm calls this "sixel_scrolls_right". That may be the explanation - will investigate.

PerBothner commented 1 year ago

I looked at the xterm logic, and implemented that. (Xterm ignores the sixel cursor when setting the text cursor.) It works ok now.