This file is indexed.

/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">&lt;&lt; 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>&nbsp;</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&nbsp;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">&lt;</SPAN><A name="label327">Definition of Display</A><SPAN class="chunkborder">&gt;=</SPAN></SPAN></DT><DD class="code"><CODE><SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Display</SPAN>&nbsp;Rs}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">case</SPAN>&nbsp;Rs&nbsp;<SPAN class="keyword">of</SPAN>&nbsp;nil&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<SPAN class="keyword">skip</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">[]</SPAN>&nbsp;R<SPAN class="keyword">|</SPAN>Rr&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{T&nbsp;tk(delete&nbsp;p(0&nbsp;0)&nbsp;<SPAN class="string">'end'</SPAN>)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Head&nbsp;ToyText<SPAN class="keyword">.</SPAN>R<SPAN class="keyword">.</SPAN>head&nbsp;Rr}&nbsp;{Body&nbsp;ToyText<SPAN class="keyword">.</SPAN>R<SPAN class="keyword">.</SPAN>body&nbsp;Rs}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P class="caption"><STRONG>Figure&nbsp;7.3:</STRONG> Displaying a ToyText page.</P><HR></DIV><P> </P><P> <A href="node40.html#figure.text.head">Figure&nbsp;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">&lt;</SPAN><A name="label328">Definition of Head</A><SPAN class="chunkborder">&gt;=</SPAN></SPAN></DT><DD class="code"><CODE><SPAN class="keyword">local</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;HF={New&nbsp;Tk<SPAN class="keyword">.</SPAN>font&nbsp;&nbsp;&nbsp;&nbsp;tkInit(family:helvetica&nbsp;size:18&nbsp;weight:bold)}<BR>&nbsp;&nbsp;&nbsp;HT={New&nbsp;Tk<SPAN class="keyword">.</SPAN>textTag&nbsp;tkInit(parent:T&nbsp;font:HF&nbsp;foreground:orange)}<BR><SPAN class="keyword">in</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Head</SPAN>&nbsp;E&nbsp;Rs}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{T&nbsp;tk(insert&nbsp;p(0&nbsp;0)&nbsp;E<SPAN class="keyword">#</SPAN><SPAN class="string">'\n'</SPAN>&nbsp;HT)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{HT&nbsp;tkBind(event:&nbsp;&nbsp;<SPAN class="string">'&lt;1&gt;'</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action:&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>}&nbsp;{Display&nbsp;Rs}&nbsp;<SPAN class="keyword">end</SPAN>)}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P class="caption"><STRONG>Figure&nbsp;7.4:</STRONG> Displaying the head of a ToyText page.</P><HR></DIV><P> </P><P> <A href="node40.html#figure.text.body">Figure&nbsp;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">&lt;</SPAN><A name="label329">Definition of Body</A><SPAN class="chunkborder">&gt;=</SPAN></SPAN></DT><DD class="code"><CODE><SPAN class="keyword">local</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;BF={New&nbsp;Tk<SPAN class="keyword">.</SPAN>font&nbsp;&nbsp;&nbsp;&nbsp;tkInit(family:helvetica&nbsp;size:12&nbsp;weight:normal)}<BR>&nbsp;&nbsp;&nbsp;BT={New&nbsp;Tk<SPAN class="keyword">.</SPAN>textTag&nbsp;tkInit(parent:T&nbsp;font:BF)}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Do</SPAN>&nbsp;Es&nbsp;CT&nbsp;Rs}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">case</SPAN>&nbsp;Es&nbsp;<SPAN class="keyword">of</SPAN>&nbsp;nil&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<SPAN class="keyword">skip</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">[]</SPAN>&nbsp;E<SPAN class="keyword">|</SPAN>Er&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">case</SPAN>&nbsp;E<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">of</SPAN>&nbsp;a(ref:R&nbsp;Es)&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RT={New&nbsp;Tk<SPAN class="keyword">.</SPAN>textTag&nbsp;tkInit(parent:T&nbsp;font:BF<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreground:blue&nbsp;underline:<SPAN class="keyword">true</SPAN>)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">in</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{RT&nbsp;tkBind(event:&nbsp;<SPAN class="string">'&lt;1&gt;'</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action:&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>}&nbsp;{Display&nbsp;R<SPAN class="keyword">|</SPAN>Rs}&nbsp;<SPAN class="keyword">end</SPAN>)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Do&nbsp;Es&nbsp;RT&nbsp;Rs}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">else</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{T&nbsp;tk(insert&nbsp;<SPAN class="string">'end'</SPAN>&nbsp;E&nbsp;CT)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Do&nbsp;Er&nbsp;CT&nbsp;Rs}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">in</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Body</SPAN>&nbsp;Es&nbsp;Rs}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Do&nbsp;Es&nbsp;BT&nbsp;Rs}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P class="caption"><STRONG>Figure&nbsp;7.5:</STRONG> Displaying the body of a ToyText page.</P><HR></DIV><P> </P><P> <A href="node40.html#figure.text.toy">Figure&nbsp;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">&nbsp;</SPAN>{<SPAN class="functionname">ToyBrowse</SPAN>&nbsp;ToyText&nbsp;Root}<BR>&nbsp;&nbsp;&nbsp;W={New&nbsp;Tk<SPAN class="keyword">.</SPAN>toplevel&nbsp;tkInit}<BR>&nbsp;&nbsp;&nbsp;T={New&nbsp;Tk<SPAN class="keyword">.</SPAN>text&nbsp;tkInit(parent:W&nbsp;width:40&nbsp;height:8&nbsp;bg:white&nbsp;wrap:word)}<BR>&nbsp;&nbsp;&nbsp;</CODE><SPAN class="chunktitle"><SPAN class="chunkborder">&lt;</SPAN><A href="node40.html#label328">Definition of Head</A><SPAN class="chunkborder">&gt;</SPAN></SPAN><CODE>&nbsp;<BR>&nbsp;&nbsp;&nbsp;</CODE><SPAN class="chunktitle"><SPAN class="chunkborder">&lt;</SPAN><A href="node40.html#label329">Definition of Body</A><SPAN class="chunkborder">&gt;</SPAN></SPAN><CODE>&nbsp;<BR>&nbsp;&nbsp;&nbsp;</CODE><SPAN class="chunktitle"><SPAN class="chunkborder">&lt;</SPAN><A href="node40.html#label327">Definition of Display</A><SPAN class="chunkborder">&gt;</SPAN></SPAN><CODE>&nbsp;<BR><SPAN class="keyword">in</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;{Tk<SPAN class="keyword">.</SPAN>send&nbsp;pack(T)}<BR>&nbsp;&nbsp;&nbsp;{Display&nbsp;[Root]}<BR><SPAN class="keyword">end</SPAN>&nbsp;<BR>{ToyBrowse&nbsp;</CODE><SPAN class="chunktitle"><SPAN class="chunkborder">&lt;</SPAN><A href="node46.html#label346">Sample ToyText</A><SPAN class="chunkborder">&gt;</SPAN></SPAN><CODE>&nbsp;canvas}</CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure&nbsp;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">&lt;&lt; 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&nbsp;Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>