The Meta-Environment API

sdf-editor-utils.tb

Go to the documentation of this file.
00001 #ifndef __SDF_EDITOR_UTILS__
00002 #define __SDF_EDITOR_UTILS__
00003 
00004 #include <editing.tb>
00005 #include <config-utils.tb>
00006 
00007 process EditSyntax(ModuleId: module-id) is
00008 let
00009   AlreadyExists: bool,
00010   Available: bool,
00011   EditorType: term,
00012   HasAttribute: bool,
00013   HasText: bool,
00014   HasStructure: bool,
00015   Modulename: str,
00016   Path: str,
00017   Editable: bool,
00018   Sid: session-id,
00019   Event: attribute-changed-event,
00020   Tree: term
00021 in
00022   EditorType := syntax-editor
00023   . GetModulePath(ModuleId, SDF_NAMESPACE, Path?)
00024   . MM-GetAttribute(ModuleId, SDF_NAMESPACE, "name", Modulename?) 
00025   . 
00026   if equal(Path, EMPTY_PATH) then
00027     TODO("dit is ook raar\n")
00028     . BuildPath(".", Modulename, SDF_EXTENSION, Path?)
00029     . printf("EditSyntax: Use CreateNewModule instead???\n")
00030   else
00031     tau
00032   fi
00033   . Edit(Path, Sid?)
00034   .
00035   if not-equal(Sid, UNDEFINED) then
00036     EditText(Sid, EditorType, AlreadyExists?)
00037     . snd-msg(te-set-tooltip(Sid, Modulename))
00038     . snd-msg(syntax-editor-started(ModuleId, Sid))
00039     .
00040     if equal(AlreadyExists, false) then
00041       MM-HasAttribute(ModuleId, SDF_NAMESPACE, "editable", HasAttribute?)
00042       .
00043       if equal(HasAttribute, true) then
00044         MM-GetAttribute(ModuleId, SDF_NAMESPACE, "editable", Editable?)
00045       else
00046         Editable := true
00047       fi
00048       . snd-msg(te-set-editable(Sid, Editable))
00049       . snd-msg(em-bind-session(Sid, ModuleId))
00050       . rec-msg(em-session-bound(Sid, ModuleId))
00051       . GetSDFParsetree(ModuleId, Tree?)
00052       . SE-UpdateTree(Sid, Tree)
00053       . MM-Subscribe-Attribute-Changed(ModuleId,SDF_NAMESPACE,"status",<term>,parsed)
00054       .
00055       (
00056         MenuSelected(Sid, EditorType)
00057       +
00058         MouseClicked(Sid)
00059       +
00060         rec-msg(te-contents-changed(Sid))
00061         . MM-SetAttribute(ModuleId, SDF_NAMESPACE, "status", edited)
00062         . RemoveSummaryFor(Path)
00063       +
00064         rec-msg(te-contents-saved(Sid))
00065         . UpdateTextRepository(Sid)
00066         . MM-SetAttribute(ModuleId, SDF_NAMESPACE, "status", available)
00067         . UpdateSyntaxStructure(Sid)
00068       +
00069         rec-note(mm-attribute-changed(Event?))
00070         . UpdateSyntaxStructure(Sid)
00071       )
00072       *
00073       EditorDisconnected(Sid)
00074       . DeleteSession(Sid)
00075     else
00076       tau
00077     fi
00078   else
00079     tau
00080   fi
00081 endlet
00082 
00083 process UpdateSyntaxStructure(Sid: session-id) is
00084 let
00085   ModuleId: module-id,
00086   Slices: list,
00087   Tree: term
00088 in
00089   GetModuleId(Sid, ModuleId?)
00090   . GetSDFParsetree(ModuleId, Tree?)
00091   . SE-UpdateTree(Sid, Tree) 
00092 endlet
00093 
00094 #endif /* __SDF_EDITOR_UTILS__ */

Generated on Fri Sep 12 13:09:47 2008 for sdf-meta by  doxygen 1.4.6