API Reference
TextWrapper
Word wrapping and end/middle truncation in terminal cells, preserving graphemes and styles.
Inheritance
- Object
- TextWrapper
Methods
public static StyledLine Truncate(StyledLine line, Int32 width, String ellipsis = "…") #StyledLineTruncates a styled line at the end, appending an ellipsis when text was cut.
Parameters
- line ConsoleMonster.Text.StyledLine
- Styled line.
- width System.Int32
- Maximum cells; non-positive values produce an empty line.
- ellipsis System.String = "…"
- Marker, clipped to the budget on grapheme boundaries.
Returns
A line no wider than the budget, with retained text styles.
public static StyledLine Truncate(StyledLine line, Int32 width, TerminalWidthProfile profile, String ellipsis = "…") #StyledLineTruncates a styled line using an explicit width profile.
Parameters
- line ConsoleMonster.Text.StyledLine
- width System.Int32
- profile ConsoleMonster.Text.TerminalWidthProfile
- ellipsis System.String = "…"
public static String Truncate(String text, Int32 width, String ellipsis = "…") #StringTruncates plain text at the end without splitting a grapheme.
Parameters
- text System.String
- Plain text.
- width System.Int32
- Maximum cells.
- ellipsis System.String = "…"
- Marker appended when text is cut.
Returns
Text within the budget.
public static String Truncate(String text, Int32 width, TerminalWidthProfile profile, String ellipsis = "…") #StringTruncates plain text with an explicit width profile.
Parameters
- text System.String
- width System.Int32
- profile ConsoleMonster.Text.TerminalWidthProfile
- ellipsis System.String = "…"
public static String TruncateMiddle(String text, Int32 width, String ellipsis = "…") #StringTruncates the middle of text, retaining both the beginning and the end (useful for paths).
Parameters
- text System.String
- Plain text.
- width System.Int32
- Maximum cells.
- ellipsis System.String = "…"
- Marker inserted between the retained ends.
Returns
Text within the budget, on grapheme boundaries.
public static String TruncateMiddle(String text, Int32 width, TerminalWidthProfile profile, String ellipsis = "…") #StringTruncates the middle using an explicit width profile.
Parameters
- text System.String
- width System.Int32
- profile ConsoleMonster.Text.TerminalWidthProfile
- ellipsis System.String = "…"
public static StyledLine TruncateMiddle(StyledLine line, Int32 width, String ellipsis = "…") #StyledLineTruncates the middle of a styled line, keeping both ends and their styles; the marker takes the style of the text before it.
Parameters
- line ConsoleMonster.Text.StyledLine
- Styled line.
- width System.Int32
- Maximum cells.
- ellipsis System.String = "…"
- Marker inserted between the retained ends.
Returns
A line within the budget, on grapheme boundaries.
public static IReadOnlyList<StyledLine> Wrap(StyledLine line, Int32 width) #IReadOnlyList<StyledLine>Word-wraps a line, keeping inner spaces and trimming spaces at breaks. Lines break after a space when one fits; otherwise after a separator (\ / ; , | & ? before . - : =, keeping a path segment or list item whole when it fits), so the line ends with it; only then by character. An indivisible grapheme wider than the budget becomes a space.
Parameters
- line ConsoleMonster.Text.StyledLine
- Styled line.
- width System.Int32
- Maximum cells per line; values below one use one.
Returns
At least one line, each within the budget.
public static IReadOnlyList<StyledLine> Wrap(StyledLine line, Int32 width, TerminalWidthProfile profile) #IReadOnlyList<StyledLine>Word-wraps a line using an explicit terminal width profile.
Parameters
- line ConsoleMonster.Text.StyledLine
- width System.Int32
- profile ConsoleMonster.Text.TerminalWidthProfile
Inherited Methods
public virtual Boolean Equals(Object? obj) #BooleanParameters
- obj Object?