public static class CommandLine.Help.TextTable extends Object
Responsible for spacing out CommandLine.Help.Ansi.Text
values according to the CommandLine.Help.Column
definitions the table was
created with. Columns have a width, indentation, and an overflow policy that decides what to do if a value is
longer than the column's width.
Modifier and Type | Class and Description |
---|---|
static class |
CommandLine.Help.TextTable.Cell
Helper class to index positions in a
Help.TextTable . |
Modifier and Type | Field and Description |
---|---|
protected List<CommandLine.Help.Ansi.Text> |
columnValues
The
char[] slots of the TextTable to copy text values into. |
int |
indentWrappedLines
By default, indent wrapped lines by 2 spaces.
|
Modifier | Constructor and Description |
---|---|
protected |
TextTable(CommandLine.Help.Ansi ansi,
CommandLine.Help.Column[] columns)
Deprecated.
use
picocli.CommandLine.Help.TextTable#TextTable(picocli.CommandLine.Help.ColorScheme, picocli.CommandLine.Help.Column[]) instead |
protected |
TextTable(CommandLine.Help.ColorScheme colorScheme,
CommandLine.Help.Column[] columns) |
Modifier and Type | Method and Description |
---|---|
void |
addEmptyRow()
Adds the required
char[] slots for a new row to the columnValues field. |
void |
addRowValues(CommandLine.Help.Ansi.Text... values)
|
void |
addRowValues(String... values)
Delegates to
addRowValues(CommandLine.Help.Ansi.Text...) , after ensuring
that multi-line values are layed out in the correct row and column. |
CommandLine.Help.Ansi.Text |
cellAt(int row,
int col)
Deprecated.
use
textAt(int, int) instead |
CommandLine.Help.Column[] |
columns()
The column definitions of this table.
|
static CommandLine.Help.TextTable |
forColumns(CommandLine.Help.Ansi ansi,
CommandLine.Help.Column... columns)
Deprecated.
|
static CommandLine.Help.TextTable |
forColumns(CommandLine.Help.ColorScheme colorScheme,
CommandLine.Help.Column... columns)
Constructs a
TextTable with the specified columns. |
static CommandLine.Help.TextTable |
forColumnWidths(CommandLine.Help.Ansi ansi,
int... columnWidths)
Deprecated.
|
static CommandLine.Help.TextTable |
forColumnWidths(CommandLine.Help.ColorScheme colorScheme,
int... columnWidths)
Constructs a new TextTable with columns with the specified width, all SPANning multiple columns on
overflow except the last column which WRAPS to the next row.
|
static CommandLine.Help.TextTable |
forDefaultColumns(CommandLine.Help.Ansi ansi,
int usageHelpWidth)
Deprecated.
|
static CommandLine.Help.TextTable |
forDefaultColumns(CommandLine.Help.Ansi ansi,
int longOptionsColumnWidth,
int usageHelpWidth)
Deprecated.
|
static CommandLine.Help.TextTable |
forDefaultColumns(CommandLine.Help.ColorScheme colorScheme,
int longOptionsColumnWidth,
int usageHelpWidth)
Constructs a TextTable with five columns as follows:
required option/parameter marker (width: 2, indent: 0, TRUNCATE on overflow)
short option name (width: 2, indent: 0, TRUNCATE on overflow)
comma separator (width: 1, indent: 0, TRUNCATE on overflow)
long option name(s) (width: 24, indent: 1, SPAN multiple columns on overflow)
description line(s) (width: 51, indent: 1, WRAP to next row on overflow)
|
boolean |
isAdjustLineBreaksForWideCJKCharacters() |
CommandLine.Help.TextTable.Cell |
putValue(int row,
int col,
CommandLine.Help.Ansi.Text value)
Writes the specified value into the cell at the specified row and column and returns the last row and
column written to.
|
int |
rowCount()
Returns the current number of rows of this
TextTable . |
CommandLine.Help.TextTable |
setAdjustLineBreaksForWideCJKCharacters(boolean adjustLineBreaksForWideCJKCharacters) |
CommandLine.Help.Ansi.Text |
textAt(int row,
int col)
Returns the
Text slot at the specified row and column to write a text value into. |
String |
toString() |
StringBuilder |
toString(StringBuilder text)
Copies the text representation that we built up from the options into the specified StringBuilder.
|
protected final List<CommandLine.Help.Ansi.Text> columnValues
char[]
slots of the TextTable
to copy text values into.public int indentWrappedLines
@Deprecated protected TextTable(CommandLine.Help.Ansi ansi, CommandLine.Help.Column[] columns)
picocli.CommandLine.Help.TextTable#TextTable(picocli.CommandLine.Help.ColorScheme, picocli.CommandLine.Help.Column[])
insteadprotected TextTable(CommandLine.Help.ColorScheme colorScheme, CommandLine.Help.Column[] columns)
@Deprecated public static CommandLine.Help.TextTable forDefaultColumns(CommandLine.Help.Ansi ansi, int usageHelpWidth)
forDefaultColumns(CommandLine.Help.Ansi, int, int)
insteadansi
- whether to emit ANSI escape codes or notusageHelpWidth
- the total width of the columns combined@Deprecated public static CommandLine.Help.TextTable forDefaultColumns(CommandLine.Help.Ansi ansi, int longOptionsColumnWidth, int usageHelpWidth)
forDefaultColumns(CommandLine.Help.ColorScheme, int, int)
insteadansi
- whether to emit ANSI escape codes or notlongOptionsColumnWidth
- the width of the long options columnusageHelpWidth
- the total width of the columns combinedpublic static CommandLine.Help.TextTable forDefaultColumns(CommandLine.Help.ColorScheme colorScheme, int longOptionsColumnWidth, int usageHelpWidth)
colorScheme
- the styles and ANSI mode to use for embedded markuplongOptionsColumnWidth
- the width of the long options columnusageHelpWidth
- the total width of the columns combined@Deprecated public static CommandLine.Help.TextTable forColumnWidths(CommandLine.Help.Ansi ansi, int... columnWidths)
forColumns(CommandLine.Help.ColorScheme, CommandLine.Help.Column...)
insteadansi
- whether to emit ANSI escape codes or notcolumnWidths
- the width of each table column (all columns have zero indent)public static CommandLine.Help.TextTable forColumnWidths(CommandLine.Help.ColorScheme colorScheme, int... columnWidths)
colorScheme
- the styles and ANSI mode to use for embedded markupcolumnWidths
- the width of each table column (all columns have zero indent)@Deprecated public static CommandLine.Help.TextTable forColumns(CommandLine.Help.Ansi ansi, CommandLine.Help.Column... columns)
forColumns(CommandLine.Help.ColorScheme, CommandLine.Help.Column...)
insteadTextTable
with the specified columns.ansi
- whether to emit ANSI escape codes or notcolumns
- columns to construct this TextTable withpublic static CommandLine.Help.TextTable forColumns(CommandLine.Help.ColorScheme colorScheme, CommandLine.Help.Column... columns)
TextTable
with the specified columns.colorScheme
- the styles and ANSI mode to use for embedded markupcolumns
- columns to construct this TextTable withpublic boolean isAdjustLineBreaksForWideCJKCharacters()
CommandLine.Model.UsageMessageSpec.adjustLineBreaksForWideCJKCharacters()
public CommandLine.Help.TextTable setAdjustLineBreaksForWideCJKCharacters(boolean adjustLineBreaksForWideCJKCharacters)
CommandLine.Model.UsageMessageSpec.adjustLineBreaksForWideCJKCharacters(boolean)
public CommandLine.Help.Column[] columns()
public CommandLine.Help.Ansi.Text textAt(int row, int col)
Text
slot at the specified row and column to write a text value into.row
- the row of the cell whose Text to returncol
- the column of the cell whose Text to return@Deprecated public CommandLine.Help.Ansi.Text cellAt(int row, int col)
textAt(int, int)
insteadText
slot at the specified row and column to write a text value into.row
- the row of the cell whose Text to returncol
- the column of the cell whose Text to returnpublic int rowCount()
TextTable
.public void addEmptyRow()
char[]
slots for a new row to the columnValues
field.public void addRowValues(String... values)
addRowValues(CommandLine.Help.Ansi.Text...)
, after ensuring
that multi-line values are layed out in the correct row and column.values
- the text values to display in each column of the current rowpublic void addRowValues(CommandLine.Help.Ansi.Text... values)
putValue
for each of the specified values, adding more empty rows
if the return value indicates that the value spanned multiple columns or was wrapped to multiple rows.values
- the values to write into a new row in this TextTableIllegalArgumentException
- if the number of values exceeds the number of Columns in this tablepublic CommandLine.Help.TextTable.Cell putValue(int row, int col, CommandLine.Help.Ansi.Text value)
Overflow
policy, the value may span
multiple columns or wrap to multiple rows when larger than the column width.row
- the target row in the tablecol
- the target column in the table to write tovalue
- the value to writeIllegalArgumentException
- if the specified row exceeds the table's row countjava.awt.Point
object)public StringBuilder toString(StringBuilder text)
text
- the StringBuilder to write into