- java.lang.Object
-
- net.morimekta.strings.chr.Control
-
- All Implemented Interfaces:
Comparable<Char>
,Char
,Stringable
- Direct Known Subclasses:
Color
public class Control extends Object implements Char
This class represents terminal control characters. These are not printable on their own, but will do stuff with the current terminal if printed out to it, and some represents non-printable keystrokes or key combinations.
-
-
Field Summary
Fields Modifier and Type Field Description static Char
ALT_D
Delete rest of current line before (left of) cursor.static Char
ALT_K
Delete rest of word before (left of) cursor.static Char
ALT_U
Delete rest of current line after (right of) cursor.static Char
ALT_W
Delete rest of word after (right of) cursor.static Control
CTRL_DOWN
The control down key combination.static Control
CTRL_LEFT
The control left key combination.static Control
CTRL_RIGHT
The control right key combination.static Control
CTRL_UP
The control up key combination.static Control
CURSOR_ERASE
Erase character at cursor position.static Control
CURSOR_RESTORE
Restore position of cursor to last saved point.static Control
CURSOR_SAVE
Save position of cursor.static Control
DELETE
The delete key.static Control
DOWN
The down key.static Control
DPAD_MID
The DPAD middle key.static Control
END
The end key.static Control
F1
F1 key.static Control
F10
F10 key.static Control
F11
NOTE: It is common to use F11 to mean 'fullscreen', so there is a good chance this is intercepted before reaching the terminal application.static Control
F12
F12 key.static Control
F2
F2 key.static Control
F3
F3 key.static Control
F4
F4 key.static Control
F5
F5 key.static Control
F6
F6 key.static Control
F7
F7 key.static Control
F8
F8 key.static Control
F9
F9 key.static Control
HOME
The home key.static Control
INSERT
The insert key.static Control
LEFT
The left key.static Control
PAGE_DOWN
The page down key.static Control
PAGE_UP
The page up key.static Control
RIGHT
The right key.static Control
TERMINAL_CLEAR
Clear screen, not moving cursor or clearing scroll history.static Control
TERMINAL_CONTROL
Enable full terminal control.static Control
TERMINAL_RESET
Reset terminal (will clear scroll history) and place cursor at top left.static Control
TERMINAL_RESTORE
Restore state of terminal back to before control taken, including cursor position.static Control
UP
The up key.-
Fields inherited from interface net.morimekta.strings.chr.Char
ABR, ACK, BEL, BS, CAN, CR, DEL, ENQ, EOF, ESC, FF, FS, GS, LF, NAK, NUL, RS, SI, SS, TAB, US, VT, XOFF, XON
-
Fields inherited from interface net.morimekta.strings.Stringable
NULL
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Char
alt(char c)
Make a keystroke char foralt + key
.String
asString()
Make a string representation of the instance value.int
codepoint()
Unicode codepoint representing this character.int
compareTo(Char o)
static Char
ctrl(char c)
Make a keystroke char forcontrol + key
, using the control char meaning in common linux terminals.static Control
cursorDown(int num)
Make control sequence moving the cursor N positions to down.static Control
cursorLeft(int num)
Make control sequence moving the cursor N positions to the left.static Control
cursorRight(int num)
Make control sequence moving the cursor N positions to the right.static Control
cursorSetPos(int line)
Make control sequence setting the cursor on a fixed position on the screen using line numbers from the top to the first char of that line.static Control
cursorSetPos(int line, int col)
Make control sequence setting the cursor on a fixed position on the screen using line numbers from the top, and column number from the left.static Control
cursorUp(int num)
Make control sequence moving the cursor N positions to up.boolean
equals(Object o)
int
hashCode()
int
length()
Number of utf-16 characters that this character takes up if enclosed in a java string.int
printableWidth()
The number of character spaces taken up by this symbol.String
toString()
-
-
-
Field Detail
-
TERMINAL_CONTROL
public static final Control TERMINAL_CONTROL
Enable full terminal control. This will also clear the screen and disable scrolling, but will not move the cursor position.
-
TERMINAL_RESTORE
public static final Control TERMINAL_RESTORE
Restore state of terminal back to before control taken, including cursor position.
-
TERMINAL_CLEAR
public static final Control TERMINAL_CLEAR
Clear screen, not moving cursor or clearing scroll history.
-
TERMINAL_RESET
public static final Control TERMINAL_RESET
Reset terminal (will clear scroll history) and place cursor at top left. Note that resetting in the alternate screen buffer will also unset it back to default, not restore the previous state (restore will do nothing).
-
CURSOR_ERASE
public static final Control CURSOR_ERASE
Erase character at cursor position.
-
CURSOR_SAVE
public static final Control CURSOR_SAVE
Save position of cursor.
-
CURSOR_RESTORE
public static final Control CURSOR_RESTORE
Restore position of cursor to last saved point.
-
UP
public static final Control UP
The up key.
-
DOWN
public static final Control DOWN
The down key.
-
RIGHT
public static final Control RIGHT
The right key.
-
LEFT
public static final Control LEFT
The left key.
-
CTRL_UP
public static final Control CTRL_UP
The control up key combination.
-
CTRL_DOWN
public static final Control CTRL_DOWN
The control down key combination.
-
CTRL_RIGHT
public static final Control CTRL_RIGHT
The control right key combination.
-
CTRL_LEFT
public static final Control CTRL_LEFT
The control left key combination.
-
DPAD_MID
public static final Control DPAD_MID
The DPAD middle key.
-
INSERT
public static final Control INSERT
The insert key.
-
DELETE
public static final Control DELETE
The delete key.
-
HOME
public static final Control HOME
The home key.
-
END
public static final Control END
The end key.
-
PAGE_UP
public static final Control PAGE_UP
The page up key.
-
PAGE_DOWN
public static final Control PAGE_DOWN
The page down key.
-
F1
public static final Control F1
F1 key.
-
F2
public static final Control F2
F2 key.
-
F3
public static final Control F3
F3 key.
-
F4
public static final Control F4
F4 key.
-
F5
public static final Control F5
F5 key.
-
F6
public static final Control F6
F6 key.
-
F7
public static final Control F7
F7 key.
-
F8
public static final Control F8
F8 key.
-
F9
public static final Control F9
F9 key.
-
F10
public static final Control F10
F10 key.
-
F11
public static final Control F11
NOTE: It is common to use F11 to mean 'fullscreen', so there is a good chance this is intercepted before reaching the terminal application.
-
F12
public static final Control F12
F12 key.
-
ALT_W
public static final Char ALT_W
Delete rest of word after (right of) cursor.
-
ALT_K
public static final Char ALT_K
Delete rest of word before (left of) cursor.
-
ALT_U
public static final Char ALT_U
Delete rest of current line after (right of) cursor.
-
ALT_D
public static final Char ALT_D
Delete rest of current line before (left of) cursor.
-
-
Method Detail
-
cursorSetPos
public static Control cursorSetPos(int line)
Make control sequence setting the cursor on a fixed position on the screen using line numbers from the top to the first char of that line.- Parameters:
line
- Line number to move to.- Returns:
- The control sequence.
-
cursorSetPos
public static Control cursorSetPos(int line, int col)
Make control sequence setting the cursor on a fixed position on the screen using line numbers from the top, and column number from the left.- Parameters:
line
- Line number to move to, 1-indexed.col
- Column number ot move to, 1-indexed.- Returns:
- The control sequence.
-
cursorUp
public static Control cursorUp(int num)
Make control sequence moving the cursor N positions to up.- Parameters:
num
- Number of positions to move cursor.- Returns:
- The control sequence.
-
cursorDown
public static Control cursorDown(int num)
Make control sequence moving the cursor N positions to down.- Parameters:
num
- Number of positions to move cursor.- Returns:
- The control sequence.
-
cursorRight
public static Control cursorRight(int num)
Make control sequence moving the cursor N positions to the right.- Parameters:
num
- Number of positions to move cursor.- Returns:
- The control sequence.
-
cursorLeft
public static Control cursorLeft(int num)
Make control sequence moving the cursor N positions to the left.- Parameters:
num
- Number of positions to move cursor.- Returns:
- The control sequence.
-
alt
public static Char alt(char c)
Make a keystroke char foralt + key
.- Parameters:
c
- The char to get 'alt' keystroke char of.- Returns:
- The keystroke char.
-
ctrl
public static Char ctrl(char c)
Make a keystroke char forcontrol + key
, using the control char meaning in common linux terminals.- Parameters:
c
- The char to get 'ctrl' keystroke char of.- Returns:
- The keystroke char.
-
codepoint
public int codepoint()
Description copied from interface:Char
Unicode codepoint representing this character.
-
asString
public String asString()
Description copied from interface:Stringable
Make a string representation of the instance value.- Specified by:
asString
in interfaceStringable
- Returns:
- The string representation.
-
printableWidth
public int printableWidth()
Description copied from interface:Char
The number of character spaces taken up by this symbol. Usually 1, but 0 for control sequences, control characters, and 2 for wide symbols like CJK characters.- Specified by:
printableWidth
in interfaceChar
- Returns:
- The printable width of the character.
-
length
public int length()
Description copied from interface:Char
Number of utf-16 characters that this character takes up if enclosed in a java string.
-
compareTo
public int compareTo(Char o)
- Specified by:
compareTo
in interfaceComparable<Char>
-
-