Skip to content

Commit c3e71ef

Browse files
new: /tip /favorite /echo /watch, changes: /define /autocomplete /reset, rewritten client-side commands: check tutorial by entering /tip. Globals autocompletion fix, and more, more
1 parent 2859c4d commit c3e71ef

File tree

9 files changed

+366
-91
lines changed

9 files changed

+366
-91
lines changed

%WebTerminal/Engine.cls.xml

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ Last joined client id</Description>
5353
<InitialExpression>$c(5)</InitialExpression>
5454
</Property>
5555

56+
<Property name="ConstServerActionReset">
57+
<Type>%Char</Type>
58+
<InitialExpression>$c(6)</InitialExpression>
59+
</Property>
60+
61+
<Property name="ConstServerActionEcho">
62+
<Type>%Char</Type>
63+
<InitialExpression>$c(7)</InitialExpression>
64+
</Property>
65+
5666
<Property name="ConstClientEnterClearIO">
5767
<Type>%Char</Type>
5868
<InitialExpression>$c(1)</InitialExpression>
@@ -404,7 +414,10 @@ This method watches only for tail of global and detects if global still alive</D
404414
</Method>
405415

406416
<Method name="GenerateAutocompleteFile">
407-
<FormalSpec>namespace:%String</FormalSpec>
417+
<Description>
418+
Generates autocomplete file for namespace. Second parameter deсides if
419+
it will be regenerated again </Description>
420+
<FormalSpec>namespace:%String,newFile:%Boolean</FormalSpec>
408421
<ReturnType>%String</ReturnType>
409422
<Implementation><![CDATA[
410423
set filename = ..GetJSAutocompleteFilePath($NAMESPACE)
@@ -419,7 +432,7 @@ This method watches only for tail of global and detects if global still alive</D
419432
420433
set namespace = $REPLACE(namespace,"%","_")
421434
422-
if (##class(%File).Exists(filename)) {
435+
if (##class(%File).Exists(filename)) && (newFile = 0) {
423436
424437
do ..EndClearIO()
425438
do ..SendData(namespace, ..ConstClientLoadAutocomplete)
@@ -546,6 +559,21 @@ If the key is empty, generates new key value.</Description>
546559
]]></Implementation>
547560
</Method>
548561

562+
<Method name="Reset">
563+
<Description>
564+
Backs terminal to default state</Description>
565+
<ClassMethod>1</ClassMethod>
566+
<ReturnType>%Status</ReturnType>
567+
<Implementation><![CDATA[
568+
// delete autocompletion files
569+
set dir = ##class(%File).GetDirectory(..GetJSAutocompleteFilePath("TEST"))
570+
if (##class(%File).DirectoryExists(dir)) {
571+
do ##class(%File).RemoveDirectoryTree(dir)
572+
}
573+
quit $$$OK
574+
]]></Implementation>
575+
</Method>
576+
549577
<Method name="SendData">
550578
<Description>
551579
Function sends data derectly to server with specified action</Description>
@@ -561,9 +589,6 @@ Function sends data derectly to server with specified action</Description>
561589
<FormalSpec>query:%String=""</FormalSpec>
562590
<ReturnType>%Status</ReturnType>
563591
<Implementation><![CDATA[
564-
set io = $io
565-
use io::("^" _ ..InitialZName)
566-
567592
do ..StartClearIO()
568593
do ##class(%Device).ReDirectIO($$$YES)
569594
@@ -579,8 +604,6 @@ Function sends data derectly to server with specified action</Description>
579604
do ##class(%Device).ReDirectIO($$$NO)
580605
do ..EndClearIO()
581606
582-
use io
583-
584607
quit $$$OK
585608
]]></Implementation>
586609
</Method>
@@ -599,14 +622,18 @@ Sends to client new namespace if last was changed</Description>
599622
<Method name="StartClearIO">
600623
<Description>
601624
Starts clear I/O mode</Description>
602-
<Implementation><![CDATA[ do ..Write(..ConstClientEnterClearIO)
625+
<Implementation><![CDATA[
626+
do ##class(%Device).ReDirectIO($$$YES)
627+
do ..Write(..ConstClientEnterClearIO)
603628
]]></Implementation>
604629
</Method>
605630

606631
<Method name="EndClearIO">
607632
<Description>
608633
Ends clear I/O mode</Description>
609-
<Implementation><![CDATA[ do ..SendData("exit",..ConstClientExitClearIO)
634+
<Implementation><![CDATA[
635+
do ##class(%Device).ReDirectIO($$$NO)
636+
do ..SendData("exit",..ConstClientExitClearIO)
610637
]]></Implementation>
611638
</Method>
612639

@@ -635,14 +662,10 @@ The heart of terminal application</Description>
635662
do ..StartClearIO() // execute session start
636663
637664
set $ZERROR = ""
638-
set io = $io
639-
use io::("^" _ ..InitialZName)
640665
641-
do ##class(%Device).ReDirectIO($$$YES)
642666
try { xecute value } catch exception {
643667
set $ZERROR = exception.DisplayString()
644668
}
645-
do ##class(%Device).ReDirectIO($$$NO)
646669
647670
if ($ZERROR '= "") {
648671
do ..SendData(..ParseError($ZERROR))
@@ -715,8 +738,8 @@ Method description:
715738
}
716739
717740
set action = $EXTRACT(data, 1, 1)
718-
set data = $REPLACE($EXTRACT(data, 2, *), $CHAR(10), " ") // terminator
719-
if ($EXTRACT(data, *) = " ") { // terminator
741+
set data = $EXTRACT(data, 2, *)
742+
if ($EXTRACT(data, *-1, 1) = $c(10)) { // terminator
720743
set data = $EXTRACT(data, 1, *-1)
721744
}
722745
@@ -746,8 +769,22 @@ Method description:
746769
do ..ExecuteSQL(data)
747770
748771
} elseif (action = ..ConstServerActionGenerateAutocomplete) {
772+
773+
do ..GenerateAutocompleteFile(..CurrentNamespace, data)
774+
775+
} elseif (action = ..ConstServerActionReset) {
776+
777+
if ($$$ISOK(..Reset())) {
778+
do ..SendData("Terminal state reseted.")
779+
} else {
780+
do ..SendData("Error while reseting terminal state.")
781+
}
782+
783+
} elseif (action = ..ConstServerActionEcho) {
749784
750-
do ..GenerateAutocompleteFile(data)
785+
do ..StartClearIO()
786+
do ..SendData(data)
787+
do ..EndClearIO()
751788
752789
} else { // something scary
753790
@@ -773,6 +810,7 @@ New connection established</Description>
773810
do ..SendData("1", ..ConstClientAuthorizationStatus)
774811
do ..SendData(..CurrentNamespace, ..ConstClientChangeNamespace)
775812
813+
use $io::("^" _ ..InitialZName)
776814
do ..ClientLoop()
777815
778816
} else {

csp/webTerminal/css/base.css.xml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ body {
1818
background: url("../img/back.png") black;
1919
}
2020
21-
.hidden { display: none; }
22-
.center { text-align: center; }
23-
.bold { font-weight: 900; }
24-
.noMargin { margin: 0 }
25-
.noPadding { padding: 0 }
26-
2721
table {
2822
padding: 0;
2923
border: 0;
@@ -37,18 +31,7 @@ tr, td {
3731
border-spacing: 0;
3832
}
3933
40-
terminal-base tr, td {
41-
padding: 0 6px 6px 6px;
42-
margin: 0;
43-
border: 0;
44-
border-spacing: 0;
45-
}
46-
47-
.noAnimations {
48-
transition: none !important;
49-
-webkit-transition: none !important;
50-
-moz-transition: none !important;
51-
-o-transition: none !important;
52-
-ms-transition: none !important;
34+
p {
35+
text-indent: 40px;
5336
}]]></CSP>
5437
</Export>

csp/webTerminal/css/extra.css.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949
100% { color: orange; }
5050
}
5151
52+
.hidden { display: none; }
53+
.center { text-align: center; }
54+
.bold { font-weight: 900; }
55+
.noMargin { margin: 0 }
56+
.noPadding { padding: 0 }
57+
.normalWrap { white-space: normal; text-wrap: normal }
58+
5259
#caret {
5360
position: relative;
5461
display: inline-block;
@@ -78,5 +85,13 @@
7885
-moz-transition: all 0.1s ease-out;
7986
-o-transition: all 0.1s ease-out;
8087
-webkit-transition: all 0.1s ease-out;
88+
}
89+
90+
.noAnimations {
91+
transition: none !important;
92+
-webkit-transition: none !important;
93+
-moz-transition: none !important;
94+
-o-transition: none !important;
95+
-ms-transition: none !important;
8196
}]]></CSP>
8297
</Export>

csp/webTerminal/css/terminal.css.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
position: relative;
66
}
77
8+
terminal-base tr, td {
9+
padding: 0 6px 6px 6px;
10+
margin: 0;
11+
border: 0;
12+
border-spacing: 0;
13+
}
14+
815
.terminal-output-block {
916
position: relative;
1017
overflow: hidden;

csp/webTerminal/index.csp.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Export generator="Cache" version="25">
33
<CSP name="WebTerminal/index.csp" application="/csp/sys/" default="1"><![CDATA[
44
<!DOCTYPE html>
5+
56
<html>
67
78
<head>
@@ -16,11 +17,11 @@
1617
<link rel="stylesheet" href="css/extra.css">
1718
<link rel="stylesheet" href="css/theme-default.css" id="terminal-color-theme">
1819
<script type="text/javascript" src="js/base.js"></script>
20+
<script type="text/javascript" src="js/parser.js"></script>
1921
<script type="text/javascript" src="js/hid.js"></script>
2022
<script type="text/javascript" src="js/application.js"></script>
2123
<script type="text/javascript" src="js/server.js"></script>
2224
<script type="text/javascript" src="js/terminal.js"></script>
23-
<script type="text/javascript" src="js/parser.js"></script>
2425
<script type="text/javascript" src="js/unit.js"></script>
2526
<script type="text/javascript" src="js/storage.js"></script>
2627
</head>

0 commit comments

Comments
 (0)