You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
TextPath is hard-coded to use POSIX path separator, which could impair UX on a platform with different primary path separator, e.g. Windows.
Describe the solution you'd like
Allow configuring TextPath to alternatively use the platform-specific path separator.
Describe alternatives you've considered
One workaround is to create wrapper class for TextPath that swaps the separator segment on render. Alternative, and probably less clunky, workaround would be to create derived implementation of TextPath which overrides the render method but that is not currently possible because the class is marked sealed.
Simplified example of the workaround wrapper class
usingSpectre.Console;usingSpectre.Console.Rendering;publicclassSystemTextPath:IRenderable,IHasJustification{privatestaticreadonlystringSystemDirectorySeparator=Path.DirectorySeparatorChar.ToString();privatestaticreadonlyboolOverrideSeparator=OperatingSystem.IsWindows()||Path.DirectorySeparatorChar!='/';privatereadonlyTextPath_textPath;privateSegment_directorySeparatorSegment;// For brevity, duplicated non-interface TextPath style etc. passthrough properties omitted.publicJustify?Justification{get=>_textPath.Justification;set=>_textPath.Justification=value;}publicSystemTextPath(stringpath){_textPath=newTextPath(path);_directorySeparatorSegment=newSegment(SystemDirectorySeparator,_textPath.SeparatorStyle??Style.Plain);}publicMeasurementMeasure(RenderOptionsoptions,intmaxWidth){// Measurement should not be affected with '/' -> '\' swap.return_textPath.Measure(options,maxWidth);}publicIEnumerable<Segment>Render(RenderOptionsoptions,intmaxWidth){if(OverrideSeparator){returnRenderSystemSpecificPath(options,maxWidth);}// Default POSIX path.return_textPath.Render(options,maxWidth);}privateIEnumerable<Segment>RenderSystemSpecificPath(RenderOptionsoptions,intmaxWidth){varpathSegments=_textPath.Render(options,maxWidth);foreach(SegmentsegmentinpathSegments){yieldreturnIsPathSeparator(segment)?_directorySeparatorSegment:segment;}}privatestaticboolIsPathSeparator(Segmentsegment){returnstring.Equals("/",segment.Text,StringComparison.Ordinal);}}
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
TextPath is hard-coded to use POSIX path separator, which could impair UX on a platform with different primary path separator, e.g. Windows.
Describe the solution you'd like
Allow configuring TextPath to alternatively use the platform-specific path separator.
Describe alternatives you've considered
One workaround is to create wrapper class for TextPath that swaps the separator segment on render. Alternative, and probably less clunky, workaround would be to create derived implementation of TextPath which overrides the render method but that is not currently possible because the class is marked sealed.
Simplified example of the workaround wrapper class
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered: