Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: XGKB

XGKB.m

Go to the documentation of this file.
  1. XGKB ;SFISC/VYD - Read with Escape Processing ;10/23/2006
  1. ;;8.0;KERNEL;**34,244,365**;Jul 10, 1995;Build 5
  1. ;;Special thanks to MELDRUM.KEVIN@ISC-SLC.DOMAIN.EXT
  1. ;
  1. INIT(XGTRM) ;turn escape processing on and passed terminator string if any
  1. N %,%OS S %OS=^%ZOSF("OS")
  1. I %OS["VAX DSM" U $I:(NOLINE:ESCAPE) D:'$D(^XUTL("XGKB")) VAXDSM^XGKB1
  1. I %OS["MSM" U $I:(0::::64) D:'$D(^XUTL("XGKB")) MSM^XGKB1
  1. I %OS["DTM" U $I:(VT=1:ESCAPE=1) D:'$D(^XUTL("XGKB")) DTM^XGKB1
  1. I %OS["OpenM" U $I:(:"CT") D:'$D(^XUTL("XGKB")) DTM^XGKB1 S:$G(XGTRM)="*" XGTRM=""
  1. I %OS["GT.M" U $I:(ESCAPE) D:'$D(^XUTL("XGKB")) GTM^XGKB1
  1. I $G(XGTRM)="*" X ^%ZOSF("TRMON") I 1 ;turn all on
  1. E I $L($G(XGTRM)) S %=$$SETTRM^%ZOSV(XGTRM) ;turn on passed terminators
  1. S XGRT=""
  1. Q
  1. ;
  1. ;
  1. EXIT ; Reset device (disable escape processing, turn terminators off)
  1. N %OS S %OS=^%ZOSF("OS")
  1. I %OS["VAX DSM" U $I:(LINE:NOESCAPE)
  1. I %OS["MSM" U $I:(0:::::64)
  1. I %OS["DTM" U $I:(ESCAPE=0)
  1. I %OS["GT.M" U $I:(NOESCAPE)
  1. X ^%ZOSF("TRMOFF")
  1. K XGRT
  1. Q
  1. ;
  1. ;
  1. ACTION(XGKEY,XGACTION) ;add or remove key-action
  1. ;XGKEY:key mnemonic ("F10","NEXT",etc.)
  1. ;XGACTION:M executable string
  1. ;if action is passed ADD mode is assumed otherwise REMOVE
  1. I $D(XGACTION) S ^TMP("XGKEY",$J,XGKEY)=XGACTION
  1. E K ^TMP("XGKEY",$J,XGKEY)
  1. Q
  1. ;
  1. ;
  1. READ(XGCHARS,XGTO) ; read XGCHARS using escape processing. XGTO timeout (optional). Result returned.
  1. ; Char that terminated the read will be in XGRT
  1. N S,XGW1,XGT1,XGSEQ ;string,window,timer,timer sequence
  1. K DTOUT
  1. S XGRT=""
  1. D:$G(XGTO)="" ;set timeout value if one wasn't passed
  1. . I $D(XGT) D Q ;if timers are defined
  1. . . S XGTO=$O(XGT(0,"")) ;get shortest time left of all timers
  1. . . S XGW1=$P(XGT(0,XGTO,$O(XGT(0,XGTO,"")),"ID"),U,1) ;get timer's window
  1. . . S XGT1=$P(XGT(0,XGTO,$O(XGT(0,XGTO,"")),"ID"),U,3) ;get timer's name
  1. . I $D(XGW) S XGTO=99999999 Q ;in emulation read forever
  1. . S XGTO=$G(DTIME,600)
  1. ;
  1. I $G(XGCHARS)>0 R S#XGCHARS:XGTO S:'$T DTOUT=1 I 1 ;fixed length read
  1. E R S:XGTO S:'$T DTOUT=1 I 1 ;read as many as possible
  1. S:$G(DTOUT)&('$D(XGT1)) S=U ;stuff ^
  1. ;
  1. S:$L($ZB) XGRT=$G(^XUTL("XGKB",$ZB)) ;get terminator if any
  1. I $G(DTOUT),$D(XGT1),$D(^TMP("XGW",$J,XGW1,"T",XGT1,"EVENT","TIMER")) D I 1 ;if timed out
  1. . D E^XGEVNT1(XGW1,"T",XGT1,"","TIMER")
  1. E I $L(XGRT),$D(^TMP("XGKEY",$J,XGRT)) X ^(XGRT) ;do some action
  1. ; this really should be handled by keyboard mapping -- later
  1. Q S
  1. ;
  1. ;
  1. TEST F S X=$$READ Q:X["^" W ?20,X,?40,XGRT,?60,$ZB,!
  1. Q