mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-28 08:16:31 +00:00
195 lines
17 KiB
HTML
Executable file
195 lines
17 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V1.06">
|
|
<style type="text/css">
|
|
body {background-color:#1f1f1f;}
|
|
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
|
|
.cF1{color:#4f84a6;background-color:#1f1f1f;}
|
|
.cF2{color:#73a255;background-color:#1f1f1f;}
|
|
.cF3{color:#297582;background-color:#1f1f1f;}
|
|
.cF4{color:#b34f4b;background-color:#1f1f1f;}
|
|
.cF5{color:#8a52c3;background-color:#1f1f1f;}
|
|
.cF6{color:#b7822f;background-color:#1f1f1f;}
|
|
.cF7{color:#444444;background-color:#1f1f1f;}
|
|
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
|
|
.cF9{color:#94bfde;background-color:#1f1f1f;}
|
|
.cFA{color:#a1ce97;background-color:#1f1f1f;}
|
|
.cFB{color:#6db4be;background-color:#1f1f1f;}
|
|
.cFC{color:#e88e88;background-color:#1f1f1f;}
|
|
.cFD{color:#ca94e8;background-color:#1f1f1f;}
|
|
.cFE{color:#d4b475;background-color:#1f1f1f;}
|
|
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<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>
|
|
<a name="l3"></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="l4"></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>);
|
|
<a name="l5"></a>
|
|
<a name="l6"></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="l7"></a>{</span><span class=cF2>//Put words from word list into hash table.</span><span class=cF0>
|
|
<a name="l8"></a> </span><span class=cF9>I64</span><span class=cF0> size;
|
|
<a name="l9"></a> </span><span class=cF9>CHashGeneric</span><span class=cF0> *tmph;
|
|
<a name="l10"></a> </span><span class=cF1>U8</span><span class=cF0> *in_ptr, *in_start, *st2;
|
|
<a name="l11"></a> </span><span class=cF9>U16</span><span class=cF0> *d;
|
|
<a name="l12"></a>
|
|
<a name="l13"></a> </span><span class=cFB>acd</span><span class=cF0>.num_words = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l14"></a>
|
|
<a name="l15"></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>)
|
|
<a name="l16"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l17"></a> in_start = in_ptr;
|
|
<a name="l18"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cFB>acd</span><span class=cF0>.word_list);
|
|
<a name="l19"></a> </span><span class=cFB>acd</span><span class=cF0>.word_list = </span><span class=cF5>SysMAlloc</span><span class=cF0>(size);
|
|
<a name="l20"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(</span><span class=cFB>acd</span><span class=cF0>.word_list, in_start, size);
|
|
<a name="l21"></a> </span><span class=cFB>acd</span><span class=cF0>.word_list_size = size;
|
|
<a name="l22"></a>
|
|
<a name="l23"></a> </span><span class=cF1>while</span><span class=cF0> (in_ptr < in_start + size)
|
|
<a name="l24"></a> {
|
|
<a name="l25"></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="l26"></a> in_ptr++;
|
|
<a name="l27"></a> </span><span class=cF1>if</span><span class=cF0> (*in_ptr)
|
|
<a name="l28"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l29"></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="l30"></a> tmph = </span><span class=cF5>SysCAlloc</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> + </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l31"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(tmph + </span><span class=cFE>1</span><span class=cF0>, st2);
|
|
<a name="l32"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
|
|
<a name="l33"></a> in_ptr += </span><span class=cF5>StrLen</span><span class=cF0>(in_ptr) + </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l34"></a> tmph->str = tmph + </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l35"></a> tmph->use_count = </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l36"></a> tmph->type = </span><span class=cF3>HTT_DICT_WORD</span><span class=cF0>;
|
|
<a name="l37"></a> d = in_ptr;
|
|
<a name="l38"></a> tmph->user_data0 = *d;
|
|
<a name="l39"></a> in_ptr += </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l40"></a> </span><span class=cF5>HashAdd</span><span class=cF0>(tmph, </span><span class=cFB>ac</span><span class=cF0>.hash_table);
|
|
<a name="l41"></a> </span><span class=cFB>acd</span><span class=cF0>.num_words++;
|
|
<a name="l42"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l43"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l44"></a> in_ptr += </span><span class=cFE>3</span><span class=cF0>;
|
|
<a name="l45"></a> }
|
|
<a name="l46"></a> </span><span class=cF5>Free</span><span class=cF0>(in_start);
|
|
<a name="l47"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l48"></a>}
|
|
<a name="l49"></a>
|
|
<a name="l50"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"AutoComplete"</span><span class=cF0>
|
|
<a name="l51"></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="l52"></a>{
|
|
<a name="l53"></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="l54"></a>
|
|
<a name="l55"></a> </span><span class=cF1>if</span><span class=cF0> (tmpw)
|
|
<a name="l56"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l57"></a> tmpw->hits++;
|
|
<a name="l58"></a> </span><span class=cF1>return</span><span class=cF0> tmpw;
|
|
<a name="l59"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l60"></a> tmpw = </span><span class=cF5>SysCAlloc</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="l61"></a> tmpw->str = </span><span class=cF5>SysStrNew</span><span class=cF0>(w);
|
|
<a name="l62"></a> tmpw->type = </span><span class=cF3>HTT_WORD</span><span class=cF0>;
|
|
<a name="l63"></a> tmpw->use_count = </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l64"></a> tmpw->hits = </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l65"></a> </span><span class=cF5>HashAdd</span><span class=cF0>(tmpw, </span><span class=cFB>ac</span><span class=cF0>.hash_table);
|
|
<a name="l66"></a> </span><span class=cFB>ac</span><span class=cF0>.num_words++;
|
|
<a name="l67"></a> </span><span class=cF1>return</span><span class=cF0> tmpw;
|
|
<a name="l68"></a>}
|
|
<a name="l69"></a>
|
|
<a name="l70"></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="l71"></a>{
|
|
<a name="l72"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
|
|
<a name="l73"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr = buf, *ptr2, *ptr3;
|
|
<a name="l74"></a>
|
|
<a name="l75"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l76"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l77"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l78"></a> {
|
|
<a name="l79"></a> </span><span class=cF1>if</span><span class=cF0> (ch = *ptr++)
|
|
<a name="l80"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l81"></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="l82"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l83"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l84"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l85"></a> </span><span class=cF1>return</span><span class=cF0>;
|
|
<a name="l86"></a> }
|
|
<a name="l87"></a> ptr3 = ptr;
|
|
<a name="l88"></a> ptr2 = ptr;
|
|
<a name="l89"></a> ptr--;
|
|
<a name="l90"></a>
|
|
<a name="l91"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l92"></a> {
|
|
<a name="l93"></a> </span><span class=cF1>if</span><span class=cF0> (ch = *ptr2++)
|
|
<a name="l94"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l95"></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="l96"></a> *ptr3++ = ch;
|
|
<a name="l97"></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="l98"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l99"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l100"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l101"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l102"></a> ptr2--;
|
|
<a name="l103"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l104"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l105"></a> }
|
|
<a name="l106"></a> *ptr3 = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l107"></a> </span><span class=cF5>ACHashAdd</span><span class=cF0>(ptr);
|
|
<a name="l108"></a> ptr = ptr2;
|
|
<a name="l109"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<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>ACMainFileListTraverse</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *files_find_mask)
|
|
<a name="l113"></a>{
|
|
<a name="l114"></a> </span><span class=cF1>U8</span><span class=cF0> *buf;
|
|
<a name="l115"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde, *tmpde1;
|
|
<a name="l116"></a>
|
|
<a name="l117"></a> </span><span class=cF1>try</span><span class=cF0>
|
|
<a name="l118"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l119"></a> tmpde = tmpde1 = </span><span class=cF5>FilesFind</span><span class=cF0>(files_find_mask, </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="l120"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde)
|
|
<a name="l121"></a> {
|
|
<a name="l122"></a> </span><span class=cF6>"%s\n"</span><span class=cF0>, tmpde->full_name;
|
|
<a name="l123"></a> buf = </span><span class=cF5>FileRead</span><span class=cF0>(tmpde->full_name);
|
|
<a name="l124"></a> </span><span class=cF5>ACSingleFileAdd</span><span class=cF0>(buf);
|
|
<a name="l125"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l126"></a> tmpde = tmpde->next;
|
|
<a name="l127"></a> }
|
|
<a name="l128"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l129"></a> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l130"></a> </span><span class=cF5>Fs</span><span class=cF0>->catch_except = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l131"></a>
|
|
<a name="l132"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde1);
|
|
<a name="l133"></a>}
|
|
<a name="l134"></a>
|
|
<a name="l135"></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="l136"></a>{</span><span class=cF2>//Read files and build AutoComplete statistics.</span><span class=cF0>
|
|
<a name="l137"></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_AUTOCOMPLETE</span><span class=cF0>);
|
|
<a name="l138"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
|
|
<a name="l139"></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="l140"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l141"></a>
|
|
<a name="l142"></a> </span><span class=cF5>HashTableDel</span><span class=cF0>(</span><span class=cFB>ac</span><span class=cF0>.hash_table);
|
|
<a name="l143"></a> </span><span class=cFB>ac</span><span class=cF0>.hash_table = </span><span class=cF5>HashTableNew</span><span class=cF0>(</span><span class=cFE>2048</span><span class=cF0>, </span><span class=cFB>sys_task</span><span class=cF0>);
|
|
<a name="l144"></a>
|
|
<a name="l145"></a> </span><span class=cFB>ac</span><span class=cF0>.num_words = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l146"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cFB>ac</span><span class=cF0>.cur_word);
|
|
<a name="l147"></a> </span><span class=cFB>ac</span><span class=cF0>.cur_word = </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l148"></a>
|
|
<a name="l149"></a> </span><span class=cF1>if</span><span class=cF0> (mask)
|
|
<a name="l150"></a> </span><span class=cF5>ACMainFileListTraverse</span><span class=cF0>(mask);
|
|
<a name="l151"></a>
|
|
<a name="l152"></a> </span><span class=cF5>ACDWordsLoad</span><span class=cF0>;
|
|
<a name="l153"></a> </span><span class=cF5>RegDefault</span><span class=cF0>(</span><span class=cF6>"AutoComplete"</span><span class=cF0>, </span><span class=cF6>"ac.col = TEXT_COLS-34;ac.row = 10;"</span><span class=cF0>);
|
|
<a name="l154"></a> </span><span class=cF5>RegExe</span><span class=cF0>(</span><span class=cF6>"AutoComplete"</span><span class=cF0>);
|
|
<a name="l155"></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="l156"></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_AUTOCOMPLETE</span><span class=cF0>);
|
|
<a name="l157"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
|
|
<a name="l158"></a>}
|
|
<a name="l159"></a>
|
|
<a name="l160"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>AutoCompleteSize</span><span class=cF0>()
|
|
<a name="l161"></a>{
|
|
<a name="l162"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ac</span><span class=cF0>.hash_table)
|
|
<a name="l163"></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_list);
|
|
<a name="l164"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l165"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l166"></a>}
|
|
</span></pre></body>
|
|
</html>
|