mentor/derived/WheelerTranscriptView.m3


 Copyright (C) 1995, Digital Equipment Corporation.       
 All rights reserved.                                     
 See the file COPYRIGHT for a full description.           
                                                          
 Last modified on Thu Feb  9 08:56:02 PST 1995 by kalsow  
      modified on Mon Jun  6 03:18:55 PDT 1994 by mhb   
      modified on Tue Feb 16 16:31:40 PST 1993 by johnh 

********************************************************************

      *  NOTE: This file is generated automatically from the event
      *        definition file Wheeler.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE WheelerTranscriptView;

<*NOWARN*> IMPORT TextConv, TextPort, Rd, ZeusClass, Filter;
<*NOWARN*> IMPORT TextEditVBT, Fmt, WheelerViewClass, ZFmt, Wr;
<*NOWARN*> IMPORT ZeusPanel, FormsVBT, VBT, View, MiscFmt;

<* FATAL FormsVBT.Error, FormsVBT.Unimplemented *>

REVEAL
  T = Public BRANDED OBJECT
    fv: FormsVBT.T := NIL;
    te: TextEditVBT.T := NIL;
  OVERRIDES
    init       := TViewInit;
    install    := TViewInstall;
    delete     := TViewDelete;
    snapshot   := TViewSnapshot;
    restore    := TViewRestore;
    config     := TViewConfig;
    reactivity := TViewReactivity;
    startrun   := TViewStartrun;
    endrun     := TViewEndrun;
    oeStartPermute := StartPermute;
    oeNextRotation := NextRotation;
    oeRotationsSorted := RotationsSorted;
    oePermuteDone := PermuteDone;
    oeStartEncode := StartEncode;
    oeEncodeNextChar := EncodeNextChar;
    oeEncodeDistinctCount := EncodeDistinctCount;
    oeEncodeFoundCode := EncodeFoundCode;
    oeEncodeDone := EncodeDone;
    oeInitDecode := InitDecode;
    oeStartDecode := StartDecode;
    oeDecodeNextCode := DecodeNextCode;
    oeDecodeDistinctCount := DecodeDistinctCount;
    oeDecodeFoundChar := DecodeFoundChar;
    oeDecodeDone := DecodeDone;
    oeStartReconstruct := StartReconstruct;
    oeFirstChars := FirstChars;
    oeConsiderChar := ConsiderChar;
    oeEqualChars := EqualChars;
    oeFinishCharRun := FinishCharRun;
    oeStartResult := StartResult;
    oeResultNextChar := ResultNextChar;
    oeEndResult := EndResult;
    oeReveal := Reveal;
  END;

PROCEDURE TViewInit (view: T): T =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "init");
    RETURN WheelerViewClass.T.init (view, NIL);
  END TViewInit;

PROCEDURE Clear (<* UNUSED *> fv  : FormsVBT.T;
                 <* UNUSED *> name: TEXT;
                              cl  : REFANY;
                 <* UNUSED *> time: VBT.TimeStamp) =
  BEGIN
    TextPort.SetText(NARROW(cl, T).te.tp, "")
  END Clear;

PROCEDURE TViewInstall (view: T) =
  <* LL = VBT.mu *>
  BEGIN
    view.fv := ZeusPanel.NewForm("WheelerTranscriptView.fv");
    view.te := FormsVBT.GetVBT(view.fv, "transcript");
    TViewZTrace (view, "install");
    FormsVBT.AttachProc(view.fv, "clear", Clear, view);
    EVAL Filter.Replace (view, view.fv);
    WheelerViewClass.T.install (view);
  END TViewInstall;

PROCEDURE TViewDelete (view: T) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "delete");
    WheelerViewClass.T.delete (view);
   END TViewDelete;

PROCEDURE TViewSnapshot (view: T; wr: Wr.T) RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "snapshot");
    WheelerViewClass.T.snapshot (view, wr);
   END TViewSnapshot;

PROCEDURE TViewRestore (view: T; rd: Rd.T) RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "restore");
    WheelerViewClass.T.restore (view, rd);
   END TViewRestore;

PROCEDURE TViewConfig (
    view: T;
    state: ZeusClass.StateChange;
    o: ZeusClass.T) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "config");
    WheelerViewClass.T.config (view, state, o);
   END TViewConfig;

PROCEDURE TViewReactivity (view: T; <*UNUSED*> on: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace(view, "reactivity");
    WheelerViewClass.T.reactivity (view, TRUE);
  END TViewReactivity;

PROCEDURE TViewStartrun (view: T) =
  <* LL = {} *>
  BEGIN
    TViewZTrace (view, "startrun");
    WheelerViewClass.T.startrun (view);
   END TViewStartrun;

PROCEDURE TViewEndrun (view: T) =
  <* LL = {} *>
  BEGIN
    TViewZTrace (view, "endrun");
    WheelerViewClass.T.endrun (view);
  END TViewEndrun;
event handling methods:

PROCEDURE StartPermute (view: T;  string, alphabet: TEXT) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "StartPermute ...")
       ELSE
          TViewTrace (view, "StartPermute "
          & TextConv.Encode(string)
          & " "
          & TextConv.Encode(alphabet)
          )
       END
    END
    END
  END StartPermute;

PROCEDURE NextRotation (view: T;  i: INTEGER; string: TEXT) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "NextRotation ...")
       ELSE
          TViewTrace (view, "NextRotation "
          & Fmt.Int(i)
          & " "
          & TextConv.Encode(string)
          )
       END
    END
    END
  END NextRotation;

PROCEDURE RotationsSorted (view: T;  rotations: MiscFmt.RefTextArray; rowIndex: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "RotationsSorted ...")
       ELSE
          TViewTrace (view, "RotationsSorted "
          & MiscFmt.TextArray(rotations)
          & " "
          & Fmt.Int(rowIndex)
          )
       END
    END
    END
  END RotationsSorted;

PROCEDURE PermuteDone (view: T;  lastchars: TEXT; rowIndex: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "PermuteDone ...")
       ELSE
          TViewTrace (view, "PermuteDone "
          & TextConv.Encode(lastchars)
          & " "
          & Fmt.Int(rowIndex)
          )
       END
    END
    END
  END PermuteDone;

PROCEDURE StartEncode (view: T;  alphabet: TEXT) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "StartEncode ...")
       ELSE
          TViewTrace (view, "StartEncode "
          & TextConv.Encode(alphabet)
          )
       END
    END
    END
  END StartEncode;

PROCEDURE EncodeNextChar (view: T;  i: INTEGER; c: CHAR) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "EncodeNextChar ...")
       ELSE
          TViewTrace (view, "EncodeNextChar "
          & Fmt.Int(i)
          & " "
          & MiscFmt.Char(c)
          )
       END
    END
    END
  END EncodeNextChar;

PROCEDURE EncodeDistinctCount (view: T;  i, k, n: INTEGER; c: CHAR) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "EncodeDistinctCount ...")
       ELSE
          TViewTrace (view, "EncodeDistinctCount "
          & Fmt.Int(i)
          & " "
          & Fmt.Int(k)
          & " "
          & Fmt.Int(n)
          & " "
          & MiscFmt.Char(c)
          )
       END
    END
    END
  END EncodeDistinctCount;

PROCEDURE EncodeFoundCode (view: T;  i, k, code: INTEGER; c: CHAR) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "EncodeFoundCode ...")
       ELSE
          TViewTrace (view, "EncodeFoundCode "
          & Fmt.Int(i)
          & " "
          & Fmt.Int(k)
          & " "
          & Fmt.Int(code)
          & " "
          & MiscFmt.Char(c)
          )
       END
    END
    END
  END EncodeFoundCode;

PROCEDURE EncodeDone (view: T;  alphabet: TEXT; codes: MiscFmt.RefIntArray; rowIndex: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "EncodeDone ...")
       ELSE
          TViewTrace (view, "EncodeDone "
          & TextConv.Encode(alphabet)
          & " "
          & MiscFmt.IntArray(codes)
          & " "
          & Fmt.Int(rowIndex)
          )
       END
    END
    END
  END EncodeDone;

PROCEDURE InitDecode (view: T;  alphabet: TEXT; codes: MiscFmt.RefIntArray; rowIndex: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "InitDecode ...")
       ELSE
          TViewTrace (view, "InitDecode "
          & TextConv.Encode(alphabet)
          & " "
          & MiscFmt.IntArray(codes)
          & " "
          & Fmt.Int(rowIndex)
          )
       END
    END
    END
  END InitDecode;

PROCEDURE StartDecode (view: T;  ) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "StartDecode ...")
       ELSE
          TViewTrace (view, "StartDecode "
          )
       END
    END
    END
  END StartDecode;

PROCEDURE DecodeNextCode (view: T;  i: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "DecodeNextCode ...")
       ELSE
          TViewTrace (view, "DecodeNextCode "
          & Fmt.Int(i)
          )
       END
    END
    END
  END DecodeNextCode;

PROCEDURE DecodeDistinctCount (view: T;  i, k, n: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "DecodeDistinctCount ...")
       ELSE
          TViewTrace (view, "DecodeDistinctCount "
          & Fmt.Int(i)
          & " "
          & Fmt.Int(k)
          & " "
          & Fmt.Int(n)
          )
       END
    END
    END
  END DecodeDistinctCount;

PROCEDURE DecodeFoundChar (view: T;  i, k: INTEGER; c: CHAR) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "DecodeFoundChar ...")
       ELSE
          TViewTrace (view, "DecodeFoundChar "
          & Fmt.Int(i)
          & " "
          & Fmt.Int(k)
          & " "
          & MiscFmt.Char(c)
          )
       END
    END
    END
  END DecodeFoundChar;

PROCEDURE DecodeDone (view: T;  lastchars: TEXT; rowIndex: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "DecodeDone ...")
       ELSE
          TViewTrace (view, "DecodeDone "
          & TextConv.Encode(lastchars)
          & " "
          & Fmt.Int(rowIndex)
          )
       END
    END
    END
  END DecodeDone;

PROCEDURE StartReconstruct (view: T;  lastchars: TEXT; rowIndex: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "StartReconstruct ...")
       ELSE
          TViewTrace (view, "StartReconstruct "
          & TextConv.Encode(lastchars)
          & " "
          & Fmt.Int(rowIndex)
          )
       END
    END
    END
  END StartReconstruct;

PROCEDURE FirstChars (view: T;  t: TEXT) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "FirstChars ...")
       ELSE
          TViewTrace (view, "FirstChars "
          & TextConv.Encode(t)
          )
       END
    END
    END
  END FirstChars;

PROCEDURE ConsiderChar (view: T;  i: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "ConsiderChar ...")
       ELSE
          TViewTrace (view, "ConsiderChar "
          & Fmt.Int(i)
          )
       END
    END
    END
  END ConsiderChar;

PROCEDURE EqualChars (view: T;  i, j: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "EqualChars ...")
       ELSE
          TViewTrace (view, "EqualChars "
          & Fmt.Int(i)
          & " "
          & Fmt.Int(j)
          )
       END
    END
    END
  END EqualChars;

PROCEDURE FinishCharRun (view: T;  ) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "FinishCharRun ...")
       ELSE
          TViewTrace (view, "FinishCharRun "
          )
       END
    END
    END
  END FinishCharRun;

PROCEDURE StartResult (view: T;  ) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "StartResult ...")
       ELSE
          TViewTrace (view, "StartResult "
          )
       END
    END
    END
  END StartResult;

PROCEDURE ResultNextChar (view: T;  pos, k: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "ResultNextChar ...")
       ELSE
          TViewTrace (view, "ResultNextChar "
          & Fmt.Int(pos)
          & " "
          & Fmt.Int(k)
          )
       END
    END
    END
  END ResultNextChar;

PROCEDURE EndResult (view: T;  ) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "EndResult ...")
       ELSE
          TViewTrace (view, "EndResult "
          )
       END
    END
    END
  END EndResult;

PROCEDURE Reveal (view: T;  i: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Reveal ...")
       ELSE
          TViewTrace (view, "Reveal "
          & Fmt.Int(i)
          )
       END
    END
    END
  END Reveal;

PROCEDURE TViewZTrace (view: T; t: TEXT) =
  BEGIN
    IF view.fv # NIL THEN
      IF FormsVBT.GetBoolean(view.fv, "zeus") THEN
        TextPort.PutText(view.te.tp, "**zeus:  " & t & "\n");
        TextPort.Normalize(view.te.tp, LAST(INTEGER))
      END
    END
  END TViewZTrace;

PROCEDURE TViewTrace (view: T; t: TEXT) =
  BEGIN
    TextPort.PutText(view.te.tp, "--event: " & t & "\n");
    TextPort.Normalize(view.te.tp, LAST(INTEGER))
  END TViewTrace;

PROCEDURE TViewNew (): View.T =
  BEGIN
    RETURN NEW(T).init()
  END TViewNew;

BEGIN
  ZeusPanel.RegisterView
      (TViewNew, "Wheeler Transcript View", "Wheeler");
END WheelerTranscriptView.

interface View is in: