@@ -76,6 +76,9 @@ protected override void OnLoad(EventArgs e)
7676 WordWrapMode = WordWrapMode . WordWrapControlWidth ;
7777 PreferredLineWidth = 0 ;
7878 ReadOnly = true ;
79+ FoldingHighlightEnabled = false ;
80+ HighlightFoldingIndicator = false ;
81+ ShowFoldingLines = false ;
7982 var testStyle = new TextStyle ( new SolidBrush ( Color . Red ) , null , FontStyle . Regular ) ;
8083 }
8184
@@ -137,28 +140,36 @@ public void WriteLine(string text, Style style)
137140 public void WriteAnsi ( string text )
138141 {
139142 // Match Ansi color codes and process them
140- var match = Regex . Match ( text , @"\e\[(?<codes>(\d+;)*\d+);*m" ) ;
141- while ( match . Captures . Count != 0 )
143+ try
142144 {
143- var codes = match . Groups [ "codes" ] . Value ;
144- if ( match . Index != 0 )
145+ SuspendLayout ( ) ;
146+ var match = Regex . Match ( text , @"\e\[(?<codes>(\d+;)*\d+);*m" ) ;
147+ while ( match . Captures . Count != 0 )
145148 {
149+ var codes = match . Groups [ "codes" ] . Value ;
150+ if ( match . Index != 0 )
151+ {
152+ if ( AnsiManager . Blinking )
153+ WriteWithStyles ( text [ ..( match . Index ) ] , new Style [ ] { CurrentStyle , DefaultBlinkingStyle } ) ;
154+ else
155+ Write ( text [ ..( match . Index ) ] , CurrentStyle ) ;
156+ }
157+ CurrentStyle = AnsiManager . ProcessCodes ( codes . Split ( ';' ) . ToList ( ) . Select ( int . Parse ) . ToList ( ) ) ;
158+ text = match . Index + match . Length < text . Length ? text [ ( match . Index + match . Length ) ..] : string . Empty ;
159+ match = Regex . Match ( text , @"\e\[(?<codes>(\d+;)*\d+);*m" ) ;
160+ }
161+
162+ if ( ! string . IsNullOrEmpty ( text ) )
146163 if ( AnsiManager . Blinking )
147- WriteWithStyles ( text [ .. ( match . Index ) ] , new Style [ ] { CurrentStyle , DefaultBlinkingStyle } ) ;
164+ WriteWithStyles ( text , new Style [ ] { CurrentStyle , DefaultBlinkingStyle } ) ;
148165 else
149- Write ( text [ .. ( match . Index ) ] , CurrentStyle ) ;
150- Application . DoEvents ( ) ;
151- }
152- CurrentStyle = AnsiManager . ProcessCodes ( codes . Split ( ';' ) . ToList ( ) . Select ( int . Parse ) . ToList ( ) ) ;
153- text = match . Index + match . Length < text . Length ? text [ ( match . Index + match . Length ) .. ] : string . Empty ;
154- match = Regex . Match ( text , @"\e\[(?<codes>(\d+;)*\d+);*m" ) ;
166+ Write ( text , CurrentStyle ) ;
167+ }
168+ finally
169+ {
170+ ResumeLayout ( ) ;
171+ Application . DoEvents ( ) ;
155172 }
156-
157- if ( ! string . IsNullOrEmpty ( text ) )
158- if ( AnsiManager . Blinking )
159- WriteWithStyles ( text , new Style [ ] { CurrentStyle , DefaultBlinkingStyle } ) ;
160- else
161- Write ( text , CurrentStyle ) ;
162173 }
163174
164175 /// <summary>
0 commit comments