LineWrappingTextWriter Constructor

Initializes a new instance of the LineWrappingTextWriter class.

Definition

Namespace: Ookii.CommandLine
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 4.2.0+a4d3631e4dcc0970081ed435288efdebc1325f83
C#
public LineWrappingTextWriter(
	TextWriter baseWriter,
	int maximumLineLength,
	bool disposeBaseWriter = true,
	bool countFormatting = false
)

Parameters

baseWriter  TextWriter
The TextWriter to which to write the wrapped output.
maximumLineLength  Int32
The maximum length of a line, in characters; a value of less than 1 or larger than 65536 means there is no maximum line length.
disposeBaseWriter  Boolean  (Optional)
If set to the baseWriter will be disposed when the LineWrappingTextWriter is disposed.
countFormatting  Boolean  (Optional)
If set to , virtual terminal sequences used to format the text will not be counted as part of the line length, and will therefore not affect where the text is wrapped. The default value is .

Remarks

The largest maximumLineLength value supported is 65535. Above that, line length is considered to be unbounded. This is done to avoid having to buffer large amounts of data to support these long line lengths.

If you want to write to the console, use ConsoleOut or ConsoleError as the baseWriter and specify ConsoleWindowWidth - 1 as the maximumLineLength and for disposeBaseWriter. If you don't subtract one from the window width, additional empty lines can be printed if a line is exactly the width of the console. You can easily create a LineWrappingTextWriter that writes to the console by using the ForConsoleOut and ForConsoleError methods.

Exceptions

ArgumentNullExceptionbaseWriter is .

See Also