389 lines
43 KiB
HTML
Executable File
389 lines
43 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>"DolDoc/File"</span><span class=cF0>
|
|
<a name="l2"></a>
|
|
<a name="l3"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DocLoad</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc,</span><span class=cF1>U8</span><span class=cF0> *src2,</span><span class=cF9>I64</span><span class=cF0> size)
|
|
<a name="l4"></a>{</span><span class=cF2>//Fetch doc from raw mem buf.</span><span class=cF0>
|
|
<a name="l5"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l6"></a> </span><span class=cF1>U8</span><span class=cF0> *src;
|
|
<a name="l7"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock=</span><span class=cF5>DocLock</span><span class=cF0>(doc);
|
|
<a name="l8"></a> </span><span class=cF9>CDocBin</span><span class=cF0> *tmpb;
|
|
<a name="l9"></a> doc->find_replace->filter_lines=0;
|
|
<a name="l10"></a> </span><span class=cF1>if</span><span class=cF0> (src2) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l11"></a> </span><span class=cF5>DocPutS</span><span class=cF0>(doc,src2); </span><span class=cF2>//Too big </span><a href="/Wb/Adam/DolDoc/DocPutS.HC.HTML#l148"><span class=cF4>DocPrint</span></a><span class=cF2>() is wasteful.</span><span class=cF0>
|
|
<a name="l12"></a> src=src2+</span><span class=cF5>StrLen</span><span class=cF0>(src2)+1;
|
|
<a name="l13"></a> i=size-(</span><span class=cF1>offset</span><span class=cF7>(</span><span class=cF9>CDocBin</span><span class=cF0>.</span><span class=cF1>end</span><span class=cF7>)</span><span class=cF0>-</span><span class=cF1>offset</span><span class=cF7>(</span><span class=cF9>CDocBin</span><span class=cF0>.</span><span class=cF1>start</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l14"></a> </span><span class=cF1>while</span><span class=cF0> (src<=src2+i) {
|
|
<a name="l15"></a> tmpb=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDocBin</span><span class=cF7>)</span><span class=cF0>,doc->mem_task);
|
|
<a name="l16"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&tmpb-></span><span class=cF1>start</span><span class=cF0>,src,</span><span class=cF1>offset</span><span class=cF7>(</span><span class=cF9>CDocBin</span><span class=cF0>.</span><span class=cF1>end</span><span class=cF7>)</span><span class=cF0>-</span><span class=cF1>offset</span><span class=cF7>(</span><span class=cF9>CDocBin</span><span class=cF0>.</span><span class=cF1>start</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l17"></a> src+=</span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CDocBin</span><span class=cF0>.</span><span class=cF1>end</span><span class=cF0>)-</span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CDocBin</span><span class=cF0>.</span><span class=cF1>start</span><span class=cF0>);
|
|
<a name="l18"></a> tmpb->data=</span><span class=cF5>MAlloc</span><span class=cF0>(tmpb->size,doc->mem_task);
|
|
<a name="l19"></a> </span><span class=cF1>if</span><span class=cF0> (tmpb->size) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l20"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(tmpb->data,src,tmpb->size);
|
|
<a name="l21"></a> src+=tmpb->size;
|
|
<a name="l22"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l23"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpb,doc->bin_head.last);
|
|
<a name="l24"></a> </span><span class=cF1>if</span><span class=cF0> (tmpb->num>=doc->cur_bin_num)
|
|
<a name="l25"></a> doc->cur_bin_num=tmpb->num+1;
|
|
<a name="l26"></a> }
|
|
<a name="l27"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l28"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>doc->flags & (</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>|</span><span class=cF3>DOCF_PLAIN_TEXT_TABS</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l29"></a> </span><span class=cF5>DocBinsValidate</span><span class=cF0>(doc);
|
|
<a name="l30"></a> </span><span class=cF5>DocTop</span><span class=cF0>(doc); </span><span class=cF2>//Calls </span><a href="/Wb/Adam/DolDoc/DocRecalc.HC.HTML#l256"><span class=cF4>DocRecalc</span></a><span class=cF2>(). DOCT_CURSOR will be set.</span><span class=cF0>
|
|
<a name="l31"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l32"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
|
|
<a name="l33"></a>}
|
|
<a name="l34"></a>
|
|
<a name="l35"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>CDoc</span><span class=cF0> *</span><span class=cF5>DocRead</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *name=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> flags=0)
|
|
<a name="l36"></a>{</span><span class=cF2>//Fetch doc from disk. See </span><a href="/Wb/Kernel/KernelA.HH.HTML#l1269"><span class=cF4>flags</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l37"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF5>DocNew</span><span class=cF0>;
|
|
<a name="l38"></a> </span><span class=cF1>U8</span><span class=cF0> *src,*name2;
|
|
<a name="l39"></a> </span><span class=cF9>I64</span><span class=cF0> size=0;
|
|
<a name="l40"></a> </span><span class=cF9>CDirContext</span><span class=cF0> *dirc;
|
|
<a name="l41"></a> </span><span class=cF1>if</span><span class=cF0> (!name) name=</span><span class=cFB>blkdev</span><span class=cF0>.tmp_filename;
|
|
<a name="l42"></a> doc->flags|=flags;
|
|
<a name="l43"></a> name2=</span><span class=cF5>FileNameAbs</span><span class=cF0>(name);
|
|
<a name="l44"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(doc->filename.name,name2);
|
|
<a name="l45"></a> </span><span class=cF1>if</span><span class=cF0> (src=</span><span class=cF5>FileRead</span><span class=cF7>(</span><span class=cF0>name2,&size,&doc->file_attr</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l46"></a> </span><span class=cF1>if</span><span class=cF0> (dirc=</span><span class=cF5>DirContextNew</span><span class=cF7>(</span><span class=cF0>name2</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l47"></a> </span><span class=cF5>DocLoad</span><span class=cF0>(doc,src,size);
|
|
<a name="l48"></a> </span><span class=cF5>DirContextDel</span><span class=cF0>(dirc);
|
|
<a name="l49"></a> }
|
|
<a name="l50"></a> </span><span class=cF5>Free</span><span class=cF0>(src);
|
|
<a name="l51"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l52"></a> </span><span class=cF5>Free</span><span class=cF0>(name2);
|
|
<a name="l53"></a> </span><span class=cF1>return</span><span class=cF0> doc;
|
|
<a name="l54"></a>}
|
|
<a name="l55"></a>
|
|
<a name="l56"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>DocSave</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc,</span><span class=cF9>I64</span><span class=cF0> *_size=</span><span class=cF3>NULL</span><span class=cF0>)
|
|
<a name="l57"></a>{</span><span class=cF2>//Store doc to raw mem buf.</span><span class=cF0>
|
|
<a name="l58"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e,*doc_e1;
|
|
<a name="l59"></a> </span><span class=cF9>CDocBin</span><span class=cF0> *b;
|
|
<a name="l60"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock=</span><span class=cF5>DocLock</span><span class=cF0>(doc);
|
|
<a name="l61"></a> </span><span class=cF9>I64</span><span class=cF0> ch,cnt=1;</span><span class=cF2>//terminator</span><span class=cF0>
|
|
<a name="l62"></a> </span><span class=cF1>U8</span><span class=cF0> *st,*res,*dst,*src;
|
|
<a name="l63"></a>
|
|
<a name="l64"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>doc->flags & (</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>|</span><span class=cF3>DOCF_PLAIN_TEXT_TABS</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l65"></a> </span><span class=cF5>DocBinsValidate</span><span class=cF0>(doc);
|
|
<a name="l66"></a> </span><span class=cF1>if</span><span class=cF0> (doc->flags&</span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>)
|
|
<a name="l67"></a> </span><span class=cF5>DocRecalc</span><span class=cF0>(doc);
|
|
<a name="l68"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l69"></a> </span><span class=cF5>DocRecalc</span><span class=cF0>(doc,</span><span class=cF3>RECALCF_ADD_CURSOR</span><span class=cF0>);
|
|
<a name="l70"></a> </span><span class=cF1>if</span><span class=cF0> (doc->head.next->type_u8==</span><span class=cF3>DOCT_CURSOR</span><span class=cF0>)
|
|
<a name="l71"></a> </span><span class=cF5>DocEntryDel</span><span class=cF0>(doc,doc->head.next); </span><span class=cF2>//If no cursor, </span><a href="/Wb/Adam/DolDoc/DocFile.HC.HTML#l3"><span class=cF4>DocLoad</span></a><span class=cF2>() puts at top.</span><span class=cF0>
|
|
<a name="l72"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l73"></a> </span><span class=cF1>for</span><span class=cF0> (doc_e=doc->head.next;doc_e!=doc;doc_e=doc_e->next) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l74"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>doldoc</span><span class=cF0>.type_flags_data,doc_e->type_u8</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l75"></a> </span><span class=cF1>switch</span><span class=cF0> (doc_e->type_u8) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l76"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_TAB</span><span class=cF0>:
|
|
<a name="l77"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_PAGE_BREAK</span><span class=cF0>:
|
|
<a name="l78"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_CURSOR</span><span class=cF0>:
|
|
<a name="l79"></a> cnt++;
|
|
<a name="l80"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l81"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_NEW_LINE</span><span class=cF0>:
|
|
<a name="l82"></a> </span><span class=cF1>if</span><span class=cF0> (doc->flags&</span><span class=cF3>DOCF_CARRIAGE_RETURN</span><span class=cF0>)
|
|
<a name="l83"></a> cnt+=2;
|
|
<a name="l84"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l85"></a> cnt++;
|
|
<a name="l86"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l87"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_SOFT_NEW_LINE</span><span class=cF0>:
|
|
<a name="l88"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l89"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_TEXT</span><span class=cF0>:
|
|
<a name="l90"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>doc_e->de_flags & ~(</span><span class=cF3>DOCEF_TAG</span><span class=cF0>|</span><span class=cF3>DOCG_BL_IV_UL</span><span class=cF0>|</span><span class=cF3>DOCEF_WORD_WRAP</span><span class=cF0>|
|
|
<a name="l91"></a> </span><span class=cF3>DOCEF_HIGHLIGHT</span><span class=cF0>|</span><span class=cF3>DOCEF_SKIP</span><span class=cF0>|</span><span class=cF3>DOCEF_FILTER_SKIP</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>&&
|
|
<a name="l92"></a> !</span><span class=cF7>(</span><span class=cF0>doc_e->type&</span><span class=cF3>DOCG_BL_IV_UL</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l93"></a> cnt+=</span><span class=cF5>StrLen</span><span class=cF0>(doc_e->tag);
|
|
<a name="l94"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>doc->flags & (</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>|</span><span class=cF3>DOCF_PLAIN_TEXT_TABS</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0> ||
|
|
<a name="l95"></a> doc->flags&</span><span class=cF3>DOCF_DBL_DOLLARS</span><span class=cF0>)
|
|
<a name="l96"></a> cnt+=</span><span class=cF5>StrOcc</span><span class=cF0>(doc_e->tag,</span><span class=cF6>'$'</span><span class=cF0>);
|
|
<a name="l97"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l98"></a> }
|
|
<a name="l99"></a> </span><span class=cF1>default</span><span class=cF0>:
|
|
<a name="l100"></a> st=</span><span class=cF5>Doc2PlainText</span><span class=cF0>(doc,doc_e);
|
|
<a name="l101"></a> cnt+=</span><span class=cF5>StrLen</span><span class=cF0>(st)+2;
|
|
<a name="l102"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
|
<a name="l103"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l104"></a> }
|
|
<a name="l105"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l106"></a> </span><span class=cF1>for</span><span class=cF0> (b=doc->bin_head.next;b!=&doc->bin_head;b=b->next)
|
|
<a name="l107"></a> </span><span class=cF1>if</span><span class=cF0> (b->use_cnt>b->tmp_use_cnt)
|
|
<a name="l108"></a> cnt+=</span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CDocBin</span><span class=cF0>.</span><span class=cF1>end</span><span class=cF0>)-</span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CDocBin</span><span class=cF0>.</span><span class=cF1>start</span><span class=cF0>)+b->size;
|
|
<a name="l109"></a> res=</span><span class=cF5>MAlloc</span><span class=cF0>(cnt);
|
|
<a name="l110"></a> dst=res;
|
|
<a name="l111"></a> doc_e=doc->head.next;
|
|
<a name="l112"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e!=doc) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l113"></a> doc_e1=doc_e->next;
|
|
<a name="l114"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>doldoc</span><span class=cF0>.type_flags_data,doc_e->type_u8</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l115"></a> </span><span class=cF1>switch</span><span class=cF0> (doc_e->type_u8) {
|
|
<a name="l116"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_CURSOR</span><span class=cF0>:
|
|
<a name="l117"></a> </span><span class=cF5>DocEntryDel</span><span class=cF0>(doc,doc_e);
|
|
<a name="l118"></a> *dst++=</span><span class=cF3>CH_CURSOR</span><span class=cF0>;
|
|
<a name="l119"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l120"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_TAB</span><span class=cF0>:
|
|
<a name="l121"></a> *dst++=</span><span class=cF6>'\t'</span><span class=cF0>;
|
|
<a name="l122"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l123"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_NEW_LINE</span><span class=cF0>:
|
|
<a name="l124"></a> </span><span class=cF1>if</span><span class=cF0> (doc->flags&</span><span class=cF3>DOCF_CARRIAGE_RETURN</span><span class=cF0>)
|
|
<a name="l125"></a> *dst++=</span><span class=cF6>'\r'</span><span class=cF0>;
|
|
<a name="l126"></a> *dst++=</span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l127"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l128"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_SOFT_NEW_LINE</span><span class=cF0>:
|
|
<a name="l129"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l130"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>DOCT_TEXT</span><span class=cF0>:
|
|
<a name="l131"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>doc_e->de_flags & ~(</span><span class=cF3>DOCEF_TAG</span><span class=cF0>|</span><span class=cF3>DOCG_BL_IV_UL</span><span class=cF0>|</span><span class=cF3>DOCEF_WORD_WRAP</span><span class=cF0>|
|
|
<a name="l132"></a> </span><span class=cF3>DOCEF_HIGHLIGHT</span><span class=cF0>|</span><span class=cF3>DOCEF_SKIP</span><span class=cF0>|</span><span class=cF3>DOCEF_FILTER_SKIP</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0> &&
|
|
<a name="l133"></a> !</span><span class=cF7>(</span><span class=cF0>doc_e->type&</span><span class=cF3>DOCG_BL_IV_UL</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l134"></a> src=doc_e->tag;
|
|
<a name="l135"></a> </span><span class=cF1>while</span><span class=cF0> (ch=*src++) {
|
|
<a name="l136"></a> *dst++=ch;
|
|
<a name="l137"></a> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'$'</span><span class=cF0> && </span><span class=cF7>(</span><span class=cF0>!(doc->flags & </span><span class=cF7>(</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>|
|
|
<a name="l138"></a> </span><span class=cF3>DOCF_PLAIN_TEXT_TABS</span><span class=cF7>)</span><span class=cF0>) || doc->flags&</span><span class=cF3>DOCF_DBL_DOLLARS</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l139"></a> *dst++=ch;
|
|
<a name="l140"></a> }
|
|
<a name="l141"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l142"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l143"></a> </span><span class=cF1>default</span><span class=cF0>:
|
|
<a name="l144"></a> *dst++=</span><span class=cF6>'$'</span><span class=cF0>;
|
|
<a name="l145"></a> st=</span><span class=cF5>Doc2PlainText</span><span class=cF0>(doc,doc_e);
|
|
<a name="l146"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(dst,st);
|
|
<a name="l147"></a> dst+=</span><span class=cF5>StrLen</span><span class=cF0>(st);
|
|
<a name="l148"></a> *dst++=</span><span class=cF6>'$'</span><span class=cF0>;
|
|
<a name="l149"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
|
<a name="l150"></a> }
|
|
<a name="l151"></a> doc_e=doc_e1;
|
|
<a name="l152"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l153"></a> *dst++=0;
|
|
<a name="l154"></a> b=doc->bin_head.next;
|
|
<a name="l155"></a> </span><span class=cF1>if</span><span class=cF0> (b!=&doc->bin_head) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l156"></a> </span><span class=cF1>do</span><span class=cF0> {
|
|
<a name="l157"></a> </span><span class=cF1>if</span><span class=cF0> (b->use_cnt>b->tmp_use_cnt) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l158"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(dst,&b-></span><span class=cF1>start</span><span class=cF0>,</span><span class=cF1>offset</span><span class=cF7>(</span><span class=cF9>CDocBin</span><span class=cF0>.</span><span class=cF1>end</span><span class=cF7>)</span><span class=cF0>-</span><span class=cF1>offset</span><span class=cF7>(</span><span class=cF9>CDocBin</span><span class=cF0>.</span><span class=cF1>start</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l159"></a> dst+=</span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CDocBin</span><span class=cF0>.</span><span class=cF1>end</span><span class=cF0>)-</span><span class=cF1>offset</span><span class=cF0>(</span><span class=cF9>CDocBin</span><span class=cF0>.</span><span class=cF1>start</span><span class=cF0>);
|
|
<a name="l160"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(dst,b->data,b->size);
|
|
<a name="l161"></a> dst+=b->size;
|
|
<a name="l162"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l163"></a> b=b->next;
|
|
<a name="l164"></a> } </span><span class=cF1>while</span><span class=cF0> (b!=&doc->bin_head);
|
|
<a name="l165"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l166"></a> cnt--; </span><span class=cF2>//No terminator</span><span class=cF0>
|
|
<a name="l167"></a> </span><span class=cF1>if</span><span class=cF0> (_size) *_size=cnt;
|
|
<a name="l168"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l169"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
|
|
<a name="l170"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l171"></a>}
|
|
<a name="l172"></a>
|
|
<a name="l173"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DocWrite</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc,</span><span class=cF1>Bool</span><span class=cF0> prompt=</span><span class=cF3>FALSE</span><span class=cF0>)
|
|
<a name="l174"></a>{</span><span class=cF2>//Store doc to disk.</span><span class=cF0>
|
|
<a name="l175"></a> </span><span class=cF9>I64</span><span class=cF0> size;
|
|
<a name="l176"></a> </span><span class=cF1>U8</span><span class=cF0> *buf;
|
|
<a name="l177"></a> </span><span class=cF1>if</span><span class=cF0> (prompt && !</span><span class=cF5>DocForm</span><span class=cF7>(</span><span class=cF0>&doc->filename</span><span class=cF7>)</span><span class=cF0> ||
|
|
<a name="l178"></a> doc->filename.name[0]==</span><span class=cF6>'A'</span><span class=cF0> && doc->filename.name[2]==</span><span class=cF6>':'</span><span class=cF0>)
|
|
<a name="l179"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>; </span><span class=cF2>//CANCEL || LK_DOC,LK_DOC_ANCHOR,LK_DOC_FIND,LK_DOC_LINE?</span><span class=cF0>
|
|
<a name="l180"></a> buf=</span><span class=cF5>DocSave</span><span class=cF0>(doc,&size);
|
|
<a name="l181"></a> </span><span class=cF5>FileWrite</span><span class=cF0>(doc->filename.name,buf,size,0,doc->file_attr);
|
|
<a name="l182"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l183"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l184"></a>}
|
|
<a name="l185"></a>
|
|
<a name="l186"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"DolDoc"</span><span class=cF0>
|
|
<a name="l187"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DocInsDoc</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>CDoc</span><span class=cF0> *doc2)
|
|
<a name="l188"></a>{</span><span class=cF2>//Insert copy of doc2 into doc at insert pt, cur_entry.</span><span class=cF0>
|
|
<a name="l189"></a></span><span class=cF2>//TODO: </span><a href="/Wb/Adam/DolDoc/DocNew.HC.HTML#l236"><span class=cF4>DocRst</span></a><span class=cF0>
|
|
<a name="l190"></a> </span><span class=cF1>U8</span><span class=cF0> *dst;
|
|
<a name="l191"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock_doc,unlock_doc2=</span><span class=cF5>DocLock</span><span class=cF0>(doc2);
|
|
<a name="l192"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_ne,*doc_e=doc2->head.next,*doc_ce;
|
|
<a name="l193"></a> </span><span class=cF1>if</span><span class=cF0> (!doc) doc=</span><span class=cF5>DocPut</span><span class=cF0>;
|
|
<a name="l194"></a> unlock_doc=</span><span class=cF5>DocLock</span><span class=cF0>(doc),
|
|
<a name="l195"></a> </span><span class=cF5>DocRemSoftNewLines</span><span class=cF0>(doc,</span><span class=cF3>NULL</span><span class=cF0>);
|
|
<a name="l196"></a> doc_ce=doc->cur_entry;
|
|
<a name="l197"></a> </span><span class=cF1>if</span><span class=cF0> (doc_ce->type_u8==</span><span class=cF3>DOCT_TEXT</span><span class=cF0> && doc->cur_col>doc_ce->min_col) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l198"></a> </span><span class=cF1>if</span><span class=cF0> (doc->cur_col<doc_ce->max_col) {
|
|
<a name="l199"></a> dst=doc_ce->tag+doc->cur_col;
|
|
<a name="l200"></a> doc_ne=</span><span class=cF5>DocEntryNewTag</span><span class=cF0>(doc,doc_ce,dst);
|
|
<a name="l201"></a> *dst=0;
|
|
<a name="l202"></a> doc_ne->type=</span><span class=cF3>DOCT_TEXT</span><span class=cF0> | doc_ce->type & 0xFFFFFF00;
|
|
<a name="l203"></a> doc_ce->max_col=doc->cur_col;
|
|
<a name="l204"></a> </span><span class=cF5>QueIns</span><span class=cF0>(doc_ne,doc_ce);
|
|
<a name="l205"></a> doc->cur_entry=doc_ne;
|
|
<a name="l206"></a> doc->cur_col=doc_ne->min_col;
|
|
<a name="l207"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l208"></a> </span><span class=cF1>if</span><span class=cF0> (doc_ce!=doc)
|
|
<a name="l209"></a> doc->cur_entry=doc_ce->next;
|
|
<a name="l210"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l211"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e!=doc2) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l212"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e->type_u8!=</span><span class=cF3>DOCT_SOFT_NEW_LINE</span><span class=cF0>) {
|
|
<a name="l213"></a> doc_ne=</span><span class=cF5>DocEntryCopy</span><span class=cF0>(doc,doc_e);
|
|
<a name="l214"></a> </span><span class=cF5>QueIns</span><span class=cF0>(doc_ne,doc->cur_entry->last);
|
|
<a name="l215"></a> }
|
|
<a name="l216"></a> doc_e=doc_e->next;
|
|
<a name="l217"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l218"></a> </span><span class=cF5>DocRecalc</span><span class=cF0>(doc);
|
|
<a name="l219"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_doc2)
|
|
<a name="l220"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc2);
|
|
<a name="l221"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_doc)
|
|
<a name="l222"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
|
|
<a name="l223"></a>}
|
|
<a name="l224"></a>
|
|
<a name="l225"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"DolDoc/Compiler;Compiler/Directive"</span><span class=cF0>
|
|
<a name="l226"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>StreamDoc</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc)
|
|
<a name="l227"></a>{</span><span class=cF2>//Inject doc into compile stream. Use inside #exe{}.</span><span class=cF0>
|
|
<a name="l228"></a></span><span class=cF2>//TODO: </span><a href="/Wb/Adam/DolDoc/DocNew.HC.HTML#l236"><span class=cF4>DocRst</span></a><span class=cF0>
|
|
<a name="l229"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock_doc=</span><span class=cF5>DocLock</span><span class=cF0>(doc);
|
|
<a name="l230"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e=doc->head.next;
|
|
<a name="l231"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e!=doc) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l232"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e->type_u8==</span><span class=cF3>DOCT_TEXT</span><span class=cF0>)
|
|
<a name="l233"></a> </span><span class=cF5>StreamPrint</span><span class=cF0>(</span><span class=cF6>"%s"</span><span class=cF0>,doc_e->tag);
|
|
<a name="l234"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (doc_e->type_u8==</span><span class=cF3>DOCT_NEW_LINE</span><span class=cF0>)
|
|
<a name="l235"></a> </span><span class=cF5>StreamPrint</span><span class=cF0>(</span><span class=cF6>"\n"</span><span class=cF0>);
|
|
<a name="l236"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (doc_e->type_u8==</span><span class=cF3>DOCT_TAB</span><span class=cF0>)
|
|
<a name="l237"></a> </span><span class=cF5>StreamPrint</span><span class=cF0>(</span><span class=cF6>"\t"</span><span class=cF0>);
|
|
<a name="l238"></a> doc_e=doc_e->next;
|
|
<a name="l239"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l240"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_doc)
|
|
<a name="l241"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
|
|
<a name="l242"></a>}
|
|
<a name="l243"></a>
|
|
<a name="l244"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"DolDoc"</span><span class=cF0>
|
|
<a name="l245"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DocCaptureUndo</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc,</span><span class=cF1>Bool</span><span class=cF0> force=</span><span class=cF3>FALSE</span><span class=cF0>)
|
|
<a name="l246"></a>{
|
|
<a name="l247"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF3>FALSE</span><span class=cF0>,unlock;
|
|
<a name="l248"></a> </span><span class=cF9>I64</span><span class=cF0> time_stamp,flags;
|
|
<a name="l249"></a> </span><span class=cF9>CDocUndo</span><span class=cF0> *u;
|
|
<a name="l250"></a> </span><span class=cF1>if</span><span class=cF0> (doc->flags&</span><span class=cF3>DOCF_ALLOW_UNDO</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l251"></a> unlock=</span><span class=cF5>DocLock</span><span class=cF0>(doc);
|
|
<a name="l252"></a> time_stamp=</span><span class=cF5>GetTSC</span><span class=cF0>;
|
|
<a name="l253"></a> </span><span class=cF1>if</span><span class=cF0> (doc->flags&</span><span class=cF3>DOCF_UNDO_DIRTY</span><span class=cF0> &&
|
|
<a name="l254"></a> time_stamp>doc->undo_head.last->time_stamp+</span><span class=cFB>cnts</span><span class=cF0>.time_stamp_freq<<4 ||
|
|
<a name="l255"></a> force) {
|
|
<a name="l256"></a> u=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDocUndo</span><span class=cF7>)</span><span class=cF0>,doc->mem_task);
|
|
<a name="l257"></a> u->time_stamp=time_stamp;
|
|
<a name="l258"></a> flags=doc->flags;
|
|
<a name="l259"></a> doc->flags&=~</span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>;
|
|
<a name="l260"></a> u->body=</span><span class=cF5>DocSave</span><span class=cF0>(doc,&u->size);
|
|
<a name="l261"></a> doc->flags=flags;
|
|
<a name="l262"></a> </span><span class=cF5>QueIns</span><span class=cF0>(u,doc->undo_head.last);
|
|
<a name="l263"></a> doc->flags&=~</span><span class=cF3>DOCF_UNDO_DIRTY</span><span class=cF0>;
|
|
<a name="l264"></a> doc->undo_cnt++;
|
|
<a name="l265"></a> u->doc_flags=doc->flags;
|
|
<a name="l266"></a> res=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l267"></a> </span><span class=cF1>if</span><span class=cF0> (doc->flags&</span><span class=cF3>DOCF_AUTO_SAVE</span><span class=cF0>)
|
|
<a name="l268"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc);
|
|
<a name="l269"></a> }
|
|
<a name="l270"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l271"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
|
|
<a name="l272"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l273"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l274"></a>}
|
|
<a name="l275"></a>
|
|
<a name="l276"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DocUndoRestore</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc)
|
|
<a name="l277"></a>{
|
|
<a name="l278"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock=</span><span class=cF5>DocLock</span><span class=cF0>(doc);
|
|
<a name="l279"></a> </span><span class=cF9>CDocUndo</span><span class=cF0> *u=doc->undo_head.last,*u_next,*u_last;
|
|
<a name="l280"></a> </span><span class=cF1>if</span><span class=cF0> (u!=&doc->undo_head) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l281"></a> </span><span class=cF5>QueRem</span><span class=cF0>(u);
|
|
<a name="l282"></a> u_next=doc->undo_head.next;
|
|
<a name="l283"></a> u_last=doc->undo_head.last;
|
|
<a name="l284"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&doc->undo_head);
|
|
<a name="l285"></a> </span><span class=cF5>DocRst</span><span class=cF0>(doc,</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l286"></a> doc->flags=u->doc_flags&~</span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>;
|
|
<a name="l287"></a> </span><span class=cF5>DocLoad</span><span class=cF0>(doc,u->body,u->size);
|
|
<a name="l288"></a> doc->flags=u->doc_flags;
|
|
<a name="l289"></a> </span><span class=cF5>DocUndoDel</span><span class=cF0>(doc,u);
|
|
<a name="l290"></a> doc->undo_head.next=u_next;
|
|
<a name="l291"></a> doc->undo_head.last=u_last;
|
|
<a name="l292"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l293"></a> </span><span class=cF5>DocUndoCntSet</span><span class=cF0>(doc);
|
|
<a name="l294"></a> doc->flags&=~</span><span class=cF3>DOCF_UNDO_DIRTY</span><span class=cF0>;
|
|
<a name="l295"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l296"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
|
|
<a name="l297"></a>}
|
|
<a name="l298"></a>
|
|
<a name="l299"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"Graphics/GR Files;DolDoc/Output;StdOut/DolDoc"</span><span class=cF0>
|
|
<a name="l300"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DocType</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF1>U8</span><span class=cF0> *filename,</span><span class=cF9>I64</span><span class=cF0> trailing_new_lines=1)
|
|
<a name="l301"></a>{</span><span class=cF2>//Output txt or graphic file to document.</span><span class=cF0>
|
|
<a name="l302"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l303"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc2;
|
|
<a name="l304"></a> </span><span class=cF1>if</span><span class=cF0> (!doc && !</span><span class=cF7>(</span><span class=cF0>doc=</span><span class=cF5>DocPut</span><span class=cF7>)</span><span class=cF0> || doc->doc_signature!=</span><span class=cF3>DOC_SIGNATURE_VAL</span><span class=cF0>)
|
|
<a name="l305"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l306"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>FilesFindMatch</span><span class=cF7>(</span><span class=cF0>filename,</span><span class=cF3>FILEMASK_TXT</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l307"></a> doc2=</span><span class=cF5>DocRead</span><span class=cF0>(filename);
|
|
<a name="l308"></a> </span><span class=cF5>DocInsDoc</span><span class=cF0>(doc,doc2);
|
|
<a name="l309"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsRaw</span><span class=cF0>)
|
|
<a name="l310"></a> </span><span class=cF5>DocDump</span><span class=cF0>(doc2,100000);
|
|
<a name="l311"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc2);
|
|
<a name="l312"></a> res=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l313"></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> (</span><span class=cF5>FilesFindMatch</span><span class=cF7>(</span><span class=cF0>filename,</span><span class=cF6>"*.GR*"</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l314"></a> </span><span class=cF5>DocGR</span><span class=cF0>(doc,filename);
|
|
<a name="l315"></a> res=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l316"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l317"></a> </span><span class=cF1>if</span><span class=cF0> (res)
|
|
<a name="l318"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>"%h*c"</span><span class=cF0>,trailing_new_lines,</span><span class=cF6>'\n'</span><span class=cF0>);
|
|
<a name="l319"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l320"></a>}
|
|
<a name="l321"></a>
|
|
<a name="l322"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"Graphics/GR Files;"</span><span class=cF0>\
|
|
<a name="l323"></a> </span><span class=cF6>"File/Cmd Line (Typically);DolDoc/Cmd Line (Typically);"</span><span class=cF0>\
|
|
<a name="l324"></a> </span><span class=cF6>"StdOut;Cmd Line (Typically)"</span><span class=cF0>
|
|
<a name="l325"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Type</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename,</span><span class=cF9>I64</span><span class=cF0> trailing_new_lines=1)
|
|
<a name="l326"></a>{</span><span class=cF2>//Output txt or graphic file to command line.</span><span class=cF0>
|
|
<a name="l327"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>DocType</span><span class=cF0>(,filename,trailing_new_lines);
|
|
<a name="l328"></a>}
|
|
<a name="l329"></a>
|
|
<a name="l330"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"DolDoc/File"</span><span class=cF0>
|
|
<a name="l331"></a>
|
|
<a name="l332"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>DocLineRead</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename,</span><span class=cF9>I64</span><span class=cF0> line,</span><span class=cF9>CTask</span><span class=cF0> *mem_task=</span><span class=cF3>NULL</span><span class=cF0>)
|
|
<a name="l333"></a>{</span><span class=cF2>//Extract line from stored doc file. (Slow.)</span><span class=cF0>
|
|
<a name="l334"></a> </span><span class=cF1>U8</span><span class=cF0> *res=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l335"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF5>DocRead</span><span class=cF0>(filename,</span><span class=cF3>DOCF_PLAIN_TEXT_TABS</span><span class=cF0>|</span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>);
|
|
<a name="l336"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>DocGoToLine</span><span class=cF7>(</span><span class=cF0>doc,line</span><span class=cF7>)</span><span class=cF0> && doc->cur_entry->type_u8==</span><span class=cF3>DOCT_TEXT</span><span class=cF0>)
|
|
<a name="l337"></a> res=</span><span class=cF5>StrNew</span><span class=cF0>(doc->cur_entry->tag,mem_task);
|
|
<a name="l338"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
|
|
<a name="l339"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l340"></a>}
|
|
<a name="l341"></a>
|
|
<a name="l342"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>DocLineWrite</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename,</span><span class=cF9>I64</span><span class=cF0> line,</span><span class=cF1>U8</span><span class=cF0> *st)
|
|
<a name="l343"></a>{</span><span class=cF2>//Write line to stored doc file. (Slow.)</span><span class=cF0>
|
|
<a name="l344"></a> </span><span class=cF1>U8</span><span class=cF0> *res=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l345"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF5>DocRead</span><span class=cF0>(filename,</span><span class=cF3>DOCF_PLAIN_TEXT_TABS</span><span class=cF0>|</span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>);
|
|
<a name="l346"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>DocGoToLine</span><span class=cF7>(</span><span class=cF0>doc,line</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l347"></a> </span><span class=cF1>if</span><span class=cF0> (doc->cur_entry->type_u8==</span><span class=cF3>DOCT_TEXT</span><span class=cF0>) {
|
|
<a name="l348"></a> </span><span class=cF5>Free</span><span class=cF0>(doc->cur_entry->tag);
|
|
<a name="l349"></a> doc->cur_entry->tag=</span><span class=cF5>StrNew</span><span class=cF0>(st);
|
|
<a name="l350"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l351"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>"%s"</span><span class=cF0>,st);
|
|
<a name="l352"></a> </span><span class=cF5>DocTop</span><span class=cF0>(doc);
|
|
<a name="l353"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc);
|
|
<a name="l354"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l355"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
|
|
<a name="l356"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l357"></a>}
|
|
</span></pre></body>
|
|
</html>
|