143 lines
3.2 KiB
Plaintext
143 lines
3.2 KiB
Plaintext
#help_index "Messages"
|
|
|
|
void InputFilterTask()
|
|
{
|
|
I1 *st;
|
|
TssCmdStruct *tempc,*tempc1;
|
|
BoolU4 old_filter;
|
|
U8 old_flags=GetFlags;
|
|
InitUserTask;
|
|
Bts(&Fs->task_flags,TSSf_INPUT_FILTER_TASK);
|
|
old_filter=Bts(&Fs->last_input_filter_tss->task_flags,TSSf_FILTER_INPUT);
|
|
AssignBit(&Fs->task_flags,TSSf_FILTER_INPUT,old_filter);
|
|
while (TRUE) {
|
|
HandleServantCmds;
|
|
Cli;
|
|
tempc1=&Fs->next_servant_cmd;
|
|
tempc=tempc1->next;
|
|
if (tempc==tempc1)
|
|
break;
|
|
else {
|
|
if (tempc->cmd_code==TSSCT_TEXT_INPUT) {
|
|
RemQue(tempc);
|
|
SetFlags(old_flags);
|
|
st=tempc->data;
|
|
AFree(tempc);
|
|
Preempt(ON);
|
|
try
|
|
ExecuteStr(st);
|
|
catch
|
|
Fs->catch_except=TRUE;
|
|
Preempt(OFF);
|
|
AFree(st);
|
|
} else
|
|
break;
|
|
}
|
|
}
|
|
Fs->next_input_filter_tss->last_input_filter_tss=Fs->last_input_filter_tss;
|
|
Fs->last_input_filter_tss->next_input_filter_tss=Fs->next_input_filter_tss;
|
|
if (!old_filter)
|
|
Btr(&Fs->last_input_filter_tss->task_flags,TSSf_FILTER_INPUT);
|
|
SetFlags(old_flags);
|
|
}
|
|
|
|
public U8 ScanMsg(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL)
|
|
{
|
|
U8 result,old_flags;
|
|
TssCmdStruct *tempc,*tempc1;
|
|
BoolU4 old_preempt;
|
|
if (!tss) tss=Fs;
|
|
old_flags=GetFlags;
|
|
tempc1=&tss->next_servant_cmd;
|
|
while (TRUE) {
|
|
if (tss==Fs)
|
|
HandleServantCmds;
|
|
Cli;
|
|
tempc=tempc1->next;
|
|
if (tempc==tempc1)
|
|
break;
|
|
else {
|
|
if (tempc->cmd_code==TSSCT_MSG) {
|
|
RemQue(tempc);
|
|
SetFlags(old_flags);
|
|
result=tempc->msg_code;
|
|
*param1=tempc->p1;
|
|
*param2=tempc->p2;
|
|
AFree(tempc);
|
|
if (Bt(&mask,result))
|
|
goto done_msg;
|
|
}
|
|
}
|
|
SetFlags(old_flags);
|
|
}
|
|
if (tss->rmt_chnl) {
|
|
old_preempt=Preempt(OFF);
|
|
start_rmt_msg:
|
|
if (Jiffies>=tss->rmt_chnl->null_msg_jiffy) {
|
|
if (result=RmtGetMsg(tss->rmt_chnl,param1,param2)) {
|
|
if (Bt(&mask,result)) {
|
|
Preempt(old_preempt);
|
|
return result;
|
|
} else
|
|
goto start_rmt_msg;
|
|
}
|
|
}
|
|
Preempt(old_preempt);
|
|
}
|
|
result=0;
|
|
*param1=0;
|
|
*param2=0;
|
|
if (tss->parent_tss) {
|
|
if (tss->parent_tss->popup_tss==tss) {
|
|
SetFlags(old_flags);
|
|
return ScanMsg(param1,param2,mask,tss->parent_tss);
|
|
}
|
|
}
|
|
done_msg:
|
|
SetFlags(old_flags);
|
|
return result;
|
|
}
|
|
|
|
public U8 FlushMsgs(TssStruct *tss=NULL)
|
|
{
|
|
U8 result=0,p1,p2;
|
|
while (ScanMsg(&p1,&p2,-2,tss))
|
|
result++;
|
|
return result;
|
|
}
|
|
|
|
public U8 GetMsg(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL)
|
|
{
|
|
U8 result;
|
|
BoolU4 old_preempt=Preempt(OFF);
|
|
if (!tss) tss=Fs;
|
|
tss->task_flags&=~(1<<TSSf_IDLE);
|
|
while (!(result=ScanMsg(param1,param2,mask,tss))) {
|
|
tss->task_flags|=1<<TSSf_IDLE;
|
|
SwapInNext;
|
|
}
|
|
tss->task_flags&=~(1<<TSSf_IDLE);
|
|
Preempt(old_preempt);
|
|
return result;
|
|
}
|
|
|
|
BoolU8 WinScanKey(I8 *ch=NULL,U8 *scancode=NULL,BoolU4 echo=FALSE)
|
|
{
|
|
U8 ch1,scancode1;
|
|
if (ScanMsg(&ch1,&scancode1,1<<MSG_KEY_DOWN)) {
|
|
if (ch) *ch=ch1;
|
|
if (scancode) *scancode=scancode1;
|
|
if (echo)
|
|
PutKey(ch1,scancode1);
|
|
return TRUE;
|
|
} else {
|
|
if (ch) *ch=0;
|
|
if (scancode) *scancode=0;
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
ext[EXT_INPUT_FILTER_TASK]=&InputFilterTask;
|
|
ext[EXT_FLUSH_MSGS]=&FlushMsgs;
|
|
#help_index ""
|