Support CTRL+D for exiting the console
Support CTRL+D for exiting the console, also support "cls" for clearing the screen (on supported terminals).
This commit is contained in:
parent
0635ea7a35
commit
0e05bb61bc
@ -116,10 +116,21 @@ public class ConsoleShellFactory implements ShellFactory {
|
||||
while (true)
|
||||
{
|
||||
String command = this.ConsoleReader.readLine("\r>", null);
|
||||
if (command == null || command.trim().isEmpty())
|
||||
// The user sent CTRL+D to close the shell, terminate the session.
|
||||
if (command == null)
|
||||
break;
|
||||
// Skip someone spamming enter
|
||||
if (command.trim().isEmpty())
|
||||
continue;
|
||||
// User wants to exit
|
||||
if (command.equals("exit") || command.equals("quit"))
|
||||
break;
|
||||
// Clear the text from the screen (on supported terminals)
|
||||
if (command.equals("cls"))
|
||||
{
|
||||
this.ConsoleReader.clearScreen();
|
||||
continue;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(
|
||||
SshdPlugin.instance, () ->
|
||||
|
@ -7,13 +7,13 @@ import jline.TerminalSupport;
|
||||
*/
|
||||
public class SshTerminal extends TerminalSupport {
|
||||
|
||||
protected SshTerminal() {
|
||||
super(true);
|
||||
}
|
||||
protected SshTerminal() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
setAnsiSupported(true);
|
||||
setEchoEnabled(true);
|
||||
}
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
setAnsiSupported(true);
|
||||
setEchoEnabled(true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user