gSyntax10.Scn.FntInfoElemsAllocVSyntax10.Scn.FntStampElemsAlloc23 Jul 980"Title": WebImages "Author": Andreas Krumenacker "Abstract": WebImages is a part of the Oberon-Web-Browser. "Keywords": pictures, images "Version": no version "From": 15 Jan 98 "Until":  "Changes": no changes so far "Hints": no hints 8FoldElemsNewSyntax10.Scn.FntCBalloonElemsAlloc#Syntax10.Scn.Fnt"WebImages" WebImages is a part of the Oberon-Web-Browser. "Install" WebImages.Install This command is used to force the loading of module WebImages. 8@8#Syntax10.Scn.FntQQ profSect = "WebImages"; profExt = "ext"; profMime = "mime"; title = "Image"; 8<8Syntax10.Scn.Fnt 8FoldElemsNew#Syntax10.Scn.Fnt00 ImageDesc = RECORD (Web.PresentatorDesc) END;8R8#Syntax10.Scn.Fnt TaskDesc = RECORD (Web.TaskDesc) ldr : Pictures.LoadInfo; imgE : WebElems.ImageElem; setTitle : BOOLEAN; act : Web.UrlStack; END;8D Image = POINTER TO ImageDesc;  Task = POINTER TO TaskDesc;  88#Syntax10.Scn.Fnt w : Texts.Writer; 8C8#Syntax10.Scn.Fnt VAR nStr : ARRAY 8 OF CHAR; docTitle : ARRAY 32 OF CHAR; i, j : INTEGER; BEGIN docTitle := title; i := 0; WHILE docTitle[i] # 0X DO INC(i) END; docTitle[i] := 20X; INC(i); Web.Int2Str(width, nStr); j := 0; WHILE nStr[j] # 0X DO docTitle[i+j] := nStr[j]; INC(j) END; docTitle[i+j] := "x"; INC(i, j + 1); Web.Int2Str(height, nStr); j := 0; WHILE nStr[j] # 0X DO docTitle[i+j] := nStr[j]; INC(j) END; docTitle[i+j] := 0X; Web.SetDocTitle(docTitle, txt) END SetDocTitle;88#Syntax10.Scn.Fnt^^ VAR thisTask : Task; prevBytes : LONGINT; done : BOOLEAN; BEGIN thisTask := Oberon.CurTask(Task); done := thisTask.cancelled; IF ~ done THEN prevBytes := thisTask.ldr.usedBytes; thisTask.ldr.Do; done := (thisTask.ldr.res = Pictures.done) OR (thisTask.ldr.res = Pictures.error) END; IF done OR ((thisTask.fi.len.act > 0) & (prevBytes = thisTask.ldr.usedBytes)) THEN IF thisTask.ldr.res = Pictures.error THEN thisTask.fi.len.def := 0 ELSIF (thisTask.ldr.res = Pictures.done) & (thisTask.fi.len.def = Web.undefinedLen) THEN thisTask.fi.len.def := thisTask.ldr.usedBytes END; WebElems.SetLoadResult(thisTask.imgE, thisTask.ldr.res = Pictures.done); IF (thisTask.ldr.picture # NIL) & (thisTask.ldr.picture.depth > 0) THEN thisTask.ldr.Completed; IF thisTask.setTitle & (thisTask.ldr.res = Pictures.done) THEN SetDocTitle(thisTask.imgE.pic.width, thisTask.imgE.pic.height, thisTask.txt) END ELSE Web.LogF("WebImages: failed to allocate memory for image (pos=#)$", Texts.ElemPos(thisTask.imgE)) END; Web.RemoveTask(thisTask); Oberon.Remove(thisTask) END END ShowImage;88#Syntax10.Scn.FntDD CONST checkLength = 10; VAR thisTask : Task; thisFile : Files.File; name : ARRAY 64 OF CHAR; src : ARRAY 512 OF CHAR; done : BOOLEAN; BEGIN thisTask := Oberon.CurTask(Task); thisFile := Files.Base(thisTask.fi.r); done := thisTask.cancelled; IF ~ done & (Files.Length(thisFile) >= checkLength) THEN thisTask.ldr := Pictures.Load(thisFile, 0); IF (thisTask.ldr # NIL) & (thisTask.ldr.res # Pictures.error) THEN IF thisTask.imgE = NIL THEN Web.ValidateText(thisTask.txt); IF thisTask.txt.len = 0 THEN thisTask.imgE := WebElems.NewImage(); Texts.WriteElem(w, thisTask.imgE); Texts.Append(thisTask.txt, w.buf); thisTask.txt.act := thisTask.act; thisTask.txt.base := NIL; Web.Url2Str(thisTask.act.url, src); WebElems.SetSource(thisTask.imgE, src, FALSE); Web.GetFileName(name, thisTask.fi.local, thisTask.txt.act.url); Web.SetDocName(name, thisTask.txt); Web.SetDocTitle(title, thisTask.txt) ELSE thisTask.fi.len.def := 0; done := TRUE END END; IF thisTask.imgE # NIL THEN IF thisTask.ldr.picture = NIL THEN thisTask.ldr.picture := thisTask.imgE.pic ELSE WebElems.ExchangePic(thisTask.imgE, thisTask.ldr.picture) END; thisTask.handle := ShowImage END ELSIF thisTask.imgE = NIL THEN Web.RejectFile(thisTask.fi, thisTask.act, thisTask.txt, thisTask.imgE); done := TRUE ELSE thisTask.fi.len.def := 0; done := TRUE END END; IF done OR ((thisTask.ldr # NIL) & (thisTask.ldr.picture = NIL)) THEN Web.RemoveTask(thisTask); Oberon.Remove(thisTask) END END CheckImage;8k8CSyntax10.Scn.FntSyntax10i.Scn.Fnt $  VAR task : Task; BEGIN ASSERT((fi # NIL) & (txt # NIL) & (act # NIL) & (act.url # NIL)); IF (elem = NIL) OR (elem IS WebElems.ImageElem) THEN NEW(task); task.safe := FALSE; task.time := 0; task.handle := CheckImage; task.txt := txt; task.fi := fi; task.ldr := NIL; IF elem # NIL THEN task.imgE := elem(WebElems.ImageElem); task.setTitle := FALSE; ELSE task.imgE := NIL; task.setTitle := TRUE END; task.act := act; Web.AddTask(task); Oberon.Install(task) ELSE (* unknown elem *) fi.len.def := 0 END END Open;8 Syntax10b.Scn.Fnt8CSyntax10.Scn.Fnt Syntax10i.Scn.Fnt$> BEGIN (* only used to force loading of module *) END Install;88sSyntax10.Scn.Fnt\8FoldElemsNew#Syntax10.Scn.Fnt VAR image : Image; BEGIN WHILE prof # NIL DO IF prof.class IN {Texts.Name, Texts.String} THEN NEW(image); COPY(prof.str, image.content); Web.InstallPresentator(image) END; prof := prof.next END; END InstallPresentators;8 VAR prof : Web.ProfileEntry; PROCEDURE InstallPresentators (prof : Web.ProfileEntry);  BEGIN Web.GetProfile(profSect, profExt, prof); InstallPresentators(prof); Web.GetProfile(profSect, profMime, prof); InstallPresentators(prof) END InstallImages;88#Syntax10.Scn.Fnt$$ Texts.OpenWriter(w); InstallImages8MODULE WebImages;   IMPORT Files, Texts, Oberon, Pictures, Web, WebElems; CONST  TYPE  VAR  PROCEDURE SetDocTitle (width, height : INTEGER; txt : Web.Text);  PROCEDURE ShowImage;  PROCEDURE CheckImage;  PROCEDURE (img : Image) Open (act : Web.UrlStack; txt : Web.Text; fi : Web.FileInfo; elem : Texts.Elem);  PROCEDURE Install*;  PROCEDURE InstallImages;  BEGIN  END WebImages.