Any way to achieve something like [Console]::SetWindowPosition? #13194

Open
opened 2026-01-31 03:36:18 +00:00 by claunia · 0 comments
Owner

Originally created by @jazzdelightsme on GitHub (Mar 25, 2021).

(and if current answer is "no", how might we design some way to do it?)

The situation is that I sometimes use PSReadLine's CaptureScreen function to select and copy portions of my console buffer. When you invoke the CaptureScreen function, PSReadLine enters a sort of mode where you can use arrow keys to move the selection around and use shift together with arrow keys (or j/k for us vi people) to extend the selection. The mode stops when you hit enter, resulting in copying a nice HTML (or is it RTF?) reproduction of the selected area into your clipboard. Very handy.

Crucially (for this Issue), when the selection gets near the top (or bottom) of the console window, CaptureScreen will scroll the buffer, so you can keep selecting (or reach the part of your buffer that you wanted to select in the first place). Like this:

CaptureScreenScrollback

But this scroll-when-you-get-near-the-top functionality does not work in Terminal. (In Terminal, the selection line just reaches the top of the window, and you can go no further.)

The root cause is that CaptureScreen is using [Console]::SetWindowPosition to scroll the buffer… and that does not work in Terminal.

Poking around, I see that it seems like this is By Design, right? (for example: #9018)

So… that brings me to the question: okay, if SetWindowPosition will not work, is there any way this could be made to work?

And if not, what might be done to eventually provide a way for this scenario to work?

Thanks!

Originally created by @jazzdelightsme on GitHub (Mar 25, 2021). (and if current answer is "no", how might we design some way to do it?) The situation is that I sometimes use PSReadLine's `CaptureScreen` function to select and copy portions of my console buffer. When you invoke the `CaptureScreen` function, PSReadLine enters a sort of mode where you can use arrow keys to move the selection around and use <kbd>shift</kbd> together with arrow keys (or <kbd>j</kbd>/<kbd>k</kbd> for us vi people) to extend the selection. The mode stops when you hit <kbd>enter</kbd>, resulting in copying a nice HTML (or is it RTF?) reproduction of the selected area into your clipboard. Very handy. Crucially (for this Issue), when the selection gets near the top (or bottom) of the console window, `CaptureScreen` will scroll the buffer, so you can keep selecting (or reach the part of your buffer that you wanted to select in the first place). Like this: ![CaptureScreenScrollback](https://user-images.githubusercontent.com/771085/112552238-b4495580-8d7f-11eb-8552-8171e6e29c27.gif) But this scroll-when-you-get-near-the-top functionality does not work in Terminal. (In Terminal, the selection line just reaches the top of the window, and you can go no further.) The root cause is that `CaptureScreen` is using `[Console]::SetWindowPosition` to scroll the buffer… and that does not work in Terminal. Poking around, I see that it seems like this is By Design, right? (for example: #9018) So… that brings me to the question: okay, if `SetWindowPosition` will not work, is there any way this could be made to work? And if not, what might be done to eventually provide a way for this scenario to work? Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#13194