@@ -143,7 +143,7 @@ private static int _SkipControlSequence( string s, int startIdx )
143143 {
144144 int commandLen = 1 ;
145145 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 "
147147
148148 return curIdx + commandLen ; // note that this could be just past the end of the string.
149149 }
@@ -327,7 +327,7 @@ private static void _StripContent( StringBuilder destSb,
327327 destSb . Append ( s [ i ] ) ;
328328 if ( s [ i ] == '#' )
329329 {
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 ").
331331 inTwoCharControlSeq = true ;
332332 }
333333 else if ( ! _IsDigitOrSemi ( s [ i ] ) )
@@ -582,8 +582,22 @@ public static int ApparentIndexOf( string s, char c )
582582
583583
584584 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
587601
588602 // public static string FG( ConsoleColor foreground )
589603 // {
@@ -715,8 +729,8 @@ public enum IndentAndWrapOptions
715729 // leading space is longer than the entire outputWidth
716730 }
717731
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 " ;
720734
721735 public static string IndentAndWrap ( string str ,
722736 int outputWidth ,
@@ -1272,9 +1286,9 @@ public CaStringUtilIndentAndWrapTestCase( string input,
12721286 0 ) ,
12731287 new CaStringUtilLengthTestCase ( "\u009b m" ,
12741288 0 ) ,
1275- new CaStringUtilLengthTestCase ( "\u009b #{ " ,
1289+ new CaStringUtilLengthTestCase ( "\u009b #p " ,
12761290 0 ) ,
1277- new CaStringUtilLengthTestCase ( "\u009b #{ \u009b 91mRED\u009b #} " ,
1291+ new CaStringUtilLengthTestCase ( "\u009b #p \u009b 91mRED\u009b #q " ,
12781292 3 ) ,
12791293 new CaStringUtilLengthTestCase ( "\u009b m123" ,
12801294 3 ) ,
@@ -1402,9 +1416,9 @@ public CaStringUtilIndentAndWrapTestCase( string input,
14021416 /* 15 */ new CaStringUtilTruncateTestCase ( "\u009b m1234567\u009b m" ,
14031417 6 ,
14041418 "\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
14061420 6 ,
1407- "\u009b m12345\u009b #{ …" ) ,
1421+ "\u009b m12345\u009b #p …" ) ,
14081422 /* 17 */ new CaStringUtilTruncateTestCase ( "" ,
14091423 1 ,
14101424 false ,
0 commit comments