TerminalTextUtils
insteadpublic class CJKUtils extends Object
TerminalTextUtils
Modifier and Type | Method | Description |
---|---|---|
static String |
fitString(String string,
int availableColumnSpace) |
Deprecated.
Use
TerminalTextUtils.fitString(string, availableColumnSpace) instead |
static String |
fitString(String string,
int fromColumn,
int availableColumnSpace) |
Deprecated.
Use
TerminalTextUtils.fitString(string, fromColumn, availableColumnSpace) instead |
static int |
getColumnIndex(String s,
int stringCharacterIndex) |
Deprecated.
Use
TerminalTextUtils.getColumnIndex(s, stringCharacterIndex) instead |
static int |
getColumnWidth(String s) |
Deprecated.
Use
TerminalTextUtils.getColumnWidth(s) instead |
static int |
getStringCharacterIndex(String s,
int columnIndex) |
Deprecated.
Use
TerminalTextUtils.getStringCharacterIndex(s, columnIndex instead |
static int |
getTrueWidth(String s) |
Deprecated.
Call
getColumnWidth(s) instead |
static boolean |
isCharCJK(char c) |
Deprecated.
Use
TerminalTextUtils.isCharJCK(c) instead |
@Deprecated public static boolean isCharCJK(char c)
TerminalTextUtils.isCharJCK(c)
insteadc
- Character to testtrue
if the character is a CJK characterTerminalTextUtils.isCharCJK(char)
@Deprecated public static int getTrueWidth(String s)
getColumnWidth(s)
insteads
- String to measure@Deprecated public static int getColumnWidth(String s)
TerminalTextUtils.getColumnWidth(s)
insteads
- String to check lengthTerminalTextUtils.getColumnWidth(String)
@Deprecated public static int getColumnIndex(String s, int stringCharacterIndex) throws StringIndexOutOfBoundsException
TerminalTextUtils.getColumnIndex(s, stringCharacterIndex)
insteadstringCharacterIndex
, but if there are CJK characters the value will be different due to CJK
characters taking up two columns in width. If the character at the index in the string is a CJK character itself,
the returned value will be the index of the left-side of character.s
- String to translate the index fromstringCharacterIndex
- Index within the string to get the terminal column index ofstringCharacterIndex
when it has been writted to a
terminalStringIndexOutOfBoundsException
- if the index given is outside the String length or negativeTerminalTextUtils.getColumnIndex(String, int)
@Deprecated public static int getStringCharacterIndex(String s, int columnIndex)
TerminalTextUtils.getStringCharacterIndex(s, columnIndex
insteadcolumnIndex
, what is the index of that
character in the string. If the string contains no CJK characters, this will always be the same as
columnIndex
. If the index specified is the right column of a CJK character, the index is the same as if
the column was the left column. So calling getStringCharacterIndex("\u82f1", 0)
and
getStringCharacterIndex("\u82f1", 1)
will both return 0.s
- String to translate the index tocolumnIndex
- Column index of the string written to a terminalcolumnIndex
TerminalTextUtils.getStringCharacterIndex(String, int)
@Deprecated public static String fitString(String string, int availableColumnSpace)
TerminalTextUtils.fitString(string, availableColumnSpace)
insteadavailableColumnSpace
columns. This method does not handle special cases like tab or new-line.
Calling this method is the same as calling fitString(string, 0, availableColumnSpace)
.
string
- The string to fit inside the availableColumnSpaceavailableColumnSpace
- Number of columns to fit the string insideTerminalTextUtils.fitString(String, int)
@Deprecated public static String fitString(String string, int fromColumn, int availableColumnSpace)
TerminalTextUtils.fitString(string, fromColumn, availableColumnSpace)
insteadavailableColumnSpace
columns. This method does not handle special cases like tab or new-line.
This overload has a fromColumn
parameter that specified where inside the string to start fitting. Please
notice that fromColumn
is not a character index inside the string, but a column index as if the string
has been printed from the left-most side of the terminal. So if the string is "日本語", fromColumn set to 1 will
not starting counting from the second character ("本") in the string but from the CJK filler character belonging
to "日". If you want to count from a particular character index inside the string, please pass in a substring
and use fromColumn set to 0.
string
- The string to fit inside the availableColumnSpacefromColumn
- From what column of the input string to start fitting (see description above!)availableColumnSpace
- Number of columns to fit the string insideTerminalTextUtils.fitString(String, int, int)
Copyright © 2020. All rights reserved.