1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-23 19:53:47 +00:00

Added missing changes that were only in the server repo

Added null check for stream.push
This commit is contained in:
Bryan Roe
2020-04-06 11:58:11 -07:00
parent 4bcb16c35a
commit 9da58723f3

View File

@@ -146,9 +146,13 @@ function windows_terminal() {
this.StartEx = function Start(CONSOLE_SCREEN_WIDTH, CONSOLE_SCREEN_HEIGHT, terminalTarget) this.StartEx = function Start(CONSOLE_SCREEN_WIDTH, CONSOLE_SCREEN_HEIGHT, terminalTarget)
{ {
// The older windows terminal does not support
CONSOLE_SCREEN_WIDTH = 80;
CONSOLE_SCREEN_HEIGHT = 25;
if (this._stream != null) if (this._stream != null)
{ {
throw ('Concurrent Terminal sessions are not supported on Windows'); throw ('Concurrent terminal sessions are not supported on Windows.');
} }
this.stopping = null; this.stopping = null;
if (this._kernel32.GetConsoleWindow().Val == 0) { if (this._kernel32.GetConsoleWindow().Val == 0) {
@@ -399,9 +403,6 @@ function windows_terminal() {
} }
this._WriteCharacter = function (key, bControlKey) this._WriteCharacter = function (key, bControlKey)
{ {
var scanCode = this._user32.VkKeyScanA(key).Val & 0xFF;
if (key == 10) { return; }
var rec = GM.CreateVariable(20); var rec = GM.CreateVariable(20);
rec.Deref(0, 2).toBuffer().writeUInt16LE(KEY_EVENT); // rec.EventType rec.Deref(0, 2).toBuffer().writeUInt16LE(KEY_EVENT); // rec.EventType
rec.Deref(4, 4).toBuffer().writeUInt16LE(1); // rec.Event.KeyEvent.bKeyDown rec.Deref(4, 4).toBuffer().writeUInt16LE(1); // rec.Event.KeyEvent.bKeyDown
@@ -409,7 +410,7 @@ function windows_terminal() {
rec.Deref(14, 1).toBuffer()[0] = key; // rec.Event.KeyEvent.uChar.AsciiChar rec.Deref(14, 1).toBuffer()[0] = key; // rec.Event.KeyEvent.uChar.AsciiChar
rec.Deref(8, 2).toBuffer().writeUInt16LE(1); // rec.Event.KeyEvent.wRepeatCount rec.Deref(8, 2).toBuffer().writeUInt16LE(1); // rec.Event.KeyEvent.wRepeatCount
rec.Deref(10, 2).toBuffer().writeUInt16LE(this._user32.VkKeyScanA(key).Val); // rec.Event.KeyEvent.wVirtualKeyCode rec.Deref(10, 2).toBuffer().writeUInt16LE(this._user32.VkKeyScanA(key).Val); // rec.Event.KeyEvent.wVirtualKeyCode
rec.Deref(12, 2).toBuffer().writeUInt16LE(this._user32.MapVirtualKeyA(scanCode, MAPVK_VK_TO_VSC).Val); rec.Deref(12, 2).toBuffer().writeUInt16LE(this._user32.MapVirtualKeyA(this._user32.VkKeyScanA(key).Val, MAPVK_VK_TO_VSC).Val);
var dwWritten = GM.CreateVariable(4); var dwWritten = GM.CreateVariable(4);
if (this._kernel32.WriteConsoleInputA(this._stdinput, rec, 1, dwWritten).Val == 0) { return (false); } if (this._kernel32.WriteConsoleInputA(this._stdinput, rec, 1, dwWritten).Val == 0) { return (false); }
@@ -478,11 +479,14 @@ function windows_terminal() {
return (retVal); return (retVal);
} }
this._SendDataBuffer = function (data) { this._SendDataBuffer = function (data)
{
// { data, attributes, width, height, x, y } // { data, attributes, width, height, x, y }
if (this._stream != null)
{
var dy, line, attr; var dy, line, attr;
for (dy = 0; dy < data.height; ++dy) { for (dy = 0; dy < data.height; ++dy)
{
line = data.data[dy]; line = data.data[dy];
attr = data.attributes[dy]; attr = data.attributes[dy];
line.s = line.toString(); line.s = line.toString();
@@ -492,9 +496,11 @@ function windows_terminal() {
this._stream.push(TranslateLine(data.x + 1, data.y + dy + 1, line, attr)); this._stream.push(TranslateLine(data.x + 1, data.y + dy + 1, line, attr));
} }
} }
}
this._SendScroll = function _SendScroll(dx, dy) { this._SendScroll = function _SendScroll(dx, dy)
if (this._scrollTimer) { return; } {
if (this._scrollTimer || this._stream == null) { return; }
var info = GM.CreateVariable(22); var info = GM.CreateVariable(22);
if (this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput, info).Val == 0) { throw ('Error getting screen buffer info'); } if (this._kernel32.GetConsoleScreenBufferInfo(this._stdoutput, info).Val == 0) { throw ('Error getting screen buffer info'); }