kbjr / terminus-scrollbar

A Terminus plugin for adding a scrollbar to the terminal pane
5 stars 3 forks source link

Incorrect scrollbar size when exiting alternate screen apps #2

Open Eugeny opened 6 years ago

Eugeny commented 6 years ago

When returning to the normal screen buffer from the alternate one, scrollbar position and size are incorrect.

STR: 1: Create some output for the scrollbar to show 2: Run htop, aptitude or similar 3: Exit it (Ctrl-C)

kbjr commented 6 years ago

Hmm... Right now, the scrollbar listens for certain events to know when something happened in the terminal that we might need to update for (see https://github.com/kbjr/terminus-scrollbar/blob/master/src/scrollbar/scrollbar.ts#L64-L66).

Is there some other event I can watch for that would notify of this? Perhaps something related to the Ctrl+C signal?

Eugeny commented 6 years ago

There's a alternateScreenActive$ Observable that fires when entering and exiting the alternate screen - see if that helps

Eugeny commented 6 years ago

(it's on the TerminalTab object)

kbjr commented 6 years ago

I've pushed out version 0.1.2 which, as far as I can tell, does seem to behave correctly. But I'm testing on Windows, and there is probably some nuance there between Windows/*nix. Can you confirm?

Eugeny commented 6 years ago

Still doesn't quite work for me. When entering htop, the scrollbar still stays in "normal" mode: image

Htop continuously updates screen, so onTerminalUpdate gets called all the time. I'm running macOS, but starting htop inside WSL or Cygwin should give you the same result.

kbjr commented 6 years ago

If you actually scroll up, what happens? Because it determines the scrollbar height and position based off of the actual height and position of the terminal element (the x-screen element inside the hterm iframe), so if its showing that there is room to scroll, there probably actually is (whether there "should" be or not). If that's the case, I don't know if I can magic that away.

Eugeny commented 6 years ago

There's probably "physical" room available for scroll, but entering alternate screen mode means that the app intends to go full screen and probably handle keyboard/mouse input directly. For instance htop catches scroll events and aptitude ignores then completely. I'd say the scrollbar should go invisible when AS is active.

kbjr commented 6 years ago

That event actually doesn't seem to trigger in WSL either (except when first opening the terminal). I published a version 0.2.0-1 with the event set up to hide the scrollbar, can you confirm that it is working as expected?

Eugeny commented 6 years ago

The scrollbar disappears properly, but when exiting an AS app, it doesn't reappear until the next output event