/usr/share/mozart/doc/demo/node38.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>Graphical Front-End: TkDictionary.oz</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="node37.html#code.dict-client.netdictionary"><< Prev</A></TD><TD><A href="dict-client.html">- Up -</A></TD><TD><A href="node39.html#code.dict-client.main">Next >></A></TD></TR></TABLE><DIV class="unnumbered" id="code.dict-client.tkdictionary"><H3><A name="code.dict-client.tkdictionary">Graphical Front-End: <CODE>TkDictionary.oz</CODE></A></H3><DIV class="apropos"><P class="margin"><A href="DictClient/TkDictionary.oz">Source File</A></P><P> </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN> <BR><SPAN class="keyword">import</SPAN> <BR> Tk(toplevel action frame label entry listbox scrollbar addYScrollbar<BR> button text send batch return returnInt isColor)<BR> TkTools(images menubar error dialog)<BR> Open(file)<BR> NetDictionary(<SPAN class="string">'class'</SPAN> <BR> defaultServer: DEFAULT_SERVER<BR> defaultPort: DEFAULT_PORT)<BR><SPAN class="keyword">export</SPAN> <BR> <SPAN class="string">'class'</SPAN>: TkDictionary<BR><SPAN class="keyword">require</SPAN> <BR> DemoUrls(image) <SPAN class="keyword">at</SPAN> <SPAN class="string">'../DemoUrls.ozf'</SPAN> <BR><SPAN class="keyword">prepare</SPAN> <BR> FixedFont = <SPAN class="string">'8x13'</SPAN> <BR> BoldFixedFont = <SPAN class="string">'8x13bold'</SPAN> <BR> BoldFont = <SPAN class="string">'-*-helvetica-bold-r-normal--*-120-*-*-*-*-*-*'</SPAN> <BR> NormalFont = <SPAN class="string">'-*-helvetica-medium-r-normal--*-120-*-*-*-*-*-*'</SPAN> <BR> <BR> ServerWidth = 20<BR> IPad = 4<BR> TextBackground = c(239 239 239)<BR> WordWidth = 42<BR> ButtonPad = 10<BR> ListHeight = 8<BR> ScrollBorder = 1<BR> ScrollWidth = 12<BR> LogWidth = 40<BR> LogHeight = 4<BR> Pad = 0<BR> <BR> %% <SPAN class="comment">The following databases and strategies are always available.<BR></SPAN> DEFAULT_DATABASES = [<SPAN class="string">'*'</SPAN><SPAN class="keyword">#</SPAN><SPAN class="string">'All'</SPAN> <BR> <SPAN class="string">'!'</SPAN><SPAN class="keyword">#</SPAN><SPAN class="string">'First with matches'</SPAN>]<BR> DEFAULT_STRATEGIES = [<SPAN class="string">'.'</SPAN><SPAN class="keyword">#</SPAN><SPAN class="string">'Default'</SPAN> <BR> <SPAN class="string">'exact'</SPAN><SPAN class="keyword">#</SPAN><SPAN class="string">'Match words exactly'</SPAN> <BR> <SPAN class="string">'prefix'</SPAN><SPAN class="keyword">#</SPAN><SPAN class="string">'Match prefixes'</SPAN>]<BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">FormatDBs</SPAN> DBs DatabaseNames}<BR> {FoldR DBs<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> DB In}<BR> {CondSelect DatabaseNames DB DB}<SPAN class="keyword">#</SPAN> <BR> <SPAN class="keyword">case</SPAN> In <SPAN class="keyword">of</SPAN> <SPAN class="keyword">unit</SPAN> <SPAN class="keyword">then</SPAN> <SPAN class="string">""</SPAN> <BR> <SPAN class="keyword">else</SPAN> <SPAN class="string">', '</SPAN><SPAN class="keyword">#</SPAN>In<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <SPAN class="keyword">unit</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Clean</SPAN> S}<BR> {FoldR S<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> C In}<BR> <SPAN class="keyword">if</SPAN> C <SPAN class="keyword">=<</SPAN> <SPAN class="string">& </SPAN> <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">case</SPAN> In <SPAN class="keyword">of</SPAN> <SPAN class="string">& </SPAN><SPAN class="keyword">|</SPAN>_ <SPAN class="keyword">then</SPAN> In<BR> <SPAN class="keyword">else</SPAN> <SPAN class="string">& </SPAN><SPAN class="keyword">|</SPAN>In<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">else</SPAN> C<SPAN class="keyword">|</SPAN>In<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> nil}<BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">define</SPAN> <BR> Images = {TkTools<SPAN class="keyword">.</SPAN>images [DemoUrls<SPAN class="keyword">.</SPAN>image<SPAN class="keyword">#</SPAN><SPAN class="string">'dict-client/dict.gif'</SPAN>]}<BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">SetMinsize</SPAN> W}<BR> {Tk<SPAN class="keyword">.</SPAN>send update(idletasks)}<BR> {Tk<SPAN class="keyword">.</SPAN>send wm(minsize W<BR> {Tk<SPAN class="keyword">.</SPAN>returnInt winfo(reqwidth W)}<BR> {Tk<SPAN class="keyword">.</SPAN>returnInt winfo(reqheight W)})}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %%<SPAN class="comment"> <BR></SPAN> %% <SPAN class="comment">Dialog to Enter a Server Address and Port<BR></SPAN> %%<SPAN class="comment"> <BR></SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">ServerDialog</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(Master Server Port Connect)<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">DoConnect</SPAN>} Server Port <SPAN class="keyword">in</SPAN> <BR> {ServerEntry tkReturn(get ?Server)}<BR> {PortEntry tkReturn(get ?Port)}<BR> <SPAN class="keyword">if</SPAN> {String<SPAN class="keyword">.</SPAN>isInt Port} <SPAN class="keyword">then</SPAN> <BR> {Toplevel tkClose()}<BR> {Connect Server {String<SPAN class="keyword">.</SPAN>toInt Port}}<BR> <SPAN class="keyword">else</SPAN> <BR> {New TkTools<SPAN class="keyword">.</SPAN>error<BR> tkInit(master: Toplevel<BR> text: <SPAN class="string">'The port must be given as a number.'</SPAN>) _}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> Toplevel = {New Tk<SPAN class="keyword">.</SPAN>toplevel tkInit(parent: Master<BR> title: <SPAN class="string">'Choose Server'</SPAN> <BR> <SPAN class="string">'class'</SPAN>: <SPAN class="string">'OzTools'</SPAN> <BR> highlightthickness: 0<BR> withdraw: <SPAN class="keyword">true</SPAN>)}<BR> {Toplevel tkBind(event: <SPAN class="string">'<Escape>'</SPAN> <BR> action: Toplevel<SPAN class="keyword">#</SPAN>tkClose())}<BR> Frame1 = {New Tk<SPAN class="keyword">.</SPAN>frame tkInit(parent: Toplevel<BR> highlightthickness: 0<BR> borderwidth: 1<BR> relief: raised)}<BR> ServerLabel = {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent: Frame1<BR> font: BoldFont<BR> text: <SPAN class="string">'Server: '</SPAN>)}<BR> ServerEntry = {New Tk<SPAN class="keyword">.</SPAN>entry tkInit(parent: Frame1<BR> font: FixedFont<BR> width: ServerWidth<BR> background: TextBackground<BR> borderwidth: 1)}<BR> {ServerEntry tkBind(event: <SPAN class="string">'<Return>'</SPAN> <BR> action: DoConnect)}<BR> {ServerEntry tk(insert <SPAN class="string">'end'</SPAN> <SPAN class="keyword">case</SPAN> Server <SPAN class="keyword">of</SPAN> <SPAN class="keyword">unit</SPAN> <SPAN class="keyword">then</SPAN> DEFAULT_SERVER<BR> <SPAN class="keyword">else</SPAN> Server<BR> <SPAN class="keyword">end</SPAN>)}<BR> PortLabel = {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent: Frame1<BR> font: BoldFont<BR> text: <SPAN class="string">'Port: '</SPAN>)}<BR> PortEntry = {New Tk<SPAN class="keyword">.</SPAN>entry tkInit(parent: Frame1<BR> font: FixedFont<BR> width: ServerWidth<BR> background: TextBackground<BR> borderwidth: 1)}<BR> {PortEntry tkBind(event: <SPAN class="string">'<Return>'</SPAN> <BR> action: DoConnect)}<BR> {PortEntry tk(insert <SPAN class="string">'end'</SPAN> <SPAN class="keyword">case</SPAN> Port <SPAN class="keyword">of</SPAN> <SPAN class="keyword">unit</SPAN> <SPAN class="keyword">then</SPAN> DEFAULT_PORT<BR> <SPAN class="keyword">else</SPAN> Port<BR> <SPAN class="keyword">end</SPAN>)}<BR> Frame2 = {New Tk<SPAN class="keyword">.</SPAN>frame tkInit(parent: Toplevel<BR> highlightthickness: 0<BR> borderwidth: 1<BR> relief: raised)}<BR> ConnectButton = {New Tk<SPAN class="keyword">.</SPAN>button tkInit(parent: Frame2<BR> text: <SPAN class="string">'Connect'</SPAN> <BR> action: DoConnect)}<BR> CloseButton = {New Tk<SPAN class="keyword">.</SPAN>button tkInit(parent: Frame2<BR> text: <SPAN class="string">'Cancel'</SPAN> <BR> action: Toplevel<SPAN class="keyword">#</SPAN>tkClose())}<BR> <SPAN class="keyword">in</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>batch [pack(Frame1 side: top expand: <SPAN class="keyword">true</SPAN> fill: both<BR> ipadx: IPad ipady: IPad)<BR> pack(Frame2 side: top expand: <SPAN class="keyword">true</SPAN> fill: both<BR> ipadx: IPad ipady: IPad)<BR> grid(ServerLabel row: 0 column: 0 sticky: w)<BR> grid(ServerEntry row: 0 column: 1)<BR> grid(PortLabel row: 1 column: 0 sticky: w)<BR> grid(PortEntry row: 1 column: 1)<BR> pack(ConnectButton CloseButton side: left expand: <SPAN class="keyword">true</SPAN>)<BR> focus(ServerEntry)]}<BR> {SetMinsize Toplevel}<BR> {Tk<SPAN class="keyword">.</SPAN>send wm(deiconify Toplevel)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %%<SPAN class="comment"> <BR></SPAN> %% <SPAN class="comment">A Simple Information Display Window<BR></SPAN> %%<SPAN class="comment"> <BR></SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">InformationWindow</SPAN> <BR> <SPAN class="keyword">feat</SPAN> toplevel text status<BR> <SPAN class="keyword">attr</SPAN> Withdrawn: <SPAN class="keyword">true</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(Master Title cursor: Cursor <SPAN class="keyword"><=</SPAN> xterm status: Status <SPAN class="keyword"><=</SPAN> <SPAN class="keyword">false</SPAN>)<BR> <SPAN class="keyword">self.</SPAN>toplevel = {New Tk<SPAN class="keyword">.</SPAN>toplevel tkInit(parent: Master<BR> title: Title<BR> <SPAN class="string">'class'</SPAN>: <SPAN class="string">'OzTools'</SPAN> <BR> highlightthickness: 0<BR> withdraw: <SPAN class="keyword">true</SPAN>)}<BR> Menu = {TkTools<SPAN class="keyword">.</SPAN>menubar <SPAN class="keyword">self.</SPAN>toplevel <SPAN class="keyword">self.</SPAN>toplevel<BR> [menubutton(text: <SPAN class="string">'File'</SPAN> <BR> feature: file<BR> menu: [command(label: <SPAN class="string">'Save as ...'</SPAN> <BR> action: <SPAN class="keyword">self#</SPAN>SaveAs())<BR> separator<BR> command(label: <SPAN class="string">'Close window'</SPAN> <BR> key: ctrl(x)<BR> action: <SPAN class="keyword">self#</SPAN>close())])<BR> menubutton(text: <SPAN class="string">'Edit'</SPAN> <BR> feature: edit<BR> menu: [command(label: <SPAN class="string">'Select all'</SPAN> <BR> action: <SPAN class="keyword">self#</SPAN>SelectAll())])]<BR> nil}<BR> <SPAN class="keyword">self.</SPAN>text = {New Tk<SPAN class="keyword">.</SPAN>text tkInit(parent: <SPAN class="keyword">self.</SPAN>toplevel<BR> cursor: Cursor<BR> font: FixedFont<BR> background: TextBackground<BR> state: disabled)}<BR> {<SPAN class="keyword">self.</SPAN>text tk(tag configure titleTag font: BoldFixedFont)}<BR> Scrollbar = {New Tk<SPAN class="keyword">.</SPAN>scrollbar tkInit(parent: <SPAN class="keyword">self.</SPAN>toplevel<BR> borderwidth: ScrollBorder<BR> width: ScrollWidth)}<BR> {Tk<SPAN class="keyword">.</SPAN>addYScrollbar <SPAN class="keyword">self.</SPAN>text Scrollbar}<BR> <SPAN class="keyword">if</SPAN> Status <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">self.</SPAN>status = {New Tk<SPAN class="keyword">.</SPAN>text tkInit(parent: <SPAN class="keyword">self.</SPAN>toplevel<BR> cursor: left_ptr<BR> border: 0<BR> wrap: none<BR> font: NormalFont<BR> width: 0<BR> height: 1<BR> state: disabled)}<BR> <SPAN class="keyword">else</SPAN> <BR> <SPAN class="keyword">self.</SPAN>status = <SPAN class="keyword">unit</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">in</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>batch<BR> grid(columnconfigure <SPAN class="keyword">self.</SPAN>toplevel 0 weight: 1)<SPAN class="keyword">|</SPAN> <BR> grid(rowconfigure <SPAN class="keyword">self.</SPAN>toplevel 1 weight: 1)<SPAN class="keyword">|</SPAN> <BR> grid(Menu row: 0 column: 0 columnspan: 2 sticky: nsew)<SPAN class="keyword">|</SPAN> <BR> grid(<SPAN class="keyword">self.</SPAN>text row: 1 column: 0 sticky: nsew)<SPAN class="keyword">|</SPAN> <BR> grid(Scrollbar row: 1 column: 1 sticky: nsew)<SPAN class="keyword">|</SPAN> <BR> <SPAN class="keyword">if</SPAN> Status <SPAN class="keyword">then</SPAN> <BR> [grid(<SPAN class="keyword">self.</SPAN>status row: 2 column: 0 columnspan: 2 sticky: nsew)]<BR> <SPAN class="keyword">else</SPAN> nil<BR> <SPAN class="keyword">end</SPAN>}<BR> {SetMinsize <SPAN class="keyword">self.</SPAN>toplevel}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">append</SPAN>(VS Tag <SPAN class="keyword"><=</SPAN> <SPAN class="keyword">unit</SPAN>)<BR> <SPAN class="keyword">try</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>batch [o(<SPAN class="keyword">self.</SPAN>text configure state: normal)<BR> <SPAN class="keyword">case</SPAN> Tag <SPAN class="keyword">of</SPAN> <SPAN class="keyword">unit</SPAN> <SPAN class="keyword">then</SPAN> o(<SPAN class="keyword">self.</SPAN>text insert <SPAN class="string">'end'</SPAN> VS)<BR> <SPAN class="keyword">else</SPAN> o(<SPAN class="keyword">self.</SPAN>text insert <SPAN class="string">'end'</SPAN> VS Tag)<BR> <SPAN class="keyword">end</SPAN> <BR> o(<SPAN class="keyword">self.</SPAN>text configure state: disabled)]}<BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>Withdrawn <SPAN class="keyword">then</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>send wm(deiconify <SPAN class="keyword">self.</SPAN>toplevel)}<BR> Withdrawn <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">false</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">catch</SPAN> _ <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> % <SPAN class="comment">window already closed<BR></SPAN> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">status</SPAN>(VS)<BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>Withdrawn <SPAN class="keyword">then</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>send wm(deiconify <SPAN class="keyword">self.</SPAN>toplevel)}<BR> Withdrawn <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">false</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>batch [o(<SPAN class="keyword">self.</SPAN>status configure state: normal)<BR> o(<SPAN class="keyword">self.</SPAN>status delete p(1 0) <SPAN class="string">'end'</SPAN>)<BR> o(<SPAN class="keyword">self.</SPAN>status insert <SPAN class="string">'end'</SPAN> VS)<BR> o(<SPAN class="keyword">self.</SPAN>status configure state: disabled)]}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">close</SPAN>()<BR> {<SPAN class="keyword">self.</SPAN>toplevel tkClose()}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">SaveAs</SPAN>() FileName <SPAN class="keyword">in</SPAN> <BR> FileName =<BR> {Tk<SPAN class="keyword">.</SPAN>return tk_getSaveFile(parent: <SPAN class="keyword">self.</SPAN>toplevel<BR> title: <SPAN class="string">'Save Text'</SPAN> <BR> filetypes: q(q(<SPAN class="string">'All Files'</SPAN> <SPAN class="string">'*'</SPAN>)))}<BR> <SPAN class="keyword">if</SPAN> FileName <SPAN class="keyword">==</SPAN> <SPAN class="string">""</SPAN> <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">else</SPAN> File <SPAN class="keyword">in</SPAN> <BR> File = {New Open<SPAN class="keyword">.</SPAN>file init(name: FileName<BR> flags: [write create truncate])}<BR> {File write(vs: {<SPAN class="keyword">self.</SPAN>text tkReturn(get p(1 0) <SPAN class="string">'end'</SPAN> $)})}<BR> {File close()}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">SelectAll</SPAN>()<BR> {<SPAN class="keyword">self.</SPAN>text tk(tag add <SPAN class="string">'sel'</SPAN> p(1 0) <SPAN class="string">'end'</SPAN>)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %%<SPAN class="comment"> <BR></SPAN> %% <SPAN class="comment">A Window to Display Definitions<BR></SPAN> %%<SPAN class="comment"> <BR></SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">DefinitionWindow</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> InformationWindow</SPAN> <BR> <SPAN class="keyword">attr</SPAN> tagNumber inTag tagText<BR> <SPAN class="keyword">feat</SPAN> action<BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(Master Action)<BR> <SPAN class="keyword">self.</SPAN>action = Action<BR> tagNumber <SPAN class="keyword"><-</SPAN> 0<BR> inTag <SPAN class="keyword"><-</SPAN> 0<BR> tagText <SPAN class="keyword"><-</SPAN> <SPAN class="string">""</SPAN> <BR> InformationWindow<SPAN class="keyword">,</SPAN> init(Master <SPAN class="string">'Definitions'</SPAN> status: <SPAN class="keyword">true</SPAN>)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">append</SPAN>(Definition)<BR> <SPAN class="keyword">case</SPAN> Definition<BR> <SPAN class="keyword">of</SPAN> definition(word: Word db: _ dbname: DBName body: Body) <SPAN class="keyword">then</SPAN> <BR> InformationWindow<SPAN class="keyword">,</SPAN> append(Word<SPAN class="keyword">#</SPAN><SPAN class="string">', '</SPAN><SPAN class="keyword">#</SPAN>DBName<SPAN class="keyword">#</SPAN><SPAN class="string">'\n'</SPAN> titleTag)<BR> DefinitionWindow<SPAN class="keyword">,</SPAN> AppendLines(nil<SPAN class="keyword">#</SPAN><SPAN class="string">'\n'</SPAN><SPAN class="keyword">#</SPAN>Body)<BR> InformationWindow<SPAN class="keyword">,</SPAN> append(<SPAN class="string">'\n\n'</SPAN>)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">AppendLines</SPAN>(VS)<BR> <SPAN class="keyword">case</SPAN> VS <SPAN class="keyword">of</SPAN> V<SPAN class="keyword">#</SPAN><SPAN class="string">'\n'</SPAN><SPAN class="keyword">#</SPAN>Rest <SPAN class="keyword">then</SPAN> V2 <SPAN class="keyword">in</SPAN> <BR> V2 = V<SPAN class="keyword">#</SPAN><SPAN class="string">'\n'</SPAN> <BR> DefinitionWindow<SPAN class="keyword">,</SPAN> AppendWithHyperLinks({VirtualString<SPAN class="keyword">.</SPAN>toString V2})<BR> DefinitionWindow<SPAN class="keyword">,</SPAN> AppendLines(Rest)<BR> <SPAN class="keyword">else</SPAN> <BR> DefinitionWindow<SPAN class="keyword">,</SPAN> AppendWithHyperLinks({VirtualString<SPAN class="keyword">.</SPAN>toString VS})<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">AppendWithHyperLinks</SPAN>(S) S1 S2 <SPAN class="keyword">in</SPAN> <BR> {List<SPAN class="keyword">.</SPAN>takeDropWhile S <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> C} C <SPAN class="keyword">\=</SPAN> <SPAN class="string">&{</SPAN> <SPAN class="keyword">andthen</SPAN> C <SPAN class="keyword">\=</SPAN> <SPAN class="string">&}</SPAN> <SPAN class="keyword">end</SPAN> ?S1 ?S2}<BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>inTag <SPAN class="keyword">></SPAN> 0 <SPAN class="keyword">then</SPAN> <BR> InformationWindow<SPAN class="keyword">,</SPAN> append(S1 <SPAN class="keyword">@</SPAN>tagNumber)<BR> tagText <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">@</SPAN>tagText<SPAN class="keyword">#</SPAN>S1<BR> <SPAN class="keyword">else</SPAN> <BR> InformationWindow<SPAN class="keyword">,</SPAN> append(S1)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">case</SPAN> S2 <SPAN class="keyword">of</SPAN> C<SPAN class="keyword">|</SPAN>Cr <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">case</SPAN> C <SPAN class="keyword">of</SPAN> <SPAN class="string">&{</SPAN> <SPAN class="keyword">then</SPAN> <BR> inTag <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">@</SPAN>inTag <SPAN class="keyword">+</SPAN> 1<BR> {<SPAN class="keyword">self.</SPAN>text tk(tag configure <SPAN class="keyword">@</SPAN>tagNumber underline: <SPAN class="keyword">true</SPAN>)}<BR> <SPAN class="keyword">if</SPAN> Tk<SPAN class="keyword">.</SPAN>isColor <SPAN class="keyword">then</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>text tk(tag configure <SPAN class="keyword">@</SPAN>tagNumber foreground: blue)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> <SPAN class="string">&}</SPAN> <SPAN class="keyword">then</SPAN> <BR> inTag <SPAN class="keyword"><-</SPAN> {Max <SPAN class="keyword">@</SPAN>inTag <SPAN class="keyword">-</SPAN> 1 0}<BR> <SPAN class="keyword">if</SPAN> <SPAN class="keyword">@</SPAN>inTag <SPAN class="keyword">==</SPAN> 0 <SPAN class="keyword">then</SPAN> Text Action <SPAN class="keyword">in</SPAN> <BR> Text = {Clean {VirtualString<SPAN class="keyword">.</SPAN>toString (tagText <SPAN class="keyword"><-</SPAN> <SPAN class="string">""</SPAN>)}}<BR> Action = {New Tk<SPAN class="keyword">.</SPAN>action<BR> tkInit(parent: <SPAN class="keyword">self.</SPAN>text<BR> action: <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>} {<SPAN class="keyword">self.</SPAN>action Text} <SPAN class="keyword">end</SPAN>)}<BR> {<SPAN class="keyword">self.</SPAN>text tk(tag bind <SPAN class="keyword">@</SPAN>tagNumber <SPAN class="string">'<1>'</SPAN> Action)}<BR> tagText <SPAN class="keyword"><-</SPAN> <SPAN class="string">""</SPAN> <BR> tagNumber <SPAN class="keyword"><-</SPAN> <SPAN class="keyword">@</SPAN>tagNumber <SPAN class="keyword">+</SPAN> 1<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> DefinitionWindow<SPAN class="keyword">,</SPAN> AppendWithHyperLinks(Cr)<BR> <SPAN class="keyword">[]</SPAN> nil <SPAN class="keyword">then</SPAN> <SPAN class="keyword">skip</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %%<SPAN class="comment"> <BR></SPAN> %% <SPAN class="comment">A Window to Display Matches<BR></SPAN> %%<SPAN class="comment"> <BR></SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">MatchWindow</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> InformationWindow</SPAN> <BR> <SPAN class="keyword">feat</SPAN> action<BR> <SPAN class="keyword">attr</SPAN> TagIndex: 0<BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(Master Action)<BR> <SPAN class="keyword">self.</SPAN>action = Action<BR> InformationWindow<SPAN class="keyword">,</SPAN> init(Master <SPAN class="string">'Matches'</SPAN> <BR> cursor: left_ptr status: <SPAN class="keyword">true</SPAN>)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">append</SPAN>(Match Databases)<BR> <SPAN class="keyword">case</SPAN> Match <SPAN class="keyword">of</SPAN> DB<SPAN class="keyword">#</SPAN>Word <SPAN class="keyword">then</SPAN> N Action <SPAN class="keyword">in</SPAN> <BR> N = <SPAN class="keyword">@</SPAN>TagIndex <SPAN class="keyword">+</SPAN> 1<BR> TagIndex <SPAN class="keyword"><-</SPAN> N<BR> InformationWindow<SPAN class="keyword">,</SPAN> append(Word<SPAN class="keyword">#</SPAN><SPAN class="string">', '</SPAN><SPAN class="keyword">#</SPAN>{CondSelect Databases<BR> {String<SPAN class="keyword">.</SPAN>toAtom DB} DB}<SPAN class="keyword">#</SPAN><SPAN class="string">'\n'</SPAN> N)<BR> Action = {New Tk<SPAN class="keyword">.</SPAN>action<BR> tkInit(parent: <SPAN class="keyword">self.</SPAN>text<BR> action: <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>} DBs <SPAN class="keyword">in</SPAN> <BR> DBs = [{String<SPAN class="keyword">.</SPAN>toAtom DB}]<BR> {<SPAN class="keyword">self.</SPAN>action Word DBs}<BR> <SPAN class="keyword">end</SPAN>)}<BR> {<SPAN class="keyword">self.</SPAN>text tk(tag bind N <SPAN class="string">'<1>'</SPAN> Action)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> %%<SPAN class="comment"> <BR></SPAN> %% <SPAN class="comment">The Main Interaction Window<BR></SPAN> %%<SPAN class="comment"> <BR></SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">TkDictionary</SPAN> <BR> <SPAN class="keyword">feat</SPAN> <BR> closed<BR> Toplevel WordEntry<BR> DatabasesList DatabaseIndices StrategiesList StrategyIndices<BR> StatusText LogText<BR> NetDict<BR> <SPAN class="keyword">attr</SPAN> <BR> CurrentServer: <SPAN class="keyword">unit</SPAN> CurrentPort: <SPAN class="keyword">unit</SPAN> <BR> Databases: <SPAN class="keyword">unit</SPAN> Strategies: <SPAN class="keyword">unit</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(Server <SPAN class="keyword"><=</SPAN> DEFAULT_SERVER Port <SPAN class="keyword"><=</SPAN> DEFAULT_PORT)<BR> NetMessages<BR> NetPort = {NewPort NetMessages}<BR> Messages<BR> P = {NewPort Messages}<BR> <BR> <SPAN class="keyword">self.</SPAN>Toplevel = {New Tk<SPAN class="keyword">.</SPAN>toplevel<BR> tkInit(title: <SPAN class="string">'Dictionary Client'</SPAN> <BR> <SPAN class="string">'class'</SPAN>: <SPAN class="string">'OzTools'</SPAN> <BR> delete: P<SPAN class="keyword">#</SPAN>close()<BR> withdraw: <SPAN class="keyword">true</SPAN>)}<BR> <BR> %% <SPAN class="comment">Menubar<BR></SPAN> Menu = {TkTools<SPAN class="keyword">.</SPAN>menubar <SPAN class="keyword">self.</SPAN>Toplevel <SPAN class="keyword">self.</SPAN>Toplevel<BR> [menubutton(text: <SPAN class="string">'Server'</SPAN> <BR> menu: [command(label: <SPAN class="string">'Open ...'</SPAN> <BR> key: ctrl(o)<BR> action: P<SPAN class="keyword">#</SPAN>ServerOpen(NetPort))<BR> separator<BR> command(label: <SPAN class="string">'Status'</SPAN> <BR> key: ctrl(s)<BR> action: P<SPAN class="keyword">#</SPAN>ServerStatus(NetPort))<BR> command(label: <SPAN class="string">'Information ...'</SPAN> <BR> action: P<SPAN class="keyword">#</SPAN>ServerInfo(NetPort))<BR> separator<BR> command(label: <SPAN class="string">'Close'</SPAN> <BR> key: ctrl(x)<BR> action: P<SPAN class="keyword">#</SPAN>close())])<BR> menubutton(text: <SPAN class="string">'Database'</SPAN> <BR> menu: [command(label: <SPAN class="string">'Information ...'</SPAN> <BR> action: P<SPAN class="keyword">#</SPAN>ShowInfo(NetPort))])]<BR> [menubutton(text: <SPAN class="string">'Help'</SPAN> <BR> menu: [command(label: <SPAN class="string">'About ...'</SPAN> <BR> action: P<SPAN class="keyword">#</SPAN>About())])]}<BR> <BR> <BR> %% <SPAN class="comment">Frames<BR></SPAN> Frame1 Frame2L Frame2R Frame3 Frame4<BR> {ForAll [Frame1 Frame2L Frame2R Frame3 Frame4]<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>}<BR> {New Tk<SPAN class="keyword">.</SPAN>frame tkInit(parent: <SPAN class="keyword">self.</SPAN>Toplevel<BR> highlightthickness: 0<BR> borderwidth: 1<BR> relief: raised)}<BR> <SPAN class="keyword">end</SPAN>}<BR> <BR> %% <SPAN class="comment">Contents of Frame1<BR></SPAN> WordLabel = {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent: Frame1<BR> font: BoldFont<BR> text: <SPAN class="string">'Word'</SPAN>)}<BR> <SPAN class="keyword">self.</SPAN>WordEntry = {New Tk<SPAN class="keyword">.</SPAN>entry tkInit(parent: Frame1<BR> font: FixedFont<BR> width: WordWidth<BR> background: TextBackground<BR> borderwidth: 1)}<BR> {<SPAN class="keyword">self.</SPAN>WordEntry tkBind(event: <SPAN class="string">'<Return>'</SPAN> <BR> action: P<SPAN class="keyword">#</SPAN>GetDefinitions(NetPort))}<BR> {<SPAN class="keyword">self.</SPAN>WordEntry tkBind(event: <SPAN class="string">'<Meta-Return>'</SPAN> <BR> action: P<SPAN class="keyword">#</SPAN>GetMatches(NetPort))}<BR> WordButtonsFrame = {New Tk<SPAN class="keyword">.</SPAN>frame tkInit(parent: Frame1<BR> highlightthickness: 0)}<BR> DefineButton = {New Tk<SPAN class="keyword">.</SPAN>button<BR> tkInit(parent: WordButtonsFrame<BR> text: <SPAN class="string">'Lookup'</SPAN> <BR> action: P<SPAN class="keyword">#</SPAN>GetDefinitions(NetPort))}<BR> MatchButton = {New Tk<SPAN class="keyword">.</SPAN>button<BR> tkInit(parent: WordButtonsFrame<BR> text: <SPAN class="string">'Match'</SPAN> <BR> action: P<SPAN class="keyword">#</SPAN>GetMatches(NetPort))}<BR> <BR> %% <SPAN class="comment">Contents of Frame2L<BR></SPAN> DatabasesLabel = {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent: Frame2L<BR> font: BoldFont<BR> text: <SPAN class="string">'Databases'</SPAN>)}<BR> DatabasesListFrame = {New Tk<SPAN class="keyword">.</SPAN>frame tkInit(parent: Frame2L<BR> highlightthickness: 0)}<BR> <SPAN class="keyword">self.</SPAN>DatabasesList = {New Tk<SPAN class="keyword">.</SPAN>listbox<BR> tkInit(parent: DatabasesListFrame<BR> selectmode: extended<BR> exportselection: <SPAN class="keyword">false</SPAN> <BR> background: TextBackground<BR> height: ListHeight<BR> borderwidth: 1)}<BR> <SPAN class="keyword">self.</SPAN>DatabaseIndices = {NewDictionary}<BR> DatabasesScrollbar = {New Tk<SPAN class="keyword">.</SPAN>scrollbar<BR> tkInit(parent: DatabasesListFrame<BR> borderwidth: ScrollBorder<BR> width: ScrollWidth)}<BR> {Tk<SPAN class="keyword">.</SPAN>addYScrollbar <SPAN class="keyword">self.</SPAN>DatabasesList DatabasesScrollbar}<BR> UpdateDatabasesButton = {New Tk<SPAN class="keyword">.</SPAN>button<BR> tkInit(parent: Frame2L<BR> text: <SPAN class="string">'Update List'</SPAN> <BR> action: P<SPAN class="keyword">#</SPAN>UpdateDatabases(NetPort))}<BR> <BR> %% <SPAN class="comment">Contents of Frame2R<BR></SPAN> StrategiesLabel = {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent: Frame2R<BR> font: BoldFont<BR> text: <SPAN class="string">'Strategies'</SPAN>)}<BR> StrategiesListFrame = {New Tk<SPAN class="keyword">.</SPAN>frame tkInit(parent: Frame2R<BR> highlightthicknes: 0)}<BR> <SPAN class="keyword">self.</SPAN>StrategiesList = {New Tk<SPAN class="keyword">.</SPAN>listbox<BR> tkInit(parent: StrategiesListFrame<BR> selectmode: browse<BR> exportselection: <SPAN class="keyword">false</SPAN> <BR> background: TextBackground<BR> height: ListHeight<BR> borderwidth: 1)}<BR> <SPAN class="keyword">self.</SPAN>StrategyIndices = {NewDictionary}<BR> StrategiesScrollbar = {New Tk<SPAN class="keyword">.</SPAN>scrollbar<BR> tkInit(parent: StrategiesListFrame<BR> borderwidth: ScrollBorder<BR> width: ScrollWidth)}<BR> {Tk<SPAN class="keyword">.</SPAN>addYScrollbar <SPAN class="keyword">self.</SPAN>StrategiesList StrategiesScrollbar}<BR> UpdateStrategiesButton = {New Tk<SPAN class="keyword">.</SPAN>button<BR> tkInit(parent: Frame2R<BR> text: <SPAN class="string">'Update List'</SPAN> <BR> action: P<SPAN class="keyword">#</SPAN>UpdateStrategies(NetPort))}<BR> <BR> %% <SPAN class="comment">Contents of Frame3<BR></SPAN> LogLabel = {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent: Frame3<BR> font: BoldFont<BR> text: <SPAN class="string">'Log'</SPAN>)}<BR> LogTextFrame = {New Tk<SPAN class="keyword">.</SPAN>frame tkInit(parent: Frame3<BR> highlightthicknes: 0)}<BR> <SPAN class="keyword">self.</SPAN>LogText = {New Tk<SPAN class="keyword">.</SPAN>text tkInit(parent: LogTextFrame<BR> wrap: word<BR> font: FixedFont<BR> background: TextBackground<BR> width: LogWidth<BR> height: LogHeight<BR> state: disabled)}<BR> LogScrollbar = {New Tk<SPAN class="keyword">.</SPAN>scrollbar<BR> tkInit(parent: LogTextFrame<BR> borderwidth: ScrollBorder<BR> width: ScrollWidth)}<BR> {Tk<SPAN class="keyword">.</SPAN>addYScrollbar <SPAN class="keyword">self.</SPAN>LogText LogScrollbar}<BR> <BR> %% <SPAN class="comment">Contents of Frame4<BR></SPAN> <SPAN class="keyword">self.</SPAN>StatusText = {New Tk<SPAN class="keyword">.</SPAN>text tkInit(parent: Frame4<BR> cursor: left_ptr<BR> border: 0<BR> wrap: none<BR> font: NormalFont<BR> width: 0<BR> height: 1<BR> state: disabled)}<BR> <SPAN class="keyword">in</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>batch [grid(columnconfigure <SPAN class="keyword">self.</SPAN>Toplevel 0 weight: 1)<BR> grid(columnconfigure <SPAN class="keyword">self.</SPAN>Toplevel 1 weight: 1)<BR> grid(rowconfigure <SPAN class="keyword">self.</SPAN>Toplevel 2 weight: 1)<BR> grid(rowconfigure <SPAN class="keyword">self.</SPAN>Toplevel 3 weight: 1)<BR> grid(Menu row: 0 column: 0 columnspan: 2 sticky: nsew)<BR> grid(Frame1 row: 1 column: 0 columnspan: 2 sticky: nsew)<BR> grid(Frame2L row: 2 column: 0 sticky: nsew)<BR> grid(Frame2R row: 2 column: 1 sticky: nsew)<BR> grid(Frame3 row: 3 column: 0 columnspan: 2 sticky: nsew)<BR> grid(Frame4 row: 4 column: 0 columnspan: 2 sticky: nsew)<BR> pack(WordLabel padx: Pad pady: Pad side: top)<BR> pack(<SPAN class="keyword">self.</SPAN>WordEntry padx: Pad pady: Pad side: top fill: x)<BR> pack(WordButtonsFrame padx: Pad pady: Pad side: top)<BR> pack(DefineButton MatchButton side: left padx: ButtonPad)<BR> pack(DatabasesLabel padx: Pad pady: Pad side: top)<BR> pack(DatabasesListFrame<BR> padx: Pad pady: Pad side: top expand: <SPAN class="keyword">true</SPAN> fill: both)<BR> pack(UpdateDatabasesButton padx: Pad pady: Pad side: top)<BR> pack(<SPAN class="keyword">self.</SPAN>DatabasesList<BR> side: left expand: <SPAN class="keyword">true</SPAN> fill: both)<BR> pack(DatabasesScrollbar side: left fill: y)<BR> pack(StrategiesLabel padx: Pad pady: Pad side: top)<BR> pack(StrategiesListFrame<BR> padx: Pad pady: Pad side: top expand: <SPAN class="keyword">true</SPAN> fill: both)<BR> pack(UpdateStrategiesButton padx: Pad pady: Pad side: top)<BR> pack(<SPAN class="keyword">self.</SPAN>StrategiesList<BR> side: left expand: <SPAN class="keyword">true</SPAN> fill: both)<BR> pack(StrategiesScrollbar side: left fill: y)<BR> pack(LogLabel padx: Pad pady: Pad side: top)<BR> pack(LogTextFrame<BR> padx: Pad pady: Pad side: top expand: <SPAN class="keyword">true</SPAN> fill: both)<BR> pack(<SPAN class="keyword">self.</SPAN>LogText side: left expand: <SPAN class="keyword">true</SPAN> fill: both)<BR> pack(LogScrollbar side: left fill: y)<BR> pack(<SPAN class="keyword">self.</SPAN>StatusText padx: Pad pady: Pad fill: x)<BR> focus(<SPAN class="keyword">self.</SPAN>WordEntry)]}<BR> {SetMinsize <SPAN class="keyword">self.</SPAN>Toplevel}<BR> {Tk<SPAN class="keyword">.</SPAN>send wm(deiconify <SPAN class="keyword">self.</SPAN>Toplevel)}<BR> <SPAN class="keyword">self.</SPAN>NetDict = {New NetDictionary<SPAN class="keyword">.</SPAN><SPAN class="string">'class'</SPAN> init()}<BR> TkDictionary<SPAN class="keyword">,</SPAN> Connect(NetPort Server Port)<BR> <SPAN class="keyword">thread</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> NetServe(NetMessages)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">thread</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Serve(Messages)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">close</SPAN>()<BR> <SPAN class="keyword">try</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>NetDict close()}<BR> <SPAN class="keyword">catch</SPAN> E <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> HandleException(E)<BR> <SPAN class="keyword">end</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>Toplevel tkClose()}<BR> <SPAN class="keyword">self.</SPAN>closed = <SPAN class="keyword">unit</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Serve</SPAN>(Ms)<BR> <SPAN class="keyword">case</SPAN> Ms <SPAN class="keyword">of</SPAN> M<SPAN class="keyword">|</SPAN>Mr <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> M<BR> TkDictionary<SPAN class="keyword">,</SPAN> Serve(Mr)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">ServerOpen</SPAN>(NetPort)<BR> {New ServerDialog init(<SPAN class="keyword">self.</SPAN>Toplevel <SPAN class="keyword">@</SPAN>CurrentServer <SPAN class="keyword">@</SPAN>CurrentPort<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> S P}<BR> TkDictionary<SPAN class="keyword">,</SPAN> Connect(NetPort S P)<BR> <SPAN class="keyword">end</SPAN>) _}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Connect</SPAN>(NetPort Server Port)<BR> TkDictionary<SPAN class="keyword">,</SPAN> SetDatabases(DEFAULT_DATABASES)<BR> TkDictionary<SPAN class="keyword">,</SPAN> SetStrategies(DEFAULT_STRATEGIES)<BR> TkDictionary<SPAN class="keyword">,</SPAN> Log(<SPAN class="string">'Connect to '</SPAN><SPAN class="keyword">#</SPAN>Server<SPAN class="keyword">#</SPAN><SPAN class="string">' on port '</SPAN><SPAN class="keyword">#</SPAN>Port)<BR> {Send NetPort connect(Server Port)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">ServerStatus</SPAN>(NetPort)<BR> TkDictionary<SPAN class="keyword">,</SPAN> Log(<SPAN class="string">'Request server status'</SPAN>)<BR> {Send NetPort serverStatus()}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">ServerInfo</SPAN>(NetPort)<BR> TkDictionary<SPAN class="keyword">,</SPAN> Log(<SPAN class="string">'Request server information'</SPAN>)<BR> {Send NetPort serverInfo()}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">ShowInfo</SPAN>(NetPort) DBs <SPAN class="keyword">in</SPAN> <BR> DBs = {Filter TkDictionary<SPAN class="keyword">,</SPAN> SelectedDatabases($)<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> DB} DB <SPAN class="keyword">\=</SPAN> <SPAN class="string">'!'</SPAN> <SPAN class="keyword">andthen</SPAN> DB <SPAN class="keyword">\=</SPAN> <SPAN class="string">'*'</SPAN> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">if</SPAN> DBs <SPAN class="keyword">\=</SPAN> nil <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Log(<SPAN class="string">'Request information on: '</SPAN><SPAN class="keyword">#</SPAN> <BR> {FormatDBs DBs <SPAN class="keyword">@</SPAN>Databases})<BR> {Send NetPort showInfo(DBs)}<BR> <SPAN class="keyword">else</SPAN> <BR> {New TkTools<SPAN class="keyword">.</SPAN>error<BR> tkInit(master: <SPAN class="keyword">self.</SPAN>Toplevel<BR> text: <SPAN class="string">'Select a non-generic database first.'</SPAN>) _}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">About</SPAN>()<BR> Dialog = {New TkTools<SPAN class="keyword">.</SPAN>dialog tkInit(master: <SPAN class="keyword">self.</SPAN>Toplevel<BR> root: pointer<BR> title: <SPAN class="string">'About Dictionary Client'</SPAN> <BR> buttons: [<SPAN class="string">'Ok'</SPAN><SPAN class="keyword">#</SPAN>tkClose]<BR> default: 1<BR> focus: 1<BR> pack: <SPAN class="keyword">false</SPAN>)}<BR> Icon = {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent: Dialog<BR> image: Images<SPAN class="keyword">.</SPAN>dict)}<BR> Title = {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent: Dialog<BR> text: <SPAN class="string">'Dictionary Client'</SPAN>)}<BR> Author = {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent: Dialog<BR> text: (<SPAN class="string">'Programming Systems Lab\n'</SPAN><SPAN class="keyword">#</SPAN> <BR> <SPAN class="string">'Universität des Saarlandes\n'</SPAN><SPAN class="keyword">#</SPAN> <BR> <SPAN class="string">'Contact: Leif Kornstaedt\n'</SPAN><SPAN class="keyword">#</SPAN> <BR> <SPAN class="string">'<kornstae@ps.uni-sb.de>'</SPAN>))}<BR> <SPAN class="keyword">in</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>batch [grid(Icon row: 0 column: 0 padx: 4 pady: 4)<BR> grid(Title row: 0 column: 1 padx: 4 pady: 4)<BR> grid(Author row: 1 column: 0 columnspan: 2<BR> padx: 8 pady: 8)]}<BR> {Dialog tkPack()}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">GetDefinitions</SPAN>(NetPort) Word DBs <SPAN class="keyword">in</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>WordEntry tkReturn(get ?Word)}<BR> TkDictionary<SPAN class="keyword">,</SPAN> SelectedDatabases(?DBs)<BR> <SPAN class="keyword">if</SPAN> Word <SPAN class="keyword">\=</SPAN> <SPAN class="string">""</SPAN> <SPAN class="keyword">andthen</SPAN> DBs <SPAN class="keyword">\=</SPAN> nil <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Log(<SPAN class="string">'Look up `'</SPAN><SPAN class="keyword">#</SPAN>Word<SPAN class="keyword">#</SPAN><SPAN class="string">'\' in: '</SPAN><SPAN class="keyword">#</SPAN> <BR> {FormatDBs DBs <SPAN class="keyword">@</SPAN>Databases})<BR> {Send NetPort getDefinitions(Word DBs NetPort)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">GetMatches</SPAN>(NetPort) Word DBs Strategy <SPAN class="keyword">in</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>WordEntry tkReturn(get ?Word)}<BR> TkDictionary<SPAN class="keyword">,</SPAN> SelectedDatabases(?DBs)<BR> TkDictionary<SPAN class="keyword">,</SPAN> SelectedStrategy(?Strategy)<BR> <SPAN class="keyword">if</SPAN> Word <SPAN class="keyword">\=</SPAN> <SPAN class="string">""</SPAN> <SPAN class="keyword">andthen</SPAN> DBs <SPAN class="keyword">\=</SPAN> nil <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Log(<SPAN class="string">'Match `'</SPAN><SPAN class="keyword">#</SPAN>Word<SPAN class="keyword">#</SPAN><SPAN class="string">'\' in: '</SPAN><SPAN class="keyword">#</SPAN> <BR> {FormatDBs DBs <SPAN class="keyword">@</SPAN>Databases}<SPAN class="keyword">#</SPAN> <BR> <SPAN class="string">' using: '</SPAN><SPAN class="keyword">#@</SPAN>Strategies<SPAN class="keyword">.</SPAN>Strategy)<BR> {Send NetPort getMatches(Word DBs Strategy NetPort)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Lookup</SPAN>(Word DB NetPort)<BR> {Send NetPort getDefinitions(Word [DB] NetPort)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">UpdateDatabases</SPAN>(NetPort)<BR> TkDictionary<SPAN class="keyword">,</SPAN> Log(<SPAN class="string">'Update databases'</SPAN>)<BR> {Send NetPort updateDatabases()}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">UpdateStrategies</SPAN>(NetPort)<BR> TkDictionary<SPAN class="keyword">,</SPAN> Log(<SPAN class="string">'Update strategies'</SPAN>)<BR> {Send NetPort updateStrategies()}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Log</SPAN>(VS)<BR> {Tk<SPAN class="keyword">.</SPAN>batch [o(<SPAN class="keyword">self.</SPAN>LogText configure state: normal)<BR> o(<SPAN class="keyword">self.</SPAN>LogText insert <SPAN class="string">'end'</SPAN> VS<SPAN class="keyword">#</SPAN><SPAN class="string">'\n'</SPAN>)<BR> o(<SPAN class="keyword">self.</SPAN>LogText configure state: disabled)<BR> o(<SPAN class="keyword">self.</SPAN>LogText see <SPAN class="string">'end'</SPAN>)]}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">NetServe</SPAN>(Ms)<BR> <SPAN class="keyword">case</SPAN> Ms <SPAN class="keyword">of</SPAN> M<SPAN class="keyword">|</SPAN>Mr <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">case</SPAN> M <SPAN class="keyword">of</SPAN> connect(Server Port) <SPAN class="keyword">then</SPAN> VS <SPAN class="keyword">in</SPAN> <BR> VS = <SPAN class="string">'Connecting to '</SPAN><SPAN class="keyword">#</SPAN>Server<SPAN class="keyword">#</SPAN><SPAN class="string">' on port '</SPAN><SPAN class="keyword">#</SPAN>Port<SPAN class="keyword">#</SPAN><SPAN class="string">' ...'</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS)<BR> <SPAN class="keyword">try</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>NetDict connect(Server Port)}<BR> CurrentServer <SPAN class="keyword"><-</SPAN> Server<BR> CurrentPort <SPAN class="keyword"><-</SPAN> Port<BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS<SPAN class="keyword">#</SPAN><SPAN class="string">' done'</SPAN>)<BR> <SPAN class="keyword">catch</SPAN> E <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> HandleException(E)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> serverStatus() <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(<SPAN class="string">'Requesting server status ...'</SPAN>)<BR> <SPAN class="keyword">try</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status({<SPAN class="keyword">self.</SPAN>NetDict status($)})<BR> <SPAN class="keyword">catch</SPAN> E <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> HandleException(E)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> serverInfo() <SPAN class="keyword">then</SPAN> VS <SPAN class="keyword">in</SPAN> <BR> VS = <SPAN class="string">'Requesting server information ...'</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS)<BR> <SPAN class="keyword">try</SPAN> W <SPAN class="keyword">in</SPAN> <BR> W = {New InformationWindow init(<SPAN class="keyword">self.</SPAN>Toplevel<BR> <SPAN class="string">'Server Information'</SPAN>)}<BR> {W append({<SPAN class="keyword">self.</SPAN>NetDict showServer($)})}<BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS<SPAN class="keyword">#</SPAN><SPAN class="string">' done'</SPAN>)<BR> <SPAN class="keyword">catch</SPAN> E <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> HandleException(E)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> showInfo(DBs) <SPAN class="keyword">then</SPAN> VS <SPAN class="keyword">in</SPAN> <BR> VS = (<SPAN class="string">'Request information on: '</SPAN><SPAN class="keyword">#</SPAN>{FormatDBs DBs <SPAN class="keyword">@</SPAN>Databases}<SPAN class="keyword">#</SPAN> <BR> <SPAN class="string">' ...'</SPAN>)<BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS)<BR> <SPAN class="keyword">try</SPAN> <BR> {ForAll DBs<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> DB} W <SPAN class="keyword">in</SPAN> <BR> W = {New InformationWindow init(<SPAN class="keyword">self.</SPAN>Toplevel<BR> <SPAN class="string">'Database Information'</SPAN>)}<BR> {W append({<SPAN class="keyword">self.</SPAN>NetDict showInfo(DB $)})}<BR> <SPAN class="keyword">end</SPAN>}<BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS<SPAN class="keyword">#</SPAN><SPAN class="string">' done'</SPAN>)<BR> <SPAN class="keyword">catch</SPAN> E <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> HandleException(E)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> getDefinitions(Word DBs NetPort) <SPAN class="keyword">then</SPAN> VS <SPAN class="keyword">in</SPAN> <BR> VS = (<SPAN class="string">'Looking up `'</SPAN><SPAN class="keyword">#</SPAN>Word<SPAN class="keyword">#</SPAN><SPAN class="string">'\' in: '</SPAN><SPAN class="keyword">#</SPAN>{FormatDBs DBs <SPAN class="keyword">@</SPAN>Databases}<SPAN class="keyword">#</SPAN> <BR> <SPAN class="string">' ...'</SPAN>)<BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS)<BR> <SPAN class="keyword">try</SPAN> T Action W TotalCount <SPAN class="keyword">in</SPAN> <BR> T = {Thread<SPAN class="keyword">.</SPAN>this}<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Action</SPAN> Word}<BR> TkDictionary<SPAN class="keyword">,</SPAN> Log(<SPAN class="string">'Look up `'</SPAN><SPAN class="keyword">#</SPAN>Word<SPAN class="keyword">#</SPAN><SPAN class="string">'\' in: '</SPAN><SPAN class="keyword">#</SPAN> <BR> {FormatDBs DBs <SPAN class="keyword">@</SPAN>Databases})<BR> {Send NetPort getDefinitions(Word DBs NetPort)}<BR> <SPAN class="keyword">end</SPAN> <BR> W = {New DefinitionWindow init(<SPAN class="keyword">self.</SPAN>Toplevel Action)}<BR> TotalCount = {NewCell 0}<BR> {ForAll DBs<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> DB} Count Res <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">thread</SPAN> <BR> <SPAN class="keyword">try</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>NetDict <SPAN class="string">'define'</SPAN>(Word db: DB<BR> count: ?Count ?Res)}<BR> <SPAN class="keyword">catch</SPAN> E <SPAN class="keyword">then</SPAN> <BR> {Thread<SPAN class="keyword">.</SPAN>injectException T E}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">if</SPAN> Count <SPAN class="keyword">></SPAN> 0 <SPAN class="keyword">then</SPAN> Got ToGet <SPAN class="keyword">in</SPAN> <BR> Got = {Access TotalCount}<BR> ToGet = Got <SPAN class="keyword">+</SPAN> Count<BR> {Assign TotalCount ToGet}<BR> {W status(<SPAN class="string">'Retrieved '</SPAN><SPAN class="keyword">#</SPAN>Got<SPAN class="keyword">#</SPAN><SPAN class="string">'; found '</SPAN><SPAN class="keyword">#</SPAN>ToGet)}<BR> {List<SPAN class="keyword">.</SPAN>forAllInd Res<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> I Definition}<BR> {W status(<SPAN class="string">'Retrieved '</SPAN><SPAN class="keyword">#</SPAN>Got <SPAN class="keyword">+</SPAN> I<SPAN class="keyword">#</SPAN><SPAN class="string">'; found '</SPAN><SPAN class="keyword">#</SPAN>ToGet)}<BR> {W append(Definition)}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN>}<BR> {W status(<SPAN class="string">'Total: '</SPAN><SPAN class="keyword">#</SPAN>{Access TotalCount})}<BR> <SPAN class="keyword">if</SPAN> {Access TotalCount} <SPAN class="keyword">==</SPAN> 0 <SPAN class="keyword">then</SPAN> <BR> {New TkTools<SPAN class="keyword">.</SPAN>error<BR> tkInit(master: <SPAN class="keyword">self.</SPAN>Toplevel<BR> text: <SPAN class="string">'No matches for `'</SPAN><SPAN class="keyword">#</SPAN>Word<SPAN class="keyword">#</SPAN><SPAN class="string">'\' found.'</SPAN>) _}<BR> {W close()}<BR> <SPAN class="keyword">end</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS<SPAN class="keyword">#</SPAN><SPAN class="string">' done'</SPAN>)<BR> <SPAN class="keyword">catch</SPAN> E <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> HandleException(E)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> getMatches(Word DBs Strategy NetPort) <SPAN class="keyword">then</SPAN> VS <SPAN class="keyword">in</SPAN> <BR> VS = (<SPAN class="string">'Matching `'</SPAN><SPAN class="keyword">#</SPAN>Word<SPAN class="keyword">#</SPAN><SPAN class="string">'\' in: '</SPAN><SPAN class="keyword">#</SPAN>{FormatDBs DBs <SPAN class="keyword">@</SPAN>Databases}<SPAN class="keyword">#</SPAN> <BR> <SPAN class="string">' using: '</SPAN><SPAN class="keyword">#@</SPAN>Strategies<SPAN class="keyword">.</SPAN>Strategy<SPAN class="keyword">#</SPAN><SPAN class="string">' ...'</SPAN>)<BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS)<BR> <SPAN class="keyword">try</SPAN> Action W TotalCount <SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Action</SPAN> Word DBs}<BR> TkDictionary<SPAN class="keyword">,</SPAN> Log(<SPAN class="string">'Look up `'</SPAN><SPAN class="keyword">#</SPAN>Word<SPAN class="keyword">#</SPAN><SPAN class="string">'\' in: '</SPAN><SPAN class="keyword">#</SPAN> <BR> {FormatDBs DBs <SPAN class="keyword">@</SPAN>Databases})<BR> {Send NetPort getDefinitions(Word DBs NetPort)}<BR> <SPAN class="keyword">end</SPAN> <BR> W = {New MatchWindow init(<SPAN class="keyword">self.</SPAN>Toplevel Action)}<BR> TotalCount = {NewCell 0}<BR> {ForAll DBs<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> DB} Count Res <SPAN class="keyword">in</SPAN> <BR> {<SPAN class="keyword">self.</SPAN>NetDict match(Word db: DB strategy: Strategy<BR> count: ?Count ?Res)}<BR> <SPAN class="keyword">if</SPAN> Count <SPAN class="keyword">></SPAN> 0 <SPAN class="keyword">then</SPAN> Got ToGet <SPAN class="keyword">in</SPAN> <BR> Got = {Access TotalCount}<BR> ToGet = Got <SPAN class="keyword">+</SPAN> Count<BR> {Assign TotalCount ToGet}<BR> {W status(<SPAN class="string">'Retrieving '</SPAN><SPAN class="keyword">#</SPAN>Got<SPAN class="keyword">#</SPAN><SPAN class="string">'; found '</SPAN><SPAN class="keyword">#</SPAN>ToGet)}<BR> {List<SPAN class="keyword">.</SPAN>forAllInd Res<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> I Match}<BR> {W status(<SPAN class="string">'Retrieved '</SPAN><SPAN class="keyword">#</SPAN>Got <SPAN class="keyword">+</SPAN> I<SPAN class="keyword">#</SPAN><SPAN class="string">'; found '</SPAN><SPAN class="keyword">#</SPAN>ToGet)}<BR> {W append(Match <SPAN class="keyword">@</SPAN>Databases)}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN>}<BR> {W status(<SPAN class="string">'Total: '</SPAN><SPAN class="keyword">#</SPAN>{Access TotalCount})}<BR> <SPAN class="keyword">if</SPAN> {Access TotalCount} <SPAN class="keyword">==</SPAN> 0 <SPAN class="keyword">then</SPAN> <BR> {New TkTools<SPAN class="keyword">.</SPAN>error<BR> tkInit(master: <SPAN class="keyword">self.</SPAN>Toplevel<BR> text: <SPAN class="string">'No matches for `'</SPAN><SPAN class="keyword">#</SPAN>Word<SPAN class="keyword">#</SPAN><SPAN class="string">'\' found.'</SPAN>) _}<BR> {W close()}<BR> <SPAN class="keyword">end</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS<SPAN class="keyword">#</SPAN><SPAN class="string">' done'</SPAN>)<BR> <SPAN class="keyword">catch</SPAN> E <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> HandleException(E)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> updateDatabases() <SPAN class="keyword">then</SPAN> VS <SPAN class="keyword">in</SPAN> <BR> VS = <SPAN class="string">'Requesting database information ...'</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS)<BR> <SPAN class="keyword">try</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> <BR> SetDatabases({Append DEFAULT_DATABASES<BR> {Map {<SPAN class="keyword">self.</SPAN>NetDict showDatabases($)}<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> DB<SPAN class="keyword">#</SPAN>DBName}<BR> {String<SPAN class="keyword">.</SPAN>toAtom DB}<SPAN class="keyword">#</SPAN>DBName<BR> <SPAN class="keyword">end</SPAN>}})<BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS<SPAN class="keyword">#</SPAN><SPAN class="string">' done'</SPAN>)<BR> <SPAN class="keyword">catch</SPAN> E <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> HandleException(E)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">[]</SPAN> updateStrategies() <SPAN class="keyword">then</SPAN> VS <SPAN class="keyword">in</SPAN> <BR> VS = <SPAN class="string">'Requesting strategy information ...'</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS)<BR> <SPAN class="keyword">try</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> <BR> SetStrategies(<SPAN class="string">'.'</SPAN><SPAN class="keyword">#</SPAN><SPAN class="string">'Default'</SPAN><SPAN class="keyword">|</SPAN> <BR> {Map {<SPAN class="keyword">self.</SPAN>NetDict showStrategies($)}<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Strat<SPAN class="keyword">#</SPAN>StrategyName}<BR> {String<SPAN class="keyword">.</SPAN>toAtom Strat}<SPAN class="keyword">#</SPAN>StrategyName<BR> <SPAN class="keyword">end</SPAN>})<BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(VS<SPAN class="keyword">#</SPAN><SPAN class="string">' done'</SPAN>)<BR> <SPAN class="keyword">catch</SPAN> E <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> HandleException(E)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> NetServe(Mr)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">HandleException</SPAN>(E)<BR> <SPAN class="keyword">case</SPAN> E <SPAN class="keyword">of</SPAN> system(os(os _ 110 <SPAN class="keyword">...</SPAN>) <SPAN class="keyword">...</SPAN>) <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(<SPAN class="string">'Connection timed out'</SPAN>)<BR> <SPAN class="keyword">elseof</SPAN> system(os(os _ 111 <SPAN class="keyword">...</SPAN>) <SPAN class="keyword">...</SPAN>) <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(<SPAN class="string">'Connection refused'</SPAN>)<BR> <SPAN class="keyword">elseof</SPAN> error(netdict(unexpectedResponse _ N Response) <SPAN class="keyword">...</SPAN>) <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">if</SPAN> N <SPAN class="keyword">==</SPAN> <SPAN class="keyword">unit</SPAN> <SPAN class="keyword">orelse</SPAN> N <SPAN class="keyword"><</SPAN> 500 <SPAN class="keyword">then</SPAN> <BR> {Raise E}<BR> <SPAN class="keyword">else</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(<SPAN class="string">'Server error: '</SPAN><SPAN class="keyword">#</SPAN>Response)<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">elseof</SPAN> error(netdict(serverClosed Reason) <SPAN class="keyword">...</SPAN>) <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(<SPAN class="string">'Connection closed'</SPAN><SPAN class="keyword">#</SPAN> <BR> <SPAN class="keyword">case</SPAN> Reason <SPAN class="keyword">of</SPAN> <SPAN class="keyword">unit</SPAN> <SPAN class="keyword">then</SPAN> <SPAN class="string">""</SPAN> <BR> <SPAN class="keyword">else</SPAN> <SPAN class="string">': '</SPAN><SPAN class="keyword">#</SPAN>Reason<BR> <SPAN class="keyword">end</SPAN>)<BR> <SPAN class="keyword">elseof</SPAN> error(netdict(notConnected) <SPAN class="keyword">...</SPAN>) <SPAN class="keyword">then</SPAN> <BR> TkDictionary<SPAN class="keyword">,</SPAN> Status(<SPAN class="string">'Not connected'</SPAN>)<BR> <SPAN class="keyword">else</SPAN> <BR> {Raise E}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">Status</SPAN>(VS)<BR> {Tk<SPAN class="keyword">.</SPAN>batch [o(<SPAN class="keyword">self.</SPAN>StatusText configure state: normal)<BR> o(<SPAN class="keyword">self.</SPAN>StatusText delete p(1 0) <SPAN class="string">'end'</SPAN>)<BR> o(<SPAN class="keyword">self.</SPAN>StatusText insert <SPAN class="string">'end'</SPAN> VS)<BR> o(<SPAN class="keyword">self.</SPAN>StatusText configure state: disabled)]}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">SetDatabases</SPAN>(Pairs)<BR> Databases <SPAN class="keyword"><-</SPAN> {List<SPAN class="keyword">.</SPAN>toRecord databases Pairs}<BR> {<SPAN class="keyword">self.</SPAN>DatabasesList tk(delete 0 <SPAN class="string">'end'</SPAN>)}<BR> {Dictionary<SPAN class="keyword">.</SPAN>removeAll <SPAN class="keyword">self.</SPAN>DatabaseIndices}<BR> {List<SPAN class="keyword">.</SPAN>forAllInd Pairs<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> I DB<SPAN class="keyword">#</SPAN>DatabaseName}<BR> {<SPAN class="keyword">self.</SPAN>DatabasesList tk(insert <SPAN class="string">'end'</SPAN> DatabaseName)}<BR> {Dictionary<SPAN class="keyword">.</SPAN>put <SPAN class="keyword">self.</SPAN>DatabaseIndices I <SPAN class="keyword">-</SPAN> 1 DB}<BR> <SPAN class="keyword">end</SPAN>}<BR> {<SPAN class="keyword">self.</SPAN>DatabasesList tk(selection set 0)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">SelectedDatabases</SPAN>($)<BR> {Map {<SPAN class="keyword">self.</SPAN>DatabasesList tkReturnListInt(curselection $)}<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> I} {Dictionary<SPAN class="keyword">.</SPAN>get <SPAN class="keyword">self.</SPAN>DatabaseIndices I} <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">SetStrategies</SPAN>(Pairs)<BR> Strategies <SPAN class="keyword"><-</SPAN> {List<SPAN class="keyword">.</SPAN>toRecord strategies Pairs}<BR> {<SPAN class="keyword">self.</SPAN>StrategiesList tk(delete 0 <SPAN class="string">'end'</SPAN>)}<BR> {Dictionary<SPAN class="keyword">.</SPAN>removeAll <SPAN class="keyword">self.</SPAN>StrategyIndices}<BR> {List<SPAN class="keyword">.</SPAN>forAllInd Pairs<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> I Strategy<SPAN class="keyword">#</SPAN>StrategyName}<BR> {<SPAN class="keyword">self.</SPAN>StrategiesList tk(insert <SPAN class="string">'end'</SPAN> StrategyName)}<BR> {Dictionary<SPAN class="keyword">.</SPAN>put <SPAN class="keyword">self.</SPAN>StrategyIndices I <SPAN class="keyword">-</SPAN> 1 Strategy}<BR> <SPAN class="keyword">end</SPAN>}<BR> {<SPAN class="keyword">self.</SPAN>StrategiesList tk(selection set 0)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">SelectedStrategy</SPAN>($)<BR> {Dictionary<SPAN class="keyword">.</SPAN>get <SPAN class="keyword">self.</SPAN>StrategyIndices<BR> {<SPAN class="keyword">self.</SPAN>StrategiesList tkReturnListInt(curselection $)}<SPAN class="keyword">.</SPAN>1}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN> <BR></PRE></BLOCKQUOTE><P> </P></DIV></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node37.html#code.dict-client.netdictionary"><< Prev</A></TD><TD><A href="dict-client.html">- Up -</A></TD><TD><A href="node39.html#code.dict-client.main">Next >></A></TD></TR></TABLE><HR><ADDRESS><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|