- java.lang.Object
-
- java.lang.Enum<TabBehaviour>
-
- com.googlecode.lanterna.screen.TabBehaviour
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<TabBehaviour>
public enum TabBehaviour extends java.lang.Enum<TabBehaviour>
What to do about the tab character when putting on aScreen
. Since tabs are a bit special, their meaning depends on which column the cursor is in when it's printed, we'll need to have some way to tell the Screen what to do when encountering a tab character.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ALIGN_TO_COLUMN_4
Tab characters are replaced with enough space characters to reach the next column index that is evenly divisible by 4, simulating a normal tab character when placed inside a text document.ALIGN_TO_COLUMN_8
Tab characters are replaced with enough space characters to reach the next column index that is evenly divisible by 8, simulating a normal tab character when placed inside a text document.CONVERT_TO_EIGHT_SPACES
Tab characters are replaced with eight blank spaces, no matter where the tab was placed.CONVERT_TO_FOUR_SPACES
Tab characters are replaced with four blank spaces, no matter where the tab was placed.CONVERT_TO_ONE_SPACE
Tab characters are replaced with a single blank space, no matter where the tab was placed.CONVERT_TO_THREE_SPACES
Tab characters are replaced with three blank spaces, no matter where the tab was placed.CONVERT_TO_TWO_SPACES
Tab characters are replaced with two blank spaces, no matter where the tab was placed.IGNORE
Tab characters are not replaced, this will probably have undefined and weird behaviour!
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Integer
alignFactor
private java.lang.Integer
replaceFactor
-
Constructor Summary
Constructors Modifier Constructor Description private
TabBehaviour(java.lang.Integer replaceFactor, java.lang.Integer alignFactor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getTabReplacement(int columnIndex)
Returns the String that can replace a tab at the specified position, according to this TabBehaviour.java.lang.String
replaceTabs(java.lang.String string, int columnIndex)
Given a string, being placed on the screen at column X, returns the same string with all tab characters (\t) replaced according to this TabBehaviour.static TabBehaviour
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static TabBehaviour[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
IGNORE
public static final TabBehaviour IGNORE
Tab characters are not replaced, this will probably have undefined and weird behaviour!
-
CONVERT_TO_ONE_SPACE
public static final TabBehaviour CONVERT_TO_ONE_SPACE
Tab characters are replaced with a single blank space, no matter where the tab was placed.
-
CONVERT_TO_TWO_SPACES
public static final TabBehaviour CONVERT_TO_TWO_SPACES
Tab characters are replaced with two blank spaces, no matter where the tab was placed.
-
CONVERT_TO_THREE_SPACES
public static final TabBehaviour CONVERT_TO_THREE_SPACES
Tab characters are replaced with three blank spaces, no matter where the tab was placed.
-
CONVERT_TO_FOUR_SPACES
public static final TabBehaviour CONVERT_TO_FOUR_SPACES
Tab characters are replaced with four blank spaces, no matter where the tab was placed.
-
CONVERT_TO_EIGHT_SPACES
public static final TabBehaviour CONVERT_TO_EIGHT_SPACES
Tab characters are replaced with eight blank spaces, no matter where the tab was placed.
-
ALIGN_TO_COLUMN_4
public static final TabBehaviour ALIGN_TO_COLUMN_4
Tab characters are replaced with enough space characters to reach the next column index that is evenly divisible by 4, simulating a normal tab character when placed inside a text document.
-
ALIGN_TO_COLUMN_8
public static final TabBehaviour ALIGN_TO_COLUMN_8
Tab characters are replaced with enough space characters to reach the next column index that is evenly divisible by 8, simulating a normal tab character when placed inside a text document.
-
-
Method Detail
-
values
public static TabBehaviour[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (TabBehaviour c : TabBehaviour.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static TabBehaviour valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
replaceTabs
public java.lang.String replaceTabs(java.lang.String string, int columnIndex)
Given a string, being placed on the screen at column X, returns the same string with all tab characters (\t) replaced according to this TabBehaviour.- Parameters:
string
- String that is going to be put to the screen, potentially containing tab characterscolumnIndex
- Column on the screen where the first character of the string is going to end up- Returns:
- The input string with all tab characters replaced with spaces, according to this TabBehaviour
-
getTabReplacement
public java.lang.String getTabReplacement(int columnIndex)
Returns the String that can replace a tab at the specified position, according to this TabBehaviour.- Parameters:
columnIndex
- Column index of where the tab character is placed- Returns:
- String consisting of 1 or more space character
-
-