Open BDisp opened 5 hours ago
@lhecker thanks for the clarification. Yes it's true. Now the window buffer size always have the window size, but the scroll bar doesn't reflect that. When the buffer size is equal to the window size the scroll bar size should be zero and not allowing scrolling the buffer. If use my changed branch https://github.com/gui-cs/Terminal.Gui/pull/3768 the buffer size always reflects the window size but not the scroll bar.
In the WT version 1.21 the change I made to my branch is working fine only using the \x1b[?1049h
and \x1b[?1049l.
which in the gui-cs are named as EscSeqUtils.CSI_SaveCursorAndActivateAltBufferNoBackscroll
and EscSeqUtils.CSI_RestoreCursorAndRestoreAltBufferWithBackscroll
, respectively.
I just remembered that we had another gui-cs issues reported on us a while ago: #17949
The summary is that gui-cs has various imperfections and bugs around the usage of the Console API. One of the bugs is that it calls SetConsoleScreenBufferSize
with the information gained from GetConsoleScreenBufferInfoEx
without realizing that this results in an off-by-one error.
Generally speaking: Do not ever resize the buffer because the window was resized. This is true without the alternate screen-buffer but it's especially true if you do use it.
I'll continue to investigate.
tl;dr: When you use SetConsoleActiveScreenBuffer
you leave the alternate screen-buffer.
The issue is caused due to the usage of SetConsoleActiveScreenBuffer
. That function used to have a pretty much undefined (random) behavior up until 1.21. Starting 1.22 it does what it's supposed to do: It switches the console screen buffer. But doing so means that you also leave the previously set alternate screen-buffer (ASB). This causes a scrollbar to show up because you aren't in the ASB anymore.
I would recommend removing all usage of the _screenBuffer
member variable. While it's possible that I misunderstood your code, I don't think it should be used in the way you're doing it. Most functions can just use _outputHandle
and _inputHandle
directly. I don't think I understand the purpose of ReadFromConsoleOutput
. Every time it gets called, it creates an entire, new text buffer (= very very expensive) and then reads from it. This will always return whitespace because there's nothing in that new text buffer. You should probably pass the _outputHandle
there.
Let me know if I can help any other way.
Thank you very much. Removing the _screenBuffer
variable and only using the _outputHandle
variable in conjunction with the alternated screen solves the issue. I really appreciated your help. If you want please see my changed PR.
Originally posted by @lhecker in #5094