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

Allow launched program to easily sync scroll position #3593

Closed
salmankhilji opened this issue May 8, 2021 · 1 comment
Closed

Allow launched program to easily sync scroll position #3593

salmankhilji opened this issue May 8, 2021 · 1 comment

Comments

@salmankhilji
Copy link

The launch mechanism does not have the equivalent of INPUT_LINE_NUMBER as scrollback_pager does.

I am feeding the contents of the current screen and scrollback to vim like this:

map f12 launch --type=overlay --stdin-source=@screen_scrollback vimw -

Where vimw is my wrapper script that execs vim.

I want to have my wrapper script scroll vim to the exact position as the scroll position within the kitty window.

The equation to compute input_line_number is:

input_line_number = (lines - (self.screen.lines - 1) - self.screen.scrolled_by)

As we can see, we need total number of lines, which kitty does not include in KITTY_PIPE_DATA.

Work Around:

I could try to compute total number of lines using wc -l within my script. However, doing so requires that I first store the entire stdin into a variable (because wc -l would consume stdin and I need stdin later to feed to vim.)

Possible Solutions:

  1. Include total number of lines in KITTY_PIPE_DATA.

  2. Add a new special argument named @input_line_number or @total_line_count (like @selection).

    The first one is preferred as the latter would still need bit of math and may force the need to write a wrapper script for folks who want it all inline within the kitty.conf file.

Notes

I am reluctant to use scrollback_pager mechanism as none of the examples mentioned in this thread implement the scrolling part. Moreover, vim's +LINE command-line argument does not seem to work when we use the term command to load stdin (as the current solutions do).

@salmankhilji salmankhilji changed the title Allow launched program easily sync scroll position Allow launched program to easily sync scroll position May 8, 2021
@salmankhilji
Copy link
Author

Never mind. I figured it all out only to end with a disappointment where vim seems to have a bug that prevents it from correctly loading large buffers using the term command. Nevertheless, if you think someone else could use this feature, go right ahead.

kovidgoyal added a commit that referenced this issue May 9, 2021
Now all ``KITTY_PIPE_DATA`` is also available via command line argument substitution
Fixes #3593
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

1 participant