Skip to content

Commit

Permalink
terminal fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
spektor56 committed Mar 29, 2022
1 parent 50dba02 commit 5b4ac5d
Show file tree
Hide file tree
Showing 6 changed files with 280 additions and 127 deletions.
118 changes: 50 additions & 68 deletions OpenpilotToolkit/Controls/Terminal/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,82 +35,64 @@
<body style="width:100%;height:100%;margin:0; padding:0">

<div id="terminal" style="width:100%;height:100%"></div>
<script>
var command = '';
<script>

CefSharp.BindObjectAsync("sshHost");

var terminal = new Terminal({
var command = '';

var terminal = new Terminal({
fontFamily: 'RobotoPowerline',
theme: {
fontFamily: 'RobotoPowerline',
theme: {
fontFamily: 'RobotoPowerline',
background: '#505050'
},
cursorBlink: true
});
background: '#505050'
},
cursorBlink: true
});

var fitaddon = new FitAddon.FitAddon();
var webgl = new WebglAddon.WebglAddon();
var fitaddon = new FitAddon.FitAddon();
var webgl = new WebglAddon.WebglAddon();

terminal.loadAddon(fitaddon);

terminal.loadAddon(fitaddon);

function runCommand(terminal, text) {
prompt(terminal);
}

function prompt(terminal) {
command = '';
terminal.write('\r\n$ ');
}
function runCommand(terminal, text) {
prompt(terminal);
}

function ClearTerminal() {
//terminal.clear();
terminal.write('\x1bc')
}
function prompt(terminal) {
command = '';
terminal.write('\r\n$ ');
}

function WriteText(stringText) {
terminal.write(stringText);
}
function ClearTerminal() {
//terminal.clear();
terminal.write('\x1bc');
}

function resizeTerminal() {
fitaddon.fit();
console.log(terminal.rows, terminal.cols);
//term.write(' (' + term.rows + ', ' + term.cols + ')');
CefSharp.PostMessage(terminal.rows + ',' + terminal.cols);
}
/*
terminal.onData(e => {
switch (e) {
case '\u0003': // Ctrl+C
terminal.write('^C');
prompt(terminal);
break;
case '\r': // terminal
runCommand(terminal, command);
command = '';
break;
case '\u007F': // Backspace (DEL)
// Do not delete the prompt
if (terminal._core.buffer.x > 2) {
terminal.write('\b \b');
if (command.length > 0) {
command = command.substr(0, command.length - 1);
}
}
break;
default: // Print all other characters for demo
if (e >= String.fromCharCode(0x20) && e <= String.fromCharCode(0x7B) || e >= '\u00a0') {
command += e;
terminal.write(e);
}
}
});
*/
terminal.open(document.getElementById('terminal'));
terminal.loadAddon(webgl);

resizeTerminal();

window.addEventListener('resize', resizeTerminal);
</script>
function WriteText(stringText) {
terminal.write(stringText);
}

function resizeTerminal() {
fitaddon.fit();
console.log(terminal.rows, terminal.cols);
//term.write(' (' + term.rows + ', ' + term.cols + ')');
//sshHost.resizeTerminal(terminal.rows, terminal.cols);
CefSharp.PostMessage(terminal.rows + ',' + terminal.cols);
}

terminal.open(document.getElementById('terminal'));
terminal.loadAddon(webgl);

resizeTerminal();

window.addEventListener('resize', resizeTerminal);

terminal.onData((e) => {
sshHost.terminalData(e);
});

</script>
</body>
</html>
13 changes: 7 additions & 6 deletions OpenpilotToolkit/Controls/Wizards/ucSshWizard.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions OpenpilotToolkit/Controls/Wizards/ucSshWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,11 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Enter)
{
if (mtcSSHWizard.SelectedTab == tpGithubLogin)
if (mtcSSHWizard.SelectedTab == tpGithubLogin && txtUsername.Focused)
{
btnLogin.PerformClick();
return true;
}
else
{
btnNext.PerformClick();
}

return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
Expand Down
Loading

0 comments on commit 5b4ac5d

Please sign in to comment.