Skip to content

Commit 0991637

Browse files
character read fixes, but not complete. Continuing testing...
1 parent dc84326 commit 0991637

File tree

5 files changed

+86
-7
lines changed

5 files changed

+86
-7
lines changed

classes/%WebTerminal.Engine.cls

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,30 +163,36 @@ wstr(s)
163163
do ##class(%Device).ReDirectIO($$$NO)
164164
do WriteMessage("O#"_s)
165165
do ##class(%Device).ReDirectIO($$$YES)
166+
set $X = $X + $LENGTH(s)
166167
quit
167168

168169
wchr(c)
169170
do ##class(%Device).ReDirectIO($$$NO)
170171
do WriteMessage("O#"_$c(c))
171172
do ##class(%Device).ReDirectIO($$$YES)
173+
set $X = $X + 1
172174
quit
173175

174176
wnl
175177
do ##class(%Device).ReDirectIO($$$NO)
176178
do WriteMessage("O#"_$c(13, 10))
177179
do ##class(%Device).ReDirectIO($$$YES)
180+
set $X = 0
178181
quit
179182

180183
wff
181184
do ##class(%Device).ReDirectIO($$$NO)
182185
do WriteMessage("CLRSCR#")
183186
do ##class(%Device).ReDirectIO($$$YES)
187+
set $Y = 0
188+
set $X = 0
184189
quit
185190

186191
wtab(s)
187192
do ##class(%Device).ReDirectIO($$$NO)
188193
do WriteMessage("O#" _ $C(27) _ "[" _ (s + 1) _ "G")
189194
do ##class(%Device).ReDirectIO($$$YES)
195+
set $X = s
190196
quit
191197

192198
rstr(len = 32656, timeout = 86400, data)
@@ -199,8 +205,8 @@ rstr(len = 32656, timeout = 86400, data)
199205
rchr(timeout = 86400, data)
200206
do ##class(%Device).ReDirectIO($$$NO)
201207
do WriteMessage("RC#")
202-
set data = $$ReadMessage(1, timeout)
203-
set data = $ASCII($EXTRACT(data,1,1))
208+
set data = $$ReadMessage(, timeout)
209+
set data = data * 1 // $ASCII($EXTRACT(data,1,1))
204210
do ##class(%Device).ReDirectIO($$$YES)
205211
quit data
206212
}
@@ -397,10 +403,15 @@ ClassMethod getGlobalsJSON(namespace As %String) As %String
397403
set out = out _ """" _ $Piece(rset.GetData(1),"(",1) _ """:0,"
398404
}
399405
set out = $EXTRACT(out,1,$LENGTH(out)-1) _ "}"
406+
407+
// todo:
408+
// Set Rset = ##class(%Library.ResultSet).%New("%SYS.GlobalQuery:NameSpaceListChui")
409+
// s Status=Rset.Execute(NameSpace,Mask,SystemGlobals,.UnavailableDatabases)
410+
400411
q out
401412
}
402413

403-
/// Generates autocomplete file for namespace. Second parameter deсides if
414+
/// Generates autocomplete file for namespace. Second parameter decides if
404415
/// it will be regenerated again. But if namespace equals to "%" - generates
405416
/// autocomplete file for system classes. Make sure that autocomplete for
406417
/// system classes generates one time and forever.
@@ -851,7 +862,10 @@ Method Server() As %Status
851862
do ..SendData("1", ..ConstClientAuthorizationStatus)
852863
do ..SendData(..CurrentNamespace, ..ConstClientChangeNamespace)
853864

854-
use $io::("^" _ ..InitialZName) // switch to routine
865+
//open $io:(/NOXY:/BREAK):"^" _ ..InitialZName // switch to routine
866+
use $io:(/NOXY:/BREAK):"^" _ ..InitialZName
867+
//OPEN $IO:(80:"BFU":$CHAR(13)) // :"^" _ ..InitialZName
868+
//USE $IO:(80:"BFU":$CHAR(13)):"^" _ ..InitialZName
855869
do ..ClientLoop()
856870

857871
} else {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
"grunt-contrib-uglify": ">=0.5.1",
1818
"grunt-preprocess": ">=4.0.0"
1919
}
20-
}
20+
}

webSource/js/CacheWebTerminalServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ CacheWebTerminalServer.prototype.onError = function () {
162162
var _this = this;
163163

164164
this.CONTROLLER.TERMINAL.output.print(
165-
this._lc.get(6, this.socket.url, this.RECONNECTION_TIMEOUT/1000)
165+
this._lc.get(6, this.socket.url, this.RECONNECTION_TIMEOUT/1000) + "\r\n"
166166
);
167167

168168
setTimeout(function () {

webSource/js/TerminalController.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,13 @@ TerminalController.prototype.clientAction = {
525525
},
526526

527527
RC: function () {
528-
this.TERMINAL.input.prompt("", 1);
528+
529+
var _this = this;
530+
531+
this.TERMINAL.input.getChar(function (char) {
532+
_this.server.send(char);
533+
});
534+
529535
},
530536

531537
AUTH: function (data) {

webSource/js/TerminalInput.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ var TerminalInput = function (TERMINAL) {
6565
*/
6666
this._handler = null;
6767

68+
/**
69+
* @type {boolean}
70+
* @private
71+
*/
72+
this.__readingChar = false;
73+
6874
/**
6975
* Shows the input beginning position.
7076
*
@@ -416,4 +422,57 @@ TerminalInput.prototype.prompt = function (invitationMessage, length, handler) {
416422

417423
this._enable();
418424

425+
};
426+
427+
/**
428+
* Get character from keyboard. This works for all keys.
429+
*
430+
* @param {function} callback
431+
*/
432+
TerminalInput.prototype.getChar = function (callback) {
433+
434+
var _this = this,
435+
shift = false;
436+
437+
if (this.__readingChar) return false;
438+
439+
this.__readingChar = true;
440+
441+
this.TERMINAL.progressIndicator.hide();
442+
443+
var listener = function (e) {
444+
445+
var code = e.keyCode,
446+
char = String.fromCharCode(code);
447+
448+
if (code === 16) shift = true;
449+
if (code === 16 || code === 17 || code === 18) return;
450+
451+
if (shift) {
452+
char = char.toUpperCase();
453+
} else {
454+
char = char.toLowerCase();
455+
}
456+
457+
_this.TERMINAL.output.print(char);
458+
459+
window.removeEventListener("keydown", listener, true);
460+
window.removeEventListener("keyup", upListener, true);
461+
e.preventDefault();
462+
e.cancelBubble = true;
463+
464+
_this.__readingChar = false;
465+
callback.call(_this, char.charCodeAt(0).toString());
466+
467+
};
468+
469+
var upListener = function (e) {
470+
471+
if (e.keyCode === 16) shift = false;
472+
473+
};
474+
475+
window.addEventListener("keydown", listener, true);
476+
window.addEventListener("keyup", upListener, true);
477+
419478
};

0 commit comments

Comments
 (0)