/usr/share/mozart/doc/wp/node40.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>7.3 Example: A ToyText Browser</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node39.html#section.text.tags"><< Prev</A></TD><TD><A href="node37.html">- Up -</A></TD></TR></TABLE><DIV id="section.text.toy"><H2><A name="section.text.toy">7.3 Example: A ToyText Browser</A></H2><P> In the following we discuss a tiny ToyText browser that supports following of links in the text and going back to previously displayed pages. A ToyText hypertext is a record, where the features are the links and the fields describe pages. For an example, see <A href="node46.html#data.text.toy">*</A>. A page consists out of head and body, where the body is a list of elements. An element is either a virtual string or a record <CODE>a(ref:</CODE><CODE><I>R</I></CODE><CODE> </CODE><CODE><I>Es</I></CODE><CODE>)</CODE>, where <CODE><I>R</I></CODE> is a feature of the record and <CODE><I>Es</I></CODE> is a list of elements. </P><P> <A href="node40.html#figure.text.display">Figure 7.3</A> shows the main routine to display a ToyText page in a text widget <CODE>T</CODE>. The procedure <CODE>Display</CODE> takes a list of references <CODE>Rs</CODE> as input, and displays the page that is referred to by its first element. </P><P> </P><DIV id="figure.text.display"><HR><P><A name="figure.text.display"></A></P><DL><DT><SPAN class="chunktitle"><SPAN class="chunkborder"><</SPAN><A name="label327">Definition of Display</A><SPAN class="chunkborder">>=</SPAN></SPAN></DT><DD class="code"><CODE><SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Display</SPAN> Rs}<BR> <SPAN class="keyword">case</SPAN> Rs <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">[]</SPAN> R<SPAN class="keyword">|</SPAN>Rr <SPAN class="keyword">then</SPAN> <BR> {T tk(delete p(0 0) <SPAN class="string">'end'</SPAN>)}<BR> {Head ToyText<SPAN class="keyword">.</SPAN>R<SPAN class="keyword">.</SPAN>head Rr} {Body ToyText<SPAN class="keyword">.</SPAN>R<SPAN class="keyword">.</SPAN>body Rs}<BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P class="caption"><STRONG>Figure 7.3:</STRONG> Displaying a ToyText page.</P><HR></DIV><P> </P><P> <A href="node40.html#figure.text.head">Figure 7.4</A> shows how the head of a ToyText page is displayed, where <CODE>E</CODE> is the virtual string to be displayed and <CODE>Rs</CODE> is the list of current references without its first element. The tag <CODE>HT</CODE> is configured such that clicking it displays the previous page. </P><P> </P><DIV id="figure.text.head"><HR><P><A name="figure.text.head"></A></P><DL><DT><SPAN class="chunktitle"><SPAN class="chunkborder"><</SPAN><A name="label328">Definition of Head</A><SPAN class="chunkborder">>=</SPAN></SPAN></DT><DD class="code"><CODE><SPAN class="keyword">local</SPAN> <BR> HF={New Tk<SPAN class="keyword">.</SPAN>font tkInit(family:helvetica size:18 weight:bold)}<BR> HT={New Tk<SPAN class="keyword">.</SPAN>textTag tkInit(parent:T font:HF foreground:orange)}<BR><SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Head</SPAN> E Rs}<BR> {T tk(insert p(0 0) E<SPAN class="keyword">#</SPAN><SPAN class="string">'\n'</SPAN> HT)}<BR> {HT tkBind(event: <SPAN class="string">'<1>'</SPAN> <BR> action: <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>} {Display Rs} <SPAN class="keyword">end</SPAN>)}<BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P class="caption"><STRONG>Figure 7.4:</STRONG> Displaying the head of a ToyText page.</P><HR></DIV><P> </P><P> <A href="node40.html#figure.text.body">Figure 7.5</A> shows how the body of a ToyText page is displayed, where <CODE>Es</CODE> is the list of elements, <CODE>CT</CODE> is the current tag to which inserted text is added, and <CODE>Rs</CODE> are the current references, including a reference to the page currently under display as first element. To display a reference element, a new tag <CODE>RT</CODE> is created that carries as action a procedure that displays the referred page. </P><P> </P><DIV id="figure.text.body"><HR><P><A name="figure.text.body"></A></P><DL><DT><SPAN class="chunktitle"><SPAN class="chunkborder"><</SPAN><A name="label329">Definition of Body</A><SPAN class="chunkborder">>=</SPAN></SPAN></DT><DD class="code"><CODE><SPAN class="keyword">local</SPAN> <BR> BF={New Tk<SPAN class="keyword">.</SPAN>font tkInit(family:helvetica size:12 weight:normal)}<BR> BT={New Tk<SPAN class="keyword">.</SPAN>textTag tkInit(parent:T font:BF)}<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Do</SPAN> Es CT Rs}<BR> <SPAN class="keyword">case</SPAN> Es <SPAN class="keyword">of</SPAN> nil <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">[]</SPAN> E<SPAN class="keyword">|</SPAN>Er <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">case</SPAN> E<BR> <SPAN class="keyword">of</SPAN> a(ref:R Es) <SPAN class="keyword">then</SPAN> <BR> RT={New Tk<SPAN class="keyword">.</SPAN>textTag tkInit(parent:T font:BF<BR> foreground:blue underline:<SPAN class="keyword">true</SPAN>)}<BR> <SPAN class="keyword">in</SPAN> <BR> {RT tkBind(event: <SPAN class="string">'<1>'</SPAN> <BR> action: <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>} {Display R<SPAN class="keyword">|</SPAN>Rs} <SPAN class="keyword">end</SPAN>)}<BR> {Do Es RT Rs}<BR> <SPAN class="keyword">else</SPAN> <BR> {T tk(insert <SPAN class="string">'end'</SPAN> E CT)}<BR> <SPAN class="keyword">end</SPAN> <BR> {Do Er CT Rs}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Body</SPAN> Es Rs}<BR> {Do Es BT Rs}<BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P class="caption"><STRONG>Figure 7.5:</STRONG> Displaying the body of a ToyText page.</P><HR></DIV><P> </P><P> <A href="node40.html#figure.text.toy">Figure 7.6</A> shows the complete ToyText browser and how it looks when displaying pages. </P><P> </P><DIV id="figure.text.toy"><HR><P><A name="figure.text.toy"></A></P><P> </P><DIV align="center"><IMG alt="" src="toy.gif"></DIV><P> </P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">ToyBrowse</SPAN> ToyText Root}<BR> W={New Tk<SPAN class="keyword">.</SPAN>toplevel tkInit}<BR> T={New Tk<SPAN class="keyword">.</SPAN>text tkInit(parent:W width:40 height:8 bg:white wrap:word)}<BR> </CODE><SPAN class="chunktitle"><SPAN class="chunkborder"><</SPAN><A href="node40.html#label328">Definition of Head</A><SPAN class="chunkborder">></SPAN></SPAN><CODE> <BR> </CODE><SPAN class="chunktitle"><SPAN class="chunkborder"><</SPAN><A href="node40.html#label329">Definition of Body</A><SPAN class="chunkborder">></SPAN></SPAN><CODE> <BR> </CODE><SPAN class="chunktitle"><SPAN class="chunkborder"><</SPAN><A href="node40.html#label327">Definition of Display</A><SPAN class="chunkborder">></SPAN></SPAN><CODE> <BR><SPAN class="keyword">in</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>send pack(T)}<BR> {Display [Root]}<BR><SPAN class="keyword">end</SPAN> <BR>{ToyBrowse </CODE><SPAN class="chunktitle"><SPAN class="chunkborder"><</SPAN><A href="node46.html#label346">Sample ToyText</A><SPAN class="chunkborder">></SPAN></SPAN><CODE> canvas}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure 7.6:</STRONG> A ToyText browser.</P><HR></DIV><P> </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node39.html#section.text.tags"><< Prev</A></TD><TD><A href="node37.html">- Up -</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|