276 lines
30 KiB
Plaintext
276 lines
30 KiB
Plaintext
|
<!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=cF1>U0</span><span class=cF0> </span><span class=cF5>InputFilterTask</span><span class=cF0>()
|
||
|
<a name="l2"></a>{
|
||
|
<a name="l3"></a> </span><span class=cF9>CJob</span><span class=cF0> *tmpc,*tmpc1;
|
||
|
<a name="l4"></a> </span><span class=cF1>Bool</span><span class=cF0> old_filter;
|
||
|
<a name="l5"></a> </span><span class=cF9>I64</span><span class=cF0> old_flags=</span><span class=cF5>GetRFlags</span><span class=cF0>;
|
||
|
<a name="l6"></a> </span><span class=cF5>Fs</span><span class=cF0>->win_inhibit=</span><span class=cF3>WIG_USER_TASK_DFT</span><span class=cF0>;
|
||
|
<a name="l7"></a> </span><span class=cF5>LBts</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags,</span><span class=cF3>TASKf_INPUT_FILTER_TASK</span><span class=cF0>);
|
||
|
<a name="l8"></a> old_filter=</span><span class=cF5>LBts</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->last_input_filter_task->task_flags,</span><span class=cF3>TASKf_FILTER_INPUT</span><span class=cF0>);
|
||
|
<a name="l9"></a> </span><span class=cF5>LBEqu</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags,</span><span class=cF3>TASKf_FILTER_INPUT</span><span class=cF0>,old_filter);
|
||
|
<a name="l10"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l11"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
||
|
<a name="l12"></a> </span><span class=cF5>JobsHndlr</span><span class=cF0>(old_flags);
|
||
|
<a name="l13"></a> tmpc1=&</span><span class=cF5>Fs</span><span class=cF0>->srv_ctrl.next_waiting;
|
||
|
<a name="l14"></a> tmpc=tmpc1->next;
|
||
|
<a name="l15"></a> </span><span class=cF1>if</span><span class=cF0> (tmpc==tmpc1)
|
||
|
<a name="l16"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l17"></a> </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l18"></a> </span><span class=cF1>if</span><span class=cF0> (tmpc->job_code==</span><span class=cF3>JOBT_TEXT_INPUT</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l19"></a> </span><span class=cF5>QueRem</span><span class=cF0>(tmpc);
|
||
|
<a name="l20"></a> </span><span class=cF5>SetRFlags</span><span class=cF0>(old_flags);
|
||
|
<a name="l21"></a> </span><span class=cF1>try</span><span class=cF0>
|
||
|
<a name="l22"></a> </span><span class=cF5>ExePrint</span><span class=cF0>(</span><span class=cF6>"%s"</span><span class=cF0>,tmpc->aux_str);
|
||
|
<a name="l23"></a> </span><span class=cF1>catch</span><span class=cF0>
|
||
|
<a name="l24"></a> </span><span class=cF5>Fs</span><span class=cF0>->catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l25"></a> </span><span class=cF5>JobDel</span><span class=cF0>(tmpc);
|
||
|
<a name="l26"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l27"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l28"></a> }
|
||
|
<a name="l29"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l30"></a> </span><span class=cF5>Fs</span><span class=cF0>->next_input_filter_task->last_input_filter_task=</span><span class=cF5>Fs</span><span class=cF0>->last_input_filter_task;
|
||
|
<a name="l31"></a> </span><span class=cF5>Fs</span><span class=cF0>->last_input_filter_task->next_input_filter_task=</span><span class=cF5>Fs</span><span class=cF0>->next_input_filter_task;
|
||
|
<a name="l32"></a> </span><span class=cF1>if</span><span class=cF0> (!old_filter)
|
||
|
<a name="l33"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->last_input_filter_task->task_flags,</span><span class=cF3>TASKf_FILTER_INPUT</span><span class=cF0>);
|
||
|
<a name="l34"></a> </span><span class=cF5>SetRFlags</span><span class=cF0>(old_flags);
|
||
|
<a name="l35"></a>}
|
||
|
<a name="l36"></a>
|
||
|
<a name="l37"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>ScanMsg</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *_arg1=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> *_arg2=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> mask=~1,</span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>)
|
||
|
<a name="l38"></a>{</span><span class=cF2>/*Check for a message of type specified by a one in the mask.</span><span class=cF0>
|
||
|
<a name="l39"></a></span><span class=cF2>Throw-out messages not in mask.</span><span class=cF0>
|
||
|
<a name="l40"></a></span><span class=cF2>If no message fit mask, return NULL immediately.</span><span class=cF0>
|
||
|
<a name="l41"></a></span><span class=cF2>Remove desired message, return </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3175"><span class=cF4>msg_code</span></a><span class=cF2>.</span><span class=cF0>
|
||
|
<a name="l42"></a></span><span class=cF2>Note: This delivers messages from parent down to pop-up.</span><span class=cF0>
|
||
|
<a name="l43"></a></span><span class=cF2>*/</span><span class=cF0>
|
||
|
<a name="l44"></a> </span><span class=cF9>I64</span><span class=cF0> res,old_flags;
|
||
|
<a name="l45"></a> </span><span class=cF9>CJob</span><span class=cF0> *tmpc,*tmpc1;
|
||
|
<a name="l46"></a> </span><span class=cF1>if</span><span class=cF0> (!task) task=</span><span class=cF5>Fs</span><span class=cF0>;
|
||
|
<a name="l47"></a> old_flags=</span><span class=cF5>GetRFlags</span><span class=cF0>;
|
||
|
<a name="l48"></a> tmpc1=&task->srv_ctrl.next_waiting;
|
||
|
<a name="l49"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l50"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
||
|
<a name="l51"></a> </span><span class=cF1>if</span><span class=cF0> (task==</span><span class=cF5>Fs</span><span class=cF0>)
|
||
|
<a name="l52"></a> </span><span class=cF5>JobsHndlr</span><span class=cF0>(old_flags);
|
||
|
<a name="l53"></a> tmpc=tmpc1->next;
|
||
|
<a name="l54"></a> </span><span class=cF1>if</span><span class=cF0> (tmpc==tmpc1)
|
||
|
<a name="l55"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l56"></a> </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l57"></a> </span><span class=cF1>if</span><span class=cF0> (tmpc->job_code==</span><span class=cF3>JOBT_MSG</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l58"></a> </span><span class=cF5>QueRem</span><span class=cF0>(tmpc);
|
||
|
<a name="l59"></a> </span><span class=cF5>SetRFlags</span><span class=cF0>(old_flags);
|
||
|
<a name="l60"></a> res=tmpc->msg_code;
|
||
|
<a name="l61"></a> </span><span class=cF1>if</span><span class=cF0> (_arg1)
|
||
|
<a name="l62"></a> *_arg1=tmpc->aux1;
|
||
|
<a name="l63"></a> </span><span class=cF1>if</span><span class=cF0> (_arg2)
|
||
|
<a name="l64"></a> *_arg2=tmpc->aux2;
|
||
|
<a name="l65"></a> </span><span class=cF5>JobDel</span><span class=cF0>(tmpc);
|
||
|
<a name="l66"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>res!=</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0> || !(tmpc->aux2&</span><span class=cF3>SCF_KEY_DESC</span><span class=cF0>) ||
|
||
|
<a name="l67"></a> !</span><span class=cF5>Bt</span><span class=cF0>(&task->win_inhibit,</span><span class=cF3>WIf_SELF_KEY_DESC</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0> && </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&mask,res</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l68"></a> </span><span class=cF1>goto</span><span class=cF0> sm_done;
|
||
|
<a name="l69"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l70"></a> }
|
||
|
<a name="l71"></a> </span><span class=cF5>SetRFlags</span><span class=cF0>(old_flags);
|
||
|
<a name="l72"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l73"></a> res=</span><span class=cF3>MSG_NULL</span><span class=cF0>;
|
||
|
<a name="l74"></a> </span><span class=cF1>if</span><span class=cF0> (_arg1)
|
||
|
<a name="l75"></a> *_arg1=0;
|
||
|
<a name="l76"></a> </span><span class=cF1>if</span><span class=cF0> (_arg2)
|
||
|
<a name="l77"></a> *_arg2=0;
|
||
|
<a name="l78"></a> </span><span class=cF1>if</span><span class=cF0> (task->parent_task&&task->parent_task->popup_task==task) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l79"></a> </span><span class=cF5>SetRFlags</span><span class=cF0>(old_flags);
|
||
|
<a name="l80"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>ScanMsg</span><span class=cF0>(_arg1,_arg2,mask,task->parent_task);
|
||
|
<a name="l81"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l82"></a>sm_done:
|
||
|
<a name="l83"></a> </span><span class=cF5>SetRFlags</span><span class=cF0>(old_flags);
|
||
|
<a name="l84"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l85"></a>}
|
||
|
<a name="l86"></a>
|
||
|
<a name="l87"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>FlushMsgs</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>)
|
||
|
<a name="l88"></a>{</span><span class=cF2>//Throw away all messages. Return count.</span><span class=cF0>
|
||
|
<a name="l89"></a> </span><span class=cF9>I64</span><span class=cF0> res=0,arg1,arg2;
|
||
|
<a name="l90"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>ScanMsg</span><span class=cF7>(</span><span class=cF0>&arg1,&arg2,~1,task</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l91"></a> res++;
|
||
|
<a name="l92"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l93"></a>}
|
||
|
<a name="l94"></a>
|
||
|
<a name="l95"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>GetMsg</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *_arg1=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> *_arg2=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> mask=~1,</span><span class=cF9>CTask</span><span class=cF0> *task=</span><span class=cF3>NULL</span><span class=cF0>)
|
||
|
<a name="l96"></a>{</span><span class=cF2>//Wait for a message of type specified by a one in the mask.</span><span class=cF0>
|
||
|
<a name="l97"></a></span><span class=cF2>//Throw-out all messages not in mask.</span><span class=cF0>
|
||
|
<a name="l98"></a> </span><span class=cF2>//Returns </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3175"><span class=cF4>msg_code</span></a><span class=cF2>. See </span><a href="/Wb/Demo/MsgLoop.HC.HTML#l1"><span class=cF4>::/Demo/MsgLoop.HC</span></a><span class=cF2>.</span><span class=cF0>
|
||
|
<a name="l99"></a> </span><span class=cF9>I64</span><span class=cF0> res;
|
||
|
<a name="l100"></a> </span><span class=cF1>if</span><span class=cF0> (!task) task=</span><span class=cF5>Fs</span><span class=cF0>;
|
||
|
<a name="l101"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&task->task_flags,</span><span class=cF3>TASKf_IDLE</span><span class=cF0>);
|
||
|
<a name="l102"></a> </span><span class=cF1>while</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>res=</span><span class=cF5>ScanMsg</span><span class=cF0>(_arg1,_arg2,mask,task)</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l103"></a> </span><span class=cF5>LBts</span><span class=cF0>(&task->task_flags,</span><span class=cF3>TASKf_IDLE</span><span class=cF0>);
|
||
|
<a name="l104"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
||
|
<a name="l105"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l106"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&task->task_flags,</span><span class=cF3>TASKf_IDLE</span><span class=cF0>);
|
||
|
<a name="l107"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l108"></a>}
|
||
|
<a name="l109"></a>
|
||
|
<a name="l110"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>ScanChar</span><span class=cF0>()
|
||
|
<a name="l111"></a>{</span><span class=cF2>//Checks for </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3176"><span class=cF4>MSG_KEY_DOWN</span></a><span class=cF2> and returns 0 immediately if no key.</span><span class=cF0>
|
||
|
<a name="l112"></a></span><span class=cF2>//Waits for </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3177"><span class=cF4>MSG_KEY_UP</span></a><span class=cF2> of non-zero </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3426"><span class=cF4>ASCII</span></a><span class=cF2> key and returns </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3426"><span class=cF4>ASCII</span></a><span class=cF2> if key.</span><span class=cF0>
|
||
|
<a name="l113"></a> </span><span class=cF2>//</span><a href="/Wb/Kernel/SerialDev/Message.HC.HTML#l37"><span class=cF4>ScanMsg</span></a><span class=cF2>() throws away other message types.</span><span class=cF0>
|
||
|
<a name="l114"></a> </span><span class=cF9>I64</span><span class=cF0> arg1a,arg2a,arg1b,arg2b;
|
||
|
<a name="l115"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>ScanMsg</span><span class=cF7>(</span><span class=cF0>&arg1a,&arg2a,1<<</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF7>)</span><span class=cF0>||!arg1a)
|
||
|
<a name="l116"></a> </span><span class=cF1>return</span><span class=cF0> 0;
|
||
|
<a name="l117"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l118"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF5>GetMsg</span><span class=cF0>(&arg1b,&arg2b,1<<</span><span class=cF3>MSG_KEY_UP</span><span class=cF0>);
|
||
|
<a name="l119"></a> </span><span class=cF1>while</span><span class=cF0> (!arg1b); </span><span class=cF2>//Be careful of </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3501"><span class=cF4>SC_SHIFT</span></a><span class=cF2> and </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3502"><span class=cF4>SC_CTRL</span></a><span class=cF2>, etc.</span><span class=cF0>
|
||
|
<a name="l120"></a> </span><span class=cF1>return</span><span class=cF0> arg1a;
|
||
|
<a name="l121"></a>}
|
||
|
<a name="l122"></a>
|
||
|
<a name="l123"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>ScanKey</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *_ch=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> *_scan_code=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF1>Bool</span><span class=cF0> echo=</span><span class=cF3>FALSE</span><span class=cF0>)
|
||
|
<a name="l124"></a>{</span><span class=cF2>//Checks for </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3176"><span class=cF4>MSG_KEY_DOWN</span></a><span class=cF2> and returns FALSE immediately if no key.</span><span class=cF0>
|
||
|
<a name="l125"></a></span><span class=cF2>//Sets </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3426"><span class=cF4>ASCII</span></a><span class=cF2> and </span><a href="/Wb/Doc/CharOverview.DD.HTML#l1"><span class=cF4>scan_code</span></a><span class=cF2>.</span><span class=cF0>
|
||
|
<a name="l126"></a> </span><span class=cF2>//Removes key message and returns TRUE.</span><span class=cF0>
|
||
|
<a name="l127"></a> </span><span class=cF2>//</span><a href="/Wb/Kernel/SerialDev/Message.HC.HTML#l37"><span class=cF4>ScanMsg</span></a><span class=cF2>() throws away other message types.</span><span class=cF0>
|
||
|
<a name="l128"></a> </span><span class=cF9>I64</span><span class=cF0> ch=0,sc=0;
|
||
|
<a name="l129"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>ScanMsg</span><span class=cF7>(</span><span class=cF0>&ch,&sc,1<<</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l130"></a> </span><span class=cF1>if</span><span class=cF0> (_ch) *_ch=ch;
|
||
|
<a name="l131"></a> </span><span class=cF1>if</span><span class=cF0> (_scan_code) *_scan_code=sc;
|
||
|
<a name="l132"></a> </span><span class=cF1>if</span><span class=cF0> (echo)
|
||
|
<a name="l133"></a> </span><span class=cF5>PutKey</span><span class=cF0>(ch,sc);
|
||
|
<a name="l134"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l135"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l136"></a> </span><span class=cF1>if</span><span class=cF0> (_ch) *_ch=0;
|
||
|
<a name="l137"></a> </span><span class=cF1>if</span><span class=cF0> (_scan_code) *_scan_code=0;
|
||
|
<a name="l138"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l139"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l140"></a>}
|
||
|
<a name="l141"></a>
|
||
|
<a name="l142"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>GetKey</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *_scan_code=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF1>Bool</span><span class=cF0> echo=</span><span class=cF3>FALSE</span><span class=cF0>,</span><span class=cF1>Bool</span><span class=cF0> raw_cursor=</span><span class=cF3>FALSE</span><span class=cF0>)
|
||
|
<a name="l143"></a>{</span><span class=cF2>//Waits for </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3176"><span class=cF4>MSG_KEY_DOWN</span></a><span class=cF2> message and returns </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3426"><span class=cF4>ASCII</span></a><span class=cF2>.</span><span class=cF0>
|
||
|
<a name="l144"></a></span><span class=cF2>//Sets </span><a href="/Wb/Doc/CharOverview.DD.HTML#l1"><span class=cF4>scan_code</span></a><span class=cF2>.</span><span class=cF0>
|
||
|
<a name="l145"></a> </span><span class=cF2>//</span><a href="/Wb/Kernel/SerialDev/Message.HC.HTML#l123"><span class=cF4>ScanKey</span></a><span class=cF2>() throws away other message types.</span><span class=cF0>
|
||
|
<a name="l146"></a> </span><span class=cF9>I64</span><span class=cF0> ch,sc;
|
||
|
<a name="l147"></a> </span><span class=cF1>Bool</span><span class=cF0> cursor_on=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l148"></a> </span><span class=cF1>while</span><span class=cF0> (!</span><span class=cF5>ScanKey</span><span class=cF7>(</span><span class=cF0>&ch,&sc,</span><span class=cF3>FALSE</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l149"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsRaw</span><span class=cF0> && raw_cursor) {
|
||
|
<a name="l150"></a> </span><span class=cF1>if</span><span class=cF0> (!cursor_on && </span><span class=cF5>ToI64</span><span class=cF7>(</span><span class=cF5>GetTSC</span><span class=cF0>*5/</span><span class=cFB>cnts</span><span class=cF0>.time_stamp_freq</span><span class=cF7>)</span><span class=cF0>&1) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l151"></a> </span><span class=cF6>'.'</span><span class=cF0>;
|
||
|
<a name="l152"></a> cursor_on=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l153"></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> (cursor_on && !</span><span class=cF7>(</span><span class=cF5>ToI64</span><span class=cF0>(</span><span class=cF5>GetTSC</span><span class=cF0>*5/</span><span class=cFB>cnts</span><span class=cF0>.time_stamp_freq)&1</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l154"></a> </span><span class=cF6>''</span><span class=cF0> </span><span class=cF3>CH_BACKSPACE</span><span class=cF0>;
|
||
|
<a name="l155"></a> cursor_on=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l156"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l157"></a> }
|
||
|
<a name="l158"></a> </span><span class=cF5>LBts</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags,</span><span class=cF3>TASKf_IDLE</span><span class=cF0>);
|
||
|
<a name="l159"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsDbgMode</span><span class=cF0>) {
|
||
|
<a name="l160"></a></span><span class=cF2>//We don't want interrupt-driven keyboard when in debugger</span><span class=cF0>
|
||
|
<a name="l161"></a> </span><span class=cF2>//because that could have side-effects or crash, so we poll</span><span class=cF0>
|
||
|
<a name="l162"></a> </span><span class=cF2>//keyboard when in debugger with interrupts off.</span><span class=cF0>
|
||
|
<a name="l163"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
||
|
<a name="l164"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
||
|
<a name="l165"></a> </span><span class=cF5>KbdMsHndlr</span><span class=cF0>(</span><span class=cF3>TRUE</span><span class=cF0>,</span><span class=cF3>FALSE</span><span class=cF0>);
|
||
|
<a name="l166"></a> </span><span class=cF5>KbdMsgsQue</span><span class=cF0>;
|
||
|
<a name="l167"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
||
|
<a name="l168"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l169"></a> </span><span class=cF5>LBts</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags,</span><span class=cF3>TASKf_AWAITING_MSG</span><span class=cF0>);
|
||
|
<a name="l170"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
||
|
<a name="l171"></a> }
|
||
|
<a name="l172"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&</span><span class=cF5>Fs</span><span class=cF0>->task_flags,</span><span class=cF3>TASKf_IDLE</span><span class=cF0>);
|
||
|
<a name="l173"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l174"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsRaw</span><span class=cF0> && raw_cursor && cursor_on)
|
||
|
<a name="l175"></a> </span><span class=cF6>''</span><span class=cF0> </span><span class=cF3>CH_BACKSPACE</span><span class=cF0>;
|
||
|
<a name="l176"></a> </span><span class=cF1>if</span><span class=cF0> (echo)
|
||
|
<a name="l177"></a> </span><span class=cF5>PutKey</span><span class=cF0>(ch,sc);
|
||
|
<a name="l178"></a> </span><span class=cF1>if</span><span class=cF0> (_scan_code) *_scan_code=sc;
|
||
|
<a name="l179"></a> </span><span class=cF1>return</span><span class=cF0> ch;
|
||
|
<a name="l180"></a>}
|
||
|
<a name="l181"></a>
|
||
|
<a name="l182"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>GetChar</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> *_scan_code=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF1>Bool</span><span class=cF0> echo=</span><span class=cF3>TRUE</span><span class=cF0>,</span><span class=cF1>Bool</span><span class=cF0> raw_cursor=</span><span class=cF3>FALSE</span><span class=cF0>)
|
||
|
<a name="l183"></a>{</span><span class=cF2>//Waits for non-zero </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3426"><span class=cF4>ASCII</span></a><span class=cF2> key.</span><span class=cF0>
|
||
|
<a name="l184"></a></span><span class=cF2>//Sets </span><a href="/Wb/Doc/CharOverview.DD.HTML#l1"><span class=cF4>scan_code</span></a><span class=cF2>.</span><span class=cF0>
|
||
|
<a name="l185"></a> </span><span class=cF9>I64</span><span class=cF0> ch1;
|
||
|
<a name="l186"></a> </span><span class=cF1>do</span><span class=cF0> ch1=</span><span class=cF5>GetKey</span><span class=cF0>(_scan_code,</span><span class=cF3>FALSE</span><span class=cF0>,raw_cursor);
|
||
|
<a name="l187"></a> </span><span class=cF1>while</span><span class=cF0> (!ch1);
|
||
|
<a name="l188"></a> </span><span class=cF1>if</span><span class=cF0> (echo)
|
||
|
<a name="l189"></a> </span><span class=cF6>"$PT$%c$FG$"</span><span class=cF0>,ch1;
|
||
|
<a name="l190"></a> </span><span class=cF1>return</span><span class=cF0> ch1;
|
||
|
<a name="l191"></a>}
|
||
|
<a name="l192"></a>
|
||
|
<a name="l193"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>GetStr</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *msg=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF1>U8</span><span class=cF0> *dft=</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF9>I64</span><span class=cF0> flags=0)
|
||
|
<a name="l194"></a>{</span><span class=cF2>//Returns a </span><a href="/Wb/Kernel/Mem/MAllocFree.HC.HTML#l387"><span class=cF4>MAlloc</span></a><span class=cF2>()ed prompted string. See </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3725"><span class=cF4>Flags</span></a><span class=cF2>.</span><span class=cF0>
|
||
|
<a name="l195"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
|
||
|
<a name="l196"></a> </span><span class=cF1>if</span><span class=cF0> (msg)
|
||
|
<a name="l197"></a> </span><span class=cF6>""</span><span class=cF0> msg,dft;
|
||
|
<a name="l198"></a> st=(*</span><span class=cFB>fp_getstr2</span><span class=cF0>)(flags);
|
||
|
<a name="l199"></a> </span><span class=cF1>if</span><span class=cF0> (!*st) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l200"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
||
|
<a name="l201"></a> </span><span class=cF1>if</span><span class=cF0> (dft)
|
||
|
<a name="l202"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>StrNew</span><span class=cF0>(dft);
|
||
|
<a name="l203"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l204"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF6>""</span><span class=cF0>);
|
||
|
<a name="l205"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l206"></a> </span><span class=cF1>return</span><span class=cF0> st;
|
||
|
<a name="l207"></a>}
|
||
|
<a name="l208"></a>
|
||
|
<a name="l209"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>GetS</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *buf,</span><span class=cF9>I64</span><span class=cF0> size,</span><span class=cF1>Bool</span><span class=cF0> allow_ext=</span><span class=cF3>TRUE</span><span class=cF0>)
|
||
|
<a name="l210"></a>{</span><span class=cF2>//Prompt into fixed length string. Size must include terminator.</span><span class=cF0>
|
||
|
<a name="l211"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
|
||
|
<a name="l212"></a> </span><span class=cF9>I64</span><span class=cF0> ch,i=0;
|
||
|
<a name="l213"></a> </span><span class=cF1>if</span><span class=cF0> (!size || !buf) </span><span class=cF1>return</span><span class=cF0> 0;
|
||
|
<a name="l214"></a> </span><span class=cF1>if</span><span class=cF0> (allow_ext) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l215"></a> st=</span><span class=cF5>GetStr</span><span class=cF0>;
|
||
|
<a name="l216"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>st</span><span class=cF7>)</span><span class=cF0>>size-1) {
|
||
|
<a name="l217"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(buf,st,size-1);
|
||
|
<a name="l218"></a> buf[size-1]=0;
|
||
|
<a name="l219"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l220"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,st);
|
||
|
<a name="l221"></a> i=</span><span class=cF5>StrLen</span><span class=cF0>(buf);
|
||
|
<a name="l222"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
||
|
<a name="l223"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l224"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
|
||
|
<a name="l225"></a> ch=</span><span class=cF5>GetChar</span><span class=cF0>(,</span><span class=cF3>FALSE</span><span class=cF0>,</span><span class=cF5>IsDbgMode</span><span class=cF0>);
|
||
|
<a name="l226"></a> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'\n'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l227"></a> </span><span class=cF6>''</span><span class=cF0> ch;
|
||
|
<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> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF3>CH_BACKSPACE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l230"></a> </span><span class=cF1>if</span><span class=cF0> (i>0) {
|
||
|
<a name="l231"></a> i--;
|
||
|
<a name="l232"></a> </span><span class=cF6>''</span><span class=cF0> ch;
|
||
|
<a name="l233"></a> }
|
||
|
<a name="l234"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l235"></a> </span><span class=cF1>if</span><span class=cF0> (i<size-1) {
|
||
|
<a name="l236"></a> buf[i++]=ch;
|
||
|
<a name="l237"></a> </span><span class=cF6>''</span><span class=cF0> ch;
|
||
|
<a name="l238"></a> }
|
||
|
<a name="l239"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l240"></a> }
|
||
|
<a name="l241"></a> buf[i]=0;
|
||
|
<a name="l242"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l243"></a> </span><span class=cF1>return</span><span class=cF0> i;
|
||
|
<a name="l244"></a>}
|
||
|
</span></pre></body>
|
||
|
</html>
|