Class ISO6429Terminal
- java.lang.Object
-
- edu.uiuc.ncsa.security.util.terminal.ISO6429Terminal
-
public class ISO6429Terminal extends Object
A basic implementation of an ISO 6429 terminal. This sends along device control characters to do hardware cursor addressing using standard I/O. Several caveats come with this.- This is not a complete implementation -- the spec. even states a full implementation is not possible. We want to allow for a command history and several other things which Java just does not do consistently cross platform.
- The old ANSI (late 1970's) terminal standard was replaced by the ECMA-48 (early 1990's) standard which in turn was replaced by the ISO 6429 standard (in the 2000's). This means that ANSI terminals do support this.
- Unix command lines are de facto ANSI standard because they started that way and nobody wants to invest the time to change it. In theory this might not work in some unix environments.
- DOS and therefore Windows did not support ANSI natively. As of Windows 10, however, their command line support the ISO standard. This means that by and large this should now work with Unix, Windows and Mac. For Windows users, it may require some configuration in the OS to enable ANSI support in command lines though.
Created by Jeff Gaynor
on 6/5/20 at 8:42 AM
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ISO6429Terminal.CSI
-
Field Summary
Fields Modifier and Type Field Description protected org.jline.utils.NonBlockingReader
reader
-
Constructor Summary
Constructors Constructor Description ISO6429Terminal(MyLoggingFacade loggingFacade)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearLine(int startCol)
clear the entire current line.protected void
debug(String x)
protected KeyStroke
getCharacter()
protected PrintStream
getCharPS()
protected PrintStream
getCommandPS()
protected ISO6429Terminal.CSI
getCSI()
int[]
getCursor()
int
getCursorCol()
int
getCursorRow()
protected KeyStroke
getKeyRemap(char y)
If you want to add key remappings (like QDL) override this.String
getName()
int[]
getScreenSize()
protected void
info(String x)
protected void
init()
static void
main(String[] args)
You can run this with mvn compile exec:java -Dexec.mainClass="edu.uiuc.ncsa.security.util.terminal.ISO6429Terminal"void
setBold(boolean setOn)
void
setColor(int color)
void
setCursor(int row, int col)
void
setCursorCol(int col)
boolean
testTerminal()
protected void
warn(String x, Throwable t)
-
-
-
Constructor Detail
-
ISO6429Terminal
public ISO6429Terminal(MyLoggingFacade loggingFacade) throws IOException
- Throws:
IOException
-
-
Method Detail
-
testTerminal
public boolean testTerminal() throws IOException
- Throws:
IOException
-
getScreenSize
public int[] getScreenSize() throws IOException
- Throws:
IOException
-
init
protected void init() throws IOException
- Throws:
IOException
-
getName
public String getName()
-
setCursorCol
public void setCursorCol(int col)
-
setCursor
public void setCursor(int row, int col)
-
clearLine
public void clearLine(int startCol)
clear the entire current line. Put the cursor at the front of the line
-
getCursorCol
public int getCursorCol() throws IOException
- Throws:
IOException
-
getCursorRow
public int getCursorRow() throws IOException
- Throws:
IOException
-
getCursor
public int[] getCursor() throws IOException
- Throws:
IOException
-
setColor
public void setColor(int color)
-
setBold
public void setBold(boolean setOn)
-
getCommandPS
protected PrintStream getCommandPS()
-
getCharPS
protected PrintStream getCharPS()
-
getCharacter
protected KeyStroke getCharacter() throws IOException
- Throws:
IOException
-
getKeyRemap
protected KeyStroke getKeyRemap(char y) throws IOException
If you want to add key remappings (like QDL) override this.- Parameters:
y
- the second byte after and escape from the terminal. If there is no more input after that, interpret it as being an alt or other key stroke.- Returns:
- Throws:
IOException
-
main
public static void main(String[] args)
You can run this with mvn compile exec:java -Dexec.mainClass="edu.uiuc.ncsa.security.util.terminal.ISO6429Terminal"- Parameters:
args
-
-
getCSI
protected ISO6429Terminal.CSI getCSI() throws IOException
- Throws:
IOException
-
info
protected void info(String x)
-
debug
protected void debug(String x)
-
-