SparrowOSTS_121127.ISO
This commit is contained in:
1 parent
0e9364ff4c
commit
e57428affb
1218 files changed
+247142
-165507
No files matched your search
@@ -0,0 +1,219 @@
|
||||
U8 captured_macro_name[136];
|
||||
StrCpy(captured_macro_name,"Test");
|
||||
|
||||
I64 sys_macro_repeat_n=1;
|
||||
|
||||
U0 SysMacroStripKey(CTaskCmd *macro_root,I64 p1,I64 p2)
|
||||
{
|
||||
CTaskCmd *tempc,*tempc1;
|
||||
tempc=macro_root->next;
|
||||
while (tempc!=macro_root) {
|
||||
tempc1=tempc->next;
|
||||
if (tempc->cmd_code==TASKCT_MSG &&
|
||||
(tempc->msg_code==MSG_KEY_DOWN ||
|
||||
tempc->msg_code==MSG_KEY_UP ||
|
||||
tempc->msg_code==MSG_KEY_DOWN_UP) &&
|
||||
p1 && tempc->p1==p1 ||
|
||||
!p1 && tempc->p2==p2) {
|
||||
QueRem(tempc);
|
||||
Free(tempc);
|
||||
}
|
||||
tempc=tempc1;
|
||||
}
|
||||
}
|
||||
|
||||
#define MT_NULL 0
|
||||
#define MT_MSG 1
|
||||
#define MT_CHAR 2
|
||||
|
||||
class CMacroTemp
|
||||
{
|
||||
CMacroTemp *next,*last;
|
||||
I64 type;
|
||||
U8 buf[136];
|
||||
};
|
||||
|
||||
CMacroTemp *Cmd2MT(CTaskCmd *tempc)
|
||||
{
|
||||
U8 buf[8];
|
||||
CMacroTemp *tempmt=CAlloc(sizeof(CMacroTemp));
|
||||
if (Bt(getkey_chars_bitmap,tempc->p1) && tempc->msg_code==MSG_KEY_DOWN) {
|
||||
tempmt->type=MT_CHAR;
|
||||
buf[0]=tempc->p1;
|
||||
buf[1]=0;
|
||||
SPrintF(tempmt->buf,"%Q",buf);
|
||||
} else {
|
||||
tempmt->type=MT_MSG;
|
||||
SPrintF(tempmt->buf,"Msg(0x%X,0x%X,0x%X);",
|
||||
tempc->msg_code,tempc->p1,tempc->p2);
|
||||
}
|
||||
return tempmt;
|
||||
}
|
||||
|
||||
|
||||
U8 *SysMacro2Str(CTaskCmd *macro_root)
|
||||
{
|
||||
CTaskCmd *tempc;
|
||||
I64 cnt=1; //terminating zero
|
||||
U8 *ptr,*m;
|
||||
CMacroTemp *tempmt,*tempmt1,root;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
|
||||
|
||||
QueInit(&root);
|
||||
root.type=MT_NULL;
|
||||
tempc=macro_root->next;
|
||||
while (tempc!=macro_root) {
|
||||
tempmt=Cmd2MT(tempc);
|
||||
QueIns(tempmt,root.last);
|
||||
cnt+=StrLen(tempmt->buf);
|
||||
if (tempmt->type==MT_CHAR) {
|
||||
if (tempmt->last->type!=MT_CHAR)
|
||||
cnt+=StrLen("\"");
|
||||
if (tempmt->next->type!=MT_CHAR)
|
||||
cnt+=StrLen("\";");
|
||||
}
|
||||
tempc=tempc->next;
|
||||
}
|
||||
|
||||
m=MAlloc(cnt);
|
||||
ptr=m;
|
||||
|
||||
tempmt=root.next;
|
||||
while (tempmt!=&root) {
|
||||
tempmt1=tempmt->next;
|
||||
if (tempmt->type==MT_MSG) {
|
||||
StrCpy(ptr, tempmt->buf);
|
||||
ptr+=StrLen(tempmt->buf);
|
||||
} else {
|
||||
if (tempmt->last->type!=MT_CHAR) {
|
||||
StrCpy(ptr, "\"");
|
||||
ptr+=StrLen("\"");
|
||||
}
|
||||
StrCpy(ptr,tempmt->buf);
|
||||
ptr+=StrLen(tempmt->buf);
|
||||
if (tempmt->next->type!=MT_CHAR) {
|
||||
StrCpy(ptr, "\";");
|
||||
ptr+=StrLen("\";");
|
||||
}
|
||||
}
|
||||
Free(tempmt);
|
||||
tempmt=tempmt1;
|
||||
}
|
||||
*ptr=0;
|
||||
Preempt(old_preempt);
|
||||
return m;
|
||||
}
|
||||
|
||||
U0 PlaySysMacro(I64 n=1)
|
||||
{
|
||||
CTask *task=sys_focus_task;
|
||||
Bool old_preempt;
|
||||
U8 *m;
|
||||
if (TaskValidate(task)) {
|
||||
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
|
||||
old_preempt=Preempt(OFF);
|
||||
m=SysMacro2Str(&sys_macro_root);
|
||||
while (n-- && TaskValidate(task)) {
|
||||
if (task==Fs)
|
||||
AutoStr("%s",m);
|
||||
else
|
||||
XTalkStrWait(task,"%s",m);
|
||||
}
|
||||
Free(m);
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
}
|
||||
|
||||
U0 EdInsCapturedMacro()
|
||||
{
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
U8 *st=SysMacro2Str(&sys_macro_root);
|
||||
if (sys_focus_task) {
|
||||
XTalk(sys_focus_task,"$$MA+A+LM+LA,\"%s\",\"%Q\"$$",
|
||||
captured_macro_name,st);
|
||||
Free(st);
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
#define SM_CANCEL -1
|
||||
#define SM_RECORD 0
|
||||
#define SM_INS 1
|
||||
#define SM_PLAY 2
|
||||
#define SM_REPEAT_N 3
|
||||
#define SM_STOP 4
|
||||
|
||||
I64 PopUpExitRecordPlayStopIns()
|
||||
{
|
||||
U8 buf[136];
|
||||
CTaskCmd *tempc;
|
||||
CDoc *doc=DocNew;
|
||||
CDocEntry *doc_e=DocPutS(doc,"$$DA-P,135,\"Name:%s\"$$");
|
||||
I64 result=0;
|
||||
doc_e->data=captured_macro_name;
|
||||
DocDataFmt(doc_e);
|
||||
doc_e=DocPutS(doc,"\n$$DA,32,\"Repeat N:%d\"$$");
|
||||
doc_e->data=&sys_macro_repeat_n;
|
||||
DocDataFmt(doc_e);
|
||||
DocPutS(doc,"\n"
|
||||
"$$CM+LX,1,3$$$$BT,\"RECORD\",SM_RECORD$$"
|
||||
"$$CM+LX,17,0$$$$BT,\"INSERT\",SM_INS$$"
|
||||
"$$CM+LX,1,3$$$$BT,\"PLAY\",SM_PLAY$$"
|
||||
"$$CM+LX,17,0$$$$BT,\"REPEAT N\",SM_REPEAT_N$$"
|
||||
"$$CM+LX,1,3$$$$BT,\"STOP\",SM_STOP$$"
|
||||
"$$CM+LX,17,0$$$$BT,\"CANCEL\",SM_CANCEL$$"
|
||||
"\n\n\n$$FG,GREEN$$SHIFT-F2$$FG$$ will play macro.\n");
|
||||
doc->flags|=DOCF_MIN_SIZE | DOCF_FORM;
|
||||
SPrintF(buf,"DocMenuDo(0x%X);",doc);
|
||||
sys_macro_util_task=Spawn(&ServantUserCmdLine,NULL,"Macro Popup",Fs);
|
||||
Fs->popup_task=sys_macro_util_task;
|
||||
LBts(&sys_macro_util_task->display_flags,DISPLAYf_WIN_ON_TOP);
|
||||
tempc=TaskRqstQue(sys_macro_util_task,Fs,buf,
|
||||
1<<TASKCf_WAKE_MASTER | 1<<TASKCf_FOCUS_MASTER);
|
||||
GetRqstResult(tempc,&result);
|
||||
Fs->popup_task=NULL;
|
||||
Kill(sys_macro_util_task);
|
||||
sys_macro_util_task=NULL;
|
||||
DocDataGet(doc_e);
|
||||
DocDel(doc);
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 MacroTask(I64)
|
||||
{
|
||||
I64 i;
|
||||
StrCpy(captured_macro_name,"Click Here");
|
||||
sys_macro_repeat_n=1;
|
||||
do {
|
||||
i=PopUpExitRecordPlayStopIns;
|
||||
WinRefocus;
|
||||
switch (i) {
|
||||
case SM_RECORD:
|
||||
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
|
||||
QueDel(&sys_macro_root,TRUE);
|
||||
LBts(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
|
||||
break;
|
||||
case SM_PLAY:
|
||||
PlaySysMacro;
|
||||
break;
|
||||
case SM_REPEAT_N:
|
||||
PlaySysMacro(sys_macro_repeat_n);
|
||||
break;
|
||||
case SM_STOP:
|
||||
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
|
||||
break;
|
||||
case SM_INS:
|
||||
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
|
||||
EdInsCapturedMacro;
|
||||
break;
|
||||
}
|
||||
} while (i>=0);
|
||||
}
|
||||
|
||||
U0 EdMacroUtil()
|
||||
{
|
||||
if (!sys_macro_util_task)
|
||||
Spawn(&MacroTask,NULL,"Macro");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user