templeos-info/public/Wb/Adam/DolDoc/DocHighlight.HC.HTML

192 lines
17 KiB
Plaintext
Raw Normal View History

2024-03-24 21:24:44 +00:00
<!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>&quot;DolDoc/Misc&quot;</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF9>CColorROPU32</span><span class=cF0> </span><span class=cFB>highlight_hash_type_colors</span><span class=cF0>[</span><span class=cF3>HTt_TYPES_NUM</span><span class=cF0>]=
<a name="l4"></a> </span><span class=cF3>DOC_COLOR_EXPORT_SYS_SYM</span><span class=cF0>,0,</span><span class=cF3>DOC_COLOR_DEFINE_STR</span><span class=cF0>,</span><span class=cF3>DOC_COLOR_GLBL_VAR</span><span class=cF0>,
<a name="l5"></a> </span><span class=cF3>DOC_COLOR_CLASS</span><span class=cF0>,</span><span class=cF3>DOC_COLOR_KEYWORD</span><span class=cF0>,</span><span class=cF3>DOC_COLOR_FUN</span><span class=cF0>,0,0,</span><span class=cF3>DOC_COLOR_KEYWORD</span><span class=cF0>,
<a name="l6"></a> </span><span class=cF3>DOC_COLOR_KEYWORD</span><span class=cF0>,</span><span class=cF3>DOC_COLOR_KEYWORD</span><span class=cF0>,</span><span class=cF3>DOC_COLOR_REG</span><span class=cF0>,0,0,0,0</span><span class=cF7>}</span><span class=cF0>;
<a name="l7"></a>
<a name="l8"></a></span><span class=cF9>U32</span><span class=cF0> *</span><span class=cF5>DocHighlight</span><span class=cF0>(</span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e,</span><span class=cF1>U8</span><span class=cF0> *src,</span><span class=cF9>I64</span><span class=cF0> len,</span><span class=cF9>I64</span><span class=cF0> _tmp_u32_attr)
<a name="l9"></a></span><span class=cF7>{</span><span class=cF2>//Be aware of </span><a href="/Wb/Demo/ToHtmlToTXTDemo/ToHtml.HC.HTML#l1"><span class=cF4>::/Demo/ToHtmlToTXTDemo/ToHtml.HC</span></a><span class=cF2>.</span><span class=cF0>
<a name="l10"></a> </span><span class=cF9>U32</span><span class=cF0> *res=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>len+1</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>U32</span><span class=cF7>)</span><span class=cF0>),*dst=res;
<a name="l11"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr;
<a name="l12"></a> </span><span class=cF9>CDocSettings</span><span class=cF0> *s=&amp;doc_e-&gt;settings;
<a name="l13"></a> </span><span class=cF9>I64</span><span class=cF0> ch,ch1,last_ch,tmp_u32_attr,mask_tmp_u32_attr=_tmp_u32_attr&amp;0xFFFFF000,
<a name="l14"></a> comment_depth,brace_depth=s-&gt;brace_depth,paren_depth=s-&gt;paren_depth;
<a name="l15"></a> </span><span class=cF9>CHash</span><span class=cF0> *tmph;
<a name="l16"></a> </span><span class=cF1>switch</span><span class=cF0> [s-&gt;state] {
<a name="l17"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCSS_NORMAL</span><span class=cF0>:
<a name="l18"></a>hl_normal:
<a name="l19"></a> </span><span class=cF1>while</span><span class=cF0> (len) </span><span class=cF7>{</span><span class=cF0>
<a name="l20"></a> </span><span class=cF1>while</span><span class=cF0> (len &amp;&amp; !</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>char_bmp_alpha_numeric</span><span class=cF0>,*src</span><span class=cF7>)</span><span class=cF0>) {
<a name="l21"></a> tmp_u32_attr=_tmp_u32_attr;
<a name="l22"></a> ch1=*src++;
<a name="l23"></a> </span><span class=cF1>switch</span><span class=cF0> (ch1) </span><span class=cF7>{</span><span class=cF0>
<a name="l24"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'/'</span><span class=cF0>:
<a name="l25"></a> </span><span class=cF1>if</span><span class=cF0> (len&gt;=2) {
<a name="l26"></a> </span><span class=cF1>if</span><span class=cF0> (*src==</span><span class=cF6>'/'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l27"></a> tmp_u32_attr=</span><span class=cF3>DOC_COLOR_COMMENT</span><span class=cF0>&lt;&lt;8|mask_tmp_u32_attr;
<a name="l28"></a> *dst++=ch1+tmp_u32_attr;
<a name="l29"></a> *dst++=*src++ +tmp_u32_attr;
<a name="l30"></a> len-=2;
<a name="l31"></a> </span><span class=cF1>goto</span><span class=cF0> hl_cpp_comment;
<a name="l32"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (*src==</span><span class=cF6>'*'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l33"></a> tmp_u32_attr=</span><span class=cF3>DOC_COLOR_COMMENT</span><span class=cF0>&lt;&lt;8|mask_tmp_u32_attr;
<a name="l34"></a> *dst++=ch1+tmp_u32_attr;
<a name="l35"></a> *dst++=*src++ +tmp_u32_attr;
<a name="l36"></a> len-=2;
<a name="l37"></a> comment_depth=1;
<a name="l38"></a> </span><span class=cF1>goto</span><span class=cF0> hl_comment;
<a name="l39"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l40"></a> }
<a name="l41"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l42"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\''</span><span class=cF0>:
<a name="l43"></a> tmp_u32_attr=</span><span class=cF3>DOC_COLOR_CHAR_CONST</span><span class=cF0>&lt;&lt;8|mask_tmp_u32_attr;
<a name="l44"></a> *dst++=ch1+tmp_u32_attr;
<a name="l45"></a> len--;
<a name="l46"></a> </span><span class=cF1>goto</span><span class=cF0> hl_single_quote;
<a name="l47"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\&quot;'</span><span class=cF0>:
<a name="l48"></a> tmp_u32_attr=</span><span class=cF3>DOC_COLOR_STR</span><span class=cF0>&lt;&lt;8|mask_tmp_u32_attr;
<a name="l49"></a> *dst++=ch1+tmp_u32_attr;
<a name="l50"></a> len--;
<a name="l51"></a> </span><span class=cF1>goto</span><span class=cF0> hl_dbl_quote;
<a name="l52"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'('</span><span class=cF0>:
<a name="l53"></a> </span><span class=cF1>if</span><span class=cF0> (paren_depth++&amp;1)
<a name="l54"></a> tmp_u32_attr=</span><span class=cF3>DOC_COLOR_ALT_TEXT</span><span class=cF0>&lt;&lt;8|mask_tmp_u32_attr;
<a name="l55"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l56"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>')'</span><span class=cF0>:
<a name="l57"></a> </span><span class=cF1>if</span><span class=cF0> (--paren_depth&amp;1)
<a name="l58"></a> tmp_u32_attr=</span><span class=cF3>DOC_COLOR_ALT_TEXT</span><span class=cF0>&lt;&lt;8|mask_tmp_u32_attr;
<a name="l59"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l60"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'{'</span><span class=cF0>:
<a name="l61"></a> </span><span class=cF1>if</span><span class=cF0> (brace_depth++&amp;1)
<a name="l62"></a> tmp_u32_attr=</span><span class=cF3>DOC_COLOR_ALT_TEXT</span><span class=cF0>&lt;&lt;8|mask_tmp_u32_attr;
<a name="l63"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l64"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'}'</span><span class=cF0>:
<a name="l65"></a> </span><span class=cF1>if</span><span class=cF0> (--brace_depth&amp;1)
<a name="l66"></a> tmp_u32_attr=</span><span class=cF3>DOC_COLOR_ALT_TEXT</span><span class=cF0>&lt;&lt;8|mask_tmp_u32_attr;
<a name="l67"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l68"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l69"></a> *dst++=ch1+tmp_u32_attr;
<a name="l70"></a> </span><span class=cF1>if</span><span class=cF0> (!--len) </span><span class=cF1>goto</span><span class=cF0> hl_normal_done;
<a name="l71"></a> }
<a name="l72"></a> ptr=src;
<a name="l73"></a> </span><span class=cF1>while</span><span class=cF0> (len &amp;&amp; </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>char_bmp_alpha_numeric</span><span class=cF0>,*src</span><span class=cF7>)</span><span class=cF0>) {
<a name="l74"></a> src++;
<a name="l75"></a> len--;
<a name="l76"></a> }
<a name="l77"></a> ch=*src;
<a name="l78"></a> *src=0;
<a name="l79"></a> </span><span class=cF1>if</span><span class=cF0> (tmph=</span><span class=cF5>HashFind</span><span class=cF7>(</span><span class=cF0>ptr,</span><span class=cFB>adam_task</span><span class=cF0>-&gt;hash_table,
<a name="l80"></a> </span><span class=cF3>HTT_EXPORT_SYS_SYM</span><span class=cF0>|</span><span class=cF3>HTT_DEFINE_STR</span><span class=cF0>|</span><span class=cF3>HTT_GLBL_VAR</span><span class=cF0>|</span><span class=cF3>HTT_CLASS</span><span class=cF0>|
<a name="l81"></a> </span><span class=cF3>HTT_INTERNAL_TYPE</span><span class=cF0>|</span><span class=cF3>HTT_FUN</span><span class=cF0>|</span><span class=cF3>HTT_KEYWORD</span><span class=cF0>|</span><span class=cF3>HTT_ASM_KEYWORD</span><span class=cF0>|
<a name="l82"></a> </span><span class=cF3>HTT_OPCODE</span><span class=cF0>|</span><span class=cF3>HTT_REG</span><span class=cF7>)</span><span class=cF0>)
<a name="l83"></a> tmp_u32_attr=</span><span class=cFB>highlight_hash_type_colors</span><span class=cF0>[</span><span class=cF5>HashTypeNum</span><span class=cF0>(tmph)]&lt;&lt;8|
<a name="l84"></a> mask_tmp_u32_attr;
<a name="l85"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l86"></a> tmp_u32_attr=_tmp_u32_attr;
<a name="l87"></a> </span><span class=cF1>while</span><span class=cF0> (ch1=*ptr++)
<a name="l88"></a> *dst++=ch1+tmp_u32_attr;
<a name="l89"></a> *src=ch;
<a name="l90"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l91"></a>hl_normal_done:
<a name="l92"></a> s-&gt;state=</span><span class=cF3>DOCSS_NORMAL</span><span class=cF0>;
<a name="l93"></a> s-&gt;comment_depth=0;
<a name="l94"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l95"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCSS_SINGLE_QUOTE</span><span class=cF0>:
<a name="l96"></a> tmp_u32_attr=</span><span class=cF3>DOC_COLOR_CHAR_CONST</span><span class=cF0>&lt;&lt;8|mask_tmp_u32_attr;
<a name="l97"></a>hl_single_quote:
<a name="l98"></a> last_ch=0;
<a name="l99"></a> </span><span class=cF1>while</span><span class=cF0> (len--) </span><span class=cF7>{</span><span class=cF0>
<a name="l100"></a> ch1=*src++;
<a name="l101"></a> *dst++=ch1+tmp_u32_attr;
<a name="l102"></a> </span><span class=cF1>if</span><span class=cF0> (last_ch!=</span><span class=cF6>'\\'</span><span class=cF0> &amp;&amp; ch1==</span><span class=cF6>'\''</span><span class=cF0>)
<a name="l103"></a> </span><span class=cF1>goto</span><span class=cF0> hl_normal;
<a name="l104"></a> </span><span class=cF1>if</span><span class=cF0> (last_ch==</span><span class=cF6>'\\'</span><span class=cF0> &amp;&amp; ch1==</span><span class=cF6>'\\'</span><span class=cF0>)
<a name="l105"></a> last_ch=0;
<a name="l106"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l107"></a> last_ch=ch1;
<a name="l108"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l109"></a> s-&gt;state=</span><span class=cF3>DOCSS_SINGLE_QUOTE</span><span class=cF0>;
<a name="l110"></a> s-&gt;comment_depth=0;
<a name="l111"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l112"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCSS_DBL_QUOTE</span><span class=cF0>:
<a name="l113"></a> tmp_u32_attr=</span><span class=cF3>DOC_COLOR_CHAR_CONST</span><span class=cF0>&lt;&lt;8|mask_tmp_u32_attr;
<a name="l114"></a>hl_dbl_quote:
<a name="l115"></a> last_ch=0;
<a name="l116"></a> </span><span class=cF1>while</span><span class=cF0> (len--) </span><span class=cF7>{</span><span class=cF0>
<a name="l117"></a> ch1=*src++;
<a name="l118"></a> *dst++=ch1+tmp_u32_attr;
<a name="l119"></a> </span><span class=cF1>if</span><span class=cF0> (last_ch!=</span><span class=cF6>'\\'</span><span class=cF0> &amp;&amp; ch1==</span><span class=cF6>'\&quot;'</span><span class=cF0>)
<a name="l120"></a> </span><span class=cF1>goto</span><span class=cF0> hl_normal;
<a name="l121"></a> </span><span class=cF1>if</span><span class=cF0> (last_ch==</span><span class=cF6>'\\'</span><span class=cF0> &amp;&amp; ch1==</span><span class=cF6>'\\'</span><span class=cF0>)
<a name="l122"></a> last_ch=0;
<a name="l123"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l124"></a> last_ch=ch1;
<a name="l125"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l126"></a> s-&gt;state=</span><span class=cF3>DOCSS_DBL_QUOTE</span><span class=cF0>;
<a name="l127"></a> s-&gt;comment_depth=0;
<a name="l128"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l129"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCSS_COMMENT</span><span class=cF0>:
<a name="l130"></a> tmp_u32_attr=</span><span class=cF3>DOC_COLOR_COMMENT</span><span class=cF0>&lt;&lt;8|mask_tmp_u32_attr;
<a name="l131"></a> comment_depth=s-&gt;comment_depth;
<a name="l132"></a>hl_comment:
<a name="l133"></a> last_ch=0;
<a name="l134"></a> </span><span class=cF1>while</span><span class=cF0> (len--) </span><span class=cF7>{</span><span class=cF0>
<a name="l135"></a> ch1=*src++;
<a name="l136"></a> *dst++=ch1+tmp_u32_attr;
<a name="l137"></a> </span><span class=cF1>if</span><span class=cF0> (last_ch==</span><span class=cF6>'*'</span><span class=cF0> &amp;&amp; ch1==</span><span class=cF6>'/'</span><span class=cF0>) {
<a name="l138"></a> </span><span class=cF1>if</span><span class=cF0> (!--comment_depth)
<a name="l139"></a> </span><span class=cF1>goto</span><span class=cF0> hl_normal;
<a name="l140"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (last_ch==</span><span class=cF6>'/'</span><span class=cF0> &amp;&amp; ch1==</span><span class=cF6>'*'</span><span class=cF0>)
<a name="l141"></a> comment_depth++;
<a name="l142"></a> last_ch=ch1;
<a name="l143"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l144"></a> s-&gt;state=</span><span class=cF3>DOCSS_COMMENT</span><span class=cF0>;
<a name="l145"></a> s-&gt;comment_depth=comment_depth;
<a name="l146"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l147"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCSS_CPP_Z_COMMENT</span><span class=cF0>:
<a name="l148"></a> tmp_u32_attr=</span><span class=cF3>DOC_COLOR_COMMENT</span><span class=cF0>&lt;&lt;8|mask_tmp_u32_attr;
<a name="l149"></a>hl_cpp_comment:
<a name="l150"></a> </span><span class=cF1>while</span><span class=cF0> (len--)
<a name="l151"></a> *dst++=*src++ +tmp_u32_attr;
<a name="l152"></a> s-&gt;state=</span><span class=cF3>DOCSS_CPP_Z_COMMENT</span><span class=cF0>;
<a name="l153"></a> s-&gt;comment_depth=0;
<a name="l154"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l155"></a> }
<a name="l156"></a> s-&gt;paren_depth=paren_depth;
<a name="l157"></a> s-&gt;brace_depth=brace_depth;
<a name="l158"></a> *dst=0;
<a name="l159"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l160"></a></span><span class=cF7>}</span><span class=cF0>
</span></pre></body>
</html>