ZealOS/docs/Kernel/EdLite.ZC.html

439 lines
41 KiB
HTML
Raw Permalink Normal View History

2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
2021-12-11 11:10:58 +00:00
<meta name="generator" content="ZealOS V1.07">
2021-07-03 05:07:57 +01:00
<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;}
2021-07-03 05:07:57 +01:00
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
2021-07-03 05:07:57 +01:00
<a name="l1"></a><span class=cF1>class</span><span class=cF0> CLine
<a name="l2"></a>{
<a name="l3"></a> CLine *next, *last;
<a name="l4"></a> </span><span class=cF1>U8</span><span class=cF0> *line;
2021-07-03 05:07:57 +01:00
<a name="l5"></a>};
<a name="l6"></a>
<a name="l7"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>EdLiteUpdate</span><span class=cF0>(CLine *head, CLine *cur_line, </span><span class=cF9>I64</span><span class=cF0> cur_col, </span><span class=cF9>I64</span><span class=cF0> line_start_col)
<a name="l8"></a>{
<a name="l9"></a> </span><span class=cF9>I64</span><span class=cF0> ch, i, j, k, k2, cursor_col, cursor_row = -</span><span class=cFE>1</span><span class=cF0>;
<a name="l10"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
<a name="l11"></a> CLine *tmpl = cur_line;
<a name="l12"></a> </span><span class=cF1>Bool</span><span class=cF0> done_eof = </span><span class=cF3>FALSE</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l13"></a>
<a name="l14"></a> </span><span class=cFB>text</span><span class=cF0>.raw_col = </span><span class=cFE>0</span><span class=cF0>;
<a name="l15"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cFB>text</span><span class=cF0>.rows / </span><span class=cFE>2</span><span class=cF0>; i++)
<a name="l16"></a> </span><span class=cF1>if</span><span class=cF0> (tmpl-&gt;last != head)
<a name="l17"></a> tmpl = tmpl-&gt;last;
<a name="l18"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cFB>text</span><span class=cF0>.rows; i++)
<a name="l19"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l20"></a> </span><span class=cF1>if</span><span class=cF0> (cursor_row &lt; </span><span class=cFE>0</span><span class=cF0> &amp;&amp; tmpl == cur_line)
<a name="l21"></a> {
<a name="l22"></a> k = </span><span class=cFE>0</span><span class=cF0>;
<a name="l23"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt; cur_col; j++)
<a name="l24"></a> </span><span class=cF1>if</span><span class=cF0> (tmpl-&gt;line[j] == </span><span class=cF6>'\t'</span><span class=cF0>)
<a name="l25"></a> k = (k + </span><span class=cFE>4</span><span class=cF0>) &amp; ~</span><span class=cFE>3</span><span class=cF0>;
<a name="l26"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l27"></a> k++;
<a name="l28"></a> cursor_col = k;
<a name="l29"></a> cursor_row = i;
<a name="l30"></a> }
<a name="l31"></a> </span><span class=cF1>if</span><span class=cF0> (tmpl != head)
<a name="l32"></a> {
<a name="l33"></a> st = tmpl-&gt;line;
<a name="l34"></a> k = </span><span class=cFE>0</span><span class=cF0>;
<a name="l35"></a> j= </span><span class=cFE>0</span><span class=cF0> ;
<a name="l36"></a> </span><span class=cF1>while</span><span class=cF0> (ch = *st++)
<a name="l37"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l38"></a> </span><span class=cF1>if</span><span class=cF0> (ch == </span><span class=cF6>'\t'</span><span class=cF0>)
<a name="l39"></a> k2 = (k + </span><span class=cFE>4</span><span class=cF0>) &amp; ~</span><span class=cFE>3</span><span class=cF0>;
<a name="l40"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l41"></a> k2 = k + </span><span class=cFE>1</span><span class=cF0>;
<a name="l42"></a> </span><span class=cF1>if</span><span class=cF0> (line_start_col &lt;= k &lt; line_start_col + </span><span class=cFB>text</span><span class=cF0>.cols)
<a name="l43"></a> {
<a name="l44"></a> </span><span class=cF6>''</span><span class=cF0> ch;
<a name="l45"></a> j = k2 - line_start_col;
<a name="l46"></a> }
<a name="l47"></a> k = k2;
<a name="l48"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l49"></a> </span><span class=cF1>if</span><span class=cF0> (j &lt; </span><span class=cFB>text</span><span class=cF0>.cols)
<a name="l50"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l51"></a> tmpl = tmpl-&gt;next;
<a name="l52"></a> }
<a name="l53"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l54"></a> {
<a name="l55"></a> </span><span class=cF1>if</span><span class=cF0> (!done_eof)
<a name="l56"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l57"></a> </span><span class=cF6>'&lt;EOF&gt;'</span><span class=cF0>;
<a name="l58"></a> done_eof = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l59"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l60"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l61"></a> }
<a name="l62"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l63"></a> </span><span class=cFB>text</span><span class=cF0>.raw_col = </span><span class=cFB>text</span><span class=cF0>.cols * cursor_row + cursor_col - line_start_col;
<a name="l64"></a> </span><span class=cF5>RawPutChar</span><span class=cF0>(</span><span class=cFE>0x7F</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l65"></a>}
<a name="l66"></a>
<a name="l67"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>EdLite</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename, </span><span class=cF9>I64</span><span class=cF0> num=</span><span class=cFE>1</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> edf_dof_flags=</span><span class=cFE>0</span><span class=cF0>)
<a name="l68"></a>{</span><span class=cF2>//Light weight text editor for debugging.</span><span class=cF0>
<a name="l69"></a> </span><span class=cF1>U8</span><span class=cF0> *src, *src2, *src3, *dst, *buf, *bin_data = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l70"></a> </span><span class=cF9>I64</span><span class=cF0> i, count = </span><span class=cFE>0</span><span class=cF0>, ch, sc, size, bin_size = </span><span class=cFE>0</span><span class=cF0>, line_start_col = </span><span class=cFE>0</span><span class=cF0>, cur_col = </span><span class=cFE>0</span><span class=cF0>, old_raw_flags = </span><span class=cFB>text</span><span class=cF0>.raw_flags;
<a name="l71"></a> CLine head, *tmpl, *tmpl1, *cur_line;
<a name="l72"></a> </span><span class=cF1>Bool</span><span class=cF0> res = </span><span class=cF3>FALSE</span><span class=cF0>,
<a name="l73"></a> old_raw = </span><span class=cF5>Raw</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>),
<a name="l74"></a> old_debug = </span><span class=cF5>DebugMode</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>),
<a name="l75"></a> old_single = </span><span class=cF5>SingleUser</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l76"></a>
<a name="l77"></a> </span><span class=cF1>if</span><span class=cF0> (!filename)
<a name="l78"></a> filename = </span><span class=cFB>blkdev</span><span class=cF0>.tmp_filename;
<a name="l79"></a> buf = </span><span class=cF5>FileRead</span><span class=cF0>(filename, &amp;size);
2021-07-03 05:07:57 +01:00
<a name="l80"></a>
<a name="l81"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
<a name="l82"></a> </span><span class=cF1>CLI</span><span class=cF0>
<a name="l83"></a> </span><span class=cFB>text</span><span class=cF0>.raw_flags = </span><span class=cFB>text</span><span class=cF0>.raw_flags &amp; ~</span><span class=cF3>RAWF_SCROLL</span><span class=cF0> | </span><span class=cF3>RAWF_SHOW_DOLLAR</span><span class=cF0>;
<a name="l84"></a> </span><span class=cFB>kbd</span><span class=cF0>.scan_code = </span><span class=cFE>0</span><span class=cF0>;
<a name="l85"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&amp;head);
<a name="l86"></a> head.line = </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>&quot;&quot;</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l87"></a>
<a name="l88"></a> </span><span class=cF1>if</span><span class=cF0> (buf)
<a name="l89"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l90"></a> src = buf;
<a name="l91"></a> </span><span class=cF1>while</span><span class=cF0> (*src)
<a name="l92"></a> {
<a name="l93"></a> src2 = src;
<a name="l94"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>ch = *src++</span><span class=cF7>)</span><span class=cF0> &amp;&amp; ch != </span><span class=cF6>'\r'</span><span class=cF0> &amp;&amp; ch != </span><span class=cF6>'\n'</span><span class=cF0>);
<a name="l95"></a> src--;
<a name="l96"></a> *src++ = </span><span class=cFE>0</span><span class=cF0>;
<a name="l97"></a> </span><span class=cF1>if</span><span class=cF0> (!ch)
<a name="l98"></a> src--;
<a name="l99"></a> </span><span class=cF1>while</span><span class=cF0> (ch == </span><span class=cF6>'\r'</span><span class=cF0> &amp;&amp; *src == </span><span class=cF6>'\n'</span><span class=cF0> || *src == </span><span class=cF3>CH_CURSOR</span><span class=cF0>)
<a name="l100"></a> src++;
<a name="l101"></a> dst = src3 = src2;
<a name="l102"></a> </span><span class=cF1>while</span><span class=cF0> (ch = *src3++)
<a name="l103"></a> </span><span class=cF1>if</span><span class=cF0> (ch != </span><span class=cF6>'\n'</span><span class=cF0> &amp;&amp; ch != </span><span class=cF3>CH_CURSOR</span><span class=cF0>)
<a name="l104"></a> *dst++ = ch;
<a name="l105"></a> *dst = </span><span class=cFE>0</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l106"></a>
<a name="l107"></a> tmpl = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>CLine</span><span class=cF7>)</span><span class=cF0>);
<a name="l108"></a> tmpl-&gt;line = </span><span class=cF5>StrNew</span><span class=cF0>(src2);
<a name="l109"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpl, head.last);
<a name="l110"></a> count++;
<a name="l111"></a> }
2021-07-03 05:07:57 +01:00
<a name="l112"></a>
<a name="l113"></a> </span><span class=cF1>if</span><span class=cF0> (src + </span><span class=cFE>1</span><span class=cF0> - buf&lt;size)
<a name="l114"></a> {
<a name="l115"></a> bin_data = </span><span class=cF5>MAlloc</span><span class=cF0>(bin_size = size - </span><span class=cF7>(</span><span class=cF0>src - buf</span><span class=cF7>)</span><span class=cF0>);
<a name="l116"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(bin_data, src, bin_size);
<a name="l117"></a> }
<a name="l118"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l119"></a> res = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l120"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l121"></a>
<a name="l122"></a> cur_line = head.next;
<a name="l123"></a> </span><span class=cF1>if</span><span class=cF0> (--num &lt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l124"></a> res = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l125"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l126"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l127"></a> </span><span class=cF1>if</span><span class=cF0> (num &lt;= count)
<a name="l128"></a> </span><span class=cF1>while</span><span class=cF0> (num--)
<a name="l129"></a> cur_line = cur_line-&gt;next;
<a name="l130"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l131"></a> {
<a name="l132"></a> cur_line = &amp;head;
<a name="l133"></a> res = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l134"></a> }
<a name="l135"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l136"></a> </span><span class=cF1>do</span><span class=cF0>
<a name="l137"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l138"></a> </span><span class=cF1>if</span><span class=cF0> (cur_line == &amp;head)
<a name="l139"></a> cur_col = </span><span class=cFE>0</span><span class=cF0>;
<a name="l140"></a> </span><span class=cF1>while</span><span class=cF0> (cur_col - line_start_col &lt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l141"></a> line_start_col -= </span><span class=cFE>8</span><span class=cF0>;
<a name="l142"></a> </span><span class=cF1>while</span><span class=cF0> (cur_col - line_start_col &gt;= </span><span class=cFB>text</span><span class=cF0>.cols)
<a name="l143"></a> line_start_col += </span><span class=cFE>8</span><span class=cF0>;
<a name="l144"></a> </span><span class=cFD>EdLiteUpdate</span><span class=cF0>(&amp;head, cur_line, cur_col, line_start_col);
<a name="l145"></a> </span><span class=cF1>switch</span><span class=cF0> (ch = </span><span class=cF5>KeyGet</span><span class=cF7>(</span><span class=cF0>&amp;sc, </span><span class=cF3>FALSE</span><span class=cF0>, </span><span class=cF3>TRUE</span><span class=cF7>)</span><span class=cF0>)
<a name="l146"></a> {
<a name="l147"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>:
<a name="l148"></a> </span><span class=cF1>switch</span><span class=cF0> (sc.u8[</span><span class=cFE>0</span><span class=cF0>])
<a name="l149"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l150"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
<a name="l151"></a> </span><span class=cF1>if</span><span class=cF0> (cur_line-&gt;last != &amp;head)
<a name="l152"></a> cur_line = cur_line-&gt;last;
<a name="l153"></a> </span><span class=cF1>if</span><span class=cF0> (cur_col &gt; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>cur_line-&gt;line</span><span class=cF7>)</span><span class=cF0>)
<a name="l154"></a> cur_col = </span><span class=cF5>StrLen</span><span class=cF0>(cur_line-&gt;line);
<a name="l155"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l156"></a>
<a name="l157"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
<a name="l158"></a> </span><span class=cF1>if</span><span class=cF0> (cur_line != &amp;head)
<a name="l159"></a> cur_line = cur_line-&gt;next;
<a name="l160"></a> </span><span class=cF1>if</span><span class=cF0> (cur_col &gt; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>cur_line-&gt;line</span><span class=cF7>)</span><span class=cF0>)
<a name="l161"></a> cur_col = </span><span class=cF5>StrLen</span><span class=cF0>(cur_line-&gt;line);
<a name="l162"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l163"></a>
<a name="l164"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
<a name="l165"></a> cur_col++;
<a name="l166"></a> </span><span class=cF1>if</span><span class=cF0> (cur_col &gt; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>cur_line-&gt;line</span><span class=cF7>)</span><span class=cF0>)
<a name="l167"></a> {
<a name="l168"></a> tmpl = cur_line-&gt;next;
<a name="l169"></a> </span><span class=cF1>if</span><span class=cF0> (tmpl != &amp;head)
<a name="l170"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l171"></a> cur_col = </span><span class=cFE>0</span><span class=cF0>;
<a name="l172"></a> cur_line = tmpl;
<a name="l173"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l174"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l175"></a> cur_col = </span><span class=cF5>StrLen</span><span class=cF0>(cur_line-&gt;line);
<a name="l176"></a> }
<a name="l177"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l178"></a>
<a name="l179"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
<a name="l180"></a> </span><span class=cF1>if</span><span class=cF0> (cur_col)
<a name="l181"></a> cur_col--;
<a name="l182"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l183"></a> {
<a name="l184"></a> tmpl = cur_line-&gt;last;
<a name="l185"></a> </span><span class=cF1>if</span><span class=cF0> (tmpl != &amp;head)
<a name="l186"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l187"></a> cur_line = tmpl;
<a name="l188"></a> cur_col = </span><span class=cF5>StrLen</span><span class=cF0>(tmpl-&gt;line);
<a name="l189"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l190"></a> }
<a name="l191"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l192"></a>
<a name="l193"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_PAGE_UP</span><span class=cF0>:
<a name="l194"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>1</span><span class=cF0>; i &lt; </span><span class=cFB>text</span><span class=cF0>.rows; i++)
<a name="l195"></a> {
<a name="l196"></a> </span><span class=cF1>if</span><span class=cF0> (cur_line-&gt;last != &amp;head)
<a name="l197"></a> cur_line = cur_line-&gt;last;
<a name="l198"></a> </span><span class=cF1>if</span><span class=cF0> (cur_col &gt; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>cur_line-&gt;line</span><span class=cF7>)</span><span class=cF0>)
<a name="l199"></a> cur_col = </span><span class=cF5>StrLen</span><span class=cF0>(cur_line-&gt;line);
<a name="l200"></a> }
<a name="l201"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l202"></a>
<a name="l203"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_PAGE_DOWN</span><span class=cF0>:
<a name="l204"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>1</span><span class=cF0>; i &lt; </span><span class=cFB>text</span><span class=cF0>.rows; i++)
<a name="l205"></a> {
<a name="l206"></a> </span><span class=cF1>if</span><span class=cF0> (cur_line != &amp;head)
<a name="l207"></a> cur_line = cur_line-&gt;next;
<a name="l208"></a> </span><span class=cF1>if</span><span class=cF0> (cur_col &gt; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>cur_line-&gt;line</span><span class=cF7>)</span><span class=cF0>)
<a name="l209"></a> cur_col = </span><span class=cF5>StrLen</span><span class=cF0>(cur_line-&gt;line);
<a name="l210"></a> }
<a name="l211"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l212"></a>
<a name="l213"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_DELETE</span><span class=cF0>:
<a name="l214"></a> </span><span class=cF1>if</span><span class=cF0> (cur_col == </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>cur_line-&gt;line</span><span class=cF7>)</span><span class=cF0>)
<a name="l215"></a> {
<a name="l216"></a> tmpl = cur_line-&gt;next;
<a name="l217"></a> </span><span class=cF1>if</span><span class=cF0> (cur_line != &amp;head &amp;&amp; tmpl != &amp;head) </span><span class=cF7>{</span><span class=cF0>
<a name="l218"></a> src = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;%s%s&quot;</span><span class=cF0>, cur_line-&gt;line, tmpl-&gt;line);
<a name="l219"></a> </span><span class=cF5>Free</span><span class=cF0>(cur_line-&gt;line);
<a name="l220"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpl-&gt;line);
<a name="l221"></a> cur_line-&gt;line = src;
<a name="l222"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpl);
<a name="l223"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpl);
<a name="l224"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l225"></a> }
<a name="l226"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l227"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(cur_line-&gt;line + cur_col, cur_line-&gt;line + cur_col + </span><span class=cFE>1</span><span class=cF0>);
<a name="l228"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l229"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l230"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l231"></a>
<a name="l232"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l233"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\r'</span><span class=cF0>:
<a name="l234"></a> tmpl = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>CLine</span><span class=cF7>)</span><span class=cF0>);
<a name="l235"></a> tmpl-&gt;line = </span><span class=cF5>StrNew</span><span class=cF0>(cur_line-&gt;line + cur_col);
<a name="l236"></a> cur_line-&gt;line[cur_col] = </span><span class=cFE>0</span><span class=cF0>;
<a name="l237"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpl, cur_line);
<a name="l238"></a> cur_line = tmpl;
<a name="l239"></a> cur_col = </span><span class=cFE>0</span><span class=cF0>;
<a name="l240"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l241"></a>
<a name="l242"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_BACKSPACE</span><span class=cF0>:
<a name="l243"></a> </span><span class=cF1>if</span><span class=cF0> (cur_col) </span><span class=cF7>{</span><span class=cF0>
<a name="l244"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(cur_line-&gt;line + cur_col - </span><span class=cFE>1</span><span class=cF0>, cur_line-&gt;line + cur_col);
<a name="l245"></a> cur_col--;
<a name="l246"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l247"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (cur_line!=&amp;head &amp;&amp; cur_line-&gt;last!=&amp;head)
<a name="l248"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l249"></a> tmpl = cur_line-&gt;last;
<a name="l250"></a> src = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;%s%s&quot;</span><span class=cF0>, tmpl-&gt;line, cur_line-&gt;line);
<a name="l251"></a> cur_col = </span><span class=cF5>StrLen</span><span class=cF0>(tmpl-&gt;line);
<a name="l252"></a> </span><span class=cF5>Free</span><span class=cF0>(cur_line-&gt;line);
<a name="l253"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpl-&gt;line);
<a name="l254"></a> tmpl-&gt;line = src;
<a name="l255"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(cur_line);
<a name="l256"></a> </span><span class=cF5>Free</span><span class=cF0>(cur_line);
<a name="l257"></a> cur_line = tmpl;
<a name="l258"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l259"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l260"></a>
<a name="l261"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_CTRLY</span><span class=cF0>:
<a name="l262"></a> </span><span class=cF1>if</span><span class=cF0> (cur_line != &amp;head)
<a name="l263"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l264"></a> tmpl = cur_line;
<a name="l265"></a> cur_line = cur_line-&gt;next;
<a name="l266"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpl);
<a name="l267"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpl-&gt;line);
<a name="l268"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpl);
<a name="l269"></a> cur_col = </span><span class=cFE>0</span><span class=cF0>;
<a name="l270"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l271"></a> </span><span class=cF1>break</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l272"></a>
<a name="l273"></a> </span><span class=cF1>default</span><span class=cF0>:
<a name="l274"></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_printable</span><span class=cF0>, ch</span><span class=cF7>)</span><span class=cF0>)
<a name="l275"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l276"></a> </span><span class=cF1>if</span><span class=cF0> (cur_line == &amp;head) {
<a name="l277"></a> cur_line = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>CLine</span><span class=cF7>)</span><span class=cF0>);
<a name="l278"></a> cur_line-&gt;line = </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>&quot;&quot;</span><span class=cF0>);
<a name="l279"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(cur_line, head.last);
<a name="l280"></a> }
<a name="l281"></a> src = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>cur_line-&gt;line</span><span class=cF7>)</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0>);
<a name="l282"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(src, cur_line-&gt;line, cur_col);
<a name="l283"></a> src[cur_col] = ch;
<a name="l284"></a> </span><span class=cF1>if</span><span class=cF0> (cur_col &lt; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>cur_line-&gt;line</span><span class=cF7>)</span><span class=cF0>)
<a name="l285"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(src + cur_col + </span><span class=cFE>1</span><span class=cF0>, cur_line-&gt;line + cur_col);
<a name="l286"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l287"></a> src[cur_col + </span><span class=cFE>1</span><span class=cF0>] = </span><span class=cFE>0</span><span class=cF0>;
<a name="l288"></a> </span><span class=cF5>Free</span><span class=cF0>(cur_line-&gt;line);
<a name="l289"></a> cur_line-&gt;line = src;
<a name="l290"></a> cur_col++;
<a name="l291"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l292"></a> }
<a name="l293"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l294"></a> </span><span class=cF1>while</span><span class=cF0> (ch != </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0> &amp;&amp; ch != </span><span class=cF3>CH_ESC</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l295"></a>
<a name="l296"></a> </span><span class=cF1>if</span><span class=cF0> (ch != </span><span class=cF3>CH_ESC</span><span class=cF0>)
<a name="l297"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l298"></a> </span><span class=cF1>if</span><span class=cF0> (edf_dof_flags &amp; </span><span class=cF3>EDF_WAS_WRITE</span><span class=cF0>)
<a name="l299"></a> res = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l300"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l301"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l302"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l303"></a> size = bin_size;
2021-07-03 05:07:57 +01:00
<a name="l304"></a>
<a name="l305"></a> tmpl = head.next;
<a name="l306"></a> </span><span class=cF1>while</span><span class=cF0> (tmpl != &amp;head)
<a name="l307"></a> {
<a name="l308"></a> size += </span><span class=cF5>StrLen</span><span class=cF0>(tmpl-&gt;line) + </span><span class=cFE>1</span><span class=cF0>;
<a name="l309"></a> tmpl = tmpl-&gt;next;
<a name="l310"></a> }
2021-07-03 05:07:57 +01:00
<a name="l311"></a>
<a name="l312"></a> buf = dst = </span><span class=cF5>MAlloc</span><span class=cF0>(size);
<a name="l313"></a> tmpl = head.next;
<a name="l314"></a> </span><span class=cF1>while</span><span class=cF0> (tmpl != &amp;head)
<a name="l315"></a> {
<a name="l316"></a> i = </span><span class=cF5>StrLen</span><span class=cF0>(tmpl-&gt;line);
<a name="l317"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(dst, tmpl-&gt;line, i);
<a name="l318"></a> dst += i;
<a name="l319"></a> *dst++ = </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l320"></a> tmpl = tmpl-&gt;next;
<a name="l321"></a> }
<a name="l322"></a> </span><span class=cF1>if</span><span class=cF0> (bin_data)
<a name="l323"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(dst, bin_data, bin_size);
<a name="l324"></a> </span><span class=cF5>FileWrite</span><span class=cF0>(filename, buf, size);
<a name="l325"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
2021-07-03 05:07:57 +01:00
<a name="l326"></a>
<a name="l327"></a> </span><span class=cF1>if</span><span class=cF0> (edf_dof_flags &amp; </span><span class=cF3>EDF_WAS_WRITE</span><span class=cF0>)
<a name="l328"></a> res = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l329"></a> </span><span class=cF7>}</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l330"></a>
<a name="l331"></a> tmpl = head.next;
<a name="l332"></a> </span><span class=cF1>while</span><span class=cF0> (tmpl != &amp;head)
<a name="l333"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l334"></a> tmpl1 = tmpl-&gt;next;
<a name="l335"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpl);
<a name="l336"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpl-&gt;line);
<a name="l337"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpl);
<a name="l338"></a> tmpl = tmpl1;
<a name="l339"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l340"></a> </span><span class=cF5>Free</span><span class=cF0>(head.line);
<a name="l341"></a> </span><span class=cF5>Free</span><span class=cF0>(bin_data);
<a name="l342"></a> </span><span class=cF5>Raw</span><span class=cF0>(old_raw);
<a name="l343"></a> </span><span class=cF5>DebugMode</span><span class=cF0>(old_debug);
<a name="l344"></a> </span><span class=cF5>SingleUser</span><span class=cF0>(old_single);
<a name="l345"></a> </span><span class=cFB>text</span><span class=cF0>.raw_flags = </span><span class=cFB>text</span><span class=cF0>.raw_flags &amp; ~</span><span class=cF3>RAWF_SHOW_DOLLAR</span><span class=cF0> | old_raw_flags &amp; (</span><span class=cF3>RAWF_SHOW_DOLLAR</span><span class=cF0> | </span><span class=cF3>RAWF_SCROLL</span><span class=cF0>);
<a name="l346"></a> </span><span class=cF1>POPFD</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l347"></a>
<a name="l348"></a> </span><span class=cF1>return</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l349"></a>}
<a name="l350"></a>
<a name="l351"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>ToFileLine</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *_fl_file_line, </span><span class=cF1>U8</span><span class=cF0> **_filename, </span><span class=cF9>I64</span><span class=cF0> *_linenum)
2021-12-11 11:10:58 +00:00
<a name="l352"></a>{</span><span class=cF2>//&quot;FI:D:/Dir/File.ZC,123&quot; to &quot;D:/Dir/File.ZC&quot; and 123.</span><span class=cF0>
<a name="l353"></a> </span><span class=cF1>U8</span><span class=cF0> *st, *fl_file_line = </span><span class=cF5>StrNew</span><span class=cF0>(_fl_file_line);
<a name="l354"></a> </span><span class=cF9>I64</span><span class=cF0> linenum;
2021-07-03 05:07:57 +01:00
<a name="l355"></a>
<a name="l356"></a> </span><span class=cF5>StrFirstRemove</span><span class=cF0>(fl_file_line, </span><span class=cF6>&quot;:&quot;</span><span class=cF0>);
<a name="l357"></a> st = </span><span class=cF5>StrNew</span><span class=cF0>(fl_file_line);
<a name="l358"></a> </span><span class=cF5>StrLastRemove</span><span class=cF0>(fl_file_line, </span><span class=cF6>&quot;,&quot;</span><span class=cF0>, st);
<a name="l359"></a> linenum = </span><span class=cF5>Str2I64</span><span class=cF0>(st);
<a name="l360"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l361"></a> *_filename = fl_file_line;
<a name="l362"></a> *_linenum = linenum;
2021-07-03 05:07:57 +01:00
<a name="l363"></a>}
<a name="l364"></a>
<a name="l365"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>EdLiteFileLine</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *fl_file_line, </span><span class=cF9>I64</span><span class=cF0> edf_dof_flags=</span><span class=cFE>0</span><span class=cF0>)
<a name="l366"></a>{
<a name="l367"></a> </span><span class=cF1>Bool</span><span class=cF0> res;
<a name="l368"></a> </span><span class=cF1>U8</span><span class=cF0> *filename;
<a name="l369"></a> </span><span class=cF9>I64</span><span class=cF0> linenum;
2021-07-03 05:07:57 +01:00
<a name="l370"></a>
<a name="l371"></a> </span><span class=cF5>ToFileLine</span><span class=cF0>(fl_file_line, &amp;filename, &amp;linenum);
<a name="l372"></a> res = </span><span class=cF5>EdLite</span><span class=cF0>(filename, linenum, edf_dof_flags);
<a name="l373"></a> </span><span class=cF5>Free</span><span class=cF0>(filename);
2021-07-03 05:07:57 +01:00
<a name="l374"></a>
<a name="l375"></a> </span><span class=cF1>return</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l376"></a>}
<a name="l377"></a>
<a name="l378"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>FixSet</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename, </span><span class=cF9>I64</span><span class=cF0> line)
<a name="l379"></a>{</span><span class=cF2>//Compiler calls this to set file line for Fix</span><span class=cF0>
<a name="l380"></a> </span><span class=cF1>U8</span><span class=cF0> *st = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;FL:%s,%d&quot;</span><span class=cF0>, filename, line);
2021-07-03 05:07:57 +01:00
<a name="l381"></a>
<a name="l382"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FIX</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l383"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l384"></a> </span><span class=cF5>Free</span><span class=cF0>(</span><span class=cFB>debug</span><span class=cF0>.fix_file_line);
<a name="l385"></a> </span><span class=cFB>debug</span><span class=cF0>.fix_file_line = </span><span class=cF5>SysStrNew</span><span class=cF0>(st);
<a name="l386"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FIX</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l387"></a>}
<a name="l388"></a>
<a name="l389"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>Fix</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> edf_dof_flags=</span><span class=cFE>0</span><span class=cF0>)
<a name="l390"></a>{</span><span class=cF2>//Jump to last error src code to fix it.</span><span class=cF0>
<a name="l391"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
<a name="l392"></a> </span><span class=cF1>Bool</span><span class=cF0> res = </span><span class=cF3>FALSE</span><span class=cF0>;
2021-07-03 05:07:57 +01:00
<a name="l393"></a>
<a name="l394"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FIX</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
<a name="l395"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l396"></a> st = </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cFB>debug</span><span class=cF0>.fix_file_line);
<a name="l397"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&amp;</span><span class=cFB>sys_semas</span><span class=cF0>[</span><span class=cF3>SEMA_FIX</span><span class=cF0>], </span><span class=cFE>0</span><span class=cF0>);
2021-07-03 05:07:57 +01:00
<a name="l398"></a>
<a name="l399"></a> </span><span class=cF1>if</span><span class=cF0> (st)
<a name="l400"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l401"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsRaw</span><span class=cF0>)
<a name="l402"></a> res = </span><span class=cF5>EdLiteFileLine</span><span class=cF0>(st, edf_dof_flags);
<a name="l403"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l404"></a> res = </span><span class=cF5>Ed</span><span class=cF0>(st, edf_dof_flags);
<a name="l405"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l406"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
2021-07-03 05:07:57 +01:00
<a name="l407"></a>
<a name="l408"></a> </span><span class=cF1>return</span><span class=cF0> res;
2021-07-03 05:07:57 +01:00
<a name="l409"></a>}
</span></pre></body>
</html>