Manual initial view creation

Our specifications state that we must be able to open a view on the tool's initial environment through the popup menu. We must also be able to clear the initial environment through a button in the popup menu. We will do so by adding elements to the tool network to emit and receive the appropriate signals.

First, we add the button to the decoration creation function to emit the signals open-view and clear:


(de :create-decoration (ctview network)
    ;;Use the convenience function of Exp.ll
    (#:Exp-environment:handle-button network "Eval Exp" 'interpret)
    (#:Exp-environment:handle-button network "Init View" 'open-view)
    (#:Exp-environment:handle-button network "Clear" 'clear-views))

Then, in the function :create-initial-view-spy, we encapsulate the tool to listen for these signals.


;;;;;;;;;;;;;;;;
;;Initial view
;;;;;;;;;;;;;;;;
(st-declare Exp-initial-env (open-view clear-views) ())

(de :create-initial-view-spy (tool network)
    (let ((stnode (st-create 'Exp-initial-env)))
       ;;Encapsulate tool.
      (st-store-and-set-action stnode tool ':initial-env-callback)
       ;;Include both stnodes in tool network.
      (st-include network stnode)
      ))

(de :initial-env-callback:open-view (stnode port)
    (lets ((tool (st-object stnode))
           (tool-network (st-up stnode))
           (var (send 'initial-environment tool))
           (ctview (with ((current-manager 
                             #:gfxobj:look:ctview:plain-manager))
                      (map-ctview-var "Initial view" var
                                       () () () () () ())))
           (view-network (:env-view:adjust ctview tool-network))
           )
       ;;Remove "File" pulldown from ctview (position 0).
       ({editor-view}:delete-menu ctview () 0)
       ;;Make view network depend on principal network
       ;;so that initial env view dies when source dies.
       (st-dependent-network tool-network view-network)
       view-network
       ))

(de :initial-env-callback:clear-views (stnode port)
    (lets ((tool (st-object stnode)))
       ;;Clear initial environment tree and redisplay ctedits.
       (:tool:set-initial-env tool ())
       ;;Clear old messages and ctedit source selections.
       (clear-std-environment tool)
       ))

N.B.


Tutorial