124 lines
9.0 KiB
HTML
Executable File
124 lines
9.0 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="generator" content="TempleOS V5.03">
|
|
<meta name="viewport" content="width=device-width">
|
|
<link rel="stylesheet" href="/style/templeos.css">
|
|
<script src="/script/templeos.js"></script>
|
|
<style type="text/css">
|
|
.cF0{color:#000000;background-color:#ffffff;}
|
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
|
.cF8{color:#555555;background-color:#ffffff;}
|
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre id="content">
|
|
<a name="l1"></a><span class=cF2>/*This does a really crappy job of</span><span class=cF0>
|
|
<a name="l2"></a></span><span class=cF2>suggesting spellings. Write a better</span><span class=cF0>
|
|
<a name="l3"></a></span><span class=cF2>one for fun.</span><span class=cF0>
|
|
<a name="l4"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l5"></a>
|
|
<a name="l6"></a></span><span class=cF1>U8</span><span class=cF0> *SuggestMatchForm(</span><span class=cF1>U8</span><span class=cF0> *src)
|
|
<a name="l7"></a>{
|
|
<a name="l8"></a> </span><span class=cF9>I64</span><span class=cF0> ch,ch1=0;
|
|
<a name="l9"></a> </span><span class=cF1>U8</span><span class=cF0> *res=</span><span class=cF5>MStrUtil</span><span class=cF0>(src,</span><span class=cF3>SUF_TO_UPPER</span><span class=cF0>),*dst;
|
|
<a name="l10"></a> dst=src=res;
|
|
<a name="l11"></a> </span><span class=cF1>while</span><span class=cF0> (ch=*src++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l12"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrOcc</span><span class=cF7>(</span><span class=cF6>"AEIOU"</span><span class=cF0>,ch</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l13"></a> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'C'</span><span class=cF0>) ch=</span><span class=cF6>'K'</span><span class=cF0>;
|
|
<a name="l14"></a> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'Z'</span><span class=cF0>) ch=</span><span class=cF6>'S'</span><span class=cF0>;
|
|
<a name="l15"></a> </span><span class=cF1>if</span><span class=cF0> (ch!=ch1) </span><span class=cF2>//double chars to single</span><span class=cF0>
|
|
<a name="l16"></a> *dst++=ch;
|
|
<a name="l17"></a> }
|
|
<a name="l18"></a> ch1=ch;
|
|
<a name="l19"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l20"></a> *dst=0;
|
|
<a name="l21"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l22"></a>}
|
|
<a name="l23"></a>
|
|
<a name="l24"></a></span><span class=cF2>/*Fmt of word lst entry:</span><span class=cF0>
|
|
<a name="l25"></a></span><span class=cF2> U8 ACD_WORD_CHAR</span><span class=cF0>
|
|
<a name="l26"></a></span><span class=cF2> U8 word[] with terminating zero</span><span class=cF0>
|
|
<a name="l27"></a></span><span class=cF2> I16 block; //definition offset in ::/Adam/AutoComplete/ACDefs.DATA</span><span class=cF0>
|
|
<a name="l28"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l29"></a>
|
|
<a name="l30"></a></span><span class=cF1>Bool</span><span class=cF0> SuggestSpelling(</span><span class=cF1>U8</span><span class=cF0> *word)
|
|
<a name="l31"></a>{
|
|
<a name="l32"></a> </span><span class=cF1>U8</span><span class=cF0> *dict=</span><span class=cFB>acd</span><span class=cF0>.word_lst,
|
|
<a name="l33"></a> *pf=SuggestMatchForm(word),
|
|
<a name="l34"></a> *wf;
|
|
<a name="l35"></a> </span><span class=cF9>I64</span><span class=cF0> len=</span><span class=cF5>StrLen</span><span class=cF0>(pf),
|
|
<a name="l36"></a> num_cols=</span><span class=cF5>Fs</span><span class=cF0>->win_width/16,
|
|
<a name="l37"></a> col=0;
|
|
<a name="l38"></a> </span><span class=cF1>if</span><span class=cF0> (len)
|
|
<a name="l39"></a> </span><span class=cF1>while</span><span class=cF0> (*dict) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l40"></a> wf=SuggestMatchForm(dict+1);
|
|
<a name="l41"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>StrNCmp</span><span class=cF7>(</span><span class=cF0>pf,wf,len</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l42"></a> </span><span class=cF6>"%16s"</span><span class=cF0>,dict+1;
|
|
<a name="l43"></a> </span><span class=cF1>if</span><span class=cF0> (++col>=num_cols) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l44"></a> col=0;
|
|
<a name="l45"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l46"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l47"></a> }
|
|
<a name="l48"></a> </span><span class=cF5>Free</span><span class=cF0>(wf);
|
|
<a name="l49"></a> dict+=</span><span class=cF5>StrLen</span><span class=cF0>(dict+1)+4;
|
|
<a name="l50"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l51"></a> </span><span class=cF5>Free</span><span class=cF0>(pf);
|
|
<a name="l52"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l53"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>ToBool</span><span class=cF0>(len);
|
|
<a name="l54"></a>}
|
|
<a name="l55"></a>
|
|
<a name="l56"></a></span><span class=cF1>U0</span><span class=cF0> SuggestSpellingDemo()
|
|
<a name="l57"></a>{
|
|
<a name="l58"></a> </span><span class=cF1>U8</span><span class=cF0> *w;
|
|
<a name="l59"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l60"></a> w=</span><span class=cF5>GetStr</span><span class=cF0>(</span><span class=cF6>"Word:"</span><span class=cF0>);
|
|
<a name="l61"></a> </span><span class=cF1>if</span><span class=cF0> (*w) {
|
|
<a name="l62"></a> SuggestSpelling(w);
|
|
<a name="l63"></a> </span><span class=cF5>Free</span><span class=cF0>(w);
|
|
<a name="l64"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l65"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l66"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l67"></a>}
|
|
<a name="l68"></a>
|
|
<a name="l69"></a></span><span class=cF2>//If you "Adam Include" this file, it will</span><span class=cF0>
|
|
<a name="l70"></a></span><span class=cF2>//install this command as a hot-key.</span><span class=cF0>
|
|
<a name="l71"></a>
|
|
<a name="l72"></a></span><span class=cF1>U0</span><span class=cF0> CtrlAltL(</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l73"></a>{
|
|
<a name="l74"></a></span><span class=cF2>//</span><a href="/Wb/Kernel/KernelA.HH.HTML#l1496"><span class=cF4>ac.cur_word</span></a><span class=cF2> is only set if AutoComplete</span><span class=cF0>
|
|
<a name="l75"></a> </span><span class=cF2>//is running.</span><span class=cF0>
|
|
<a name="l76"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>TaskValidate</span><span class=cF7>(</span><span class=cFB>ac</span><span class=cF0>.task</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l77"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
|
|
<a name="l78"></a> </span><span class=cF5>Sleep</span><span class=cF0>(500);
|
|
<a name="l79"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l80"></a> </span><span class=cF5>PopUp</span><span class=cF0>(</span><span class=cF6>"if (SuggestSpelling(ac.cur_word)) View;"</span><span class=cF0>);
|
|
<a name="l81"></a>}
|
|
<a name="l82"></a>
|
|
<a name="l83"></a></span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0>!=</span><span class=cFB>adam_task</span><span class=cF0>)
|
|
<a name="l84"></a> SuggestSpellingDemo;
|
|
<a name="l85"></a></span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l86"></a> </span><span class=cF5>CtrlAltCBSet</span><span class=cF0>(</span><span class=cF6>'L'</span><span class=cF0>,&CtrlAltL,</span><span class=cF6>"Cmd /Suggest Spelling"</span><span class=cF0>);
|
|
<a name="l87"></a></span><span class=cF2>//Appears in the Adam Task Window</span><span class=cF0>
|
|
<a name="l88"></a> </span><span class=cF6>"<CTRL-ALT-l> installed\n"</span><span class=cF0>;
|
|
<a name="l89"></a>}
|
|
<a name="l90"></a>
|
|
<a name="l91"></a></span><span class=cF2>//Note: It would be more appropriate</span><span class=cF0>
|
|
<a name="l92"></a></span><span class=cF2>//to define a key in </span><a href="/Wb/Home/HomeKeyPlugIns.HC.HTML#l11"><span class=cF4>MyPutKey</span></a><span class=cF2>().</span><span class=cF0>
|
|
</span></pre></body>
|
|
</html>
|