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

Set console prompt cursor position at last line if application writes also messages to console #285

Open
abrasat opened this issue Jun 17, 2024 · 1 comment

Comments

@abrasat
Copy link

abrasat commented Jun 17, 2024

I have a test application where the Prompt.Select is located in a loop and different actions are performed depending on the actual selection. If the actions also write messages to the console, the Prompt.Select text is displayed somewehere in the midddle of the console messages generated during the execution of the different actions. For the first iteration is all ok, but after that the prompt select text is not at the last line anymore. I tried to call Console.SetCursorPosition(0, Console.CursorTop) before Prompt.Select() , but it does not help....

@abrasat
Copy link
Author

abrasat commented Jun 18, 2024

@shibayan By making the following change in the code, the Prompt.Select displays the message at the right position, after the application-generated messages:

    public RenderScope(OffscreenBuffer offscreenBuffer, IConsoleDriver consoleDriver, int cursorBottom, int writtenLineCount)
    {
        _offscreenBuffer = offscreenBuffer;
        _consoleDriver = consoleDriver;

        // old
        //_cursorBottom = Math.Min(cursorBottom, _consoleDriver.WindowHeight - 1);
        // new
        _cursorBottom =  cursorBottom;

        _writtenLineCount = Math.Min(writtenLineCount, _consoleDriver.WindowHeight - 1);

        _offscreenBuffer.ClearBuffer();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant