Bat: Support terminal resize.

Created on 26 Sep 2018  路  7Comments  路  Source: sharkdp/bat

I've been using bat for sometime now continuously, and have just one major annoyance: no support for terminal resize events (we have to restart bat to adapt to the new size).

My usecase: going from windowed to fullscreen mode in tmux panes.

Screenshots:

image
image

Here, we could have seen the lines completely after a resize.

duplicate question

All 7 comments

Thank you for the feedback.

Please see #294.

Thanks for pointing to that. I'd say that these aren't duplicates because:

  1. naive usage of less doesn't have this bug.
  2. disabling the pager would just 'cat' the output and not ideal for reading.

I do agree that it is probably a bug in the pager but I wonder why it isn't visible in less by default.

@aero31aero You can simply use bat --wrap=never and the content should resize accordingly.

I would really like to see this reopened. less repaints when the terminal changes size but bat doesn't. I don't want to disable the pager, I want to be able to page through syntax-colorized content the same way I can page with less, but I also want to be able to resize my terminal without restarting bat if I decide it's too hard to read at the current width.

I guess the problem here is bat is not using less's wrapping but doing its own, so when less repaints it's still repainting with hard line breaks. And I imagine there's no way for less to ask bat to provide new content? So upon reflection this would probably require teaching bat how to be a full-fledged pager itself.

I guess the problem here is bat is not using less's wrapping but doing its own, so when less repaints it's still repainting with hard line breaks.

More or less, yeah. Disabling bat's wrapping would fix that problem, but then the wrapping would encroach on the area where the sidebar is supposed to go.

And I imagine there's no way for less to ask bat to provide new content?

Outside of incorporating less as a library to be used inside of bat, I don't believe there's any way to either: clear less's scrollback buffer; or have less clear its own buffer and send a signal to its parent on SIGWINCH.

If there is, though, we would also run into an issue because we don't buffer data. We would need to redraw all the previous lines as part of that, and we can't seek a pipe (e.g. process substitution or mkfifo) back to the beginning to do that. We would either need to buffer the input data and rehighlight it all again (slow), or buffer the highlighted lines before converting them to their final printable representation.

So upon reflection this would probably require teaching bat how to be a full-fledged pager itself.

Pretty much.

possible long term solution to this issue: #1053

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gAmUssA picture gAmUssA  路  3Comments

gwpl picture gwpl  路  3Comments

mjlbach picture mjlbach  路  3Comments

sharkdp picture sharkdp  路  3Comments

x70b1 picture x70b1  路  3Comments