@@ -91,32 +91,43 @@ class ProgressPane
91
91
92
92
int rows = tempProgressRegion . GetLength ( 0 ) ;
93
93
int cols = tempProgressRegion . GetLength ( 1 ) ;
94
- _location = _rawui . WindowPosition ;
95
-
96
- // We have to show the progress pane in the first column, as the screen buffer at any point might contain
97
- // a CJK double-cell characters, which makes it impractical to try to find a position where the pane would
98
- // not slice a character. Column 0 is the only place where we know for sure we can place the pane.
99
-
100
94
_location . X = 0 ;
101
- _location . Y = Math . Min ( _location . Y + 2 , _bufSize . Height ) ;
102
95
103
96
#if UNIX
104
- // replace the saved region in the screen buffer with our progress display
105
- _location = _rawui . CursorPosition ;
97
+ _location . Y = _rawui . CursorPosition . Y ;
106
98
107
- //set the cursor position back to the beginning of the region to overwrite write-progress
108
- //if the cursor is at the bottom, back it up to overwrite the previous write progress
109
- if ( _location . Y >= _rawui . BufferSize . Height - rows )
99
+ //if the cursor is at the bottom, create screen buffer space by scrolling
100
+ int scrollRows = rows - ( ( _rawui . BufferSize . Height - 1 ) - _location . Y ) ;
101
+ for ( int i = 0 ; i < rows ; i ++ )
110
102
{
111
103
Console . Out . Write ( '\n ' ) ;
112
- if ( _location . Y >= rows )
104
+ }
105
+ if ( scrollRows > 0 )
106
+ {
107
+ _location . Y -= scrollRows ;
108
+ }
109
+
110
+ //create cleared region to clear progress bar later
111
+ _savedRegion = tempProgressRegion ;
112
+ for ( int row = 0 ; row < rows ; row ++ )
113
+ {
114
+ for ( int col = 0 ; col < cols ; col ++ )
113
115
{
114
- _location . Y -= rows ;
116
+ _savedRegion [ row , col ] . Character = ' ' ;
115
117
}
116
118
}
117
119
120
+ //put cursor back to where output should be
118
121
_rawui . CursorPosition = _location ;
119
122
#else
123
+ _location = _rawui . WindowPosition ;
124
+
125
+ // We have to show the progress pane in the first column, as the screen buffer at any point might contain
126
+ // a CJK double-cell characters, which makes it impractical to try to find a position where the pane would
127
+ // not slice a character. Column 0 is the only place where we know for sure we can place the pane.
128
+
129
+ _location . Y = Math . Min ( _location . Y + 2 , _bufSize . Height ) ;
130
+
120
131
// Save off the current contents of the screen buffer in the region that we will occupy
121
132
_savedRegion =
122
133
_rawui . GetBufferContents (
0 commit comments