java.lang.Object
polimi.ingsw.am21.codex.view.TUI.utils.CliUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
colorize
(String string, Color color, ColorStyle style) Colorizes a string with the given color and style, automatically resetting the formatting afterwardcolorize
(T colorable, ColorStyle style) Colorizes a string with the given color and style, automatically resetting the formatting afterwardcolorize
(T colorable, ColorStyle style, int length) Colorizes a string with the given color and style, automatically resetting the formatting afterwardcolorizeAndCenter
(List<T> colorables, int length, char padChar, ColorStyle style) Colorizes a string with the given color and style, automatically resetting the formatting afterwardstatic int
getColorableLength
(Colorable colorable, int colorableSize, ColorStyle style) Gets the length of a colorable element when colorized with the given stylestatic String
Gets a table with the given headers and columnsstatic String
joinMinLines
(String s1, String s2)
-
Constructor Details
-
CliUtils
public CliUtils()
-
-
Method Details
-
joinMinLines
- Parameters:
s1
- the first string to be returneds2
- the second string to be returned- Returns:
- the concatenated lines of the two given strings: it has a number of lines equal to the minimum between the number of lines of s1 and s2. The rest are discarded.
-
colorize
Colorizes a string with the given color and style, automatically resetting the formatting afterward- Parameters:
colorable
- The colorable to colorizestyle
- The style to uselength
- The length to truncate the string to
-
colorize
Colorizes a string with the given color and style, automatically resetting the formatting afterward- Parameters:
colorable
- The colorable to colorizestyle
- The style to use
-
colorize
Colorizes a string with the given color and style, automatically resetting the formatting afterward- Parameters:
string
- The string to colorizecolor
- The color to usestyle
- The style to use
-
colorizeAndCenter
public static <T extends Colorable> String colorizeAndCenter(List<T> colorables, int length, char padChar, ColorStyle style) Colorizes a string with the given color and style, automatically resetting the formatting afterward- Parameters:
colorables
- The list of colorable elements to colorizelength
- The length to truncate the string topadChar
- The character to pad the string withstyle
- The style to use
-
getColorableLength
Gets the length of a colorable element when colorized with the given style- Parameters:
colorable
- The colorable elementcolorableSize
- The size of the colorable elementstyle
- The style to use
-
getTable
Gets a table with the given headers and columns- Parameters:
headers
- The headers of the tablecolumns
- The columns of the table
-