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

Is it possible to limit the terminal not to go over a single page? #6935

Closed
AnFunctionArray opened this issue Jul 15, 2020 · 6 comments
Closed
Labels
Area-VT Virtual Terminal sequence support Issue-Question For questions or discussion Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity.

Comments

@AnFunctionArray
Copy link

AnFunctionArray commented Jul 15, 2020

I have a code that uses SetConsoleCursorPosition to set a position on the screen and write to it. However sometimes it goes over the window buffer and the terminal scrolls down. Is it possible to restrict this and limit the cursor at the current window.

If it's not I would be grateful if you at least point me in the right direction. I've been tinkering with the source code - limiting cursor positions and scrolls all day (both in my application and lately mostly at the terminal source).

@AnFunctionArray AnFunctionArray added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Jul 15, 2020
@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jul 15, 2020
@zadjii-msft
Copy link
Member

Well, I'd probably start writing code to clamp all your calls to SetCursorPosition within the bounds of the srWindow returned in the CONSOLE_SCREEN_BUFFER_INFO from GetConsoleScreenBufferInfo.

Another thing you could do, which is common for applications which are "painting the entire viewport" (for things like vim, emacs, top, tmux, etc), is use the "alternate screen buffer". This is a special buffer which is exactly the size of the window. You can make edits to the contents of this buffer, and when you leave the buffer, the changes will not be persisted in the "main" buffer, so you don't just have the contents of vim leftover in your history.

You can see a sample of using the alt buffer in a console app here. You'll need to enable ENABLE_VIRTUAL_TERMINAL_PROCESSING, and emit "\x1b[?1049h" to enter the alt buffer, and "\x1b[?1049l" to leave.

You should note that the alt buffer doesn't work exactly right in the Windows Terminal quite yet (see #381, #3492 and others), but it'll work just fine in the vintage console window (conhost.exe)

@zadjii-msft zadjii-msft added Area-VT Virtual Terminal sequence support Issue-Question For questions or discussion Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Jul 16, 2020
@AnFunctionArray
Copy link
Author

AnFunctionArray commented Jul 16, 2020

So it looks like this alternative buffer is exactly what I need - but I also need it in Windows Terminal because I depend on the Unicode support.

I guess for now the only thing I can do is wait.

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jul 16, 2020
@zadjii-msft
Copy link
Member

You can definitely still use the alt buffer currently in the Windows Terminal, there'll just be slight bugs in our implementation. Heck, you can use vim, emacs, htop, etc currently in the Terminal, and they're all pretty fundamentally relying on it.

Currently in the Windows Terminal, your cursor positioning will still be clamped to the size of the viewport, it's just, we'll leave the output in the main buffer for now.

I'd say go ahead and start prototyping with that now and keep an eye on the issues I've linked previously ☺️

@AnFunctionArray
Copy link
Author

@zadjii-msft The alternative buffer isn't locked to the viewpoint - is this an issue? I was able to restrict the viewpoint by commenting some code but I think it would be better is we can write this on stone. Alternatively we could implement a viewpointLock setting to enable. If you think any of those things can be useful/accepted - I can create some code plus I think I can write some tests too.

@zadjii-msft
Copy link
Member

Sorry for the incredibly delayed response. You're right that the alt buffer in the Terminal currently isn't locked to the viewport. That's something that'll need #381 to actually be finished to fix. I'd rather not implement another workaround - let's just focus on fixing the real root cause 😄

@zadjii-msft zadjii-msft added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Attention The core contributors need to come back around and look at this ASAP. labels Aug 19, 2020
@ghost ghost added the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Aug 23, 2020
@ghost
Copy link

ghost commented Aug 23, 2020

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost ghost closed this as completed Aug 26, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-VT Virtual Terminal sequence support Issue-Question For questions or discussion Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity.
Projects
None yet
Development

No branches or pull requests

2 participants