@@ -143,7 +143,7 @@ private static int _SkipControlSequence( string s, int startIdx )
143
143
{
144
144
int commandLen = 1 ;
145
145
if ( c == '#' )
146
- commandLen = 2 ; // '#' is the first char of a command like "#{ " or "#} "
146
+ commandLen = 2 ; // '#' is the first char of a command like "#p " or "#q "
147
147
148
148
return curIdx + commandLen ; // note that this could be just past the end of the string.
149
149
}
@@ -327,7 +327,7 @@ private static void _StripContent( StringBuilder destSb,
327
327
destSb . Append ( s [ i ] ) ;
328
328
if ( s [ i ] == '#' )
329
329
{
330
- // This is the first char of a two-char command code ("#{ " or "#} ").
330
+ // This is the first char of a two-char command code ("#p " or "#q ").
331
331
inTwoCharControlSeq = true ;
332
332
}
333
333
else if ( ! _IsDigitOrSemi ( s [ i ] ) )
@@ -582,8 +582,22 @@ public static int ApparentIndexOf( string s, char c )
582
582
583
583
584
584
internal const string SGR = "m" ; // SGR: "Select Graphics Rendition"
585
- internal const string PUSH = "#{" ; // XTPUSHSGR
586
- internal const string POP = "#}" ; // XTPOPSGR
585
+
586
+ // TROUBLE: The current definition of XTPUSHSGR and XTPOPSGR use curly brackets,
587
+ // which turns out to conflict badly with C# string formatting. For example, this:
588
+ //
589
+ //
590
+ // $csFmt = (New-ColorString).AppendPushFg( 'Cyan' ).Append( 'this should all be cyan: {0}' )
591
+ // [string]::format( $csFmt.ToString( $true ), 'blah' )
592
+ //
593
+ // will blow up.
594
+ //
595
+ // For now, I'm going to switch to some other characters while we see if we get
596
+ // can something worked out with xterm.
597
+ //internal const string PUSH = "#{"; // XTPUSHSGR
598
+ //internal const string POP = "#}"; // XTPOPSGR
599
+ internal const string PUSH = "#p" ; // NOT XTPUSHSGR
600
+ internal const string POP = "#q" ; // NOT XTPOPSGR
587
601
588
602
// public static string FG( ConsoleColor foreground )
589
603
// {
@@ -715,8 +729,8 @@ public enum IndentAndWrapOptions
715
729
// leading space is longer than the entire outputWidth
716
730
}
717
731
718
- private const string c_PushAndReset = "\u009b #{ \u009b 0m" ;
719
- private const string c_StandalonePop = "\u009b #} " ;
732
+ private const string c_PushAndReset = "\u009b #p \u009b 0m" ;
733
+ private const string c_StandalonePop = "\u009b #q " ;
720
734
721
735
public static string IndentAndWrap ( string str ,
722
736
int outputWidth ,
@@ -1272,9 +1286,9 @@ public CaStringUtilIndentAndWrapTestCase( string input,
1272
1286
0 ) ,
1273
1287
new CaStringUtilLengthTestCase ( "\u009b m" ,
1274
1288
0 ) ,
1275
- new CaStringUtilLengthTestCase ( "\u009b #{ " ,
1289
+ new CaStringUtilLengthTestCase ( "\u009b #p " ,
1276
1290
0 ) ,
1277
- new CaStringUtilLengthTestCase ( "\u009b #{ \u009b 91mRED\u009b #} " ,
1291
+ new CaStringUtilLengthTestCase ( "\u009b #p \u009b 91mRED\u009b #q " ,
1278
1292
3 ) ,
1279
1293
new CaStringUtilLengthTestCase ( "\u009b m123" ,
1280
1294
3 ) ,
@@ -1402,9 +1416,9 @@ public CaStringUtilIndentAndWrapTestCase( string input,
1402
1416
/* 15 */ new CaStringUtilTruncateTestCase ( "\u009b m1234567\u009b m" ,
1403
1417
6 ,
1404
1418
"\u009b m12345\u009b m…" ) ,
1405
- /* 16 */ new CaStringUtilTruncateTestCase ( "\u009b m1234567\u009b #{ " , // <-- Note: two-char command code
1419
+ /* 16 */ new CaStringUtilTruncateTestCase ( "\u009b m1234567\u009b #p " , // <-- Note: two-char command code
1406
1420
6 ,
1407
- "\u009b m12345\u009b #{ …" ) ,
1421
+ "\u009b m12345\u009b #p …" ) ,
1408
1422
/* 17 */ new CaStringUtilTruncateTestCase ( "" ,
1409
1423
1 ,
1410
1424
false ,
0 commit comments