Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ebdab679b |
No files matched your search
@@ -118,6 +118,7 @@ namespace FluentTerminal.App.Views
|
||||
|
||||
public event EventHandler<object> OnOutput;
|
||||
public event EventHandler<string> OnPaste;
|
||||
public event EventHandler<string> OnSessionRestart;
|
||||
|
||||
public XtermTerminalView()
|
||||
{
|
||||
@@ -225,10 +226,23 @@ namespace FluentTerminal.App.Views
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private const string OpenSSH = "OpenSSH";
|
||||
|
||||
public async Task ReconnectAsync()
|
||||
{
|
||||
// Fill full screen with new output to not allow erasing of available output on start of new shell
|
||||
Terminal_OutputReceived(this, System.Text.Encoding.UTF8.GetBytes(new String('\n', _requestedSize.Rows + 1)));
|
||||
if (ViewModel.ShellProfile.Location.Contains(OpenSSH))
|
||||
{
|
||||
OnSessionRestart?.Invoke(this, OpenSSH);
|
||||
|
||||
await Task.Delay(500).ConfigureAwait(false);
|
||||
|
||||
Terminal_OutputReceived(this, System.Text.Encoding.UTF8.GetBytes("\n\x1b[2EReconnecting current session...\n\x1b[E"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fill full screen with new output to not allow erasing of available output on start of new shell
|
||||
Terminal_OutputReceived(this, System.Text.Encoding.UTF8.GetBytes(new String('\n', _requestedSize.Rows + 1)));
|
||||
}
|
||||
|
||||
if (true == await StartShellProcessAsync(_requestedSize).ConfigureAwait(false))
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ let serializeAddon: SerializeAddon;
|
||||
let webLinksAddon: WebLinksAddon;
|
||||
let unicode11Addon: Unicode11Addon;
|
||||
let altGrPressed = false;
|
||||
let filterOutOpenSSHOutput = false;
|
||||
|
||||
const terminalContainer = document.getElementById('terminal-container');
|
||||
|
||||
@@ -102,7 +103,46 @@ window.createTerminal = (options, theme, keyBindings) => {
|
||||
|
||||
window.term = term;
|
||||
|
||||
function stringToUint8Array(param: string) {
|
||||
var str = unescape(encodeURIComponent(param));
|
||||
var charList = str.split('');
|
||||
var output = [];
|
||||
for (var i = 0; i < charList.length; i++) {
|
||||
output.push(charList[i].charCodeAt(0));
|
||||
}
|
||||
return new Uint8Array(output);
|
||||
}
|
||||
|
||||
function uint8ArrayToString(param: Uint8Array) {
|
||||
var encodedString = String.fromCharCode.apply(null, param);
|
||||
return decodeURIComponent(escape(encodedString));
|
||||
}
|
||||
|
||||
window.terminalBridge.onsessionrestart = ((param: string) => {
|
||||
if (filterOutOpenSSHOutput == false) {
|
||||
filterOutOpenSSHOutput = true;
|
||||
}
|
||||
});
|
||||
|
||||
window.terminalBridge.onoutput = (data => {
|
||||
if (filterOutOpenSSHOutput == true) {
|
||||
var str = uint8ArrayToString(data);
|
||||
var sessionStarted = str.search(/(\x1b\[H\x1b\[\?25h)|(\x1b\[2;1H\x1b\]0;OpenSSH SSH client)/u);
|
||||
|
||||
if (sessionStarted != -1) {
|
||||
filterOutOpenSSHOutput = false;
|
||||
}
|
||||
|
||||
// Filter out new line characters following by cursor movement CSIs X and C
|
||||
str = replaceAll(/\n\x1b\[\d*X\x1b\[\d*C/u, "", str);
|
||||
// Filter out J (clear screen) CSIs and H (set cursor position) CSIs
|
||||
str = replaceAll(/\x1b\[\d*J/u, "", str);
|
||||
// Filter out H (set cursor position) CSIs
|
||||
str = replaceAll(/\x1b\[\d*;?\d*H/u, "", str);
|
||||
|
||||
data = stringToUint8Array(str);
|
||||
}
|
||||
|
||||
term.writeUtf8(data);
|
||||
});
|
||||
|
||||
|
||||
@@ -24,5 +24,6 @@ namespace FluentTerminal.RuntimeComponent.Interfaces
|
||||
|
||||
event EventHandler<object> OnOutput;
|
||||
event EventHandler<string> OnPaste;
|
||||
event EventHandler<string> OnSessionRestart;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ namespace FluentTerminal.RuntimeComponent.WebAllowedObjects
|
||||
_terminalEventListener = terminalEventListener;
|
||||
_terminalEventListener.OnOutput += OnOutput;
|
||||
_terminalEventListener.OnPaste += OnPaste;
|
||||
_terminalEventListener.OnSessionRestart += OnSessionRestart;
|
||||
}
|
||||
|
||||
private void OnPaste(object sender, string e)
|
||||
@@ -29,8 +30,14 @@ namespace FluentTerminal.RuntimeComponent.WebAllowedObjects
|
||||
Task.Factory.StartNew(() => Output?.Invoke(this, e));
|
||||
}
|
||||
|
||||
private void OnSessionRestart(object sender, string e)
|
||||
{
|
||||
Task.Factory.StartNew(() => SessionRestart?.Invoke(this, e));
|
||||
}
|
||||
|
||||
public event EventHandler<object> Output;
|
||||
public event EventHandler<string> Paste;
|
||||
public event EventHandler<string> SessionRestart;
|
||||
|
||||
public void InputReceived(string message)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user