@@ -72,12 +72,10 @@ private void Render()
7272
7373 private void ReallyRender ( )
7474 {
75- _renderForDemoNeeded = false ;
76-
7775 var text = ParseInput ( ) ;
7876
7977 int statusLineCount = GetStatusLineCount ( ) ;
80- int bufferLineCount = ConvertOffsetToCoordinates ( text . Length ) . Y - _initialY + 1 + _demoWindowLineCount + statusLineCount ;
78+ int bufferLineCount = ConvertOffsetToCoordinates ( text . Length ) . Y - _initialY + 1 + statusLineCount ;
8179 int bufferWidth = Console . BufferWidth ;
8280 if ( _consoleBuffer . Length != bufferLineCount * bufferWidth )
8381 {
@@ -202,7 +200,7 @@ private void ReallyRender()
202200 }
203201 }
204202
205- for ( ; j < ( _consoleBuffer . Length - ( ( statusLineCount + _demoWindowLineCount ) * _bufferWidth ) ) ; j ++ )
203+ for ( ; j < ( _consoleBuffer . Length - ( statusLineCount * _bufferWidth ) ) ; j ++ )
206204 {
207205 _consoleBuffer [ j ] = _space ;
208206 }
@@ -225,17 +223,12 @@ private void ReallyRender()
225223 _consoleBuffer [ j ] . BackgroundColor = backgroundColor ;
226224 }
227225
228- for ( ; j < ( _consoleBuffer . Length - ( _demoWindowLineCount * _bufferWidth ) ) ; j ++ )
226+ for ( ; j < _consoleBuffer . Length ; j ++ )
229227 {
230228 _consoleBuffer [ j ] = _space ;
231229 }
232230 }
233231
234- if ( _demoMode )
235- {
236- RenderDemoWindow ( j ) ;
237- }
238-
239232 bool rendered = false ;
240233 if ( _parseErrors . Length > 0 )
241234 {
@@ -266,9 +259,9 @@ private void ReallyRender()
266259
267260 PlaceCursor ( ) ;
268261
269- if ( ( _initialY + bufferLineCount + ( _demoMode ? 1 : 0 ) ) > ( Console . WindowTop + Console . WindowHeight ) )
262+ if ( ( _initialY + bufferLineCount ) > ( Console . WindowTop + Console . WindowHeight ) )
270263 {
271- Console . WindowTop = _initialY + bufferLineCount + ( _demoMode ? 1 : 0 ) - Console . WindowHeight ;
264+ Console . WindowTop = _initialY + bufferLineCount - Console . WindowHeight ;
272265 }
273266
274267 _lastRenderTime . Restart ( ) ;
@@ -487,9 +480,9 @@ private static void ScrollBuffer(int lines)
487480 private void PlaceCursor ( int x , ref int y )
488481 {
489482 int statusLineCount = GetStatusLineCount ( ) ;
490- if ( ( y + _demoWindowLineCount + statusLineCount ) >= Console . BufferHeight )
483+ if ( ( y + statusLineCount ) >= Console . BufferHeight )
491484 {
492- ScrollBuffer ( ( y + _demoWindowLineCount + statusLineCount ) - Console . BufferHeight + 1 ) ;
485+ ScrollBuffer ( ( y + statusLineCount ) - Console . BufferHeight + 1 ) ;
493486 y = Console . BufferHeight - 1 ;
494487 }
495488 Console . SetCursorPosition ( x , y ) ;
@@ -631,139 +624,6 @@ private bool PromptYesOrNo(string s)
631624 return key . Key == ConsoleKey . Y ;
632625 }
633626
634- #region Demo mode
635-
636- private readonly HistoryQueue < string > _demoStrings ;
637- private bool _demoMode ;
638- private int _demoWindowLineCount ;
639- private bool _renderForDemoNeeded ;
640-
641- /// <summary>
642- /// Turn on demo mode (display events like keys pressed)
643- /// </summary>
644- public static void EnableDemoMode ( ConsoleKeyInfo ? key = null , object arg = null )
645- {
646- const int windowLineCount = 4 ; // 1 blank line, 2 border lines, 1 line of info
647- _singleton . _captureKeys = true ;
648- _singleton . _demoMode = true ;
649- _singleton . _demoWindowLineCount = windowLineCount ;
650- var newBuffer = new CHAR_INFO [ _singleton . _consoleBuffer . Length + ( windowLineCount * _singleton . _bufferWidth ) ] ;
651- Array . Copy ( _singleton . _consoleBuffer , newBuffer ,
652- _singleton . _initialX + ( _singleton . Options . ExtraPromptLineCount * _singleton . _bufferWidth ) ) ;
653- _singleton . _consoleBuffer = newBuffer ;
654- _singleton . Render ( ) ;
655- }
656-
657- /// <summary>
658- /// Turn off demo mode (display events like keys pressed)
659- /// </summary>
660- public static void DisableDemoMode ( ConsoleKeyInfo ? key = null , object arg = null )
661- {
662- _singleton . _savedKeys . Clear ( ) ;
663- _singleton . _captureKeys = false ;
664- _singleton . _demoMode = false ;
665- _singleton . _demoStrings . Clear ( ) ;
666- _singleton . _demoWindowLineCount = 0 ;
667- _singleton . ClearDemoWindow ( ) ;
668- }
669-
670-
671- private void RenderDemoWindow ( int windowStart )
672- {
673- int i ;
674-
675- Action < int , char > setChar = ( index , c ) =>
676- {
677- _consoleBuffer [ index ] . UnicodeChar = c ;
678- _consoleBuffer [ index ] . ForegroundColor = ConsoleColor . DarkCyan ;
679- _consoleBuffer [ index ] . BackgroundColor = ConsoleColor . White ;
680- } ;
681-
682- for ( i = 0 ; i < _bufferWidth ; i ++ )
683- {
684- _consoleBuffer [ windowStart + i ] . UnicodeChar = ' ' ;
685- _consoleBuffer [ windowStart + i ] . ForegroundColor = _initialForegroundColor ;
686- _consoleBuffer [ windowStart + i ] . BackgroundColor = _initialBackgroundColor ;
687- }
688- windowStart += _bufferWidth ;
689-
690- const int extraSpace = 2 ;
691- // Draw the box
692- setChar ( windowStart + extraSpace , ( char ) 9484 ) ; // upper left
693- setChar ( windowStart + _bufferWidth * 2 + extraSpace , ( char ) 9492 ) ; // lower left
694- setChar ( windowStart + _bufferWidth - 1 - extraSpace , ( char ) 9488 ) ; // upper right
695- setChar ( windowStart + _bufferWidth * 3 - 1 - extraSpace , ( char ) 9496 ) ; // lower right
696- setChar ( windowStart + _bufferWidth + extraSpace , ( char ) 9474 ) ; // side
697- setChar ( windowStart + _bufferWidth * 2 - 1 - extraSpace , ( char ) 9474 ) ; // side
698-
699- for ( i = 1 + extraSpace ; i < _bufferWidth - 1 - extraSpace ; i ++ )
700- {
701- setChar ( windowStart + i , ( char ) 9472 ) ;
702- setChar ( windowStart + i + 2 * _bufferWidth , ( char ) 9472 ) ;
703- }
704-
705- while ( _savedKeys . Count > 0 )
706- {
707- var key = _savedKeys . Dequeue ( ) ;
708- _demoStrings . Enqueue ( key . ToGestureString ( ) ) ;
709- }
710-
711- int charsToDisplay = _bufferWidth - 2 - ( 2 * extraSpace ) ;
712- i = windowStart + _bufferWidth + 1 + extraSpace ;
713- bool first = true ;
714- for ( int j = _demoStrings . Count ; j > 0 ; j -- )
715- {
716- string eventString = _demoStrings [ j - 1 ] ;
717- if ( ( eventString . Length + ( first ? 0 : 1 ) ) > charsToDisplay )
718- break ;
719-
720- if ( ! first )
721- {
722- setChar ( i ++ , ' ' ) ;
723- charsToDisplay -- ;
724- }
725-
726- foreach ( char c in eventString )
727- {
728- setChar ( i , c ) ;
729- if ( first )
730- {
731- // Invert the first word to highlight it
732- var color = _consoleBuffer [ i ] . ForegroundColor ;
733- _consoleBuffer [ i ] . ForegroundColor = _consoleBuffer [ i ] . BackgroundColor ;
734- _consoleBuffer [ i ] . BackgroundColor = color ;
735- }
736- i ++ ;
737- charsToDisplay -- ;
738- }
739-
740- first = false ;
741- }
742- while ( charsToDisplay -- > 0 )
743- {
744- setChar ( i ++ , ' ' ) ;
745- }
746- }
747-
748- private void ClearDemoWindow ( )
749- {
750- int bufferWidth = Console . BufferWidth ;
751- var charInfoBuffer = new CHAR_INFO [ bufferWidth * 3 ] ;
752-
753- for ( int i = 0 ; i < charInfoBuffer . Length ; i ++ )
754- {
755- charInfoBuffer [ i ] . UnicodeChar = ' ' ;
756- charInfoBuffer [ i ] . ForegroundColor = _initialForegroundColor ;
757- charInfoBuffer [ i ] . BackgroundColor = _initialBackgroundColor ;
758- }
759-
760- int bufferLineCount = ConvertOffsetToCoordinates ( _buffer . Length ) . Y - _initialY + 1 ;
761- int y = _initialY + bufferLineCount + 1 ;
762- WriteBufferLines ( charInfoBuffer , ref y ) ;
763- }
764-
765- #endregion Demo mode
766-
767627 #region Screen scrolling
768628
769629 /// <summary>
0 commit comments