@@ -53,6 +53,16 @@ Last joined client id</Description>
53
53
<InitialExpression >$c(5)</InitialExpression >
54
54
</Property >
55
55
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
+
56
66
<Property name =" ConstClientEnterClearIO" >
57
67
<Type >%Char</Type >
58
68
<InitialExpression >$c(1)</InitialExpression >
@@ -404,7 +414,10 @@ This method watches only for tail of global and detects if global still alive</D
404
414
</Method >
405
415
406
416
<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 >
408
421
<ReturnType >%String</ReturnType >
409
422
<Implementation ><![CDATA[
410
423
set filename = ..GetJSAutocompleteFilePath($NAMESPACE)
@@ -419,7 +432,7 @@ This method watches only for tail of global and detects if global still alive</D
419
432
420
433
set namespace = $REPLACE(namespace,"%","_")
421
434
422
- if (##class(%File).Exists(filename)) {
435
+ if (##class(%File).Exists(filename)) && (newFile = 0) {
423
436
424
437
do ..EndClearIO()
425
438
do ..SendData(namespace, ..ConstClientLoadAutocomplete)
@@ -546,6 +559,21 @@ If the key is empty, generates new key value.</Description>
546
559
]]> </Implementation >
547
560
</Method >
548
561
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
+
549
577
<Method name =" SendData" >
550
578
<Description >
551
579
Function sends data derectly to server with specified action</Description >
@@ -561,9 +589,6 @@ Function sends data derectly to server with specified action</Description>
561
589
<FormalSpec >query:%String=""</FormalSpec >
562
590
<ReturnType >%Status</ReturnType >
563
591
<Implementation ><![CDATA[
564
- set io = $io
565
- use io::("^" _ ..InitialZName)
566
-
567
592
do ..StartClearIO()
568
593
do ##class(%Device).ReDirectIO($$$YES)
569
594
@@ -579,8 +604,6 @@ Function sends data derectly to server with specified action</Description>
579
604
do ##class(%Device).ReDirectIO($$$NO)
580
605
do ..EndClearIO()
581
606
582
- use io
583
-
584
607
quit $$$OK
585
608
]]> </Implementation >
586
609
</Method >
@@ -599,14 +622,18 @@ Sends to client new namespace if last was changed</Description>
599
622
<Method name =" StartClearIO" >
600
623
<Description >
601
624
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)
603
628
]]> </Implementation >
604
629
</Method >
605
630
606
631
<Method name =" EndClearIO" >
607
632
<Description >
608
633
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)
610
637
]]> </Implementation >
611
638
</Method >
612
639
@@ -635,14 +662,10 @@ The heart of terminal application</Description>
635
662
do ..StartClearIO() // execute session start
636
663
637
664
set $ZERROR = ""
638
- set io = $io
639
- use io::("^" _ ..InitialZName)
640
665
641
- do ##class(%Device).ReDirectIO($$$YES)
642
666
try { xecute value } catch exception {
643
667
set $ZERROR = exception.DisplayString()
644
668
}
645
- do ##class(%Device).ReDirectIO($$$NO)
646
669
647
670
if ($ZERROR '= "") {
648
671
do ..SendData(..ParseError($ZERROR))
@@ -715,8 +738,8 @@ Method description:
715
738
}
716
739
717
740
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
720
743
set data = $EXTRACT(data, 1, *-1)
721
744
}
722
745
@@ -746,8 +769,22 @@ Method description:
746
769
do ..ExecuteSQL(data)
747
770
748
771
} 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) {
749
784
750
- do ..GenerateAutocompleteFile(data)
785
+ do ..StartClearIO()
786
+ do ..SendData(data)
787
+ do ..EndClearIO()
751
788
752
789
} else { // something scary
753
790
@@ -773,6 +810,7 @@ New connection established</Description>
773
810
do ..SendData("1", ..ConstClientAuthorizationStatus)
774
811
do ..SendData(..CurrentNamespace, ..ConstClientChangeNamespace)
775
812
813
+ use $io::("^" _ ..InitialZName)
776
814
do ..ClientLoop()
777
815
778
816
} else {
0 commit comments