Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

correctly presenting progressbar when buffer scrolls and clearing at end#3362

Merged
lzybkr merged 1 commit into
PowerShell:masterPowerShell/PowerShell:masterfrom
SteveL-MSFT:progressbar-2SteveL-MSFT/PowerShell:progressbar-2Copy head branch name to clipboard
Mar 19, 2017
Merged

correctly presenting progressbar when buffer scrolls and clearing at end#3362
lzybkr merged 1 commit into
PowerShell:masterPowerShell/PowerShell:masterfrom
SteveL-MSFT:progressbar-2SteveL-MSFT/PowerShell:progressbar-2Copy head branch name to clipboard

Conversation

@SteveL-MSFT

Copy link
Copy Markdown
Member

Windows progressbar requires ability to cache the screen buffer contents so it can write it back once progress is done. Linux doesn't provide a way for console apps to read the screen buffer (security concern). Changes:

  • scroll buffer appropriately by the size needed for progress bar if near bottom of screen, adjust progressbar location to account for scrolling
  • create an empty screen buffer used to clear the progress bar once done

No easy way to add tests for ProgressBar.

addresses #1625

Before the change:
before

After the change:
after

if (_location.Y >= _rawui.BufferSize.Height - rows)
//if the cursor is at the bottom, create screen buffer space by scrolling
int scrollRows = rows - ((_rawui.BufferSize.Height - 1) - _location.Y);
for (int i = 0; i < rows; i++)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In rare cases, there may be junk on the screen below the prompt. Maybe we should be writing out spaces to make sure it's clear.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's junk, it'll get overwritten anyways with tempProgressRegion where every cell has a character including spaces

@lzybkr lzybkr self-assigned this Mar 19, 2017
@lzybkr lzybkr merged commit 30eb61e into PowerShell:master Mar 19, 2017
@iSazonov

iSazonov commented Mar 19, 2017

Copy link
Copy Markdown
Collaborator

No easy way to add tests for ProgressBar.

We can try to use our TestHostCS.psm1

@SteveL-MSFT SteveL-MSFT deleted the progressbar-2 branch March 19, 2017 23:21
@SteveL-MSFT

Copy link
Copy Markdown
Member Author

@iSazonov don't think TestHostCS.psm1 will help here since we're trying to validate how powershell.exe handles progressbar

@lzybkr

lzybkr commented Mar 20, 2017

Copy link
Copy Markdown
Contributor

Testing this would be similar to how I test PSReadline - I introduce a mock console interface, so instead of Console.Write, you write something more like _console.Write - then the test framework has a mock for the interface (which doesn't really exist, you need to invent one.)

It's a pain to write these tests and there is little return in that investment, so that's why I didn't ask Steve for any tests.

@iSazonov

Copy link
Copy Markdown
Collaborator

there is little return in that investment

If the stock price change, I may try to enhance our TestHostCS.psm1 to support this scenarios. 😄

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

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.