201 lines
19 KiB
HTML
Executable File
201 lines
19 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=cF0>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"AutoComplete/Dictionary"</span><span class=cF0>
|
|
<a name="l2"></a></span><span class=cFB>acd</span><span class=cF0>.has_words=</span><span class=cF5>FileFind</span><span class=cF0>(</span><span class=cF3>ACD_WORD_FILENAME</span><span class=cF0>);
|
|
<a name="l3"></a></span><span class=cFB>acd</span><span class=cF0>.has_defs =</span><span class=cF5>FileFind</span><span class=cF0>(</span><span class=cF3>ACD_DEF_FILENAME</span><span class=cF0>)||</span><span class=cF5>FileFind</span><span class=cF0>(</span><span class=cF3>ACD_DEF_FILENAME_Z</span><span class=cF0>);
|
|
<a name="l4"></a>
|
|
<a name="l5"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>ACDWordsLoad</span><span class=cF0>()
|
|
<a name="l6"></a>{</span><span class=cF2>//Put words from word list into hash table.</span><span class=cF0>
|
|
<a name="l7"></a> </span><span class=cF9>I64</span><span class=cF0> size;
|
|
<a name="l8"></a> </span><span class=cF9>CHashGeneric</span><span class=cF0> *tmph;
|
|
<a name="l9"></a> </span><span class=cF1>U8</span><span class=cF0> *in_ptr,*in_start,*st2;
|
|
<a name="l10"></a> </span><span class=cF9>U16</span><span class=cF0> *d;
|
|
<a name="l11"></a> </span><span class=cFB>acd</span><span class=cF0>.num_words=0;
|
|
<a name="l12"></a> </span><span class=cF1>if</span><span class=cF0> (in_ptr=</span><span class=cF5>FileRead</span><span class=cF7>(</span><span class=cF3>ACD_WORD_FILENAME</span><span class=cF0>,&size</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l13"></a> in_start=in_ptr;
|
|
<a name="l14"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cFB>acd</span><span class=cF0>.word_lst);
|
|
<a name="l15"></a> </span><span class=cFB>acd</span><span class=cF0>.word_lst=</span><span class=cF5>AMAlloc</span><span class=cF0>(size);
|
|
<a name="l16"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(</span><span class=cFB>acd</span><span class=cF0>.word_lst,in_start,size);
|
|
<a name="l17"></a> </span><span class=cFB>acd</span><span class=cF0>.word_lst_size=size;
|
|
<a name="l18"></a>
|
|
<a name="l19"></a> </span><span class=cF1>while</span><span class=cF0> (in_ptr<in_start+size) {
|
|
<a name="l20"></a> </span><span class=cF1>if</span><span class=cF0> (*in_ptr==</span><span class=cF3>ACD_WORD_CHAR</span><span class=cF0>)
|
|
<a name="l21"></a> in_ptr++;
|
|
<a name="l22"></a> </span><span class=cF1>if</span><span class=cF0> (*in_ptr) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l23"></a> st2=</span><span class=cF5>MStrUtil</span><span class=cF0>(in_ptr,</span><span class=cF3>SUF_TO_UPPER</span><span class=cF0>);
|
|
<a name="l24"></a> tmph=</span><span class=cF5>ACAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHashGeneric</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>st2</span><span class=cF7>)</span><span class=cF0>+1);
|
|
<a name="l25"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(tmph+1,st2);
|
|
<a name="l26"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
|
|
<a name="l27"></a> in_ptr+=</span><span class=cF5>StrLen</span><span class=cF0>(in_ptr)+1;
|
|
<a name="l28"></a> tmph->str=tmph+1;
|
|
<a name="l29"></a> tmph->use_cnt=1;
|
|
<a name="l30"></a> tmph->type=</span><span class=cF3>HTT_DICT_WORD</span><span class=cF0>;
|
|
<a name="l31"></a> d=in_ptr;
|
|
<a name="l32"></a> tmph->user_data0=*d;
|
|
<a name="l33"></a> in_ptr+=2;
|
|
<a name="l34"></a> </span><span class=cF5>HashAdd</span><span class=cF0>(tmph,</span><span class=cFB>ac</span><span class=cF0>.hash_table);
|
|
<a name="l35"></a> </span><span class=cFB>acd</span><span class=cF0>.num_words++;
|
|
<a name="l36"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l37"></a> in_ptr+=3;
|
|
<a name="l38"></a> }
|
|
<a name="l39"></a> </span><span class=cF5>Free</span><span class=cF0>(in_start);
|
|
<a name="l40"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l41"></a>}
|
|
<a name="l42"></a>
|
|
<a name="l43"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"AutoComplete"</span><span class=cF0>
|
|
<a name="l44"></a></span><span class=cF9>CHashAC</span><span class=cF0> *</span><span class=cF5>ACHashAdd</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *w)
|
|
<a name="l45"></a>{
|
|
<a name="l46"></a> </span><span class=cF9>CHashAC</span><span class=cF0> *tmpw=</span><span class=cF5>HashFind</span><span class=cF0>(w,</span><span class=cFB>ac</span><span class=cF0>.hash_table,</span><span class=cF3>HTT_WORD</span><span class=cF0>);
|
|
<a name="l47"></a> </span><span class=cF1>if</span><span class=cF0> (tmpw) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l48"></a> tmpw->hits++;
|
|
<a name="l49"></a> </span><span class=cF1>return</span><span class=cF0> tmpw;
|
|
<a name="l50"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l51"></a> tmpw=</span><span class=cF5>ACAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CHashAC</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l52"></a> tmpw->str=</span><span class=cF5>AStrNew</span><span class=cF0>(w);
|
|
<a name="l53"></a> tmpw->type=</span><span class=cF3>HTT_WORD</span><span class=cF0>;
|
|
<a name="l54"></a> tmpw->use_cnt=1;
|
|
<a name="l55"></a> tmpw->hits=1;
|
|
<a name="l56"></a> </span><span class=cF5>HashAdd</span><span class=cF0>(tmpw,</span><span class=cFB>ac</span><span class=cF0>.hash_table);
|
|
<a name="l57"></a> </span><span class=cFB>ac</span><span class=cF0>.num_words++;
|
|
<a name="l58"></a> </span><span class=cF1>return</span><span class=cF0> tmpw;
|
|
<a name="l59"></a>}
|
|
<a name="l60"></a>
|
|
<a name="l61"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>ACSingleFileAdd</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *buf)
|
|
<a name="l62"></a>{
|
|
<a name="l63"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
|
|
<a name="l64"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr=buf,*ptr2,*ptr3;
|
|
<a name="l65"></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="l66"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
|
|
<a name="l67"></a> </span><span class=cF1>if</span><span class=cF0> (ch=*ptr++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l68"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>char_bmp_alpha_numeric</span><span class=cF0>,ch</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l69"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l70"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l71"></a> </span><span class=cF1>return</span><span class=cF0>;
|
|
<a name="l72"></a> }
|
|
<a name="l73"></a> ptr3=ptr;
|
|
<a name="l74"></a> ptr2=ptr;
|
|
<a name="l75"></a> ptr--;
|
|
<a name="l76"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
|
|
<a name="l77"></a> </span><span class=cF1>if</span><span class=cF0> (ch=*ptr2++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l78"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>char_bmp_alpha_numeric</span><span class=cF0>,ch</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l79"></a> *ptr3++=ch;
|
|
<a name="l80"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (ch!=</span><span class=cF3>CH_CURSOR</span><span class=cF0>)
|
|
<a name="l81"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l82"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l83"></a> ptr2--;
|
|
<a name="l84"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l85"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l86"></a> }
|
|
<a name="l87"></a> *ptr3=0;
|
|
<a name="l88"></a> </span><span class=cF5>ACHashAdd</span><span class=cF0>(ptr);
|
|
<a name="l89"></a> ptr=ptr2;
|
|
<a name="l90"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l91"></a>}
|
|
<a name="l92"></a>
|
|
<a name="l93"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>ACMainFileLstTraverse</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *files_find_mask)
|
|
<a name="l94"></a>{
|
|
<a name="l95"></a> </span><span class=cF1>U8</span><span class=cF0> *buf;
|
|
<a name="l96"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde,*tmpde1;
|
|
<a name="l97"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l98"></a> tmpde=tmpde1=</span><span class=cF5>FilesFind</span><span class=cF0>(files_find_mask,
|
|
<a name="l99"></a> </span><span class=cF3>FUF_RECURSE</span><span class=cF0>|</span><span class=cF3>FUF_JUST_TXT</span><span class=cF0>|</span><span class=cF3>FUF_JUST_FILES</span><span class=cF0>|</span><span class=cF3>FUF_CLUS_ORDER</span><span class=cF0>);
|
|
<a name="l100"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde) {
|
|
<a name="l101"></a> </span><span class=cF6>"%s\n"</span><span class=cF0>,tmpde->full_name;
|
|
<a name="l102"></a> buf=</span><span class=cF5>FileRead</span><span class=cF0>(tmpde->full_name);
|
|
<a name="l103"></a> </span><span class=cF5>ACSingleFileAdd</span><span class=cF0>(buf);
|
|
<a name="l104"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l105"></a> tmpde=tmpde->next;
|
|
<a name="l106"></a> }
|
|
<a name="l107"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l108"></a> </span><span class=cF5>Fs</span><span class=cF0>->catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l109"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde1);
|
|
<a name="l110"></a>}
|
|
<a name="l111"></a>
|
|
<a name="l112"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>ACProgressTask</span><span class=cF0>(</span><span class=cF1>Bool</span><span class=cF0> *_start_flag)
|
|
<a name="l113"></a>{
|
|
<a name="l114"></a> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF1>start</span><span class=cF0>=</span><span class=cFB>blkdev</span><span class=cF0>.write_cnt;
|
|
<a name="l115"></a> </span><span class=cFB>progress1</span><span class=cF0>=0;
|
|
<a name="l116"></a> </span><span class=cFB>progress1_max</span><span class=cF0>=(</span><span class=cF5>Size</span><span class=cF7>(</span><span class=cF3>ACD_DEF_FILENAME_Z</span><span class=cF0>,</span><span class=cF6>"+x+s"</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF3>BLK_SIZE</span><span class=cF0>-1)>></span><span class=cF3>BLK_SIZE_BITS</span><span class=cF0>;
|
|
<a name="l117"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(</span><span class=cFB>progress1_desc</span><span class=cF0>,</span><span class=cF6>"Uncompressing Dictionary"</span><span class=cF0>);
|
|
<a name="l118"></a> </span><span class=cF1>start</span><span class=cF0>=</span><span class=cFB>blkdev</span><span class=cF0>.write_cnt;
|
|
<a name="l119"></a> *_start_flag=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l120"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cFB>progress1</span><span class=cF0><</span><span class=cFB>progress1_max</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l121"></a> </span><span class=cFB>progress1</span><span class=cF0>=</span><span class=cFB>blkdev</span><span class=cF0>.write_cnt-</span><span class=cF1>start</span><span class=cF0>;
|
|
<a name="l122"></a> </span><span class=cF5>Sleep</span><span class=cF0>(10);
|
|
<a name="l123"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l124"></a> *</span><span class=cFB>progress1_desc</span><span class=cF0>=</span><span class=cFB>progress1</span><span class=cF0>=</span><span class=cFB>progress1_max</span><span class=cF0>=0;
|
|
<a name="l125"></a>}
|
|
<a name="l126"></a>
|
|
<a name="l127"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>ACInit</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *mask=</span><span class=cF3>NULL</span><span class=cF0>)
|
|
<a name="l128"></a>{</span><span class=cF2>//Read files and build AutoComplete statistics.</span><span class=cF0>
|
|
<a name="l129"></a> </span><span class=cF1>Bool</span><span class=cF0> start_flag;
|
|
<a name="l130"></a> </span><span class=cF9>CBlkDev</span><span class=cF0> *bd=</span><span class=cF5>Let2BlkDev</span><span class=cF0>;
|
|
<a name="l131"></a>
|
|
<a name="l132"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&</span><span class=cFB>sys_run_level</span><span class=cF0>,</span><span class=cF3>RLf_AUTO_COMPLETE</span><span class=cF0>);
|
|
<a name="l133"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
|
|
<a name="l134"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&</span><span class=cFB>ac</span><span class=cF0>.flags,</span><span class=cF3>ACf_INIT_IN_PROGRESS</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l135"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l136"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>DrvIsWritable</span><span class=cF0> && </span><span class=cF5>FileFind</span><span class=cF7>(</span><span class=cF3>ACD_DEF_FILENAME_Z</span><span class=cF7>)</span><span class=cF0> &&
|
|
<a name="l137"></a> !</span><span class=cF5>FileFind</span><span class=cF7>(</span><span class=cF3>ACD_DEF_FILENAME</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l138"></a> </span><span class=cF1>if</span><span class=cF0> (bd->type!=</span><span class=cF3>BDT_RAM</span><span class=cF0>) {
|
|
<a name="l139"></a> start_flag=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l140"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&</span><span class=cF5>ACProgressTask</span><span class=cF0>,&start_flag);
|
|
<a name="l141"></a> </span><span class=cF1>while</span><span class=cF0> (!start_flag)
|
|
<a name="l142"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l143"></a> }
|
|
<a name="l144"></a> </span><span class=cF5>Move</span><span class=cF0>(</span><span class=cF3>ACD_DEF_FILENAME_Z</span><span class=cF0>,</span><span class=cF3>ACD_DEF_FILENAME</span><span class=cF0>);
|
|
<a name="l145"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l146"></a>
|
|
<a name="l147"></a> </span><span class=cF5>HashTableDel</span><span class=cF0>(</span><span class=cFB>ac</span><span class=cF0>.hash_table);
|
|
<a name="l148"></a> </span><span class=cFB>ac</span><span class=cF0>.hash_table=</span><span class=cF5>HashTableNew</span><span class=cF0>(2048,</span><span class=cFB>adam_task</span><span class=cF0>);
|
|
<a name="l149"></a>
|
|
<a name="l150"></a> </span><span class=cFB>ac</span><span class=cF0>.num_words=0;
|
|
<a name="l151"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cFB>ac</span><span class=cF0>.cur_word);
|
|
<a name="l152"></a> </span><span class=cFB>ac</span><span class=cF0>.cur_word=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l153"></a>
|
|
<a name="l154"></a> </span><span class=cF1>if</span><span class=cF0> (mask)
|
|
<a name="l155"></a> </span><span class=cF5>ACMainFileLstTraverse</span><span class=cF0>(mask);
|
|
<a name="l156"></a>
|
|
<a name="l157"></a> </span><span class=cF5>ACDWordsLoad</span><span class=cF0>;
|
|
<a name="l158"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&</span><span class=cFB>ac</span><span class=cF0>.flags,</span><span class=cF3>ACf_INIT_IN_PROGRESS</span><span class=cF0>);
|
|
<a name="l159"></a> </span><span class=cF5>LBts</span><span class=cF0>(&</span><span class=cFB>sys_run_level</span><span class=cF0>,</span><span class=cF3>RLf_AUTO_COMPLETE</span><span class=cF0>);
|
|
<a name="l160"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
|
|
<a name="l161"></a>}
|
|
<a name="l162"></a>
|
|
<a name="l163"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>AutoCompleteSize</span><span class=cF0>()
|
|
<a name="l164"></a>{
|
|
<a name="l165"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ac</span><span class=cF0>.hash_table)
|
|
<a name="l166"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>HashTableSize2</span><span class=cF0>(</span><span class=cFB>ac</span><span class=cF0>.hash_table)+</span><span class=cF5>MSize2</span><span class=cF0>(</span><span class=cFB>acd</span><span class=cF0>.word_lst);
|
|
<a name="l167"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l168"></a> </span><span class=cF1>return</span><span class=cF0> 0;
|
|
<a name="l169"></a>}
|
|
</span></pre></body>
|
|
</html>
|