public final class SttySupport
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_SSHD_STTY_COMMAND |
static int |
DEFAULT_TERMINAL_HEIGHT |
static int |
DEFAULT_TERMINAL_WIDTH |
static java.lang.String |
SSHD_STTY_COMMAND_PROP |
private static java.util.concurrent.atomic.AtomicReference<java.lang.String> |
STTY_COMMAND_HOLDER |
private static java.util.concurrent.atomic.AtomicReference<java.lang.String> |
TTY_PROPS_HOLDER |
private static java.util.concurrent.atomic.AtomicLong |
TTY_PROPS_LAST_FETCHED_HOLDER |
Modifier | Constructor and Description |
---|---|
private |
SttySupport() |
Modifier and Type | Method and Description |
---|---|
private static int |
copyStream(java.io.InputStream in,
java.io.OutputStream bout) |
private static java.lang.String |
exec(java.lang.String... cmd)
Execute the specified command and return the output
(both stdout and stderr).
|
static java.lang.String |
exec(java.lang.String cmd)
Execute the specified command and return the output
(both stdout and stderr).
|
private static int |
findChar(java.lang.String stty,
java.lang.String name) |
private static int |
findFlag(java.lang.String stty,
java.lang.String name) |
static java.lang.String |
getSttyCommand() |
static int |
getTerminalHeight()
Returns the value of "stty size" height param.
|
static int |
getTerminalProperty(java.lang.String prop) |
static int |
getTerminalWidth()
Returns the value of "stty size" width param.
|
static java.lang.String |
getTtyProps() |
static java.util.Map<PtyMode,java.lang.Integer> |
getUnixPtyModes() |
static java.util.Map<PtyMode,java.lang.Integer> |
parsePtyModes(java.lang.String stty) |
static void |
setSttyCommand(java.lang.String cmd) |
static java.lang.String |
stty(java.lang.String args)
Execute the stty command with the specified arguments
against the current active terminal.
|
public static final int DEFAULT_TERMINAL_WIDTH
public static final int DEFAULT_TERMINAL_HEIGHT
public static final java.lang.String SSHD_STTY_COMMAND_PROP
public static final java.lang.String DEFAULT_SSHD_STTY_COMMAND
private static final java.util.concurrent.atomic.AtomicReference<java.lang.String> STTY_COMMAND_HOLDER
private static final java.util.concurrent.atomic.AtomicReference<java.lang.String> TTY_PROPS_HOLDER
private static final java.util.concurrent.atomic.AtomicLong TTY_PROPS_LAST_FETCHED_HOLDER
public static java.util.Map<PtyMode,java.lang.Integer> getUnixPtyModes() throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public static java.util.Map<PtyMode,java.lang.Integer> parsePtyModes(java.lang.String stty)
private static int findFlag(java.lang.String stty, java.lang.String name)
private static int findChar(java.lang.String stty, java.lang.String name)
public static int getTerminalWidth()
Returns the value of "stty size" width param.
Note: this method caches the value from the first time it is called in order to increase speed, which means that changing to size of the terminal will not be reflected in the console.
public static int getTerminalHeight()
Returns the value of "stty size" height param.
Note: this method caches the value from the first time it is called in order to increase speed, which means that changing to size of the terminal will not be reflected in the console.
public static int getTerminalProperty(java.lang.String prop) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public static java.lang.String getTtyProps() throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public static java.lang.String stty(java.lang.String args) throws java.io.IOException, java.lang.InterruptedException
args
- The command argumentsjava.io.IOException
- If failed to execute the commandjava.lang.InterruptedException
- If interrupted while awaiting command executionexec(String)
public static java.lang.String exec(java.lang.String cmd) throws java.io.IOException, java.lang.InterruptedException
cmd
- The command to executejava.io.IOException
- If failed to execute the commandjava.lang.InterruptedException
- If interrupted while awaiting command executionexec(String[])
private static java.lang.String exec(java.lang.String... cmd) throws java.io.IOException, java.lang.InterruptedException
cmd
- The command componentsjava.io.IOException
- If failed to execute the commandjava.lang.InterruptedException
- If interrupted while awaiting command executionprivate static int copyStream(java.io.InputStream in, java.io.OutputStream bout) throws java.io.IOException
java.io.IOException
public static java.lang.String getSttyCommand()
setSttyCommand(String)
public static void setSttyCommand(java.lang.String cmd)
cmd
- The command to use to set the terminal options. Defaults
to DEFAULT_SSHD_STTY_COMMAND
, or the value of the
SSHD_STTY_COMMAND_PROP
system property if not set via this method