mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-28 08:16:31 +00:00
330 lines
35 KiB
HTML
Executable file
330 lines
35 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V0.10">
|
|
<style type="text/css">
|
|
body {background-color:#000000;}
|
|
.cF0{color:#ffffff;background-color:#000000;}
|
|
.cF1{color:#3465a4;background-color:#000000;}
|
|
.cF2{color:#4e9a06;background-color:#000000;}
|
|
.cF3{color:#06989a;background-color:#000000;}
|
|
.cF4{color:#a24444;background-color:#000000;}
|
|
.cF5{color:#75507b;background-color:#000000;}
|
|
.cF6{color:#ce982f;background-color:#000000;}
|
|
.cF7{color:#bcc0b9;background-color:#000000;}
|
|
.cF8{color:#555753;background-color:#000000;}
|
|
.cF9{color:#729fcf;background-color:#000000;}
|
|
.cFA{color:#82bc49;background-color:#000000;}
|
|
.cFB{color:#34e2e2;background-color:#000000;}
|
|
.cFC{color:#ac3535;background-color:#000000;}
|
|
.cFD{color:#ad7fa8;background-color:#000000;}
|
|
.cFE{color:#fce94f;background-color:#000000;}
|
|
.cFF{color:#000000;background-color:#000000;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<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>RFlagsGet</span><span class=cF0>;
|
|
<a name="l6"></a>
|
|
<a name="l7"></a> </span><span class=cF5>Fs</span><span class=cF0>->win_inhibit = </span><span class=cF3>WIG_USER_TASK_DEFAULT</span><span class=cF0>;
|
|
<a name="l8"></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="l9"></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="l10"></a> </span><span class=cF5>LBEqual</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="l11"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l12"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l13"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l14"></a> </span><span class=cF5>JobsHandler</span><span class=cF0>(old_flags);
|
|
<a name="l15"></a> tmpc1 = &</span><span class=cF5>Fs</span><span class=cF0>->server_ctrl.next_waiting;
|
|
<a name="l16"></a> tmpc = tmpc1->next;
|
|
<a name="l17"></a> </span><span class=cF1>if</span><span class=cF0> (tmpc == tmpc1)
|
|
<a name="l18"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l19"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l20"></a> {
|
|
<a name="l21"></a> </span><span class=cF1>if</span><span class=cF0> (tmpc->job_code == </span><span class=cF3>JOBT_TEXT_INPUT</span><span class=cF0>)
|
|
<a name="l22"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l23"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpc);
|
|
<a name="l24"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(old_flags);
|
|
<a name="l25"></a> </span><span class=cF1>try</span><span class=cF0>
|
|
<a name="l26"></a> </span><span class=cF5>ExePrint</span><span class=cF0>(</span><span class=cF6>"%s"</span><span class=cF0>, tmpc->aux_str);
|
|
<a name="l27"></a> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l28"></a> </span><span class=cF5>Fs</span><span class=cF0>->catch_except = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l29"></a> </span><span class=cF5>JobDel</span><span class=cF0>(tmpc);
|
|
<a name="l30"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l31"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l32"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l33"></a> }
|
|
<a name="l34"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l35"></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="l36"></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="l37"></a> </span><span class=cF1>if</span><span class=cF0> (!old_filter)
|
|
<a name="l38"></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="l39"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(old_flags);
|
|
<a name="l40"></a>}
|
|
<a name="l41"></a>
|
|
<a name="l42"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>MessageScan</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=~</span><span class=cFE>1</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="l43"></a>{</span><span class=cF2>/*Check for a message of type specified by a one in the mask.</span><span class=cF0>
|
|
<a name="l44"></a></span><span class=cF2>Throw-out messages not in mask.</span><span class=cF0>
|
|
<a name="l45"></a></span><span class=cF2>If no message fit mask, return NULL immediately.</span><span class=cF0>
|
|
<a name="l46"></a></span><span class=cF2>Remove desired message, return </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3845"><span class=cF4>message_code</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l47"></a></span><span class=cF2>Note: This delivers messages from parent down to pop-up.</span><span class=cF0>
|
|
<a name="l48"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l49"></a> </span><span class=cF9>I64</span><span class=cF0> res, old_flags;
|
|
<a name="l50"></a> </span><span class=cF9>CJob</span><span class=cF0> *tmpc, *tmpc1;
|
|
<a name="l51"></a>
|
|
<a name="l52"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l53"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l54"></a> old_flags = </span><span class=cF5>RFlagsGet</span><span class=cF0>;
|
|
<a name="l55"></a> tmpc1 =&task->server_ctrl.next_waiting;
|
|
<a name="l56"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l57"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l58"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l59"></a> </span><span class=cF1>if</span><span class=cF0> (task == </span><span class=cF5>Fs</span><span class=cF0>)
|
|
<a name="l60"></a> </span><span class=cF5>JobsHandler</span><span class=cF0>(old_flags);
|
|
<a name="l61"></a> tmpc = tmpc1->next;
|
|
<a name="l62"></a> </span><span class=cF1>if</span><span class=cF0> (tmpc == tmpc1)
|
|
<a name="l63"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l64"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l65"></a> {
|
|
<a name="l66"></a> </span><span class=cF1>if</span><span class=cF0> (tmpc->job_code == </span><span class=cF3>JOBT_MESSAGE</span><span class=cF0>)
|
|
<a name="l67"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l68"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpc);
|
|
<a name="l69"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(old_flags);
|
|
<a name="l70"></a> res = tmpc->message_code;
|
|
<a name="l71"></a> </span><span class=cF1>if</span><span class=cF0> (_arg1)
|
|
<a name="l72"></a> *_arg1 = tmpc->aux1;
|
|
<a name="l73"></a> </span><span class=cF1>if</span><span class=cF0> (_arg2)
|
|
<a name="l74"></a> *_arg2 = tmpc->aux2;
|
|
<a name="l75"></a> </span><span class=cF5>JobDel</span><span class=cF0>(tmpc);
|
|
<a name="l76"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>res != </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0> || !(tmpc->aux2 & </span><span class=cF3>SCF_KEY_DESC</span><span class=cF0>) || !</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> &&
|
|
<a name="l77"></a> </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="l78"></a> </span><span class=cF1>goto</span><span class=cF0> sm_done;
|
|
<a name="l79"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l80"></a> }
|
|
<a name="l81"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(old_flags);
|
|
<a name="l82"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l83"></a> res = </span><span class=cF3>MESSAGE_NULL</span><span class=cF0>;
|
|
<a name="l84"></a> </span><span class=cF1>if</span><span class=cF0> (_arg1)
|
|
<a name="l85"></a> *_arg1 = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l86"></a> </span><span class=cF1>if</span><span class=cF0> (_arg2)
|
|
<a name="l87"></a> *_arg2 = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l88"></a> </span><span class=cF1>if</span><span class=cF0> (task->parent_task && task->parent_task->popup_task == task)
|
|
<a name="l89"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l90"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(old_flags);
|
|
<a name="l91"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>MessageScan</span><span class=cF0>(_arg1, _arg2, mask, task->parent_task);
|
|
<a name="l92"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l93"></a>sm_done:
|
|
<a name="l94"></a> </span><span class=cF5>RFlagsSet</span><span class=cF0>(old_flags);
|
|
<a name="l95"></a>
|
|
<a name="l96"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l97"></a>}
|
|
<a name="l98"></a>
|
|
<a name="l99"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>FlushMessages</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="l100"></a>{</span><span class=cF2>//Throw away all messages. Return count.</span><span class=cF0>
|
|
<a name="l101"></a> </span><span class=cF9>I64</span><span class=cF0> res = </span><span class=cFE>0</span><span class=cF0>, arg1, arg2;
|
|
<a name="l102"></a>
|
|
<a name="l103"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>MessageScan</span><span class=cF7>(</span><span class=cF0>&arg1, &arg2, ~</span><span class=cFE>1</span><span class=cF0>, task</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l104"></a> res++;
|
|
<a name="l105"></a>
|
|
<a name="l106"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l107"></a>}
|
|
<a name="l108"></a>
|
|
<a name="l109"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>MessageGet</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=~</span><span class=cFE>1</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="l110"></a>{</span><span class=cF2>//Wait for a message of type specified by a one in the mask.</span><span class=cF0>
|
|
<a name="l111"></a></span><span class=cF2>//Throw-out all messages not in mask.</span><span class=cF0>
|
|
<a name="l112"></a> </span><span class=cF2>//Returns </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3845"><span class=cF4>message_code</span></a><span class=cF2>. See </span><a href="https://tomawezome.github.io/ZealOS/Demo/MessageLoop.CC.html#l1"><span class=cF4>::/Demo/MessageLoop.CC</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l113"></a> </span><span class=cF9>I64</span><span class=cF0> res;
|
|
<a name="l114"></a>
|
|
<a name="l115"></a> </span><span class=cF1>if</span><span class=cF0> (!task)
|
|
<a name="l116"></a> task = </span><span class=cF5>Fs</span><span class=cF0>;
|
|
<a name="l117"></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="l118"></a> </span><span class=cF1>while</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>res = </span><span class=cF5>MessageScan</span><span class=cF0>(_arg1, _arg2, mask, task)</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l119"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l120"></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="l121"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l122"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l123"></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="l124"></a>
|
|
<a name="l125"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
|
<a name="l126"></a>}
|
|
<a name="l127"></a>
|
|
<a name="l128"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>CharScan</span><span class=cF0>()
|
|
<a name="l129"></a>{</span><span class=cF2>//Checks for </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3846"><span class=cF4>MESSAGE_KEY_DOWN</span></a><span class=cF2> and returns 0 immediately if no key.</span><span class=cF0>
|
|
<a name="l130"></a></span><span class=cF2>//Waits for </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3847"><span class=cF4>MESSAGE_KEY_UP</span></a><span class=cF2> of non-zero </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l4095"><span class=cF4>ASCII</span></a><span class=cF2> key and returns </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l4095"><span class=cF4>ASCII</span></a><span class=cF2> if key.</span><span class=cF0>
|
|
<a name="l131"></a> </span><span class=cF2>//</span><a href="https://tomawezome.github.io/ZealOS/Kernel/SerialDev/Message.CC.html#l42"><span class=cF4>MessageScan</span></a><span class=cF2>() throws away other message types.</span><span class=cF0>
|
|
<a name="l132"></a> </span><span class=cF9>I64</span><span class=cF0> arg1a, arg2a, arg1b, arg2b;
|
|
<a name="l133"></a>
|
|
<a name="l134"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>MessageScan</span><span class=cF7>(</span><span class=cF0>&arg1a, &arg2a, </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF7>)</span><span class=cF0> || !arg1a)
|
|
<a name="l135"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l136"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l137"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF5>MessageGet</span><span class=cF0>(&arg1b, &arg2b, </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_KEY_UP</span><span class=cF0>);
|
|
<a name="l138"></a> </span><span class=cF1>while</span><span class=cF0> (!arg1b); </span><span class=cF2>//Be careful of </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l4169"><span class=cF4>SC_SHIFT</span></a><span class=cF2> and </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l4170"><span class=cF4>SC_CTRL</span></a><span class=cF2>, etc.</span><span class=cF0>
|
|
<a name="l139"></a>
|
|
<a name="l140"></a> </span><span class=cF1>return</span><span class=cF0> arg1a;
|
|
<a name="l141"></a>}
|
|
<a name="l142"></a>
|
|
<a name="l143"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>KeyScan</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="l144"></a>{</span><span class=cF2>//Checks for </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3846"><span class=cF4>MESSAGE_KEY_DOWN</span></a><span class=cF2> and returns FALSE immediately if no key.</span><span class=cF0>
|
|
<a name="l145"></a></span><span class=cF2>//Sets </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l4095"><span class=cF4>ASCII</span></a><span class=cF2> and </span><a href="https://tomawezome.github.io/ZealOS/Doc/CharOverview.DD.html#l1"><span class=cF4>scan_code</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l146"></a> </span><span class=cF2>//Removes key message and returns TRUE.</span><span class=cF0>
|
|
<a name="l147"></a> </span><span class=cF2>//</span><a href="https://tomawezome.github.io/ZealOS/Kernel/SerialDev/Message.CC.html#l42"><span class=cF4>MessageScan</span></a><span class=cF2>() throws away other message types.</span><span class=cF0>
|
|
<a name="l148"></a> </span><span class=cF9>I64</span><span class=cF0> ch = </span><span class=cFE>0</span><span class=cF0>, sc = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l149"></a>
|
|
<a name="l150"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>MessageScan</span><span class=cF7>(</span><span class=cF0>&ch, &sc, </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l151"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l152"></a> </span><span class=cF1>if</span><span class=cF0> (_ch)
|
|
<a name="l153"></a> *_ch = ch;
|
|
<a name="l154"></a> </span><span class=cF1>if</span><span class=cF0> (_scan_code)
|
|
<a name="l155"></a> *_scan_code = sc;
|
|
<a name="l156"></a> </span><span class=cF1>if</span><span class=cF0> (echo)
|
|
<a name="l157"></a> </span><span class=cF5>PutKey</span><span class=cF0>(ch, sc);
|
|
<a name="l158"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l159"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l160"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l161"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l162"></a> </span><span class=cF1>if</span><span class=cF0> (_ch)
|
|
<a name="l163"></a> *_ch = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l164"></a> </span><span class=cF1>if</span><span class=cF0> (_scan_code)
|
|
<a name="l165"></a> *_scan_code = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l166"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l167"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l168"></a>}
|
|
<a name="l169"></a>
|
|
<a name="l170"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>KeyGet</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="l171"></a>{</span><span class=cF2>//Waits for </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l3846"><span class=cF4>MESSAGE_KEY_DOWN</span></a><span class=cF2> message and returns </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l4095"><span class=cF4>ASCII</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l172"></a></span><span class=cF2>//Sets </span><a href="https://tomawezome.github.io/ZealOS/Doc/CharOverview.DD.html#l1"><span class=cF4>scan_code</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l173"></a> </span><span class=cF2>//</span><a href="https://tomawezome.github.io/ZealOS/Kernel/SerialDev/Message.CC.html#l143"><span class=cF4>KeyScan</span></a><span class=cF2>() throws away other message types.</span><span class=cF0>
|
|
<a name="l174"></a> </span><span class=cF9>I64</span><span class=cF0> ch, sc;
|
|
<a name="l175"></a> </span><span class=cF1>Bool</span><span class=cF0> cursor_on = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l176"></a>
|
|
<a name="l177"></a> </span><span class=cF1>while</span><span class=cF0> (!</span><span class=cF5>KeyScan</span><span class=cF7>(</span><span class=cF0>&ch, &sc, </span><span class=cF3>FALSE</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l178"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l179"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsRaw</span><span class=cF0> && raw_cursor)
|
|
<a name="l180"></a> {
|
|
<a name="l181"></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>TSCGet</span><span class=cF0> * </span><span class=cFE>5</span><span class=cF0> / </span><span class=cFB>counts</span><span class=cF0>.time_stamp_freq</span><span class=cF7>)</span><span class=cF0> & </span><span class=cFE>1</span><span class=cF0>)
|
|
<a name="l182"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l183"></a> </span><span class=cF6>'.'</span><span class=cF0>;
|
|
<a name="l184"></a> cursor_on = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l185"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l186"></a> </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>TSCGet</span><span class=cF0> * </span><span class=cFE>5</span><span class=cF0> / </span><span class=cFB>counts</span><span class=cF0>.time_stamp_freq) & </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l187"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l188"></a> </span><span class=cF6>''</span><span class=cF0> </span><span class=cF3>CH_BACKSPACE</span><span class=cF0>;
|
|
<a name="l189"></a> cursor_on = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l190"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l191"></a> }
|
|
<a name="l192"></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="l193"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsDebugMode</span><span class=cF0>)
|
|
<a name="l194"></a> {
|
|
<a name="l195"></a></span><span class=cF2>//We don't want interrupt-driven keyboard when in debugger</span><span class=cF0>
|
|
<a name="l196"></a> </span><span class=cF2>//because that could have side-effects or crash, so we poll</span><span class=cF0>
|
|
<a name="l197"></a> </span><span class=cF2>//keyboard when in debugger with interrupts off.</span><span class=cF0>
|
|
<a name="l198"></a> </span><span class=cF1>PUSHFD</span><span class=cF0>
|
|
<a name="l199"></a> </span><span class=cF1>CLI</span><span class=cF0>
|
|
<a name="l200"></a> </span><span class=cF5>KbdMouseHandler</span><span class=cF0>(</span><span class=cF3>TRUE</span><span class=cF0>, </span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l201"></a> </span><span class=cF5>KbdMessagesQueue</span><span class=cF0>;
|
|
<a name="l202"></a> </span><span class=cF1>POPFD</span><span class=cF0>
|
|
<a name="l203"></a> }
|
|
<a name="l204"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l205"></a> {
|
|
<a name="l206"></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_MESSAGE</span><span class=cF0>);
|
|
<a name="l207"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l208"></a> }
|
|
<a name="l209"></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="l210"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l211"></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="l212"></a> </span><span class=cF6>''</span><span class=cF0> </span><span class=cF3>CH_BACKSPACE</span><span class=cF0>;
|
|
<a name="l213"></a> </span><span class=cF1>if</span><span class=cF0> (echo)
|
|
<a name="l214"></a> </span><span class=cF5>PutKey</span><span class=cF0>(ch, sc);
|
|
<a name="l215"></a> </span><span class=cF1>if</span><span class=cF0> (_scan_code)
|
|
<a name="l216"></a> *_scan_code = sc;
|
|
<a name="l217"></a> </span><span class=cF1>return</span><span class=cF0> ch;
|
|
<a name="l218"></a>}
|
|
<a name="l219"></a>
|
|
<a name="l220"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>CharGet</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="l221"></a>{</span><span class=cF2>//Waits for non-zero </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l4095"><span class=cF4>ASCII</span></a><span class=cF2> key.</span><span class=cF0>
|
|
<a name="l222"></a></span><span class=cF2>//Sets </span><a href="https://tomawezome.github.io/ZealOS/Doc/CharOverview.DD.html#l1"><span class=cF4>scan_code</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l223"></a> </span><span class=cF9>I64</span><span class=cF0> ch1;
|
|
<a name="l224"></a>
|
|
<a name="l225"></a> </span><span class=cF1>do</span><span class=cF0> ch1 = </span><span class=cF5>KeyGet</span><span class=cF0>(_scan_code, </span><span class=cF3>FALSE</span><span class=cF0>, raw_cursor);
|
|
<a name="l226"></a> </span><span class=cF1>while</span><span class=cF0> (!ch1);
|
|
<a name="l227"></a> </span><span class=cF1>if</span><span class=cF0> (echo)
|
|
<a name="l228"></a> </span><span class=cF6>"$PT$%c$FG$"</span><span class=cF0>, ch1;
|
|
<a name="l229"></a>
|
|
<a name="l230"></a> </span><span class=cF1>return</span><span class=cF0> ch1;
|
|
<a name="l231"></a>}
|
|
<a name="l232"></a>
|
|
<a name="l233"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>StrGet</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *message=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF1>default</span><span class=cF0>=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> flags=</span><span class=cF3>NONE</span><span class=cF0>)
|
|
<a name="l234"></a>{</span><span class=cF2>//Returns a </span><a href="https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.CC.html#l391"><span class=cF4>MAlloc</span></a><span class=cF2>()ed prompted string. See </span><a href="https://tomawezome.github.io/ZealOS/Kernel/KernelA.HH.html#l4330"><span class=cF4>Flags</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l235"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
|
|
<a name="l236"></a>
|
|
<a name="l237"></a> </span><span class=cF1>if</span><span class=cF0> (message)
|
|
<a name="l238"></a> </span><span class=cF6>""</span><span class=cF0> message, </span><span class=cF1>default</span><span class=cF0>;
|
|
<a name="l239"></a> st = (*</span><span class=cFB>fp_getstr2</span><span class=cF0>)(flags);
|
|
<a name="l240"></a> </span><span class=cF1>if</span><span class=cF0> (!*st)
|
|
<a name="l241"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l242"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
|
<a name="l243"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF1>default</span><span class=cF0>)
|
|
<a name="l244"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>StrNew</span><span class=cF0>(</span><span class=cF1>default</span><span class=cF0>);
|
|
<a name="l245"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l246"></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="l247"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l248"></a> </span><span class=cF1>return</span><span class=cF0> st;
|
|
<a name="l249"></a>}
|
|
<a name="l250"></a>
|
|
<a name="l251"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>StrNGet</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="l252"></a>{</span><span class=cF2>//Prompt into fixed length string. Size must include terminator.</span><span class=cF0>
|
|
<a name="l253"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
|
|
<a name="l254"></a> </span><span class=cF9>I64</span><span class=cF0> ch, i = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l255"></a>
|
|
<a name="l256"></a> </span><span class=cF1>if</span><span class=cF0> (!size || !buf)
|
|
<a name="l257"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l258"></a> </span><span class=cF1>if</span><span class=cF0> (allow_ext)
|
|
<a name="l259"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l260"></a> st = </span><span class=cF5>StrGet</span><span class=cF0>;
|
|
<a name="l261"></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 - </span><span class=cFE>1</span><span class=cF0>)
|
|
<a name="l262"></a> {
|
|
<a name="l263"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(buf, st, size - </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l264"></a> buf[size - </span><span class=cFE>1</span><span class=cF0>] = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l265"></a> }
|
|
<a name="l266"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l267"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(buf, st);
|
|
<a name="l268"></a> i = </span><span class=cF5>StrLen</span><span class=cF0>(buf);
|
|
<a name="l269"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
|
<a name="l270"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l271"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l272"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l273"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l274"></a> {
|
|
<a name="l275"></a> ch = </span><span class=cF5>CharGet</span><span class=cF0>(, </span><span class=cF3>FALSE</span><span class=cF0>, </span><span class=cF5>IsDebugMode</span><span class=cF0>);
|
|
<a name="l276"></a> </span><span class=cF1>if</span><span class=cF0> (ch == </span><span class=cF6>'\n'</span><span class=cF0>)
|
|
<a name="l277"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l278"></a> </span><span class=cF6>''</span><span class=cF0> ch;
|
|
<a name="l279"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l280"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l281"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (ch == </span><span class=cF3>CH_BACKSPACE</span><span class=cF0>)
|
|
<a name="l282"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l283"></a> </span><span class=cF1>if</span><span class=cF0> (i > </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l284"></a> {
|
|
<a name="l285"></a> i--;
|
|
<a name="l286"></a> </span><span class=cF6>''</span><span class=cF0> ch;
|
|
<a name="l287"></a> }
|
|
<a name="l288"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l289"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l290"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l291"></a> </span><span class=cF1>if</span><span class=cF0> (i < size - </span><span class=cFE>1</span><span class=cF0>)
|
|
<a name="l292"></a> {
|
|
<a name="l293"></a> buf[i++] = ch;
|
|
<a name="l294"></a> </span><span class=cF6>''</span><span class=cF0> ch;
|
|
<a name="l295"></a> }
|
|
<a name="l296"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l297"></a> }
|
|
<a name="l298"></a> buf[i] = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l299"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l300"></a> </span><span class=cF1>return</span><span class=cF0> i;
|
|
<a name="l301"></a>}
|
|
</span></pre></body>
|
|
</html>
|