mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 15:40:23 +00:00
Improve terminal clearing
This commit is contained in:
parent
d1953fbe10
commit
7f85b4b535
2 changed files with 18 additions and 10 deletions
|
@ -423,8 +423,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
@Override
|
@Override
|
||||||
public void launch(String name, String file) throws Exception {
|
public void launch(String name, String file) throws Exception {
|
||||||
try (ShellControl pc = LocalStore.getShell()) {
|
try (ShellControl pc = LocalStore.getShell()) {
|
||||||
var clearscript = ScriptHelper.createLocalExecScript("printf \"\\e[1;1H\\e[2J\"\n" + file);
|
var suffix = "\"" + file.replaceAll("\"", "\\\\\"") + "\"";
|
||||||
var suffix = "\"" + clearscript.replaceAll("\"", "\\\\\"") + "\"";
|
|
||||||
pc.osascriptCommand(String.format(
|
pc.osascriptCommand(String.format(
|
||||||
"""
|
"""
|
||||||
activate application "Terminal"
|
activate application "Terminal"
|
||||||
|
@ -480,24 +479,29 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void launch(String name, String file) throws Exception {
|
public void launch(String name, String file) throws Exception {
|
||||||
|
var app = this.getApplicationPath();
|
||||||
|
if (app.isEmpty()) {
|
||||||
|
throw new IllegalStateException("iTerm installation not found");
|
||||||
|
}
|
||||||
|
|
||||||
try (ShellControl pc = LocalStore.getShell()) {
|
try (ShellControl pc = LocalStore.getShell()) {
|
||||||
// TODO: Wait for launch. But how?
|
var a = app.get().toString();
|
||||||
pc.osascriptCommand(String.format(
|
pc.osascriptCommand(String.format(
|
||||||
"""
|
"""
|
||||||
if application "iTerm" is not running then
|
if application "%s" is not running then
|
||||||
launch application "iTerm"
|
launch application "%s"
|
||||||
delay 1
|
delay 1
|
||||||
tell application "iTerm"
|
tell application "%s"
|
||||||
tell current tab of current window
|
tell current tab of current window
|
||||||
close
|
close
|
||||||
end tell
|
end tell
|
||||||
end tell
|
end tell
|
||||||
end if
|
end if
|
||||||
tell application "iTerm"
|
tell application "%s"
|
||||||
create window with default profile command "%s"
|
create window with default profile command "%s"
|
||||||
end tell
|
end tell
|
||||||
""",
|
""",
|
||||||
file.replaceAll("\"", "\\\\\"")))
|
a, a, a, a, file.replaceAll("\"", "\\\\\"")))
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -535,7 +539,6 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var clearscript = ScriptHelper.createLocalExecScript("printf \"\\e[1;1H\\e[2J\"\n" + file);
|
|
||||||
try (ShellControl pc = LocalStore.getShell()) {
|
try (ShellControl pc = LocalStore.getShell()) {
|
||||||
pc.osascriptCommand(String.format(
|
pc.osascriptCommand(String.format(
|
||||||
"""
|
"""
|
||||||
|
@ -550,7 +553,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
||||||
end tell
|
end tell
|
||||||
end tell
|
end tell
|
||||||
""",
|
""",
|
||||||
clearscript.replaceAll("\"", "\\\\\"")))
|
file.replaceAll("\"", "\\\\\"")))
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,11 @@ public class ScriptHelper {
|
||||||
String nl = t.getNewLine().getNewLineString();
|
String nl = t.getNewLine().getNewLineString();
|
||||||
var content = "";
|
var content = "";
|
||||||
|
|
||||||
|
var clear = t.clearDisplayCommand();
|
||||||
|
if (clear != null) {
|
||||||
|
content += clear + nl;
|
||||||
|
}
|
||||||
|
|
||||||
var applyRcCommand = t.applyRcFileCommand();
|
var applyRcCommand = t.applyRcFileCommand();
|
||||||
if (applyRcCommand != null) {
|
if (applyRcCommand != null) {
|
||||||
content = content + nl + applyRcCommand + nl;
|
content = content + nl + applyRcCommand + nl;
|
||||||
|
|
Loading…
Reference in a new issue