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

paging support #65

Open
dan-da opened this issue Oct 11, 2023 · 1 comment
Open

paging support #65

dan-da opened this issue Oct 11, 2023 · 1 comment

Comments

@dan-da
Copy link

dan-da commented Oct 11, 2023

Is there any way to scroll thumbnails one page at a time? If I try to pipe lsix output through more or less there is just garbage, not too surprising I guess.

@hackerb9
Copy link
Owner

Good question! I rarely have that many photos in one directory so I never thought about it. I typically just use Shift+PgUp in xterm to scroll back.

Idea 1: Theoretically, one could create a general pager which could read sixel data and know how many rows to scroll down. (For example, cat foo.six | identify - six:- would work most of the time to get the pixel height).

Idea 2: Although I strive to keep lsix as simple as possible, it may make more sense to build the pager into it. My biggest problem with doing that would be that to do it right I'd need to query the terminal to find out how tall the character cell is in pixels and not all terminals handle that correctly. I could make simplifying assumptions, like having lsix prompt "More?" after every three rows no matter the terminal size or resolution, but that might feel embarrassingly kludgy.

Idea 3: Investigate how to send the proper number of newlines to the terminal such that a pager like less -r would show the sixel images at the proper rate. Something like this, perhaps:

lsix | awk -v count=10 -v esc=$'\e'  '
BEGIN { s="";  for (i=0; i<count; i++) {s=s i "\n";}  
        s = s "\r" esc "[" count "A" esc "P";}   
{ gsub(esc "P", s esc "P");  
  print; 
}'  | less -r

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

No branches or pull requests

2 participants