Skip to content

Commit 5b4ac5d

Browse files
committed
terminal fixes
1 parent 50dba02 commit 5b4ac5d

File tree

6 files changed

+280
-127
lines changed

6 files changed

+280
-127
lines changed

OpenpilotToolkit/Controls/Terminal/index.html

Lines changed: 50 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -35,82 +35,64 @@
3535
<body style="width:100%;height:100%;margin:0; padding:0">
3636

3737
<div id="terminal" style="width:100%;height:100%"></div>
38-
<script>
39-
var command = '';
38+
<script>
39+
40+
CefSharp.BindObjectAsync("sshHost");
4041

41-
var terminal = new Terminal({
42+
var command = '';
43+
44+
var terminal = new Terminal({
45+
fontFamily: 'RobotoPowerline',
46+
theme: {
4247
fontFamily: 'RobotoPowerline',
43-
theme: {
44-
fontFamily: 'RobotoPowerline',
45-
background: '#505050'
46-
},
47-
cursorBlink: true
48-
});
48+
background: '#505050'
49+
},
50+
cursorBlink: true
51+
});
4952

50-
var fitaddon = new FitAddon.FitAddon();
51-
var webgl = new WebglAddon.WebglAddon();
53+
var fitaddon = new FitAddon.FitAddon();
54+
var webgl = new WebglAddon.WebglAddon();
5255

53-
terminal.loadAddon(fitaddon);
54-
56+
terminal.loadAddon(fitaddon);
5557

56-
function runCommand(terminal, text) {
57-
prompt(terminal);
58-
}
5958

60-
function prompt(terminal) {
61-
command = '';
62-
terminal.write('\r\n$ ');
63-
}
59+
function runCommand(terminal, text) {
60+
prompt(terminal);
61+
}
6462

65-
function ClearTerminal() {
66-
//terminal.clear();
67-
terminal.write('\x1bc')
68-
}
63+
function prompt(terminal) {
64+
command = '';
65+
terminal.write('\r\n$ ');
66+
}
6967

70-
function WriteText(stringText) {
71-
terminal.write(stringText);
72-
}
68+
function ClearTerminal() {
69+
//terminal.clear();
70+
terminal.write('\x1bc');
71+
}
7372

74-
function resizeTerminal() {
75-
fitaddon.fit();
76-
console.log(terminal.rows, terminal.cols);
77-
//term.write(' (' + term.rows + ', ' + term.cols + ')');
78-
CefSharp.PostMessage(terminal.rows + ',' + terminal.cols);
79-
}
80-
/*
81-
terminal.onData(e => {
82-
switch (e) {
83-
case '\u0003': // Ctrl+C
84-
terminal.write('^C');
85-
prompt(terminal);
86-
break;
87-
case '\r': // terminal
88-
runCommand(terminal, command);
89-
command = '';
90-
break;
91-
case '\u007F': // Backspace (DEL)
92-
// Do not delete the prompt
93-
if (terminal._core.buffer.x > 2) {
94-
terminal.write('\b \b');
95-
if (command.length > 0) {
96-
command = command.substr(0, command.length - 1);
97-
}
98-
}
99-
break;
100-
default: // Print all other characters for demo
101-
if (e >= String.fromCharCode(0x20) && e <= String.fromCharCode(0x7B) || e >= '\u00a0') {
102-
command += e;
103-
terminal.write(e);
104-
}
105-
}
106-
});
107-
*/
108-
terminal.open(document.getElementById('terminal'));
109-
terminal.loadAddon(webgl);
110-
111-
resizeTerminal();
112-
113-
window.addEventListener('resize', resizeTerminal);
114-
</script>
73+
function WriteText(stringText) {
74+
terminal.write(stringText);
75+
}
76+
77+
function resizeTerminal() {
78+
fitaddon.fit();
79+
console.log(terminal.rows, terminal.cols);
80+
//term.write(' (' + term.rows + ', ' + term.cols + ')');
81+
//sshHost.resizeTerminal(terminal.rows, terminal.cols);
82+
CefSharp.PostMessage(terminal.rows + ',' + terminal.cols);
83+
}
84+
85+
terminal.open(document.getElementById('terminal'));
86+
terminal.loadAddon(webgl);
87+
88+
resizeTerminal();
89+
90+
window.addEventListener('resize', resizeTerminal);
91+
92+
terminal.onData((e) => {
93+
sshHost.terminalData(e);
94+
});
95+
96+
</script>
11597
</body>
11698
</html>

OpenpilotToolkit/Controls/Wizards/ucSshWizard.Designer.cs

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OpenpilotToolkit/Controls/Wizards/ucSshWizard.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,11 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
122122
{
123123
if (keyData == Keys.Enter)
124124
{
125-
if (mtcSSHWizard.SelectedTab == tpGithubLogin)
125+
if (mtcSSHWizard.SelectedTab == tpGithubLogin && txtUsername.Focused)
126126
{
127127
btnLogin.PerformClick();
128+
return true;
128129
}
129-
else
130-
{
131-
btnNext.PerformClick();
132-
}
133-
134-
return true;
135130
}
136131
return base.ProcessCmdKey(ref msg, keyData);
137132
}

0 commit comments

Comments
 (0)