Package de.mhus.lib.core.console
Class ANSIConsole
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- java.io.PrintStream
-
- de.mhus.lib.core.console.Console
-
- de.mhus.lib.core.console.ANSIConsole
-
- All Implemented Interfaces:
IBase,Closeable,Flushable,Appendable,AutoCloseable
- Direct Known Subclasses:
XTermConsole
public class ANSIConsole extends Console
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.mhus.lib.core.console.Console
Console.COLOR
-
-
Field Summary
Fields Modifier and Type Field Description protected Console.COLORbackgroundprotected booleanblinkprotected booleanboldprotected Console.COLORforegroundprotected intheightstatic intKEY_0static intKEY_9static intKEY_astatic intKEY_Astatic intKEY_CTRL_Astatic intKEY_CTRL_Zstatic intKEY_ENTERstatic intKEY_ESCstatic intKEY_F1static intKEY_F2static intKEY_F3static intKEY_F4static intKEY_FUNCTIONstatic intKEY_qstatic intKEY_SPECIAL_DOWNstatic intKEY_SPECIAL_LEFTstatic intKEY_SPECIAL_RIGHTstatic intKEY_SPECIAL_UPstatic intKEY_TABstatic intKEY_zstatic intKEY_Zprotected org.jline.reader.impl.LineReaderImplreaderprotected booleansupportSizeprotected intwidth-
Fields inherited from class de.mhus.lib.core.console.Console
DEFAULT_HEIGHT, DEFAULT_WIDTH, history
-
Fields inherited from class java.io.FilterOutputStream
out
-
-
Constructor Summary
Constructors Constructor Description ANSIConsole()ANSIConsole(InputStream in, PrintStream out)ANSIConsole(InputStream in, PrintStream out, boolean flush, String charset)ANSIConsole(org.jline.reader.impl.LineReaderImpl reader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TadaptTo(Class<? extends T> clazz)static StringansiAttributes(boolean blink, boolean bold)static StringansiBackground(Console.COLOR color)static StringansiCleanup()static StringansiColorValue(Console.COLOR col)static StringansiForeground(Console.COLOR color)static StringansiReset()static StringansiSetCursor(int x, int y)voidcleanup()Console.COLORgetBackgroundColor()intgetCursorX()intgetCursorY()Console.COLORgetForegroundColor()intgetHeight()static String[]getRawAnsiSettings()intgetWidth()booleanisAnsi()booleanisBlink()booleanisBold()booleanisSupportBlink()booleanisSupportBold()booleanisSupportColor()booleanisSupportCursor()booleanisSupportSize()Return true if the console knows about the current size of the terminal.protected voidloadSettings()intread()Returns the next character from input stream of the console.ConsoleKeyreadKey()StringreadLine(LinkedList<String> history)StringreadPassword()voidresetTerminal()voidsetBlink(boolean blink)voidsetBold(boolean bold)voidsetColor(Console.COLOR foreground, Console.COLOR background)voidsetCursor(int x, int y)voidsetHeight(int h)voidsetWidth(int w)-
Methods inherited from class de.mhus.lib.core.console.Console
askQuestion, cr, create, createProgressBar, get, isInitialized, printLine, printLine, readLine, resetConsole, set
-
Methods inherited from class java.io.PrintStream
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, write
-
Methods inherited from class java.io.FilterOutputStream
write
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Field Detail
-
KEY_SPECIAL_LEFT
public static final int KEY_SPECIAL_LEFT
- See Also:
- Constant Field Values
-
KEY_SPECIAL_UP
public static final int KEY_SPECIAL_UP
- See Also:
- Constant Field Values
-
KEY_SPECIAL_DOWN
public static final int KEY_SPECIAL_DOWN
- See Also:
- Constant Field Values
-
KEY_SPECIAL_RIGHT
public static final int KEY_SPECIAL_RIGHT
- See Also:
- Constant Field Values
-
KEY_ENTER
public static final int KEY_ENTER
- See Also:
- Constant Field Values
-
KEY_q
public static final int KEY_q
- See Also:
- Constant Field Values
-
KEY_a
public static final int KEY_a
- See Also:
- Constant Field Values
-
KEY_z
public static final int KEY_z
- See Also:
- Constant Field Values
-
KEY_A
public static final int KEY_A
- See Also:
- Constant Field Values
-
KEY_Z
public static final int KEY_Z
- See Also:
- Constant Field Values
-
KEY_0
public static final int KEY_0
- See Also:
- Constant Field Values
-
KEY_9
public static final int KEY_9
- See Also:
- Constant Field Values
-
KEY_TAB
public static final int KEY_TAB
- See Also:
- Constant Field Values
-
KEY_ESC
public static final int KEY_ESC
- See Also:
- Constant Field Values
-
KEY_CTRL_A
public static final int KEY_CTRL_A
- See Also:
- Constant Field Values
-
KEY_CTRL_Z
public static final int KEY_CTRL_Z
- See Also:
- Constant Field Values
-
KEY_FUNCTION
public static final int KEY_FUNCTION
- See Also:
- Constant Field Values
-
KEY_F1
public static final int KEY_F1
- See Also:
- Constant Field Values
-
KEY_F2
public static final int KEY_F2
- See Also:
- Constant Field Values
-
KEY_F3
public static final int KEY_F3
- See Also:
- Constant Field Values
-
KEY_F4
public static final int KEY_F4
- See Also:
- Constant Field Values
-
foreground
protected Console.COLOR foreground
-
background
protected Console.COLOR background
-
blink
protected boolean blink
-
bold
protected boolean bold
-
reader
protected org.jline.reader.impl.LineReaderImpl reader
-
width
protected int width
-
height
protected int height
-
supportSize
protected boolean supportSize
-
-
Constructor Detail
-
ANSIConsole
public ANSIConsole() throws IOException- Throws:
IOException
-
ANSIConsole
public ANSIConsole(org.jline.reader.impl.LineReaderImpl reader) throws IOException- Throws:
IOException
-
ANSIConsole
public ANSIConsole(InputStream in, PrintStream out, boolean flush, String charset) throws IOException
- Throws:
IOException
-
ANSIConsole
public ANSIConsole(InputStream in, PrintStream out) throws IOException
- Throws:
IOException
-
-
Method Detail
-
loadSettings
protected void loadSettings()
-
readPassword
public String readPassword() throws IOException
- Overrides:
readPasswordin classConsole- Throws:
IOException
-
readLine
public String readLine(LinkedList<String> history)
-
read
public int read()
Description copied from class:ConsoleReturns the next character from input stream of the console. In some cases check for ALT key pressed and return character + 1000, see JLine ConsoleReader In case of error a value lesser 0 will be returned.
-
readKey
public ConsoleKey readKey()
-
isSupportSize
public boolean isSupportSize()
Description copied from class:ConsoleReturn true if the console knows about the current size of the terminal.- Specified by:
isSupportSizein classConsole- Returns:
- True if support size
-
isSupportCursor
public boolean isSupportCursor()
- Specified by:
isSupportCursorin classConsole
-
ansiSetCursor
public static String ansiSetCursor(int x, int y)
-
getCursorX
public int getCursorX()
- Specified by:
getCursorXin classConsole
-
getCursorY
public int getCursorY()
- Specified by:
getCursorYin classConsole
-
isSupportColor
public boolean isSupportColor()
- Specified by:
isSupportColorin classConsole
-
setColor
public void setColor(Console.COLOR foreground, Console.COLOR background)
-
ansiForeground
public static String ansiForeground(Console.COLOR color)
-
ansiBackground
public static String ansiBackground(Console.COLOR color)
-
getForegroundColor
public Console.COLOR getForegroundColor()
- Specified by:
getForegroundColorin classConsole
-
getBackgroundColor
public Console.COLOR getBackgroundColor()
- Specified by:
getBackgroundColorin classConsole
-
isSupportBlink
public boolean isSupportBlink()
- Specified by:
isSupportBlinkin classConsole
-
ansiAttributes
public static String ansiAttributes(boolean blink, boolean bold)
-
isSupportBold
public boolean isSupportBold()
- Specified by:
isSupportBoldin classConsole
-
ansiColorValue
public static String ansiColorValue(Console.COLOR col)
-
ansiCleanup
public static String ansiCleanup()
-
resetTerminal
public void resetTerminal()
- Overrides:
resetTerminalin classConsole
-
ansiReset
public static String ansiReset()
-
getRawAnsiSettings
public static String[] getRawAnsiSettings() throws IOException
- Throws:
IOException
-
-