SparrowOSTS_121127.ISO

This commit is contained in:
Terry A. Davis
2012-11-26 09:52:21 +01:00
committed by minexew
parent 0e9364ff4c
commit e57428affb
1228 changed files with 247142 additions and 165703 deletions
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-181
View File
@@ -1,181 +0,0 @@
//Change anything you want in this
//account file or others.
//Set Time Zone
local_time_offset=0*60*60*LTDATE_FREQ;
//$AN,"","mouse_move_scale"$adjust these to set mouse move scale
mxx_scale=0.5;
myy_scale=0.5;
mzz_scale=1.0; //wheel
//don't change these
mxx_prescale=mxx/mxx_scale;
myy_prescale=myy/myy_scale;
mzz_prescale=mzz/mzz_scale;
class RenameSymbolStruct
{
I1 find[256] fmtstr "$$DA -P ,255 \"Find :%s\"$$\r\n";
I1 replace[256] fmtstr "$$DA -P ,255 \"Replace:%s\"$$\r\n";
};
void RenameCurSymbol()
{
I1 *buf;
RenameSymbolStruct r;
BoolU4 old_preempt=Preempt(OFF);
StrCpy(r.find,ws_cur_word);
StrCpy(r.replace,ws_cur_word);
Preempt(old_preempt);
if (PopUpDoForm(&r,"RenameSymbolStruct")) {
buf=MSPrintF("R(\"%s\",\"%s\",\"+r+l+a\");",r.find,r.replace);
PopUp(buf,Fs);
Free(buf);
}
}
void RenameFile()
{
I1 *buf;
RenameSymbolStruct r;
BoolU4 old_preempt=Preempt(OFF);
StrCpy(r.find,ws_cur_word);
StrCpy(r.replace,ws_cur_word);
Preempt(old_preempt);
if (PopUpDoForm(&r,"RenameSymbolStruct")) {
buf=MSPrintF("R(\"%s\",\"%s\",\"+r+l+a\");",r.find,r.replace);
PopUp(buf,Fs);
Free(buf);
}
Move(r.find,r.replace);
}
void FillinTime()
{
LTDate ltdt;
ltdt=GetCurTimeLTDate;
PrintF("$$IV 1$$----%D %T----$$IV 0$$\r",ltdt,ltdt);
}
BoolU8 MyPutKey(I8 ch,U8 sc)
{ //ch=ASCII; sc=scancode
//You can customize keys. This routine
//is called before the main editor
//key handler $LK,"LtfPutKeyExt","MN:LtfPutKeyExt"$().
//You can intercept any key.
//Return TRUE if you completely
//handled the key.
nounusedwarn ch;
U8 sc2=sc.u1[0];
if (sc2>=SC_F1 && sc2<=SC_F10 &&
(sc & SCF_ALT) &&
!(sc & SCF_CTRL)) {
if (sc2==SC_F1) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTPURPLE$$");
else
PutS("$$FG PURPLE$$");
} else if (sc2==SC_F2) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTRED$$");
else
PutS("$$FG,RED$$");
} else if (sc2==SC_F3) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTGREEN$$");
else
PutS("$$FG,GREEN$$");
} else if (sc2==SC_F4) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTBLUE$$");
else
PutS("$$FG$$");
} else if (sc2==SC_F6) {
if (!(sc & SCF_SHIFT))
PopUp("WsInit(\"/LT\");");
} else if (sc2==SC_F7) {
if ((sc & SCF_SHIFT))
LtfSafeInsert(Fs->cur_ltf,
"$$HS+C$$$$FG$$$$HE$$");
else
FillinTime();
} else if (sc2==SC_F8) {
if ((sc & SCF_SHIFT))
RenameFile();
else
RenameCurSymbol();
} else if (sc2==SC_F9)
PopUp("PunchIn;");
else if (sc2==SC_F10)
PopUp("PunchOut;");
return TRUE;
}
return FALSE;
}
BoolU8 MyPutS(I1 *st)
{
nounusedwarn st;
return FALSE;
}
AddKeyDev(&MyPutKey,&MyPutS,0x20000000);
MPStart;
Cd("/LT/Adam");;
#include "PicWords2"
#include "HOME/PicWords3"
Cd("/LT/Utils/Boot");;
#include "InsBoot"
Cd("/LT/Utils");;
#include "Disk20"
#include "Diff"
#include "Grep"
#include "Merge"
#include "S2T"
#include "IDE"
#include "LinkChk"
#include "HeapLog"
#include "ListFile"
LoadMapFile("::/LT/OSMain/OS.MPZ"); //Enable Man()
LoadMapFile("::/LT/Compiler/Compiler.MPZ"); //Enable Man()
LoadMapFile("::/LT/Adam/GrAsm/GrAsm.MPZ"); //Enable Man()
void StartUpTsks()
{
I1 buf[80];
TssStruct *tss,*tss1;
InitLocalTask; //needed for disk access
Preempt(ON); //off by default
Silent(ON); //no output to screen
try {
tss1=SpawnUser;
tss=SpawnUser;
WinToTop(tss1);
WinTileVert;
PopUp("#include \"::/LT/Doc/StartSong.CPZ\";");
SPrintF(buf,"Boot Time:%h17Ts\r\n",BootTime);
AdamLog(buf);
XTalk(tss1,"#include \"DoIt\";\r");
WsInit("/LT");
WordStat;
} catch
CatchAll;
}
//This must be spawned because start-up files
// may invoke the Adam() cmd.
Spawn(&StartUpTsks,"Spawn Users");
PrintF("\r\nOS Compile Time:%D %T\r\n",sys_compile_time,sys_compile_time);
-51
View File
@@ -1,51 +0,0 @@
/* When a fault occurs, a child process is
spawned running this file and the parent
gets suspended. You can modify what gets
displayed during faults to assist debugging.
If you modify this file, you should place it
into your HOME directory. This version is the
default for accounts without a version in HOME.
*/
TssStruct *tss=Fs->parent_tss;
void **rsp_ptr=&tss->rsp,*rsp=tss->rsp,
*rbp_ptr=&tss->rbp,*rbp=tss->rbp,
*rip_ptr=&tss->rip,*rip=tss->rip;
switch (tss->fault_num)
{
case 0: //if divide except
//push rip as param to ThrowDivide
rsp-=8;
*rsp_ptr=rsp;
rsp[1]=rip;
*rip_ptr=&ThrowDivide;
Btr(&tss->task_flags,TSSf_SUSPENDED);
Exit;
case 0x10:
rsp-=8;
*rsp_ptr=rsp;
rsp[1]=rip;
*rip_ptr=&ThrowFloating;
Btr(&tss->task_flags,TSSf_SUSPENDED);
Exit;
}
/*
Raw(ON);
coutln "Faulting TSS:",tss," IRQ#",tss->fault_num;
PrintF("Fault Location:%P\r\n",*rip);
Raw(OFF);
*/
UseConsoleLtf(NULL);
Bts(&Fs->crt_flags,CRTf_SHOW);
coutln "Faulting TSS:",tss," IRQ#",tss->fault_num;
CallerRep(rbp,tss);
StackRep(rsp);
coutln "$$LK,\"See HOME/Fault.CPZ\",\"FI:HOME/Fault.CPZ\"$$";
Dasm(rip-0x20,0x20);
-16
View File
@@ -1,16 +0,0 @@
$WW,1$This is a handy file which can be accessed with CTRL-SHIFT-F, known as a favorites file. I use it for links and "TODO" type stuff in my account.
If you modify this file, you should place it
into your HOME directory. This version is the
default for accounts without a version in HOME.
$LK+S,"Goto OS Systext","FA:::/LT/OSMain/SysText.CPZ,OS_SYSTEXT"$
$LK,"Goto Compiler Systext","FA:::/LT/Compiler/CmpInit.CPZ,COMPILE_SYSTEXT"$
$LK,"::/LT/Doc/Help.TXZ","FI:::/LT/Doc/Help.TXZ"$
$LK,"::/LT/Doc/GuideLines.TXZ","FI:::/LT/Doc/GuideLines.TXZ"$
$LK,"::/LT/Doc/OSGlossary.GLZ","FI:::/LT/Doc/OSGlossary.GLZ"$
$LK,"::/LT/Doc/Tips.TXZ","FI:::/LT/Doc/Tips.TXZ"$
$LK,"::/LT/Doc/Dollar.TXZ","FI:::/LT/Doc/Dollar.TXZ"$
$FG,5$
-181
View File
@@ -1,181 +0,0 @@
//Change anything you want in this
//account file or others.
//Set Time Zone
local_time_offset=0*60*60*LTDATE_FREQ;
//$AN,"","mouse_move_scale"$adjust these to set mouse move scale
mxx_scale=0.5;
myy_scale=0.5;
mzz_scale=1.0; //wheel
//don't change these
mxx_prescale=mxx/mxx_scale;
myy_prescale=myy/myy_scale;
mzz_prescale=mzz/mzz_scale;
class RenameSymbolStruct
{
I1 find[256] fmtstr "$$DA -P ,255 \"Find :%s\"$$\r\n";
I1 replace[256] fmtstr "$$DA -P ,255 \"Replace:%s\"$$\r\n";
};
void RenameCurSymbol()
{
I1 *buf;
RenameSymbolStruct r;
BoolU4 old_preempt=Preempt(OFF);
StrCpy(r.find,ws_cur_word);
StrCpy(r.replace,ws_cur_word);
Preempt(old_preempt);
if (PopUpDoForm(&r,"RenameSymbolStruct")) {
buf=MSPrintF("R(\"%s\",\"%s\",\"+r+l+a\");",r.find,r.replace);
PopUp(buf,Fs);
Free(buf);
}
}
void RenameFile()
{
I1 *buf;
RenameSymbolStruct r;
BoolU4 old_preempt=Preempt(OFF);
StrCpy(r.find,ws_cur_word);
StrCpy(r.replace,ws_cur_word);
Preempt(old_preempt);
if (PopUpDoForm(&r,"RenameSymbolStruct")) {
buf=MSPrintF("R(\"%s\",\"%s\",\"+r+l+a\");",r.find,r.replace);
PopUp(buf,Fs);
Free(buf);
}
Move(r.find,r.replace);
}
void FillinTime()
{
LTDate ltdt;
ltdt=GetCurTimeLTDate;
PrintF("$$IV 1$$----%D %T----$$IV 0$$\r",ltdt,ltdt);
}
BoolU8 MyPutKey(I8 ch,U8 sc)
{ //ch=ASCII; sc=scancode
//You can customize keys. This routine
//is called before the main editor
//key handler $LK,"LtfPutKeyExt","MN:LtfPutKeyExt"$().
//You can intercept any key.
//Return TRUE if you completely
//handled the key.
nounusedwarn ch;
U8 sc2=sc.u1[0];
if (sc2>=SC_F1 && sc2<=SC_F10 &&
(sc & SCF_ALT) &&
!(sc & SCF_CTRL)) {
if (sc2==SC_F1) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTPURPLE$$");
else
PutS("$$FG PURPLE$$");
} else if (sc2==SC_F2) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTRED$$");
else
PutS("$$FG,RED$$");
} else if (sc2==SC_F3) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTGREEN$$");
else
PutS("$$FG,GREEN$$");
} else if (sc2==SC_F4) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTBLUE$$");
else
PutS("$$FG$$");
} else if (sc2==SC_F6) {
if (!(sc & SCF_SHIFT))
PopUp("WsInit(\"/LT\");");
} else if (sc2==SC_F7) {
if ((sc & SCF_SHIFT))
LtfSafeInsert(Fs->cur_ltf,
"$$HS+C$$$$FG$$$$HE$$");
else
FillinTime();
} else if (sc2==SC_F8) {
if ((sc & SCF_SHIFT))
RenameFile();
else
RenameCurSymbol();
} else if (sc2==SC_F9)
PopUp("PunchIn;");
else if (sc2==SC_F10)
PopUp("PunchOut;");
return TRUE;
}
return FALSE;
}
BoolU8 MyPutS(I1 *st)
{
nounusedwarn st;
return FALSE;
}
AddKeyDev(&MyPutKey,&MyPutS,0x20000000);
Cd("/LT/Adam");;
#include "PicWords2"
#include "HOME/PicWords3"
Cd("/LT/Utils/Boot");;
#include "InsBoot"
Cd("/LT/Utils");;
#include "Disk20"
#include "Diff"
#include "Grep"
#include "Merge"
#include "S2T"
#include "IDE"
#include "LinkChk"
#include "HeapLog"
#include "ListFile"
LoadMapFile("::/LT/OSMain/OS.MPZ"); //Enable Man()
LoadMapFile("::/LT/Compiler/Compiler.MPZ"); //Enable Man()
LoadMapFile("::/LT/Adam/GrAsm/GrAsm.MPZ"); //Enable Man()
void StartUpTsks()
{
I1 buf[80];
TssStruct *tss,*tss1;
InitLocalTask; //needed for disk access
Preempt(ON); //off by default
Silent(ON); //no output to screen
try {
tss1=SpawnUser;
tss=SpawnUser;
WinToTop(tss1);
WinTileVert;
PopUp("#include \"::/LT/Doc/StartSong.CPZ\";");
SPrintF(buf,"Boot Time:%h17Ts\r\n",BootTime);
AdamLog(buf);
XTalk(tss1,"#include \"DoIt\";\r");
WsInit("");
// WordStat;
} catch
CatchAll;
}
//This must be spawned because start-up files
// may invoke the Adam() cmd.
Spawn(&StartUpTsks,"Spawn Users");
PrintF("\r\nOS Compile Time:%D %T\r\n",sys_compile_time,sys_compile_time);
Binary file not shown.
Binary file not shown.
-9
View File
@@ -1,9 +0,0 @@
// Create Pictures Here
void LoadUserPicWords()
{
//Call $LK,"AddPicWord","MN:AddPicWord"$()
}
LoadUserPicWords;
-11
View File
@@ -1,11 +0,0 @@
/*
This is the startup file for servant tasks.
If you modify this file, you should place it
into your HOME directory. This version is the
default for accounts without a version in HOME.
*/
UseConsoleLtf(NULL);
Bts(&Fs->crt_flags,CRTf_SHOW);
//Turn on preemption
-176
View File
@@ -1,176 +0,0 @@
//Change anything you want in this
//account file or others.
//Set Time Zone
local_time_offset=0*60*60*LTDATE_FREQ;
//$AN,"","mouse_move_scale"$adjust these to set mouse move scale
mxx_scale=0.5;
myy_scale=0.5;
mzz_scale=1.0; //wheel
//don't change these
mxx_prescale=mxx/mxx_scale;
myy_prescale=myy/myy_scale;
mzz_prescale=mzz/mzz_scale;
class RenameSymbolStruct
{
I1 find[256] fmtstr "$$DA -P ,255 \"Find :%s\"$$\r\n";
I1 replace[256] fmtstr "$$DA -P ,255 \"Replace:%s\"$$\r\n";
};
void RenameCurSymbol()
{
I1 *buf;
RenameSymbolStruct r;
BoolU4 old_preempt=Preempt(OFF);
StrCpy(r.find,ws_cur_word);
StrCpy(r.replace,ws_cur_word);
Preempt(old_preempt);
if (PopUpDoForm(&r,"RenameSymbolStruct")) {
buf=MSPrintF("R(\"%s\",\"%s\",\"+r+l+a\");",r.find,r.replace);
PopUp(buf,Fs);
Free(buf);
}
}
void RenameFile()
{
I1 *buf;
RenameSymbolStruct r;
BoolU4 old_preempt=Preempt(OFF);
StrCpy(r.find,ws_cur_word);
StrCpy(r.replace,ws_cur_word);
Preempt(old_preempt);
if (PopUpDoForm(&r,"RenameSymbolStruct")) {
buf=MSPrintF("R(\"%s\",\"%s\",\"+r+l+a\");",r.find,r.replace);
PopUp(buf,Fs);
Free(buf);
}
Move(r.find,r.replace);
}
void FillinTime()
{
LTDate ltdt;
ltdt=GetCurTimeLTDate;
PrintF("$$IV 1$$----%D %T----$$IV 0$$\r",ltdt,ltdt);
}
BoolU8 MyPutKey(I8 ch,U8 sc)
{ //ch=ASCII; sc=scancode
//You can customize keys. This routine
//is called before the main editor
//key handler $LK,"LtfPutKeyExt","MN:LtfPutKeyExt"$().
//You can intercept any key.
//Return TRUE if you completely
//handled the key.
nounusedwarn ch;
U8 sc2=sc.u1[0];
if (sc2>=SC_F1 && sc2<=SC_F10 &&
(sc & SCF_ALT) &&
!(sc & SCF_CTRL)) {
if (sc2==SC_F1) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTPURPLE$$");
else
PutS("$$FG PURPLE$$");
} else if (sc2==SC_F2) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTRED$$");
else
PutS("$$FG,RED$$");
} else if (sc2==SC_F3) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTGREEN$$");
else
PutS("$$FG,GREEN$$");
} else if (sc2==SC_F4) {
if ((sc & SCF_SHIFT))
PutS("$$FG LTBLUE$$");
else
PutS("$$FG$$");
} else if (sc2==SC_F6) {
if (!(sc & SCF_SHIFT))
PopUp("WsInit(\"/LT\");");
} else if (sc2==SC_F7) {
if ((sc & SCF_SHIFT))
LtfSafeInsert(Fs->cur_ltf,
"$$HS+C$$$$FG$$$$HE$$");
else
FillinTime();
} else if (sc2==SC_F8) {
if ((sc & SCF_SHIFT))
RenameFile();
else
RenameCurSymbol();
} else if (sc2==SC_F9)
PopUp("PunchIn;");
else if (sc2==SC_F10)
PopUp("PunchOut;");
return TRUE;
}
return FALSE;
}
BoolU8 MyPutS(I1 *st)
{
nounusedwarn st;
return FALSE;
}
AddKeyDev(&MyPutKey,&MyPutS,0x20000000);
Cd("/LT/Adam");;
#include "PicWords2"
#include "HOME/PicWords3"
Cd("/LT/Utils/Boot");;
#include "InsBoot"
Cd("/LT/Utils");;
#include "Disk20"
#include "Diff"
#include "Grep"
#include "Merge"
#include "S2T"
#include "IDE"
#include "LinkChk"
#include "HeapLog"
#include "ListFile"
LoadMapFile("::/LT/OSMain/OS.MPZ"); //Enable Man()
LoadMapFile("::/LT/Compiler/Compiler.MPZ"); //Enable Man()
LoadMapFile("::/LT/Adam/GrAsm/GrAsm.MPZ"); //Enable Man()
void StartUpTsks()
{
I1 buf[80];
TssStruct *tss;
InitLocalTask; //needed for disk access
Preempt(ON); //off by default
Silent(ON); //no output to screen
try {
tss=SpawnUser;
WinToTop(tss);
WinTileVert;
XTalk(tss,"#include \"DoIt\";\r");
WsInit("");
} catch
CatchAll;
}
//This must be spawned because start-up files
// may invoke the Adam() cmd.
Spawn(&StartUpTsks,"Spawn Users");
PrintF("\r\nOS Compile Time:%D %T\r\n",sys_compile_time,sys_compile_time);
-4
View File
@@ -1,4 +0,0 @@
Cd("::/LT/Apps/MusicOrgan");;
#include "Load";;
JukeBox("Examples");
-5
View File
@@ -1,5 +0,0 @@
UseConsoleLtf("User.MUZ");
PutSysText("ST_USER_STARTUP");
Type("::/LT/Doc/Help.TXZ");
Bts(&Fs->crt_flags,CRTf_SHOW);
Preempt(ON);
Binary file not shown.
-1
View File
@@ -1 +0,0 @@
AutoFile("Tour");
-37
View File
@@ -1,37 +0,0 @@
public I8 PopUpTourPart()
{
I8 i;
Ltf *l=LtfNew;
LtfPutSExt(l,"$$FG PURPLE$$LoseThos Tours$$FG$$\r\n\r\n");
LtfPutSExt(l,"$$CM +LX, 4,4$$$$BT, \"Part 1: The basics\",1$$");
LtfPutSExt(l,"$$CM +LX, 4,4$$$$BT, \"Part 2: Editing and running programs\",2$$");
LtfPutSExt(l,"$$CM +LX, 4,4$$$$BT, \"Part 3: Adding macros to your start menu\",3$$");
LtfPutSExt(l,"$$CM +LX, 4,4$$$$BT, \"Part 4: WordStat\",4$$");
LtfPutSExt(l,"$$CM +LX, 4,4$$$$BT, \"Part 5: Wow!!\",5$$");
LtfPutSExt(l,"$$CM +LX, 4,4$$$$BT, \"Done\",-1$$");
i=PopUpMenu(l);
LtfDel(l);
return i;
}
I8 i;
do {
switch (i=PopUpTourPart)
{
case 1:
ExecuteFile("::/LT/Accts/Tour/Tour1.AUZ");
break;
case 2:
ExecuteFile("::/LT/Accts/Tour/Tour2.AUZ");
break;
case 3:
ExecuteFile("::/LT/Accts/Tour/Tour3.AUZ");
break;
case 4:
ExecuteFile("::/LT/Accts/Tour/Tour4.AUZ");
break;
case 5:
ExecuteFile("::/LT/Accts/Tour/Tour5.AUZ");
break;
}
} while (i>=1);
-105
View File
@@ -1,105 +0,0 @@
//This puts the cursor at the bottom
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN|SCF_CTRL);
PutS("\r");
PopUpOk(
"After clicking 'OKAY', you will be at the\r\n"
"command line.\r\n"
"\r\n"
"The syntax is like $$FG,GREEN$$C/C++$$FG$$ except you\r\n"
"don't need $$FG,GREEN$$()$$FG$$ if there are no parameters.\r\n"
"\r\n"
"Type \"$$FG,GREEN$$Dir;$$FG$$\" and press $$FG,GREEN$$ENTER$$FG$$.\r\n\r\n"
"You must remember the semicolon.\r\n"
);
AFPmtStr("Dir;\r");
Sleep(1000); //allow user time to see dir
PutChar(CH_CR);
PopUpOk(
"After clicking 'OKAY', you will be at the\r\n"
"command line.\r\n\r\n"
"Press the $$FG,GREEN$$WINDOW$$FG$$s key.\r\n\r\n"
"This will access your macro/menu/help area.\r\n"
"You can customize it. It's like your\r\n"
"START menu.\r\n");
AFGetKey(SC_GUI);
Sleep(1000);
PopUpOk(
"You can get to the menu/macro/help area\r\n"
"by clicking on the word \"MENU\" in the\r\n"
"title bar.\r\n");
PopUpOk(
"$$UL,1$$$$FG,LTBLUE$$Blue Underlined Text are Macros$$FG$$$$UL,0$$\r\n"
"\t$$FG,GREEN$$SPACE BAR$$FG$$\t=Left Mouse\t-->Execute Macro\r\n"
"\r\n\r\n"
"$$UL,1$$$$FG,LTRED$$Red Underlined Text are Links$$FG$$$$UL,0$$\r\n"
"\t$$FG,GREEN$$SPACE BAR$$FG$$\t=Left Mouse\t-->Edit/View Link Doc\r\n"
"\t$$FG,GREEN$$ENTER$$FG$$\t\t=Right Mouse\t-->Link Menu\r\n"
"\r\n\r\n"
"Exiting Documents/Forms\r\n"
"\t$$FG,GREEN$$ESC$$FG$$\t=Left Double Mouse\t-->Save and Exit\r\n"
"\t$$FG,GREEN$$CTRL-Q$$FG$$\t=Right Double Mouse\t-->Abort/Cancel/Quit or Back\r\n"
);
PopUpOk(
"$$FG,GREEN$$CTRL-ALT-ESC$$FG$$\tSpawn new user shell window\r\n"
"$$FG,GREEN$$CTRL-ALT-X$$FG$$\tKill window\r\n"
"$$FG,GREEN$$CTRL-ALT-C$$FG$$\tBreak(interrupt) program\r\n"
);
PopUpOk(
"After clicking 'OKAY', you will be back at\r\n"
"the menu/macro/help area.\r\n\r\n"
"Press $$FG,GREEN$$CURSOR-DOWN$$FG$$ nine times.\r\n");
//This puts the cursor at the top
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
I8 i;
for (i=0;i<9;i++)
AFGetKey(SC_CURSOR_DOWN);
PopUpOk(
"After clicking 'OKAY', the cursor will be\r\n"
"on top of a macro we wish to run.\r\n"
"\r\n"
"After clicking OKAY, press $$FG,GREEN$$SPACE$$FG$$.\r\n");
AFPmtStr(" ");
Sleep(1000);
PopUpOk(
"The macro changed directories and did\r\n"
"a $$FG,GREEN$$Dir;$$FG$$ command.\r\n\r\n"
"The $$FG,RED$$RED$$FG$$ filenames listed are file\r\n"
"links. Left-clicking will edit/view them.\r\n"
"Right-clicking or pressing $$FG,GREEN$$ENTER$$FG$$\r\n"
"when the cursor is on top will bring-up a\r\n"
"menu of options.\r\n\r\n"
"The $$FG LTBLUE$$BLUE$$FG$$ underline entries \"$$FG LTBLUE$$.$$FG$$\" and \"$$FG LTBLUE$$..$$FG$$\"\r\n"
"are macros and will change directories.\r\n");
PopUpOk(
"As you can see, the command line is not\r\n"
"different from the help/menu/macro area.\r\n"
"Both use the same commands and have the same\r\n"
"'Widgets' available.\r\n\r\n"
"Both utilize the same underlying document format.\r\n"
"It is similar to $$FG,GREEN$$html$$FG$$ because it has ASCII\r\n"
"behind it. LoseThos documents can include graphics.\r\n\r\n"
"Press \"$$FG,GREEN$$CTRL-T$$FG$$\" after clicking 'OKAY' to toggle\r\n"
"to plain text mode.\r\n");
AFGetChar(20);
Sleep(1000);
PopUpOk(
"The widgets are bracketed with dollar sign\r\n"
"characters. \"LK\" stands \"link\" and \"MA\"\r\n"
"stands for \"macro\".\r\n\r\n"
"Now, press \"$$FG,GREEN$$CTRL-T$$FG$$\" to toggle back to\r\n"
"regular mode.\r");
AFGetChar(20);
Sleep(1000);
-76
View File
@@ -1,76 +0,0 @@
//This puts the cursor at the bottom
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN|SCF_CTRL);
PutS("\r");
PopUpOk(
"Now, we're going to demonstrate how to work\r\n"
"with programs. We'll change to the \LT\Demo\r\n"
"directory. The change directory command\r\n"
"will be typed for you and you just need\r\n"
"to press $$FG,GREEN$$ENTER$$FG$$.\r\n\r\n"
"Note, that directories are specified with\r\n"
"a forward slash, not a backslash.\r\n"
"Drives can be specified in a $$FG,GREEN$$Cd()$$FG$$ command\r\n"
"and the boot drive is specified with \"$$FG,GREEN$$::$$FG$$\".");
PutS("Cd(\"::/LT/Demo\");Dir;");
AFPmtStr("\r");
PopUpOk(
"Now, we're going to edit a file. Normally,\r\n"
"you'll probably left-click on a directory\r\n"
"listing to edit a file, but we're going to\r\n"
"type it on the command line.\r\n\r\n"
"Press $$FG,GREEN$$ENTER$$FG$$ to complete the command.\r\n");
PutS("Edit(\"ASCIIOrgan.CPZ\");");
AFPmtStr("\r");
Sleep(1000);
PopUpOk(
"This program gets keys and plays frequencies.\r\n"
"It quits when you press $$FG,GREEN$$ESC$$FG$$.\r\n\r\n"
"There is no \"$$FG,GREEN$$main()$$FG$$\" function in LoseThos\r\n"
"programs. Any program statements outside\r\n"
"functions get executed when you $$FG,GREEN$$#include$$FG$$\r\n"
"them at the command line.\r\n\r\n"
"The \"$$FG,GREEN$$ASCIIOrgan;$$FG$$\" statement at the bottom\r\n"
"will run the program when we $$FG,GREEN$$#include$$FG$$ it.\r\n");
PopUpOk(
"The editor and most things exit when you press\r\n"
"$$FG,GREEN$$ESC$$FG$$. $$FG,GREEN$$CTRL-Q$$FG$$ will abort (cancel) most things.\r\n\r\n"
"The $$FG,GREEN$$ESC$$FG$$ key can be simulated with a left\r\n"
"double-click, while the $$FG,GREEN$$CTRL-Q$$FG$$ key can be\r\n"
"simulated with a right double-click. When\r\n"
"you browse documentation, you'll left-click\r\n"
"on links and right double-click to go back,\r\n"
"unless you want to save changes to documents\r\n"
"using left double-click.\r\n\r\n"
"Press $$FG,GREEN$$CTRL-Q$$FG$$ to quit out of the editor.\r\n"
);
AFGetChar(CH_CTRLQ);
PopUpOk(
"Now, we'll run the ASCIIOrgan.CPZ program.\r\n"
"Press $$FG,GREEN$$ENTER$$FG$$ at the command line to\r\n"
"$$FG,GREEN$$#include$$FG$$ it. Then press keys to\r\n"
"cause sounds and press $$FG,GREEN$$ESC$$FG$$ when\r\n"
"you are done.\r\n");
PutS("#include \"ASCIIOrgan.CPZ\";");
AFPmtStr("\r");
AFUntilChar(CH_ESC);
PopUpOk(
"The program is still in memory and we\r\n"
"can start it again by typing \"$$FG,GREEN$$ASCIIOrgan;$$FG$$\".\r\n\r\n"
"Press $$FG,GREEN$$ENTER$$FG$$ at the command line to\r\n"
"run it again.\r\n");
PutS("ASCIIOrgan;");
AFPmtStr("\r");
AFUntilChar(27);
-110
View File
@@ -1,110 +0,0 @@
//This puts the cursor at the bottom
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN|SCF_CTRL);
PutS("\rCd(\"::/LT/Demo\");Dir;\r");
PopUpOk(
"Now, we're going to add the ASCIIOrgan.CPZ\r\n"
"program to your start menu.\r\n\r\n"
"Press the $$FG,GREEN$$WINDOW$$FG$$s key\r\n"
"to get to your menu/macro/help area.\r\n");
AFGetKey(SC_GUI);
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
Sleep(1000);
PopUpOk(
"Press $$FG,GREEN$$CTRL-L$$FG$$ to invoke the\r\n"
"text-widget resource editor.\r\n"
"\r\n"
"($$FG,GREEN$$CTRL-R$$FG$$ invokes the\r\n"
"graphic resource editor.)\r\n"
);
AFGetChar(12);
Sleep(100);
PopUpOk(
"Press $$FG,GREEN$$CURSOR-DOWN$$FG$$ until you reach\r\n"
"\"Macro\".\r\n");
I8 i;
for (i=0;i<8;i++)
AFGetKey(SC_CURSOR_DOWN);
PopUpOk(
"Press $$FG,GREEN$$SPACE$$FG$$.\r\n");
AFPmtStr(" ");
Sleep(1000);
PopUpOk(
"Now, we'll fill-in the visible text\r\n"
"of the macro.\r\n");
AFDelayedPutS("Click Here");
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN);
PopUpOk("Now, we'll fill-in the macro text.\r\n");
AFDelayedPutS("Cd(\\\"::/LT/Demo\\\");;#include \\\"ASCIIOrgan.CPZ\\\";\\r");
PopUpOk("Press $$FG,GREEN$$ESC$$FG$$ to exit the form.\r\n");
AFGetChar(CH_ESC);
Sleep(1000);
PopUpOk(
"Press $$FG,GREEN$$CTRL-SHIFT-ENTER$$FG$$ to insert a line feed.\r\n"
"($$FG,GREEN$$CTRL-ENTER$$FG$$ does a page break and $$FG,GREEN$$ENTER$$FG$$\r\n"
"would execute the macro.)\r\n");
AFGetKey(SC_CR|SCF_CTRL|SCF_SHIFT);
Sleep(1000);
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
PopUpOk(
"Press $$FG,GREEN$$SPACE$$FG$$ to test it.\r\n");
AFPmtStr(" ");
AFUntilChar(CH_ESC);
PopUpOk(
"Now, we'll do a fancier macro that pops-up\r\n"
"a new window which dies when finished,\r\n"
"returning memory to the system.\r\n");
Msg(MSG_KEY_DOWN,0,SC_GUI);
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
Msg(MSG_KEY_DOWN,12,0); //CTRL-L
for (i=0;i<8;i++)
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN);
AFDelayedPutS(" Click here for Pop-up version");
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN);
AFDelayedPutS("Cd(\\\"::/LT/Demo\\\");;#include \\\"ASCIIOrgan.CPZ\\\";\\r");
Msg(MSG_KEY_DOWN,0,SC_CURSOR_LEFT|SCF_CTRL);
PopUpOk(
"Press $$FG,GREEN$$CURSOR-DOWN$$FG$$ until you reach\r\n"
"the \"Pop-Up\" check-box.\r\n");
for (i=0;i<2;i++)
AFGetKey(SC_CURSOR_DOWN);
PopUpOk(
"Press $$FG,GREEN$$SPACE$$FG$$ to\r\n"
"check the box.\r\n");
AFPmtStr(" ");
Sleep(500);
PopUpOk("Press $$FG,GREEN$$ESC$$FG$$ to exit the form.\r\n");
AFGetChar(CH_ESC);
Sleep(500);
PopUpOk("Press $$FG,GREEN$$CTRL-SHIFT-ENTER$$FG$$ to insert a line feed.\r\n");
AFGetKey(SC_CR|SCF_CTRL|SCF_SHIFT");
Sleep(500);
Msg(MSG_KEY_DOWN,0,SC_CURSOR_UP|SCF_CTRL);
PopUpOk(
"Press $$FG,GREEN$$SPACE$$FG$$ to test it.\r\n");
AFPmtStr(" ");
Sleep(5000);
PopUpOk(
"Press $$FG,GREEN$$CTRL-S$$FG$$ to save your\r\n"
"macro/menu/help area file, if you wish.\r\n");
if (Fs->parent_tss->popup_tss) {
PutChar(CH_CTRLQ);
Sleep(100);
}
PutChar(CH_CTRLQ); //exit menu
-58
View File
@@ -1,58 +0,0 @@
PopUp("WsInit(\"::/LT\");");
WordStat;
//This puts the cursor at the bottom
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN|SCF_CTRL);
PutS("\rCd(\"::/LT/Demo\");\r");
PopUpOk(
"WordStat is an autocomplete feature\r\n"
"which will also jump to source code.\r\n"
"The function keys work with code, while\r\n"
"the number keys work with the dictionary.\r\n\r\n"
"We will now place some text on the command\r\n"
"line and jump to source code.\r\n");
PutS("InstallB");
Sleep(1000);
PopUpOk(
"After clicking $$FG,GREEN$$OKAY$$FG$$, look at\r\n"
"the $$FG,GREEN$$InstallBoot$$FG$$ entry in the WordStat\r\n"
"window. Notice it has a '$$FG,GREEN$$*$$FG$$' by it.\r\n"
"This means a source code link is available.\r\n");
Sleep(2000);
PopUpOk(
"Press $$FG,GREEN$$CTRL-SHIFT-F1$$FG$$ to jump to source code.\r\n");
AFGetKey(SC_F1|SCF_CTRL|SCF_SHIFT);
Sleep(500);
PopUpOk(
"Press $$FG,GREEN$$CTRL-Q$$FG$$ to quit the source code.\r\n");
AFUntilChar(CH_CTRLQ);
Sleep(100);
sys_cur_focus_task=Fs;
PopUpOk(
"Press $$FG,GREEN$$CTRL-F1$$FG$$ to autocomplete.\r\n");
AFGetKey(SC_F1|SCF_CTRL);
Sleep(500);
Msg(MSG_KEY_DOWN,CH_CR,SCF_CTRL|SCF_SHIFT);
PutS("\r");
PopUpOk(
"Tip: You can restart the WordStat window if you\r\n"
"have closed it by pressing $$FG,GREEN$$CTRL-F1$$FG$$.\r\n");
PopUpOk(
"You can also use the $$FG,GREEN$$Man()$$FG$$ function\r\n"
"to jump to source code.\r\n");
AFDelayedPutS("Man(\"InstallBoot\");");
Sleep(1000);
PutS("\r");
Sleep(2000);
PopUpOk(
"Press $$FG,GREEN$$CTRL-Q$$FG$$ to quit the source code.\r\n");
AFUntilChar(CH_CTRLQ);
-19
View File
@@ -1,19 +0,0 @@
PopUpOk(
"All text widgets work everywhere.\r\n"
"The $$FG,GREEN$$Type()$$FG$$ command is like\r\n"
"the DOS command of the same name\r\n"
"or the UNIX, $$FG,GREEN$$cat$$FG$$ command.\r\n"
"We will now send your menu document\r\n"
"to the command line. They use the same\r\n"
"document format and it is active!!.\r\n");
PopUpOk("Press $$FG,GREEN$$ENTER$$FG$$.");
//This puts the cursor at the bottom
Msg(MSG_KEY_DOWN,0,SC_CURSOR_DOWN|SCF_CTRL);
PutS("\r");
PutS("Type(\"HOME/User.MUZ\");");
AFPmtStr("\r");
Binary file not shown.
-37
View File
@@ -1,37 +0,0 @@
#help_index "Utils"
/*
This is the startup file for new local users.
If you modify this file, you should place it
into your HOME directory. This version is the
default for accounts without a version in HOME.
*/
UseConsoleLtf("User.MUZ");
U8 F(I1 *pattern,I1 *flags=NULL)
{
return Grep(pattern,"/LT/"TEXT_FILE_MASK,flags);
}
U8 R(I1 *pattern,I1 *replace_text=NULL,I1 *flags="+l-i")
{
return Grep(pattern,"/LT/"TEXT_FILE_MASK,flags,replace_text);
}
U8 FD(I1 *pattern,I1 *flags=NULL)
{
return Grep(pattern,TEXT_FILE_MASK,flags);
}
U8 RD(I1 *pattern,I1 *replace_text=NULL,I1 *flags="+l-i")
{
return Grep(pattern,TEXT_FILE_MASK,flags,replace_text);
}
PutSysText("ST_USER_STARTUP");
Type("::/LT/Doc/Help.TXZ");
Fs->scroll_speed=10;
Bts(&Fs->crt_flags,CRTf_SHOW);
Preempt(ON);
#help_index ""
BIN
View File
Binary file not shown.
-2
View File
@@ -1,2 +0,0 @@
Type("::/LT/Doc/Customize.TXZ");
-55
View File
@@ -1,55 +0,0 @@
public double os_version=3.05;
#include "AdamExt.HPZ"
Load("GrAsm/GrAsm");
#include "GrAsm/GrAsm.HPZ"
#include "KbdMouse"
#include "InputPointer"
#include "IncCompress"
#include "Math"
#include "ODE"
Cd("::/LT/Adam/Gr");;
#include "Gr"
Cd("::/LT/Adam");;
#include "Music"
#include "Disk10"
#include "DiskCDDVD"
#include "Comm"
#include "Remote"
#include "JoyStick"
#include "Utils"
#include "Message"
#include "Window"
#include "LPT"
Cd("::/LT/Adam/Ltf");;
#include "Ltf"
Cd("::/LT/Adam");;
#include "AutoFile"
#include "LogIn"
Cd("::/LT/Adam/WordStat");;
#include "WordStat"
Cd("::/LT/Adam");;
#include "Dbg"
#include "HashUtils"
#include "FileManager"
UseConsoleLtf(NULL);
adam_tss->win_top=2;
adam_tss->win_bottom=10;
sys_update_screen_tss=Spawn(&WinManagerTsk,"Window Manager");
CollectAccntList;
Bts(&Fs->crt_flags,CRTf_SHOW);
if (!(Fs->account=FindSysAccnt(sys_startup_account)))
Fs->account=PopUpGetSysAccnt;
sys_update_screen_tss->account=Fs->account;
LoadAccntRegistry;
Cd("::/LT/Adam");;
#include "WallPaper"
Cd("HOME");;
#include "Adam3"
-46
View File
@@ -1,46 +0,0 @@
extern void UseConsoleLtf(I1 *menu_file);
extern BoolU8 WinToTop(TssStruct *tss=NULL);
extern U8 GetMsg(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL);
extern U8 ScanMsg(I8 *param1,I8 *param2,U8 mask=-2,TssStruct *tss=NULL);
extern void PlotInputPointer(GrBitMap *base);
extern void GrPlot0(GrBitMap *base,I8 x,I8 y);
extern void DrawTaskBorder(TssStruct *tss);
extern void UpdateOdes(TssStruct *tss);
extern void IDEClearAllBpts(Ltf *l);
extern void IDEToggleBpt(Ltf *l);
extern U8 ltf_display_types[1],ltf_nondisplay_invisible_types[1],
ltf_form_types[1],ltf_data_types[1];
extern I8 PopUp(I1 *msg,TssStruct *parent=NULL,TssStruct **pu_tss=NULL);
extern LtfEntry *LtfPutSExt(Ltf *l,I1 *st);
extern I8 PopUpMenu(Ltf *l,I1 *help=NULL);
extern Ltf *LtfNew();
extern void LtfDel(Ltf *l);
extern LtfEntry *LtfPrintF(Ltf *l,I1 *src,...);
extern I1 *EditPicture();
extern BoolU8 View();
extern void IDEGo();
extern void IDEStep(Ltf *l);
extern void IDESetLineNum(Ltf *l);
extern void IDE(I1 *filename);
extern void LtfD(U1 *buf,U8 cnt=0x80);
extern void LtfUpdateWinJoin(Ltf *l,BoolU4 to_screen,BoolU4 has_cursor,
BoolU4 recalc,BoolU4 find_cur_entry,BoolU4 preempt,
LtfEntry *pg_found=NULL,I8 num_del_entries=0);
extern void LtfRecalc(Ltf *l);
extern BoolU8 DoForm(U1 *D,I1 *class_name,
I1 *help=NULL,BoolU4 help_is_file=FALSE,
I1 *header=NULL,I1 *footer=NULL);
extern void WsFillin(I8 n);
extern void WsMan(I8 n,TssStruct *parent=NULL);
extern void WsdFillin(I8 n);
extern void WsdDef(I8 n,TssStruct *parent=NULL);
extern BoolU8 WordStat(BoolU8 val=ON);
extern void WsdPopUpDef(I1 *st,I8 num=-1,TssStruct *parent=NULL);
extern void FileManager(I1 *mask="/*",I1 *flags=NULL);
extern void LtfHelpIndex(Ltf *l,I1 *index);
extern void AccntOneTimePopUp(I8 flag_num,I1 *msg);
#define CTRL_L_HELP "::/LT/Doc/CtrlL.MUZ"
Binary file not shown.
BIN
View File
Binary file not shown.
-1410
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
-543
View File
@@ -1,543 +0,0 @@
#help_index "File/CD DVD"
void FillBigEndianU2(U2 *dst,U2 w)
{
U2 *src=&w;
dst->u1[0]=src->u1[1];
dst->u1[1]=src->u1[0];
}
void FillBigEndianU4(U4 *dst,U8 d)
{
U8 *src=&d;
dst->u1[0]=src->u1[3];
dst->u1[1]=src->u1[2];
dst->u1[2]=src->u1[1];
dst->u1[3]=src->u1[0];
}
void FillU2Palindrome(U2Palindrome *dst,U2 w)
{
FillBigEndianU2(&dst->big,w);
dst->little=w;
}
void FillU4Palindrome(U4Palindrome *dst,U8 d)
{
FillBigEndianU4(&dst->big,d);
dst->little=d;
}
class CCdUserData
{
U8 location,path_entry_num,
short_dir_blks,long_dir_blks;
};
U8 DoCreateCDFile(LTFile *out_file,LTDirEntry *tempm,
ISODirEntry *tempi,ISODirEntry *tempi2,
U8 *cur_blk,
LTDirEntry *parent,BoolU4 write)
{
CCdUserData *tempc;
LTDirEntry *tempm1,*tempm2;
LTFile *in_file;
U1 *buf=MAlloc(CD_BLK_SIZE),*ptr1,*ptr2;
ISODirEntry *dir_blk_buf=MAllocZ(CD_BLK_SIZE*128),
*de=dir_blk_buf,*de1;
ISODirEntry *dir_blk_buf2=MAllocZ(CD_BLK_SIZE*128),
*de2=dir_blk_buf2,*de12;
U8 i,n;
tempc=parent->user_data;
de->length=sizeof(ISODirEntry)-1;
de->ext_attr_length=0;
FillU2Palindrome(&de->volume_sequence_num,1);
LTDateToISO(&de->date,tempm->datetime);
de->flags=ISO_ATTR_DIR;
de->name_len=1;
de->name=0;
de->length+=de->name_len;
de+=de->length;
de->length=sizeof(ISODirEntry)-1;
de->ext_attr_length=0;
FillU4Palindrome(&de->location,tempc->location);
FillU4Palindrome(&de->size,tempc->short_dir_blks*CD_BLK_SIZE);
FillU2Palindrome(&de->volume_sequence_num,1);
LTDateToISO(&de->date,parent->datetime);
de->flags=ISO_ATTR_DIR;
de->name_len=1;
de->name=1;
de->length+=de->name_len;
de+=de->length;
de2->length=sizeof(ISODirEntry)-1;
de2->ext_attr_length=0;
FillU2Palindrome(&de2->volume_sequence_num,1);
LTDateToISO(&de2->date,tempm->datetime);
de2->flags=ISO_ATTR_DIR;
de2->name_len=1;
de2->name=0;
de2->length=de2->length+de2->name_len;
de2+=de2->length;
de2->length=sizeof(ISODirEntry)-1;
de2->ext_attr_length=0;
FillU4Palindrome(&de2->location,tempc->location+tempc->short_dir_blks);
FillU4Palindrome(&de2->size,tempc->long_dir_blks*CD_BLK_SIZE);
FillU2Palindrome(&de2->volume_sequence_num,1);
LTDateToISO(&de2->date,parent->datetime);
de2->flags=ISO_ATTR_DIR;
de2->name_len=1;
de2->name=1;
de2->length+=de2->name_len;
de2+=de2->length;
tempm1=tempm->sub;
while (tempm1) {
tempm2=tempm1->next;
if (!write) tempm1->user_data=MAllocZ(sizeof(CCdUserData));
de1=de;
de12=de2;
if (tempm1->attr & LT_ATTR_DIR) {
n=DoCreateCDFile(out_file,tempm1,de,de2,cur_blk,tempm,write);
de+=sizeof(ISODirEntry)-1+n;
de2+=sizeof(ISODirEntry)-1+n<<1;
} else {
tempc=tempm1->user_data;
de->length=sizeof(ISODirEntry)-1;
de->ext_attr_length=0;
FillU4Palindrome(&de->location,*cur_blk);
tempc->location=*cur_blk;
if (write)
coutln *cur_blk,":",tempm1->full_name;
FillU4Palindrome(&de->size,tempm1->size);
FillU2Palindrome(&de->volume_sequence_num,1);
LTDateToISO(&de->date,tempm1->datetime);
de->flags=0;
de->name_len=StrLen(tempm1->name);
StrCpy(&de->name,tempm1->name);
de->length=de->length+de->name_len;
de+=de->length;
de2->length=sizeof(ISODirEntry)-1;
de2->ext_attr_length=0;
FillU4Palindrome(&de2->location,*cur_blk);
FillU4Palindrome(&de2->size,tempm1->size);
FillU2Palindrome(&de2->volume_sequence_num,1);
LTDateToISO(&de2->date,tempm1->datetime);
de2->flags=0;
de2->name_len=StrLen(tempm1->name)<<1;
ptr1=&de2->name;
ptr2=&tempm1->name;
for (i=0;i<de2->name_len;i=i+2) {
ptr1++;
*ptr1++=*ptr2++;
}
de2->length+=de2->name_len;
de2+=de2->length;
in_file=FOpen(tempm1->full_name,"r");
for (i=0;i<(FSize(in_file)+CD_BLK_SIZE-1)/CD_BLK_SIZE;i++) {
n=4;
if ((i+1)<<2>(FSize(in_file)+BLK_SIZE-1)>>BLK_SIZE_BITS) {
n=((FSize(in_file)+BLK_SIZE-1)>>BLK_SIZE_BITS)%4;
MemSet(buf,0,CD_BLK_SIZE);
}
if (write) {
FRBlks(in_file,buf,i<<2,n);
FWBlks(out_file,buf,(*cur_blk)<<2,n);
}
*cur_blk+=1;
}
FClose(in_file);
}
if ((de1-dir_blk_buf)/CD_BLK_SIZE!=
(de -dir_blk_buf)/CD_BLK_SIZE) {
i=de1->length;
MemCpy(buf,de1,i);
MemSet(de1,0,i);
de=dir_blk_buf+((de-dir_blk_buf)/CD_BLK_SIZE)*CD_BLK_SIZE;
MemCpy(de,buf,i);
de+=i;
}
if ((de12-dir_blk_buf2)/CD_BLK_SIZE!=
(de2 -dir_blk_buf2)/CD_BLK_SIZE) {
i=de12->length;
MemCpy(buf,de12,i);
MemSet(de12,0,i);
de2=dir_blk_buf2+((de2-dir_blk_buf2)/CD_BLK_SIZE)*CD_BLK_SIZE;
MemCpy(de2,buf,i);
de2+=i;
}
tempm1=tempm2;
}
tempc=tempm->user_data;
tempi->length=sizeof(ISODirEntry)-1;
tempi->ext_attr_length=0;
tempi->flags=ISO_ATTR_DIR;
if (!tempm->name[0]) {
tempi->name_len=1;
tempi->name=1;
} else {
tempi->name_len=StrLen(tempm->name);
StrCpy(&tempi->name,tempm->name);
}
tempi->length+=tempi->name_len;
n=de+1-dir_blk_buf;
n=(n+CD_BLK_SIZE-1)/CD_BLK_SIZE;
FillU4Palindrome(&tempi->size,n*CD_BLK_SIZE);
FillU4Palindrome(&tempi->location,*cur_blk);
tempc->short_dir_blks=n;
tempc->location=*cur_blk;
FillU4Palindrome(&dir_blk_buf->size,n*CD_BLK_SIZE);
FillU4Palindrome(&dir_blk_buf->location,*cur_blk);
FillU2Palindrome(&tempi->volume_sequence_num,1);
LTDateToISO(&tempi->date,tempm->datetime);
if (write)
coutln *cur_blk,":",tempm->full_name;
if (write)
FWBlks(out_file,dir_blk_buf,(*cur_blk)<<2,n<<2);
*cur_blk+=n;
tempi2->length=sizeof(ISODirEntry)-1;
tempi2->ext_attr_length=0;
tempi2->flags=ISO_ATTR_DIR;
if (!tempm->name[0]) {
tempi2->name_len=1;
tempi->name=1;
} else {
tempi2->name_len=StrLen(tempm->name)<<1;
ptr1=&tempi2->name;
ptr2=&tempm->name;
for (i=0;i<tempi2->name_len;i=i+2) {
ptr1++;
*ptr1++=*ptr2++;
}
}
tempi2->length+=tempi2->name_len;
n=de2+1-dir_blk_buf2;
n=(n+CD_BLK_SIZE-1)/CD_BLK_SIZE;
FillU4Palindrome(&tempi2->size,n*CD_BLK_SIZE);
FillU4Palindrome(&tempi2->location,*cur_blk);
tempc->long_dir_blks=n;
FillU4Palindrome(&dir_blk_buf2->size,n*CD_BLK_SIZE);
FillU4Palindrome(&dir_blk_buf2->location,*cur_blk);
FillU2Palindrome(&tempi2->volume_sequence_num,1);
LTDateToISO(&tempi2->date,tempm->datetime);
if (write)
coutln *cur_blk,":",tempm->full_name;
if (write)
FWBlks(out_file,dir_blk_buf2,(*cur_blk)<<2,n<<2);
*cur_blk+=n;
Free(dir_blk_buf);
Free(dir_blk_buf2);
Free(buf);
return tempi->name_len;
}
U8 CDTableLength(LTDirEntry *tempm,U8 *size1,U8 *size2,U8 cur_depth)
//returns depth
{
LTDirEntry *tempm1=tempm->sub;
U8 max_depth=cur_depth,i;
while (tempm1) {
if (tempm1->attr & LT_ATTR_DIR) {
*size1+=sizeof(ISOPathTableEntry)-2+((StrLen(tempm1->name)+1) & -0x2);
*size2+=sizeof(ISOPathTableEntry)-2+StrLen(tempm1->name)<<1;
i=CDTableLength(tempm1,size1,size2,cur_depth+1);
if (i>max_depth) max_depth=i;
}
tempm1=tempm1->next;
}
return max_depth;
}
void CDFillPathTable(LTDirEntry *tempm,
ISOPathTableEntry *itabbuf,ISOPathTableEntry *itabbuf2,
U8 parent_entry_num,BoolU4 big_endian,U8 *first_free,I8 cur_level,I8 output_level)
{
I1 *ptr1,*ptr2;
U8 i;
ISOPathTableEntry *tabbuf=*itabbuf;
ISOPathTableEntry *tabbuf2=*itabbuf2;
LTDirEntry *tempm1=tempm->sub,*tempm2;
CCdUserData *tempc;
if (cur_level==output_level) {
while (tempm1) {
if (tempm1->attr & LT_ATTR_DIR) {
tempc=tempm1->user_data;
tempc->path_entry_num=*first_free;
tabbuf->name_len=StrLen(tempm1->name);
if (big_endian) {
FillBigEndianU4(&tabbuf->blk,tempc->location);
FillBigEndianU2(&tabbuf->parent_entry_num,parent_entry_num);
} else {
tabbuf->blk=tempc->location;
tabbuf->parent_entry_num=parent_entry_num;
}
StrCpy(&tabbuf->name,tempm1->name);
tabbuf+=sizeof(ISOPathTableEntry)-2+
((StrLen(tempm1->name)+1) & -0x2);
tabbuf2->name_len=StrLen(tempm1->name)<<1;
if (big_endian) {
FillBigEndianU4(&tabbuf2->blk,tempc->location+tempc->short_dir_blks);
FillBigEndianU2(&tabbuf2->parent_entry_num,parent_entry_num);
} else {
tabbuf2->blk=tempc->location+tempc->short_dir_blks;
tabbuf2->parent_entry_num=parent_entry_num;
}
ptr1=&tabbuf2->name;
ptr2=&tempm1->name;
for (i=0;i<tabbuf2->name_len;i=i+2) {
ptr1++;
*ptr1++=*ptr2++;
}
tabbuf2+=sizeof(ISOPathTableEntry)-2+
StrLen(tempm1->name)<<1;
*first_free+=1;
}
tempm1=tempm1->next;
}
*itabbuf=tabbuf;
*itabbuf2=tabbuf2;
}
tempm1=tempm->sub;
while (tempm1) {
tempm2=tempm1->next;
if (tempm1->attr & LT_ATTR_DIR) {
tempc=tempm1->user_data;
CDFillPathTable(tempm1,itabbuf,itabbuf2,tempc->path_entry_num,
big_endian,first_free,cur_level+1,output_level);
}
tempm1=tempm2;
}
}
class ElTorito
{
U2 w[16];
U1 bootable; //88=bootable 00=not bootable
U1 media_type; //0=no emulation 4=hard disk
U2 load_seg; //0000->07C0
U1 sys_type;
U1 zero;
U2 sector_cnt;
U4 load_rba; //start address of virtual disk
U1 zero2[20];
};
public U8 CreateCDFile(I1 *filename,I1 src_drive,
I1 *bootfile=NULL)
{
ISOPrimaryDescriptor *iso =MAllocZ(CD_BLK_SIZE),
*iso1=MAllocZ(CD_BLK_SIZE),
*iso2=MAllocZ(CD_BLK_SIZE),
*iso3=MAllocZ(CD_BLK_SIZE);
LTDirEntry *rootdir=MAllocZ(sizeof(LTDirEntry));
U8 cur_blk=0,bsize,tabsize,tabsize2,first_free,max_depth;
U4 *d;
I1 mask[8];
I1 *filename2;
ElTorito *et=MAllocZ(CD_BLK_SIZE);
U1 *buf=MAllocZ(CD_BLK_SIZE),
*bootfile_buf=NULL;
ISOPathTableEntry *tabbuf=NULL,*tabbuf2=NULL,
*itabbuf,*itabbuf2;
BoolU4 okay=TRUE;
U8 i,j;
LTFile *out_file=NULL;
ISODirEntry *tempi;
CCdUserData *tempc;
if (!filename)
filename=default_iso_name;
filename2=DefaultExtension(filename,"ISO");
SPrintF(mask,"%c:/*",src_drive);
if (bootfile)
bootfile_buf=ReadFile(bootfile,&bsize);
rootdir->attr=LT_ATTR_DIR;
rootdir->sub=FindFiles(mask,1<<FUf_RECURSE);
rootdir->datetime=GetCurTimeLTDate;
rootdir->user_data=MAllocZ(sizeof(CCdUserData));
tempc=rootdir->user_data;
tempc->path_entry_num=1;
if (okay) {
cur_blk=CD_FILE_OFFSET>>2;
if (bootfile_buf)
cur_blk+=2;
DoCreateCDFile(out_file,rootdir,
&iso->root_directory_record,
&iso2->root_directory_record,
&cur_blk,rootdir,FALSE);
tabsize=sizeof(ISOPathTableEntry);
tabsize2=sizeof(ISOPathTableEntry);
max_depth=CDTableLength(rootdir,&tabsize,&tabsize2,1);
FillU4Palindrome(&iso->path_table_size,tabsize);
FillU4Palindrome(&iso2->path_table_size,tabsize2);
tabsize=(tabsize+CD_BLK_SIZE-1)/CD_BLK_SIZE;
cur_blk+=tabsize<<1;
tabsize2=(tabsize2+CD_BLK_SIZE-1)/CD_BLK_SIZE;
cur_blk+=tabsize2<<1;
}
if (okay) {
if (FileAttr(filename2) & LT_ATTR_CONTIGUOUS)
out_file=FOpen(filename2,"wc",cur_blk<<2);
else
out_file=FOpen(filename2,"w",cur_blk<<2);
if (!out_file)
okay=FALSE;
}
if (okay) {
cur_blk=0;
while (cur_blk<CD_FILE_OFFSET>>2) {
FWBlks(out_file,buf,cur_blk<<2,4);
cur_blk++;
}
iso->type=ISOT_PRIMARY_VOLUME_DESC;
StrCpy(iso->id,"CD001");
iso->version=1;
FillU2Palindrome(&iso->volume_set_size,1);
FillU2Palindrome(&iso->volume_sequence_number,1);
FillU2Palindrome(&iso->logical_block_size,CD_BLK_SIZE);
iso->file_structure_version=1;
iso2->type=ISOT_SUPPLEMENTARY_DESC;
StrCpy(iso2->id,"CD001");
iso2->version=1;
FillU2Palindrome(&iso2->volume_set_size,1);
FillU2Palindrome(&iso2->volume_sequence_number,1);
FillU2Palindrome(&iso2->logical_block_size,CD_BLK_SIZE);
iso2->file_structure_version=1;
iso1->type=ISOT_BOOT_RECORD;
StrCpy(iso1->id,"CD001");
iso1->version=1;
StrCpy(iso1+7,"EL TORITO SPECIFICATION");
cur_blk=CD_FILE_OFFSET>>2;
if (bootfile_buf) {
d=iso1+0x47;
*d=cur_blk;
et->w[0]=1;
StrCpy(&et->w[2],"LoseThos");
et->w[15]=0xAA55;
j=0;
for (i=0;i<16;i++) //Checksum
j+=et->w[i];
et->w[14]=-j;
if (bootfile_buf)
et->bootable=0x88;
et->media_type=0; //0=no emu 2=1.44meg 4=hard drive
et->sector_cnt=4;
et->load_rba=cur_blk+1;
coutln cur_blk,": Pre Boot Blk";
FWBlks(out_file,et,cur_blk<<2,4);
cur_blk++;
coutln cur_blk,": Boot Blk";
FWBlks(out_file,bootfile_buf,cur_blk<<2,4);
cur_blk++;
}
DoCreateCDFile(out_file,rootdir,
&iso->root_directory_record,
&iso2->root_directory_record,
&cur_blk,rootdir,TRUE);
tabbuf=MAllocZ(tabsize*CD_BLK_SIZE);
iso->type_l_path_table=cur_blk;
tabbuf->name_len=2; //Fill-in adam entry
tempi=&iso->root_directory_record;
tabbuf->blk=tempi->location.little;
tabbuf->parent_entry_num=1;
tabbuf2=MAllocZ(tabsize2*CD_BLK_SIZE);
iso2->type_l_path_table=cur_blk+tabsize;
tabbuf2->name_len=2; //Fill-in adam entry
tempi=&iso2->root_directory_record;
tabbuf2->blk=tempi->location.little;
tabbuf2->parent_entry_num=1;
itabbuf=tabbuf+sizeof(ISOPathTableEntry);
itabbuf2=tabbuf2+sizeof(ISOPathTableEntry);
first_free=2;
for (i=1;i<=max_depth;i++)
CDFillPathTable(rootdir,&itabbuf,&itabbuf2,
1,FALSE,&first_free,1,i);
coutln cur_blk,": Path Table 0";
FWBlks(out_file,tabbuf,cur_blk<<2,tabsize<<2);
cur_blk+=tabsize;
coutln cur_blk,": Path Table 1";
FWBlks(out_file,tabbuf2,cur_blk<<2,tabsize2<<2);
cur_blk+=tabsize2;
MemSet(tabbuf,0,tabsize*CD_BLK_SIZE);
FillBigEndianU4(&iso->type_m_path_table,cur_blk);
tabbuf->name_len=2; //Fill-in adam entry
tempi=&iso->root_directory_record;
tabbuf->blk=tempi->location.big;
FillBigEndianU2(&tabbuf->parent_entry_num,1);
MemSet(tabbuf2,0,tabsize2*CD_BLK_SIZE);
FillBigEndianU4(&iso2->type_m_path_table,cur_blk+tabsize);
tabbuf2->name_len=2; //Fill-in adam entry
tempi=&iso2->root_directory_record;
tabbuf2->blk=tempi->location.big;
FillBigEndianU2(&tabbuf2->parent_entry_num,1);
itabbuf=tabbuf+sizeof(ISOPathTableEntry);
itabbuf2=tabbuf2+sizeof(ISOPathTableEntry);
first_free=2;
for (i=1;i<=max_depth;i++)
CDFillPathTable(rootdir,&itabbuf,&itabbuf2,
1,TRUE,&first_free,1,i);
coutln cur_blk,": Path Table 2";
FWBlks(out_file,tabbuf,cur_blk<<2,tabsize<<2);
cur_blk+=tabsize;
coutln cur_blk,": Path Table 3";
FWBlks(out_file,tabbuf2,cur_blk<<2,tabsize2<<2);
cur_blk+=tabsize2;
DelLTDirList(rootdir); //TODO: Free user_data
FillU4Palindrome(&iso->volume_space_size,cur_blk);
FillU4Palindrome(&iso2->volume_space_size,cur_blk);
FWBlks(out_file,iso,16<<2,4);
iso3->type=ISOT_TERMINATOR;
StrCpy(iso3->id,"CD001");
iso3->version=1;
if (bootfile_buf) {
FWBlks(out_file,iso1,17<<2,4);
FWBlks(out_file,iso2,18<<2,4);
FWBlks(out_file,iso3,19<<2,4);
} else {
FWBlks(out_file,iso2,17<<2,4);
FWBlks(out_file,iso3,18<<2,4);
}
} else
cur_blk=0;
FClose(out_file);
Free(tabbuf);
Free(tabbuf2);
Free(et);
Free(bootfile_buf);
Free(iso);
Free(iso1);
Free(iso2);
Free(iso3);
Free(filename2);
return cur_blk;
}
#help_index ""
Binary file not shown.
-684
View File
@@ -1,684 +0,0 @@
#help_index "File/Cmd Line (Typically)"
#define FILEMANAGER_MENU_NAME "::/LT/Doc/FileManager.MUZ"
class FMUncollapsedList
{
FMUncollapsedList *next;
I1 *name;
};
void AddTempDriveWizard()
{
TssStruct *tss;
I1 *a_drive=NULL,*a_size=NULL,*a_type=NULL,*a_name=NULL,*a_default=NULL;
I8 size,drive,type,drive2;
LTPartition *p;
PartitionRep;
BoolU4 okay=FALSE,sure=FALSE,in_use,valid_drive2;
cout "$$WW,1$$";
a_type =PmtStr("\r\n(R)am or (F)ile : ");
type =ToUpper(*a_type);
if (type=='R' || type=='F') {
a_drive =PmtStr("\r\nNew Drive Letter: ");
drive=ToUpper(*a_drive);
if (drive>'A' && drive<='Z') {
p=&local_partitions[drive-'A'];
try {
CheckLTPartition(p);
in_use=TRUE;
} catch {
Fs->catch_except=TRUE;
in_use=FALSE;
}
if (in_use)
coutln "$$FG,RED$$Drive letter in use.$$FG$$";
else {
a_size =PmtStr("\r\nSize in Meg : ");
size=AtoI(a_size)*0x100000>>BLK_SIZE_BITS;
if (size<0x800)
coutln "$$FG,RED$$Invalid size.$$FG$$";
else {
if (type=='F') {
coutln "$$FG,RED$$Specify entire path, including drive, but leave-off "
"the filename extension.$$FG$$";
a_default=MSPrintF("%c:/Temp/Drive%c",default_drive,drive);
a_name=PmtStr("\r\nFile Name (%s): ",a_default);
if (*a_name==':')
*a_name=default_drive;
if (StrLen(a_name)<4 || a_name[1]!=':' ||
Occurrences(a_name,'.'))
coutln "$$FG,RED$$Invalid file name.$$FG$$";
else {
drive2=ToUpper(*a_name);
p=&local_partitions[drive2-'A'];
valid_drive2=FALSE;
if (p->type==PT_LT) {
try {
CheckLTPartition(p);
valid_drive2=TRUE;
} catch
Fs->catch_except=TRUE;
}
if (!valid_drive2)
coutln "$$FG,RED$$Invalid drive in file name.$$FG$$";
else
okay=TRUE;
}
} else {
if (size<<BLK_SIZE_BITS>7*UnusedSysMem/8)
coutln "$$FG,RED$$Size is too big.$$FG$$";
else
okay=TRUE;
}
}
}
} else
coutln "$$FG,RED$$Invalid drive letter.$$FG$$";
}
CrLf;
if (okay)
sure=AreYouSure;
if (okay && sure) {
tss=SpawnUser;
tss->win_top=Fs->win_top;
tss->win_bottom=(Fs->win_top+Fs->win_bottom)>>2-1;
Fs-> win_top=tss->win_bottom+3;
tss->win_right=Fs->win_right;
tss->win_left=Fs->win_left;
WinToTop(Fs);
XTalk(tss,"AddDrives;\r");
XTalk(tss,"%c",drive);
if (type=='R') {
XTalk(tss,"1");
XTalk(tss,"%d\r",size);
} else {
XTalk(tss,"5");
XTalk(tss,"%s\r",a_name);
XTalk(tss,"Y");
XTalk(tss,"%d\r",size);
}
XTalkWithWait(tss,"\r");
Fs->win_top=tss->win_top;
Kill(tss);
PartitionRep;
} else
coutln "$$FG,RED$$Canceled$$FG$$";
CrLf;
PressAKey;
Free(a_drive);
Free(a_type);
Free(a_size);
Free(a_name);
Free(a_default);
}
void FMAddTempDrive()
{
PopUp("AddTempDriveWizard;\r",Fs);
}
FMUncollapsedList *FMCollectUncollapsedList(Ltf *l)
{
LtfEntry *ll=l->dummy.next;
FMUncollapsedList *result=NULL,*tempc;
LTDirEntry *tempm;
while (ll!=l) {
if (ll->btype==LTFT_TREE) {
if (!(ll->flags&LTFLF_COLLAPSED)) {
if (tempm=ll->user_data) {
tempc=MAlloc(sizeof(FMUncollapsedList));
tempc->next=result;
result=tempc;
tempc->name=NewStr(tempm->full_name);
}
}
}
ll=ll->next;
}
return result;
}
void FMMarkUncollapsed(Ltf *l,FMUncollapsedList *tempc,I1 *cur_entry,I1 *next_entry)
{
LtfEntry *ll=l->dummy.next;
FMUncollapsedList *tempc1;
LTDirEntry *tempm;
while (ll!=l) {
if (ll->btype==LTFT_TREE) {
tempm=ll->user_data;
tempc1=tempc;
while (tempc1) {
if (!StrCmp(tempc1->name,tempm->full_name)) {
ll->flags&=~LTFLF_COLLAPSED;
break;
}
tempc1=tempc1->next;
}
if (cur_entry) {
if (!StrNCmp(cur_entry,tempm->full_name,StrLen(tempm->full_name))) {
l->cur_entry=ll;
if (StrLen(tempm->full_name)==StrLen(cur_entry))
cur_entry=NULL;
} else if (next_entry) {
if (!StrNCmp(next_entry,tempm->full_name,StrLen(tempm->full_name))) {
l->cur_entry=ll;
if (StrLen(tempm->full_name)==StrLen(next_entry))
cur_entry=NULL;
}
}
}
} else if (ll->btype==LTFT_MENU_VALUE) {
tempm=ll->left_exp;
if (cur_entry) {
if (!StrNCmp(cur_entry,tempm->full_name,StrLen(tempm->full_name))) {
l->cur_entry=ll;
if (StrLen(tempm->full_name)==StrLen(cur_entry))
cur_entry=NULL;
} else if (next_entry) {
if (!StrNCmp(next_entry,tempm->full_name,StrLen(tempm->full_name))) {
l->cur_entry=ll;
if (StrLen(tempm->full_name)==StrLen(next_entry))
cur_entry=NULL;
}
}
}
}
ll=ll->next;
}
}
void FMDelUncollapsedList(FMUncollapsedList *tempc)
{
FMUncollapsedList *tempc1;
while (tempc) {
tempc1=tempc->next;
Free(tempc->name);
Free(tempc);
tempc=tempc1;
}
}
LTDirEntry *FMRebuildLtfDrive(I1 drive,Ltf *l,LTDirEntry **root,BoolU4 init)
{
U8 f=0;
LtfEntry *ll;
LTDirEntry *tempm,*tempm1;
I1 *st;
GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),"+r");
tempm=MAllocZ(sizeof(LTDirEntry));
tempm->full_name=MSPrintF("%c:/",drive);
StrCpy(tempm->name,"");
st=MSPrintF("%c:/*",drive);
if (init) {
tempm1=FindFiles(st,f);
tempm->sub=tempm1;
} else
tempm1=NULL;
Free(st);
ll=LtfPrintF(l,"$$TR,\"%s\"$$",tempm->full_name);
ll->user_data=tempm;
tempm->next=*root;
*root=tempm;
LtfPutSExt(l,"\r\n$$ID,+2$$");
LtfBottom(l);
if (init) {
LTDirEntryToFileLtf(l,tempm1);
while (tempm1) {
tempm1->parent=tempm;
tempm1=tempm1->next;
}
}
LtfPutSExt(l,"$$ID,-2$$");
return tempm;
}
void FMRebuildLtf(Ltf **l_,LTDirEntry **root)
{
LTPartition *p;
I8 i;
Ltf *l=*l_,*m,*b=sys_clipboard_ltf;
FMUncollapsedList *tempc=NULL;
I1 *cur_entry=NULL,*next_entry=NULL;
LtfEntry *cl;
LTDirEntry *tempm,*tempm1,*cur_tree_entry;
if (l) {
cur_tree_entry=NULL;
cl=l->cur_entry;
if (cl->btype==LTFT_TREE)
cur_tree_entry=cl->user_data;
else if (cl->btype==LTFT_MENU_VALUE)
cur_tree_entry=cl->left_exp;
if (cur_tree_entry)
cur_entry=NewStr(cur_tree_entry->full_name);
tempm=NULL;
if (cl!=l)
cl=cl->next;
while (cl!=l) {
if (cl->btype==LTFT_TREE)
tempm=cl->user_data;
else if (cl->btype==LTFT_MENU_VALUE)
tempm=cl->left_exp;
else
tempm=NULL;
if (tempm) {
tempm1=tempm->parent;
while (tempm1) {
if (tempm1==cur_tree_entry) {
tempm=NULL;
break;
} else
tempm1=tempm1->parent;
}
if (tempm)
break;
}
cl=cl->next;
}
if (tempm)
next_entry=NewStr(tempm->full_name);
tempc=FMCollectUncollapsedList(l);
Fs->cur_ltf=NULL;
LtfDel(l);
}
if (*root) {
DelLTDirList(*root);
*root=NULL;
}
l=LtfNew;
l->flags|=LTFF_FORM;
m=LtfRead(FILEMANAGER_MENU_NAME);
m->text_attribute=(WHITE<<4)+LTBLUE;
l->menu_ltf=m;
for (i=0;i<32;i++) {
p=&local_partitions[i];
if (p->type==PT_LT)
FMRebuildLtfDrive(p->drive,l,root,TRUE);
else if (p->type==PT_ISO9660) {
if (p->bdev->flags&LTBDF_INITIALIZED)
tempm=FMRebuildLtfDrive(p->drive,l,root,TRUE);
else {
tempm=FMRebuildLtfDrive(p->drive,l,root,FALSE);
tempm->flags|=LTDEF_NOT_INITIALIZED;
}
tempm->flags|=LTDEF_REMOVABLE;
}
}
LtfHome(l);
FMMarkUncollapsed(l,tempc,cur_entry,next_entry);
l->recalc_start=l;
LtfCenter(l);
LtfReset(b,TRUE);
FMDelUncollapsedList(tempc);
Free(cur_entry);
Free(next_entry);
*l_=l;
Fs->cur_ltf=l;
}
void FMRename(Ltf *l)
{
EditFileNameStruct fn;
LtfEntry *ll=l->cur_entry;
LTDirEntry *tempm=NULL,*parent;
if (ll->btype==LTFT_MENU_VALUE) {
tempm=ll->left_exp;
if (parent=tempm->parent) {
Cd(parent->full_name);
StrCpy(fn.name,tempm->name);
if (DoForm(fn.name,"EditFileNameStruct")) {
Silent(ON);
Move(tempm->name,fn.name);
Silent(OFF);
}
}
} else if (ll->btype==LTFT_TREE) {
tempm=ll->user_data;
if (parent=tempm->parent) {
Cd(parent->full_name);
StrCpy(fn.name,tempm->name);
if (DoForm(fn.name,"EditFileNameStruct")) {
if (StrCmp(tempm->name,fn.name)) {
Silent(ON);
CopyTree(tempm->name,fn.name);
DelTree(tempm->name);
Silent(OFF);
}
}
}
}
}
void FMDelete(Ltf *l)
{
LtfEntry *cl=l->cur_entry;
LTDirEntry *tempm;
if (cl->btype==LTFT_MENU_VALUE) {
tempm=cl->left_exp;
Silent(ON);
Del(tempm->full_name);
Silent(OFF);
} else if (cl->btype==LTFT_TREE) {
tempm=cl->user_data;
Silent(ON);
DelTree(tempm->full_name);
Silent(OFF);
}
}
void FMMount(Ltf *l)
{
LtfEntry *cl=l->cur_entry;
LTDirEntry *tempm;
if (cl->btype==LTFT_TREE)
tempm=cl->user_data;
else if (cl->btype==LTFT_MENU_VALUE)
tempm=cl->left_exp;
else
tempm=NULL;
if (tempm) {
while (tempm->parent)
tempm=tempm->parent;
Silent(ON);
ChangeDisk(*tempm->full_name);
Silent(OFF);
}
}
void FMFormatDrive(Ltf *l)
{
LtfEntry *cl=l->cur_entry;
LTDirEntry *tempm;
I1 *st=NULL;
if (cl->btype==LTFT_TREE)
tempm=cl->user_data;
else if (cl->btype==LTFT_MENU_VALUE)
tempm=cl->left_exp;
else
tempm=NULL;
if (tempm) {
while (tempm->parent)
tempm=tempm->parent;
st=MSPrintF("Format Drive '%c'?\r\nAre You Sure?\r\n",*tempm->full_name);
if (PopUpNoYes(st)) {
Silent(ON);
Format(*tempm->full_name,TRUE,FALSE);
Silent(OFF);
}
}
Free(st);
}
void FMMakeISO(Ltf *l)
{
LtfEntry *cl=l->cur_entry;
LTDirEntry *tempm;
if (cl->btype==LTFT_TREE)
tempm=cl->user_data;
else if (cl->btype==LTFT_MENU_VALUE)
tempm=cl->left_exp;
else
tempm=NULL;
if (tempm) {
while (tempm->parent)
tempm=tempm->parent;
Silent(ON);
CreateCDFile(NULL,*tempm->full_name);
Silent(OFF);
}
}
void FMBurnISO(Ltf *l)
{
LtfEntry *cl=l->cur_entry;
LTDirEntry *tempm;
if (cl->btype==LTFT_TREE)
tempm=cl->user_data;
else if (cl->btype==LTFT_MENU_VALUE)
tempm=cl->left_exp;
else
tempm=NULL;
if (tempm) {
while (tempm->parent)
tempm=tempm->parent;
Silent(ON);
WriteCDImage(*tempm->full_name,NULL);
Silent(OFF);
}
}
void FMCopy(Ltf *l)
{
Ltf *b=sys_clipboard_ltf;
I1 *st;
LtfEntry *cl=l->cur_entry,*ll=b->dummy.next;
LTDirEntry *tempm,*tempm1,*tempm2;
if (cl->btype==LTFT_TREE) {
tempm1=cl->user_data;
while (ll!=b) {
if (ll->btype==LTFT_MENU_VALUE) {
tempm=ll->left_exp;
tempm->flags|=LTDEF_PROCESSED;
tempm2=tempm->parent;
if (!tempm2 || !(tempm2->flags&LTDEF_PROCESSED)) {
Silent(ON);
Copy(tempm->full_name,tempm1->full_name);
Silent(OFF);
}
} else if (ll->btype==LTFT_TREE) {
tempm=ll->user_data;
tempm->flags|=LTDEF_PROCESSED;
tempm2=tempm->parent;
if (!tempm2 || !(tempm2->flags&LTDEF_PROCESSED)) {
Silent(ON);
if (*tempm1->name)
st=MSPrintF("%s/%s",tempm1->full_name,tempm->name);
else
st=MSPrintF("%s%s",tempm1->full_name,tempm->name);
CopyTree(tempm->full_name,st);
Free(st);
Silent(OFF);
}
}
ll=ll->next;
}
}
}
I8 PopUpCancelPasteDel(I1 *header=NULL,I1 *footer=NULL)
{
I8 i;
Ltf *l=LtfNew;
if (header) LtfPutSExt(l,header);
LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"RENAME \",7$$");
LtfPutSExt(l,"$$CM+LX,28,0$$$$BT, \"DELETE \",2$$");
LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"PASTE CLIPBOARD FILES\",1$$");
LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"CHANGE DISK(MOUNT IT)\",3$$");
LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"ADD TEMP DRIVE \",4$$");
LtfPutSExt(l,"$$CM+LX,28,0$$$$BT, \"FORMAT \",6$$");
LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"MAKE ISO FILE \",8$$");
LtfPutSExt(l,"$$CM+LX,28,0$$$$BT, \"BURN ISO FILE \",9$$");
LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"HELP \",5$$");
LtfPutSExt(l,"$$CM+LX,28,0$$$$BT, \"CANCEL \",0$$");
if (footer) LtfPutSExt(l,footer);
i=PopUpMenu(l);
LtfDel(l);
return i;
}
void FMRightClick()
{
I8 i=PopUpCancelPasteDel;
if (i>0) {
switch (i) {
case 1:
Msg(MSG_KEY_DOWN,0,SC_INSERT+SCF_SHIFT);
break;
case 2:
Msg(MSG_KEY_DOWN,0x19,0);
break;
case 3:
Msg(MSG_KEY_DOWN,'m',0);
break;
case 4:
Msg(MSG_KEY_DOWN,'t',0);
break;
case 5:
Msg(MSG_KEY_DOWN,0,SC_GUI);
break;
case 6:
Msg(MSG_KEY_DOWN,'f',0);
break;
case 7:
Msg(MSG_KEY_DOWN,CH_CR,0);
break;
case 8:
Msg(MSG_KEY_DOWN,'M',0);
break;
case 9:
Msg(MSG_KEY_DOWN,'B',0);
break;
}
}
}
public void FileManager()
{
LTDirEntry *root=NULL,*tempm,*tempm1,*tempm2;
U8 sc,ch,p1,p2,cmd;
Ltf *l=NULL,*old_ltf=Fs->cur_ltf;
void *old_update=Fs->update_win;
BoolU4 old_preempt=Preempt(OFF);
I1 *st,*old_cur_dir=NewStr(Fs->cur_dir);
LTPartition *old_p=Fs->cur_partition;
LtfEntry *cl=NULL,*ll;
BoolU4 okay;
FMRebuildLtf(&l,&root);
Fs->update_win=&LtfUpdateBothLtf;
do {
Preempt(OFF);
if (cmd=ScanMsg(&p1,&p2,
1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
1<<MSG_IP_R_UP)) {
WinSync;
switch (cmd) {
case MSG_IP_R_UP:
FMRightClick;
break;
case MSG_IP_L_DOWN:
cl=l->cur_entry;
break;
case MSG_IP_L_UP:
if (cl) {
if (cl->btype==LTFT_MENU_VALUE) {
tempm=cl->left_exp;
if (SetCursorPosition(Fs,p1/FONT_WIDTH+Fs->win_left,p2/FONT_HEIGHT+Fs->win_top,TRUE)) {
ll=l->cur_entry;
if (ll->btype==LTFT_TREE) {
tempm1=ll->user_data;
Silent(ON);
Move(tempm->full_name,tempm1->full_name);
Silent(OFF);
PutKey(CH_SPACE,0); //toggle collapse again
FMRebuildLtf(&l,&root);
}
}
} else if (cl->btype==LTFT_TREE) {
tempm=cl->user_data;
if (SetCursorPosition(Fs,p1/FONT_WIDTH+Fs->win_left,p2/FONT_HEIGHT+Fs->win_top,TRUE)) {
ll=l->cur_entry;
if (ll->btype==LTFT_TREE) {
tempm1=ll->user_data;
okay=TRUE;
tempm2=tempm1;
while (tempm2) {
if (tempm2!=tempm)
tempm2=tempm2->parent;
else {
okay=FALSE;
break;
}
}
if (okay) {
if (*tempm1->name)
st=MSPrintF("%s/%s",tempm1->full_name,tempm->name);
else
st=MSPrintF("%s%s",tempm1->full_name,tempm->name);
if (StrCmp(tempm->full_name,st)) {
Silent(ON);
CopyTree(tempm->full_name,st);
DelTree(tempm->full_name);
Silent(OFF);
PutKey(CH_SPACE,0); //toggle collapse again
FMRebuildLtf(&l,&root);
}
Free(st);
}
}
}
}
cl=NULL;
}
break;
case MSG_KEY_DOWN:
ch=p1; sc=p2;
if (ch==CH_CR) {
FMRename(l);
FMRebuildLtf(&l,&root);
} else if (ch==0x19 || //ctrl-y
(sc.u1[0]==SC_DELETE && !(sc&(SCF_SHIFT|SCF_CTRL)))) {
FMDelete(l);
FMRebuildLtf(&l,&root);
} else if (ch=='m') {
FMMount(l);
FMRebuildLtf(&l,&root);
} else if (ch=='M') {
FMMakeISO(l);
FMRebuildLtf(&l,&root);
} else if (ch=='B') {
FMBurnISO(l);
FMRebuildLtf(&l,&root);
} else if (ch=='t') {
FMAddTempDrive;
FMRebuildLtf(&l,&root);
} else if (ch=='f') {
FMFormatDrive(l);
FMRebuildLtf(&l,&root);
} else if (sc.u1[0]==SC_INSERT && sc&SCF_SHIFT && !(sc&SCF_CTRL)) {
FMCopy(l);
FMRebuildLtf(&l,&root);
} else if (ch!=0x14 && ch!=CH_ESC && ch!=CH_CTRLQ) {//ctrl T not allowed
if (ch!=CH_SPACE || l->cur_entry->btype!=LTFT_MENU_VALUE) {
Preempt(old_preempt);
PutKey(ch,sc);
Preempt(OFF);
LtfRecalc(Fs->cur_ltf);
}
}
break;
}
} else {
Fs->task_flags|=1<<TSSf_IDLE;
WinSync;
Fs->task_flags&=~(1<<TSSf_IDLE);
}
} while (ch!=CH_ESC && ch!=CH_CTRLQ);
Fs->cur_ltf=old_ltf;
Fs->update_win=old_update;
Preempt(old_preempt);
LtfDel(l);
DelLTDirList(root);
Drive(old_p->drive);
Cd(old_cur_dir);
Free(old_cur_dir);
}
#help_index ""
-13
View File
@@ -1,13 +0,0 @@
#help_index "Graphics"
extern GrBitMap *GrAlias(GrBitMap *base,TssStruct *tss);
extern void GrDel(GrBitMap *base);
#include "GrMath"
#include "GrScreen"
#include "GrBitMap"
#include "GrPlot"
#include "GrChar"
#include "GrElem"
#help_index ""
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
-569
View File
@@ -1,569 +0,0 @@
#help_index "Graphics/Math"
I8 GrXOffsets[8]={-1,0,1,-1,1,-1,0,1},
GrYOffsets[8]={-1,-1,-1,0,0,1,1,1};
public void Line(void *aux_data,
I8 x1,I8 y1,I8 z1,
I8 x2,I8 y2,I8 z2,
void plot_cb(void *aux,I8 x,I8 y,I8 z),
I8 step=1,I8 start=0)
{
I8 i,j,d,dx=x2-x1,dy=y2-y1,dz=z2-z1;
I8 adx=AbsI8(dx),ady=AbsI8(dy),adz=AbsI8(dz);
if (adx>=ady) {
if (adx>=adz) {
if (d=adx) {
if (dx>=0)
dx=0x100000000;
else
dx=-0x100000000;
dy=dy<<32/d;
dz=dz<<32/d;
}
} else {
if (d=adz) {
dx=dx<<32/d;
dy=dy<<32/d;
if (dz>=0)
dz=0x100000000;
else
dz=-0x100000000;
}
}
} else {
if (ady>=adz) {
if (d=ady) {
dx=dx<<32/d;
if (dy>=0)
dy=0x100000000;
else
dy=-0x100000000;
dz=dz<<32/d;
}
} else {
if (d=adz) {
dx=dx<<32/d;
dy=dy<<32/d;
if (dz>=0)
dz=0x100000000;
else
dz=-0x100000000;
}
}
}
x1<<=32; y1<<=32; z1<<=32;
for (j=0;j<start;j++) {
x1+=dx; y1+=dy; z1+=dz;
}
if (step==1) {
for (i=start;i<=d;i++) {
plot_cb(aux_data,x1.i4[1],y1.i4[1],z1.i4[1]);
x1+=dx; y1+=dy; z1+=dz;
}
} else {
for (i=start;i<=d;i+=step) {
plot_cb(aux_data,x1.i4[1],y1.i4[1],z1.i4[1]);
for (j=0;j<step;j++) {
x1+=dx; y1+=dy; z1+=dz;
}
}
}
}
public void Box(void *aux_data,
I8 x1,I8 y1,I8 z1,
I8 x2,I8 y2,I8 z2,
I8 x3,I8 y3,I8 z3,
void plot_cb(void *aux,I8 x,I8 y,I8 z))
{
I8 i,j,
d1,dx1=x2-x1,dy1=y2-y1,dz1=z2-z1,
d2,dx2=x3-x1,dy2=y3-y1,dz2=z3-z1,
adx1=AbsI8(dx1),ady1=AbsI8(dy1),adz1=AbsI8(dz1),
adx2=AbsI8(dx2),ady2=AbsI8(dy2),adz2=AbsI8(dz2);
if (adx1>=ady1)
d1=(adx1>=adz1) ? adx1:adz1;
else
d1=(ady1>=adz1) ? ady1:adz1;
d1<<=1;
if (d1) {
dx1=dx1<<32/d1;
dy1=dy1<<32/d1;
dz1=dz1<<32/d1;
}
if (adx2>=ady2)
d2=(adx2>=adz2) ? adx2:adz2;
else
d2=(ady2>=adz2) ? ady2:adz2;
d2<<=1;
if (d2) {
dx2=dx2<<32/d2;
dy2=dy2<<32/d2;
dz2=dz2<<32/d2;
}
x1<<=32; y1<<=32; z1<<=32;
for (j=0;j<=d1;j++) {
x2=x1; y2=y1; z2=z1;
for (i=0;i<=d2;i++) {
plot_cb(aux_data,x2.i4[1],y2.i4[1],z2.i4[1]);
x2+=dx2; y2+=dy2; z2+=dz2;
}
x1+=dx1; y1+=dy1; z1+=dz1;
}
}
#help_index "Graphics/Math/3D Transformation"
I8 gr_scale;
gr_scale.u4[0]=0;
gr_scale.u4[1]=1;
void *gr_screen_capture=NULL;
public void GrRotate(I8 *r,I8 *x,I8 *y,I8 *z)
{
I8 x1,y1,z1,xx=*x,yy=*y,zz=*z;
x1=(r[0]*xx+r[1]*yy+r[2]*zz+r[3])>>32;
y1=(r[4]*xx+r[5]*yy+r[6]*zz+r[7])>>32;
z1=(r[8]*xx+r[9]*yy+r[10]*zz+r[11])>>32;
*x=x1;*y=y1;*z=z1;
}
public void GrTransform(GrBitMap *base,I8 *x,I8 *y,I8 *z)
{
GrRotate(base->r,x,y,z);
*x+=base->x;
*y+=base->y;
*z+=base->z;
}
public I8 *GrTheta(double theta,TssStruct *tss=NULL)
{
double my_cos,my_sin;
I8 *r=MAllocZ(sizeof(I8)*16,tss);
my_cos=Cos(theta)*gr_scale;
my_sin=Sin(theta)*gr_scale;
r[0]=my_cos;
r[5]=my_cos;
r[4]=my_sin;
r[1]=-my_sin;
r[10]=gr_scale;
return r;
}
public I8 *GrPhi(double phi,TssStruct *tss=NULL)
{
double my_cos,my_sin;
I8 *r=MAllocZ(sizeof(I8)*16,tss);
my_cos=Cos(phi)*gr_scale;
my_sin=Sin(phi)*gr_scale;
r[5]=my_cos;
r[10]=my_cos;
r[9]=my_sin;
r[6]=-my_sin;
r[0]=gr_scale;
return r;
}
public I8 *GrScaleMat(I8 *m1,double s,TssStruct *tss=NULL)
{
I8 i,*r=MAllocZ(sizeof(I8)*16,tss);
for (i=0;i<16;i++)
r[i]=m1[i]*s;
return r;
}
public I8 *GrMulMat(I8 *m1,I8 *m2,TssStruct *tss=NULL)
{
I8 *r=MAllocZ(sizeof(I8)*16,tss);
I8 i,j,k;
double d;
for (i=0;i<4;i++) {
for (j=0;j<4;j++) {
for (k=0;k<4;k++) {
d=m1[k+4*j];
d*=m2[i+4*k];
d/=gr_scale;
r[i+4*j]+=d;
}
}
}
return r;
}
public I8 GrDetMat(I8 *m1)
{
I8 i;
double m[16],d;
for (i=0;i<16;i++)
m[i]=m1[i]/(1.0*0x100000000);
d=m[0]*(m[5]*m[10]-m[6]*m[9])-
m[1]*(m[4]*m[10]-m[6]*m[8])+
m[2]*(m[4]*m[9]-m[5]*m[8]);
return d*0x100000000;
}
public void GrScalePenWidth(GrBitMap *base)
{
I8 d;
if (base->flags&BMF_TRANSFORMATION) {
if (base->pen_width) {
d=base->pen_width*GrDetMat(base->r)+0x80000000;
base->pen_width=d.u4[1];
if (base->pen_width<1)
base->pen_width=1;
}
}
}
public void GrSetIdent(I8 *r)
{
MemSet(r,0,16<<3);
r[0].u4[1]=1;
r[5].u4[1]=1;
r[10].u4[1]=1;
r[15].u4[1]=1;
}
public void GrSetTranslation(I8 *r,I8 x,I8 y,I8 z)
{
r[3]=x<<32;
r[7]=y<<32;
r[11]=z<<32;
}
#help_index "Graphics/Math"
public void Circle(void *aux_data,
I8 cx,I8 cy,I8 cz,
I8 radius,
void plot_cb(void *aux,I8 x,I8 y,I8 z),
I8 step=1,
double start_rad=0,
double len_rad=pi2)
{
I8 i,j,len=len_rad*radius;
I8 x,y,x1,y1,s1,s2,c;
double t;
if (radius<0) return;
if (!radius) {
plot_cb(aux_data,cx,cy,cz);
return;
}
t=1.0/radius;
s1=(1<<24)*Sin(t);
s2=-s1;
c=(1<<24)*Cos(t);
if (start_rad) {
x=radius*Cos(start_rad);
y=-radius*Sin(start_rad);
} else {
x=radius;
y=0;
}
x<<=8;
y<<=8;
for (i=0;i<=len;i+=step) {
plot_cb(aux_data,cx+x>>8,cy+y>>8,cz);
for (j=0;j<step;j++) {
x1=(c*x+s1*y)>>24;
y1=(s2*x+c*y)>>24;
x=x1; y=y1;
}
}
}
public void Ellipse(void *aux_data,
I8 cx,I8 cy,I8 cz,
I8 x_radius,I8 y_radius,
void plot_cb(void *aux,I8 x,I8 y,I8 z),
double rot_angle=0,
I8 step=1,
double start_rad=0,
double len_rad=pi2)
{
I8 i,j,len;
I8 x,y,x1,y1,x2,y2, s1,s2,c, s12,s22,c2;
double t;
if (x_radius<0 || y_radius<0 || step<1)
return;
if (!x_radius && !y_radius) {
plot_cb(aux_data,cx,cy,cz);
return;
}
if (x_radius>=y_radius) {
t=1.0/x_radius;
len=len_rad*x_radius;
} else {
t=1.0/y_radius;
len=len_rad*y_radius;
}
s1=(1<<24)*Sin(t);
s2=-s1;
c=(1<<24)*Cos(t);
s12=(1<<24)*Sin(rot_angle);
s22=-s12;
c2=(1<<24)*Cos(rot_angle);
if (start_rad) {
x=x_radius*Cos(start_rad);
y=-x_radius*Sin(start_rad);
} else {
x=x_radius;
y=0;
}
x<<=8;
y<<=8;
x2=x;
y2=y;
y1=y2*y_radius/x_radius;
x=(c2*x2+s12*y1)>>24;
y=(s22*x2+c2*y1)>>24;
for (i=0;i<=len;i+=step) {
plot_cb(aux_data,cx+x>>8,cy+y>>8,cz);
for (j=0;j<step;j++) {
x1=(c*x2+s1*y2)>>24;
y1=(s2*x2+c*y2)>>24;
x2=x1;
y2=y1;
y1=y1*y_radius/x_radius;
x=(c2*x1+s12*y1)>>24;
y=(s22*x1+c2*y1)>>24;
}
}
}
public I8 DistP3I4(P3I4 *p1,P3I4 *p2)
{
return Sqrt(SqrI8(p1->x-p2->x)+SqrI8(p1->y-p2->y)+SqrI8(p1->z-p2->z));
}
public void Bezier2(void *aux_data,P3I4 *ctrl,void plot_cb(void *aux,I8 x,I8 y,I8 z))
{//2nd order
I8 x,y,z,xx,yy,zz,dx,dy,dz,d_max;
double x0=ctrl[0].x,y0=ctrl[0].y,z0=ctrl[0].z;
double x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0;
double x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0;
double t,d=DistP3I4(&ctrl[0],&ctrl[1])+
DistP3I4(&ctrl[1],&ctrl[2])+
DistP3I4(&ctrl[2],&ctrl[0]),
s=0.5/d,t1,t2;
xx=x0; yy=y0; zz=z0;
for (t=0.0;t<=1.0;t+=s) {
t1=t*(1.0-t);
t2=t*t;
x=x0+x1*t1+x2*t2;
y=y0+y1*t1+y2*t2;
z=z0+z1*t1+z2*t2;
dx=AbsI8(x-xx);
dy=AbsI8(y-yy);
dz=AbsI8(z-zz);
if (dx>dy)
d_max=dx;
else
d_max=dy;
if (dz>d_max)
d_max=dz;
if (!d_max)
s*=1.1;
else {
s*=0.9;
plot_cb(aux_data,x,y,z);
xx=x;yy=y;zz=z;
}
}
}
public void Bezier3(void *aux_data,P3I4 *ctrl,void plot_cb(void *aux,I8 x,I8 y,I8 z))
{ //3rd order
I8 x,y,z,xx,yy,zz,dx,dy,dz,d_max;
double x0=ctrl[0].x,y0=ctrl[0].y,z0=ctrl[0].z;
double x1=ctrl[1].x-x0,y1=ctrl[1].y-y0,z1=ctrl[1].z-z0;
double x2=ctrl[2].x-x0,y2=ctrl[2].y-y0,z2=ctrl[2].z-z0;
double x3=ctrl[3].x-x0,y3=ctrl[3].y-y0,z3=ctrl[3].z-z0;
double t,d=DistP3I4(&ctrl[0],&ctrl[1])+
DistP3I4(&ctrl[1],&ctrl[2])+
DistP3I4(&ctrl[2],&ctrl[3])+
DistP3I4(&ctrl[3],&ctrl[0]),
s=0.5/d,nt,t1,t2,t3;
xx=x0; yy=y0; zz=z0;
for (t=0.0;t<=1.0;t+=s) {
nt=1.0-t;
t1=t*nt*nt;
t2=t*t*nt;
t3=t*t*t;
x=x0+x1*t1+x2*t2+x3*t3;
y=y0+y1*t1+y2*t2+y3*t3;
z=z0+z1*t1+z2*t2+z3*t3;
dx=AbsI8(x-xx);
dy=AbsI8(y-yy);
dz=AbsI8(z-zz);
if (dx>dy)
d_max=dx;
else
d_max=dy;
if (dz>d_max)
d_max=dz;
if (!d_max)
s*=1.1;
else {
s*=0.9;
plot_cb(aux_data,x,y,z);
xx=x;yy=y;zz=z;
}
}
}
public void BSpline2(void *aux_data,P3I4 *ctrl,I8 cnt,void plot_cb(void *aux,I8 x,I8 y,I8 z),BoolU4 closed=FALSE)
{ //2nd order
I8 i,j;
P3I4 *c;
if (cnt<3) return;
if (closed) {
cnt++;
c=MAlloc(sizeof(P3I4)*(cnt*2-1));
j=1;
for (i=0;i<cnt-2;i++) {
c[j].x=(ctrl[i].x+ctrl[i+1].x)/2.0;
c[j].y=(ctrl[i].y+ctrl[i+1].y)/2.0;
c[j].z=(ctrl[i].z+ctrl[i+1].z)/2.0;
j+=2;
}
c[j].x=(ctrl[0].x+ctrl[cnt-2].x)/2.0;
c[j].y=(ctrl[0].y+ctrl[cnt-2].y)/2.0;
c[j].z=(ctrl[0].z+ctrl[cnt-2].z)/2.0;
c[0].x=(c[1].x+c[j].x)/2.0;
c[0].y=(c[1].y+c[j].y)/2.0;
c[0].z=(c[1].z+c[j].z)/2.0;
j=2;
for (i=0;i<cnt-2;i++) {
c[j].x=(c[j-1].x+c[j+1].x)/2.0;
c[j].y=(c[j-1].y+c[j+1].y)/2.0;
c[j].z=(c[j-1].z+c[j+1].z)/2.0;
j+=2;
}
c[j].x=c[0].x;
c[j].y=c[0].y;
c[j].z=c[0].z;
} else {
c=MAlloc(sizeof(P3I4)*(cnt*2-1));
c[0].x=ctrl[0].x;
c[0].y=ctrl[0].y;
c[0].z=ctrl[0].z;
c[cnt*2-2].x=ctrl[cnt-1].x;
c[cnt*2-2].y=ctrl[cnt-1].y;
c[cnt*2-2].z=ctrl[cnt-1].z;
j=1;
for (i=0;i<cnt-1;i++) {
c[j].x=(ctrl[i].x+ctrl[i+1].x)/2.0;
c[j].y=(ctrl[i].y+ctrl[i+1].y)/2.0;
c[j].z=(ctrl[i].z+ctrl[i+1].z)/2.0;
j+=2;
}
j=2;
for (i=0;i<cnt-2;i++) {
c[j].x=(c[j-1].x+c[j+1].x)/2.0;
c[j].y=(c[j-1].y+c[j+1].y)/2.0;
c[j].z=(c[j-1].z+c[j+1].z)/2.0;
j+=2;
}
}
for (i=0;i<cnt*2-2;i+=2)
Bezier2(aux_data,&c[i],plot_cb);
Free(c);
}
public void BSpline3(void *aux_data,P3I4 *ctrl,I8 cnt,void plot_cb(void *aux,I8 x,I8 y,I8 z),BoolU4 closed=FALSE)
{ //3rd order
I8 i,j;
double x,y,z;
P3I4 *c;
if (cnt<3) return;
if (closed) {
cnt++;
c=MAlloc(sizeof(P3I4)*(cnt*3-2));
j=1;
for (i=0;i<cnt-2;i++) {
x=ctrl[i].x;
y=ctrl[i].y;
z=ctrl[i].z;
c[j].x=(ctrl[i+1].x-x)/3.0+x;
c[j].y=(ctrl[i+1].y-y)/3.0+y;
c[j].z=(ctrl[i+1].z-z)/3.0+z;
j++;
c[j].x=2.0*(ctrl[i+1].x-x)/3.0+x;
c[j].y=2.0*(ctrl[i+1].y-y)/3.0+y;
c[j].z=2.0*(ctrl[i+1].z-z)/3.0+z;
j+=2;
}
x=ctrl[cnt-2].x;
y=ctrl[cnt-2].y;
z=ctrl[cnt-2].z;
c[j].x=(ctrl[0].x-x)/3.0+x;
c[j].y=(ctrl[0].y-y)/3.0+y;
c[j].z=(ctrl[0].z-z)/3.0+z;
j++;
c[j].x=2.0*(ctrl[0].x-x)/3.0+x;
c[j].y=2.0*(ctrl[0].y-y)/3.0+y;
c[j].z=2.0*(ctrl[0].z-z)/3.0+z;
c[0].x=(c[1].x+c[j].x)/2.0;
c[0].y=(c[1].y+c[j].y)/2.0;
c[0].z=(c[1].z+c[j].z)/2.0;
j=3;
for (i=0;i<cnt-2;i++) {
c[j].x=(c[j-1].x+c[j+1].x)/2.0;
c[j].y=(c[j-1].y+c[j+1].y)/2.0;
c[j].z=(c[j-1].z+c[j+1].z)/2.0;
j+=3;
}
c[j].x=c[0].x;
c[j].y=c[0].y;
c[j].z=c[0].z;
} else {
c=MAlloc(sizeof(P3I4)*(cnt*3-2));
c[0].x=ctrl[0].x;
c[0].y=ctrl[0].y;
c[0].z=ctrl[0].z;
c[cnt*3-3].x=ctrl[cnt-1].x;
c[cnt*3-3].y=ctrl[cnt-1].y;
c[cnt*3-3].z=ctrl[cnt-1].z;
j=1;
for (i=0;i<cnt-1;i++) {
x=ctrl[i].x;
y=ctrl[i].y;
z=ctrl[i].z;
c[j].x=(ctrl[i+1].x-x)/3.0+x;
c[j].y=(ctrl[i+1].y-y)/3.0+y;
c[j].z=(ctrl[i+1].z-z)/3.0+z;
j++;
c[j].x=2.0*(ctrl[i+1].x-x)/3.0+x;
c[j].y=2.0*(ctrl[i+1].y-y)/3.0+y;
c[j].z=2.0*(ctrl[i+1].z-z)/3.0+z;
j+=2;
}
j=3;
for (i=0;i<cnt-2;i++) {
c[j].x=(c[j-1].x+c[j+1].x)/2.0;
c[j].y=(c[j-1].y+c[j+1].y)/2.0;
c[j].z=(c[j-1].z+c[j+1].z)/2.0;
j+=3;
}
}
for (i=0;i<cnt*3-3;i+=3)
Bezier3(aux_data,&c[i],plot_cb);
Free(c);
}
#help_index "Graphics"
-728
View File
@@ -1,728 +0,0 @@
public void GrPlot(GrBitMap *base,I8 x,I8 y)
{ //Clipping but No transformation or pen width
BoolU4 draw=TRUE;
if (base->brush) {
GrBlot(base,x,y,base->brush);
return;
}
if (base->flags & BMF_SCREEN_BITMAP) {
if (x<0) draw=FALSE;
x+=base->win_tss->win_pixel_left;
if (x>base->win_tss->win_pixel_right) draw=FALSE;
if (y<0) draw=FALSE;
y+=base->win_tss->win_pixel_top;
if (y>base->win_tss->win_pixel_bottom) draw=FALSE;
if (x>=base->width) draw=FALSE;
if (y>=base->height) draw=FALSE;
if (IsPixelCovered(base->win_tss,x,y)) draw=FALSE;
} else {
if (x<0) draw=FALSE;
if (x>=base->width) draw=FALSE;
if (y<0) draw=FALSE;
if (y>=base->height) draw=FALSE;
}
if (draw)
GrPlot0(base,x,y);
}
public I8 GrPeek(GrBitMap *base,I8 x,I8 y)
{ //Clipping but No transformation
BoolU4 peek=TRUE;
if (base->flags & BMF_SCREEN_BITMAP) {
if (x<0) peek=FALSE;
x+=base->win_tss->win_pixel_left;
if (x>base->win_tss->win_pixel_right) peek=FALSE;
if (y<0) peek=FALSE;
y+=base->win_tss->win_pixel_top;
if (y>base->win_tss->win_pixel_bottom) peek=FALSE;
if (x>=base->width) peek=FALSE;
if (y>=base->height) peek=FALSE;
if (IsPixelCovered(base->win_tss,x,y)) peek=FALSE;
} else {
if (x<0) peek=FALSE;
if (x>=base->width) peek=FALSE;
if (y<0) peek=FALSE;
if (y>=base->height) peek=FALSE;
}
if (peek)
return GrPeek0(base,x,y);
else
return -1;
}
#define CC_LEFT 1
#define CC_RIGHT 2
#define CC_TOP 4
#define CC_BOTTOM 8
U8 ClipCode(I8 x,I8 y,I8 right,I8 bottom)
{
U8 result;
if (y>bottom)
result=CC_BOTTOM;
else if (y<0)
result=CC_TOP;
else
result=0;
if (x>right)
result|=CC_RIGHT;
else if (x<0)
result|=CC_LEFT;
return result;
}
public BoolU8 ClipLine(GrBitMap *base,I8 *x1,I8 *y1,I8 *x2,I8 *y2)
{
I8 x,y,right,bottom;
U8 cc,cc1,cc2;
if (base->flags & BMF_SCREEN_BITMAP) {
right=base->win_tss->win_pixel_right-base->win_tss->win_pixel_left-1;
if (base->width-1<right)
right=base->width-1;
bottom=base->win_tss->win_pixel_bottom-base->win_tss->win_pixel_top-1;
if (base->height-1<bottom)
bottom=base->height-1;
} else {
right=base->width-1;
bottom=base->height-1;
}
cc1=ClipCode(*x1,*y1,right,bottom);
cc2=ClipCode(*x2,*y2,right,bottom);
do {
if (!(cc1|cc2))
return TRUE;
if (cc1&cc2)
return FALSE;
if (cc1)
cc=cc1;
else
cc=cc2;
if (cc&CC_BOTTOM) {
x=*x1+(*x2-*x1)*(bottom-*y1)/(*y2-*y1);
y=bottom;
} else if (cc&CC_TOP) {
x=*x1+(*x2-*x1)*(-*y1)/(*y2-*y1);
y=0;
} else if (cc&CC_RIGHT) {
y=*y1+(*y2-*y1)*(right-*x1)/(*x2-*x1);
x=right;
} else {
y=*y1+(*y2-*y1)*(-*x1)/(*x2-*x1);
x=0;
}
if (cc==cc1) {
*x1=x;
*y1=y;
cc1=ClipCode(*x1,*y1,right,bottom);
} else {
*x2=x;
*y2=y;
cc2=ClipCode(*x2,*y2,right,bottom);
}
} while (TRUE);
}
I8 GrFloodFillRay(GrBitMap *base,I8 x,I8 y)
{
I8 cnt,j,x1,ray_len,ray_len2;
cnt=ray_len=GrRayLen(base,&x,y);
y--;
j=ray_len;
x1=x;
while (j>0) {
if (ray_len2=GrRayLenMinus(base,x1,y))
cnt+=GrFloodFillRay(base,x1,y);
j-=ray_len2+1;
x1-=ray_len2+1;
}
y+=2;
j=ray_len;
x1=x;
while (j>0) {
if (ray_len2=GrRayLenMinus(base,x1,y))
cnt+=GrFloodFillRay(base,x1,y);
j-=ray_len2+1;
x1-=ray_len2+1;
}
return cnt;
}
public I8 GrFloodFill(GrBitMap *base,I8 x,I8 y,BoolU4 not_color=TRUE)
{
I8 cnt=0,j,c,old_color2=base->color2,old_flags=base->flags;
GrBitMap *old_brush;
if (base->flags & BMF_DONT_DRAW) //TODO
return 0;
old_brush=base->brush;
base->brush=NULL;
j=GrPeek(base,x,y);
if (j>=0) {
switch (base->type) {
case BMT_COLOR4:
if (not_color) {
base->color2=base->color&0xFFFFFF;
base->flags|=BMF_FILL_NOT_COLOR;
} else {
base->color2=j;
if (base->color2==base->color&0xFFFFFF)
break;
base->flags&=~BMF_FILL_NOT_COLOR;
}
if (not_color && j!=base->color2 ||
!not_color)
cnt=GrFloodFillRay(base,x,y);
break;
case BMT_MONO:
c=(base->color&0xFFFFFF)?1:0;
if (not_color) {
base->color2=c;
base->flags|=BMF_FILL_NOT_COLOR;
} else {
base->color2=(j)?1:0;
if (base->color2==c)
break;
base->flags&=~BMF_FILL_NOT_COLOR;
}
if (not_color && j!=c ||
!not_color)
cnt=GrFloodFillRay(base,x,y);
break;
}
}
base->brush=old_brush;
base->flags=old_flags;
base->color2=old_color2;
return cnt;
}
public void GrPlot2(GrBitMap *base,I8 x,I8 y,I8 z)
{ //Clipping and transformation but no pen_width
if (base->flags & BMF_TRANSFORMATION) {
GrRotate(base->r,&x,&y,&z);
x+=base->x;
y+=base->y;
z+=base->z;
}
GrPlot(base,x,y);
}
public void GrPlot3(GrBitMap *base,I8 x,I8 y,I8 z)
{ //clipping and transformation and pen width
I8 i,j,w,old_color,dist;
if (base->flags & BMF_TRANSFORMATION) {
GrRotate(base->r,&x,&y,&z);
x+=base->x;
y+=base->y;
z+=base->z;
}
w=base->pen_width>>1;
if (w<=0)
GrPlot(base,x,y);
else if (base->pen_width<GR_NUM_PEN_BRUSHES) {
old_color=base->color;
if (base->color.u1[3]==ROPB_EQU)
base->color.u1[3]=ROPB_TRANSPARENT;
if (GrBlot(base,x-w,y-w,gr_pen_brushes[base->pen_width])) {
if (base->flags & BMF_SCREEN_BITMAP) {
x+=base->win_tss->win_pixel_left;
y+=base->win_tss->win_pixel_top;
}
if (base->flags & BMF_LOCATE_NEAREST) {
dist=DistI8(x,y,base->cur_x,base->cur_y);
if (dist<base->nearest_dist) {
base->nearest_sub_grelem=base->cur_sub_grelem;
base->nearest_dist=dist;
}
}
}
base->color=old_color;
} else if (base->pen_width & 1) {
for (i=-w;i<=w;i++)
for (j=-w;j<=w;j++)
GrPlot(base,x+i,y+j);
} else {
for (i=-w;i<w;i++)
for (j=-w;j<w;j++)
GrPlot(base,x+i,y+j);
}
}
public void GrPlot4(GrBitMap *base,I8 x,I8 y)
{ //Plot with base->brush
BoolU4 draw=TRUE;
if (x<0) draw=FALSE;
x+=base->win_tss->win_pixel_left;
if (x>base->win_tss->win_pixel_right) draw=FALSE;
if (y<0) draw=FALSE;
y+=base->win_tss->win_pixel_top;
if (y>base->win_tss->win_pixel_bottom) draw=FALSE;
if (x>=base->width) draw=FALSE;
if (y>=base->height) draw=FALSE;
if (draw) {
if (base->brush)
GrBlot(base,x,y,base->brush);
else
GrPlot0(base,x,y);
}
}
void GrLinePlot(GrBitMap *base,I8 x,I8 y,I8 z)
{
nounusedwarn z;
GrPlot(base,x,y);
}
public void GrLine(GrBitMap *base,I8 x1,I8 y1,I8 x2,I8 y2,I8 step=1,I8 start=0)
{
if (ClipLine(base,&x1,&y1,&x2,&y2))
Line(base,x1,y1,0,x2,y2,0,&GrLinePlot,step,start);
}
public void GrCircle(GrBitMap *base,I8 cx,I8 cy,I8 radius,
I8 step=1,double start_rad=0,double len_rad=pi2)
{
Circle(base,cx,cy,0,radius,&GrLinePlot,step,start_rad,len_rad);
}
public void GrEllipse(GrBitMap *base,
I8 cx,I8 cy,
I8 x_radius,I8 y_radius,
double rot_angle=0,
I8 step=1,
double start_rad=0,
double len_rad=pi2)
{
Ellipse(base,cx,cy,0,x_radius,y_radius,&GrLinePlot,rot_angle,step,start_rad,len_rad);
}
public void Gr2Bezier(GrBitMap *base,P3I4 *ctrl)
{
Bezier2(base,ctrl,&GrLinePlot);
}
public void Gr3Bezier(GrBitMap *base,P3I4 *ctrl)
{
Bezier3(base,ctrl,&GrLinePlot);
}
public void Gr2BSpline(GrBitMap *base,P3I4 *ctrl,I8 cnt,BoolU4 closed=FALSE)
{
BSpline2(base,ctrl,cnt,&GrLinePlot,closed);
}
public void Gr3BSpline(GrBitMap *base,P3I4 *ctrl,I8 cnt,BoolU4 closed=FALSE)
{
BSpline3(base,ctrl,cnt,&GrLinePlot,closed);
}
public void GrLine2(GrBitMap *base,I8 x1,I8 y1,I8 z1,I8 x2,I8 y2,I8 z2,I8 step=1,I8 start=0)
{ //transformation but not pen width
if (base->flags & BMF_TRANSFORMATION) {
GrRotate(base->r,&x1,&y1,&z1);
x1+=base->x;
y1+=base->y;
z1+=base->z;
GrRotate(base->r,&x2,&y2,&z2);
x2+=base->x;
y2+=base->y;
z2+=base->z;
}
if (ClipLine(base,&x1,&y1,&x2,&y2))
Line(base,x1,y1,0,x2,y2,0,&GrLinePlot,step,start);
}
void GrLine3Plot(GrBitMap *base,I8 x,I8 y,I8 z)
{
GrPlot3(base,x,y,z);
}
public void GrLine3(GrBitMap *base,I8 x1,I8 y1,I8 z1,I8 x2,I8 y2,I8 z2,I8 step=1,I8 start=0)
{ //transformation with pen width
U8 old_flags=base->flags;
if (base->flags & BMF_TRANSFORMATION) {
GrRotate(base->r,&x1,&y1,&z1);
x1+=base->x;
y1+=base->y;
z1+=base->z;
GrRotate(base->r,&x2,&y2,&z2);
x2+=base->x;
y2+=base->y;
z2+=base->z;
}
if (ClipLine(base,&x1,&y1,&x2,&y2)) {
base->flags&=~BMF_TRANSFORMATION;
Line(base,x1,y1,0,x2,y2,0,&GrLine3Plot,step,start);
base->flags=old_flags;
}
}
public void GrText3(GrBitMap *base,I8 x1,I8 y1,I8 z1,I1 *s)
{ //transformation
if (base->flags & BMF_TRANSFORMATION) {
GrRotate(base->r,&x1,&y1,&z1);
x1+=base->x;
y1+=base->y;
z1+=base->z;
}
GrText(base,x1,y1,s);
}
public void GrCircle3(GrBitMap *base,I8 cx,I8 cy,I8 cz,I8 radius,
I8 step=1,double start_rad=0,double len_rad=pi2)
{ //transformation with pen width
I8 x,y,z;
double m1,a1,m2;
if (base->flags & BMF_TRANSFORMATION) {
base->flags&=~BMF_TRANSFORMATION;
GrRotate(base->r,&cx,&cy,&cz);
cx+=base->x;
cy+=base->y;
cz+=base->z;
radius<<=24;
x=radius; y=0; z=0;
GrRotate(base->r,&x,&y,&z);
R2P(&m1,&a1,x,y);
x=0; y=radius; z=0;
GrRotate(base->r,&x,&y,&z);
m2=Sqrt(x*x+y*y);
Ellipse(base,cx,cy,cz,
m1/0x1000000,m2/0x1000000,
&GrLine3Plot,-a1,step,start_rad,len_rad);
base->flags|=BMF_TRANSFORMATION;
} else
Circle(base,cx,cy,cz,radius,&GrLine3Plot,step,start_rad,len_rad);
}
public void GrEllipse3(GrBitMap *base,
I8 cx,I8 cy,I8 cz,
I8 x_radius,I8 y_radius,
double rot_angle=0,
I8 step=1,
double start_rad=0,
double len_rad=pi2)
{
I8 x,y,z;
double m1,a1,m2,a2,s,c;
if (base->flags & BMF_TRANSFORMATION) {
base->flags&=~BMF_TRANSFORMATION;
GrRotate(base->r,&cx,&cy,&cz);
cx+=base->x;
cy+=base->y;
cz+=base->z;
c=Cos(rot_angle);
s=Sin(rot_angle);
x_radius<<=24;
y_radius<<=24;
x=x_radius*c;
y=x_radius*s;
z=0;
GrRotate(base->r,&x,&y,&z);
R2P(&m1,&a1,x,y);
x=-y_radius*s;
y=y_radius*c;
z=0;
GrRotate(base->r,&x,&y,&z);
R2P(&m2,&a2,x,y);
m2=m2*Abs(Sin(a2-a1));
Ellipse(base,cx,cy,cz,
m1/0x1000000,m2/0x1000000,&GrLine3Plot,-a1,step,start_rad,len_rad);
base->flags|=BMF_TRANSFORMATION;
} else
Ellipse(base,cx,cy,cz,x_radius,y_radius,&GrLine3Plot,rot_angle,step,start_rad,len_rad);
}
public I8 GrFloodFill3(GrBitMap *base,I8 x1,I8 y1,I8 z1,BoolU4 not_color=TRUE)
{ //transformation
I8 cnt,old_flags=base->flags;
if (base->flags & BMF_TRANSFORMATION) {
GrRotate(base->r,&x1,&y1,&z1);
x1+=base->x;
y1+=base->y;
z1+=base->z;
}
base->flags&=~BMF_TRANSFORMATION;
cnt=GrFloodFill(base,x1,y1,not_color);
base->flags=old_flags;
return cnt;
}
public void GrBox3(GrBitMap *base,I8 x,I8 y,I8 z,I8 w,I8 h)
{ //Clipping and transformation
I8 x2,y2,z2,x3,y3,z3;
GrBitMap *old_brush=base->brush;
if (base->flags & BMF_TRANSFORMATION) {
base->brush=NULL;
x2=x+w; y2=y; z2=z;
x3=x; y3=y+h; z3=z;
GrRotate(base->r,&x,&y,&z);
x+=base->x;
y+=base->y;
z+=base->z;
GrRotate(base->r,&x2,&y2,&z2);
x2+=base->x;
y2+=base->y;
z2+=base->z;
GrRotate(base->r,&x3,&y3,&z3);
x3+=base->x;
y3+=base->y;
z3+=base->z;
Box(base,x,y,z,x2,y2,z2,x3,y3,z3,&GrLinePlot);
base->brush=old_brush;
} else
GrBox(base,x,y,w,h);
}
public BoolU8 GrBlot3(GrBitMap *base,I8 x1,I8 y1,I8 z1,GrBitMap *img)
{ //Clipping and transformation
I8 reg i,j,w=img->width,h=img->height,old_color=base->color,reg color,
d1,dx1,dy1,dz1,
reg d2,dx2,dy2,dz2,
adx1,ady1,adz1,
adx2,ady2,adz2,
x2,y2,z2,x3,y3,z3,
dw,reg dh,x,y;
GrBitMap *old_brush=base->brush;
if (base->flags & BMF_TRANSFORMATION) {
x2=x1+w; y2=y1; z2=z1;
x3=x1; y3=y1+h; z3=z1;
GrRotate(base->r,&x1,&y1,&z1);
x1+=base->x;
y1+=base->y;
z1+=base->z;
GrRotate(base->r,&x2,&y2,&z2);
x2+=base->x;
y2+=base->y;
z2+=base->z;
GrRotate(base->r,&x3,&y3,&z3);
x3+=base->x;
y3+=base->y;
z3+=base->z;
dx1=x2-x1; dy1=y2-y1; dz1=z2-z1;
dx2=x3-x1; dy2=y3-y1; dz2=z3-z1;
adx1=AbsI8(dx1); ady1=AbsI8(dy1); adz1=AbsI8(dz1);
adx2=AbsI8(dx2); ady2=AbsI8(dy2); adz2=AbsI8(dz2);
if (adx1>=ady1)
d1=(adx1>=adz1) ? adx1:adz1;
else
d1=(ady1>=adz1) ? ady1:adz1;
d1<<=1;
if (d1) {
dx1=dx1<<32/d1;
dy1=dy1<<32/d1;
dz1=dz1<<32/d1;
} else
return FALSE;
if (adx2>=ady2)
d2=(adx2>=adz2) ? adx2:adz2;
else
d2=(ady2>=adz2) ? ady2:adz2;
d2<<=1;
if (d2) {
dx2=dx2<<32/d2;
dy2=dy2<<32/d2;
dz2=dz2<<32/d2;
} else
return FALSE;
base->brush=NULL;
x=0;y=0;
dw=w<<32/d1;
dh=h<<32/d2;
x1<<=32; y1<<=32; z1<<=32;
for (j=0;j<=d1;j++) {
x2=x1; y2=y1; z2=z1;
y=0;
for (i=0;i<=d2;i++) {
color=GrPeek(img,x.i4[1],y.i4[1]);
if (color>=0 &&
(old_color.u1[3]!=ROPB_TRANSPARENT ||
color&0xFFFFFF!=img->bkcolor&0xFFFFFF)) {
base->color=old_color&0xFF000000+color;
GrPlot(base,x2.i4[1],y2.i4[1]);
}
x2+=dx2; y2+=dy2; z2+=dz2;
y+=dh;
}
x1+=dx1; y1+=dy1; z1+=dz1;
x+=dw;
}
base->color=old_color;
base->brush=old_brush;
return TRUE; //TODO: check off screen
} else
return GrBlot(base,x1,y1,img);
}
public void Gr2Bezier3(GrBitMap *base,P3I4 *ctrl)
{
I8 i,x,y,z;
P3I4 *ctrl2;
if (base->flags & BMF_TRANSFORMATION) {
ctrl2=MAlloc(sizeof(P3I4)*3);
for (i=0;i<3;i++) {
x=ctrl[i].x;
y=ctrl[i].y;
z=ctrl[i].z;
GrRotate(base->r,&x,&y,&z);
ctrl2[i].x=x+base->x;
ctrl2[i].y=y+base->y;
ctrl2[i].z=z+base->z;
}
base->flags&=~BMF_TRANSFORMATION;
Bezier2(base,ctrl2,&GrLine3Plot);
base->flags|=BMF_TRANSFORMATION;
Free(ctrl2);
} else
Bezier2(base,ctrl,&GrLine3Plot);
}
public void Gr3Bezier3(GrBitMap *base,P3I4 *ctrl)
{
I8 i,x,y,z;
P3I4 *ctrl2;
if (base->flags & BMF_TRANSFORMATION) {
ctrl2=MAlloc(sizeof(P3I4)*4);
for (i=0;i<4;i++) {
x=ctrl[i].x;
y=ctrl[i].y;
z=ctrl[i].z;
GrRotate(base->r,&x,&y,&z);
ctrl2[i].x=x+base->x;
ctrl2[i].y=y+base->y;
ctrl2[i].z=z+base->z;
}
base->flags&=~BMF_TRANSFORMATION;
Bezier3(base,ctrl2,&GrLine3Plot);
base->flags|=BMF_TRANSFORMATION;
Free(ctrl2);
} else
Bezier3(base,ctrl,&GrLine3Plot);
}
public void Gr2BSpline3(GrBitMap *base,P3I4 *ctrl,I8 cnt,BoolU4 closed=FALSE)
{
I8 i,x,y,z;
P3I4 *ctrl2;
if (base->flags & BMF_TRANSFORMATION) {
ctrl2=MAlloc(sizeof(P3I4)*cnt);
for (i=0;i<cnt;i++) {
x=ctrl[i].x;
y=ctrl[i].y;
z=ctrl[i].z;
GrRotate(base->r,&x,&y,&z);
ctrl2[i].x=x+base->x;
ctrl2[i].y=y+base->y;
ctrl2[i].z=z+base->z;
}
base->flags&=~BMF_TRANSFORMATION;
BSpline2(base,ctrl2,cnt,&GrLine3Plot,closed);
base->flags|=BMF_TRANSFORMATION;
Free(ctrl2);
} else
BSpline2(base,ctrl,cnt,&GrLine3Plot,closed);
}
public void Gr3BSpline3(GrBitMap *base,P3I4 *ctrl,I8 cnt,BoolU4 closed=FALSE)
{
I8 i,x,y,z;
P3I4 *ctrl2;
if (base->flags & BMF_TRANSFORMATION) {
ctrl2=MAlloc(sizeof(P3I4)*cnt);
for (i=0;i<cnt;i++) {
x=ctrl[i].x;
y=ctrl[i].y;
z=ctrl[i].z;
GrRotate(base->r,&x,&y,&z);
ctrl2[i].x=x+base->x;
ctrl2[i].y=y+base->y;
ctrl2[i].z=z+base->z;
}
base->flags&=~BMF_TRANSFORMATION;
BSpline3(base,ctrl2,cnt,&GrLine3Plot,closed);
base->flags|=BMF_TRANSFORMATION;
Free(ctrl2);
} else
BSpline3(base,ctrl,cnt,&GrLine3Plot,closed);
}
void GrLinePlot4(GrBitMap *base,I8 x,I8 y,I8 z)
{
nounusedwarn z;
GrPlot4(base,x,y);
}
public void GrLine4(GrBitMap *base,I8 x1,I8 y1,I8 x2,I8 y2,I8 step=1,I8 start=0)
{ //Line with base->brush
if (ClipLine(base,&x1,&y1,&x2,&y2))
Line(base,x1,y1,0,x2,y2,0,&GrLinePlot4,step,start);
}
public void GrSpeedLine(GrBitMap *base,I8 x1,I8 y1,I8 x2,I8 y2,double speed)
{
U8 old_flags=base->flags;
I8 old_pen_width=base->pen_width;
if (ClipLine(base,&x1,&y1,&x2,&y2)) {
base->pen_width=base->speedline_scale*speed;
base->flags&=~BMF_TRANSFORMATION;
GrLine3(base,x1,y1,0,x2,y2,0);
base->flags=old_flags;
base->pen_width=old_pen_width;
}
}
public void GrSpeedLine2(GrBitMap *base,I8 x1,I8 y1,I8 z1,I8 x2,I8 y2,I8 z2,double speed)
{ //transformation but not pen width
U8 old_flags=base->flags;
if (base->flags & BMF_TRANSFORMATION) {
GrRotate(base->r,&x1,&y1,&z1);
x1+=base->x;
y1+=base->y;
z1+=base->z;
GrRotate(base->r,&x2,&y2,&z2);
x2+=base->x;
y2+=base->y;
z2+=base->z;
}
base->flags&=~BMF_TRANSFORMATION;
GrSpeedLine(base,x1,y1,x2,y2,speed);
base->flags=old_flags;
}
Binary file not shown.
-593
View File
@@ -1,593 +0,0 @@
IMPORT sys_update_screen_tss;
ALIGN 8,OC_NOP
NORMAL_KEY_SCAN_DECODE_TABLE::
DU1 0,CH_ESC,"1234567890-=",8,9;
DU1 "qwertyuiop[]",CH_CR,0,"as";
DU1 "dfghjkl;'\`",0,"\\zxcv";
DU1 "bnm,./",0,'*',0,CH_SPACE,0,0,0,0,0,0;
DU1 0,0,0,0,0,0,0,0,0,0,'-',0,0,0,'+',0;
SHIFT_KEY_SCAN_DECODE_TABLE::
DU1 0,CH_ESC,"!@#$$%^&*()_+",8,9;
DU1 "QWERTYUIOP{}",CH_CR,0,"AS";
DU1 "DFGHJKL:\"~",0,"|ZXCV";
DU1 "BNM<>?",0,'*',0,CH_SHIFT_SPACE,0,0,0,0,0,0;
DU1 0,0,0,0,0,0,0,0,0,0,'-',0,0,0,'+',0;
CTRL_KEY_SCAN_DECODE_TABLE::
DU1 0,CH_ESC,"1234567890-=",8,9;
DU1 17,23,5,18,20,25,21,9,15,16,"[]",CH_CR,0,1,19;
DU1 4,6,7,8,CH_LINE_FEED,11,12,";'\`",0,"\\",26,24,3,22;
DU1 2,14,13,",./",0,'*',0,CH_SPACE,0,0,0,0,0,0;
DU1 0,0,0,0,0,0,0,0,0,0,'-',0,0,0,'+',0;
ALIGN 8,OC_NOP
////**************************PROCEDURE*************************
ALIGN 8,OC_NOP
CP_PLOT_SCREEN_I1::
PUSH RBP
MOV RBP,RSP
MOV RBX,U8 SF_PARAM2[RBP]
MOV RAX,U8 SF_PARAM3[RBP]
OR RBX,RBX
JS @@100
OR RAX,RAX
JS @@100
CMP RBX,TEXT_COLS
JGE @@100
CMP RAX,TEXT_ROWS
JGE @@100
IMUL2 RAX,TEXT_COLS
ADD RBX,RAX
SHL RBX,2
ADD RBX,U8 [SYS_TEXTBASE]
MOV RAX,U8 SF_PARAM1[RBP]
MOV U4 [RBX],EAX
POP RBP
MOV RAX,1
RET
@@100: POP RBP
XOR EAX,EAX
RET
////**************************PROCEDURE*************************
ALIGN 8,OC_NOP
CP_PLOT_WIN_I1::
PUSH RBP
MOV RBP,RSP
MOV RBX,U8 SF_PARAM3[RBP]
MOV RAX,U8 SF_PARAM4[RBP]
MOV RCX,U8 SF_PARAM1[RBP]
OR RBX,RBX
JS @@100
ADD RBX,U8 TSS_WIN_LEFT[RCX]
CMP RBX,U8 TSS_WIN_RIGHT[RCX]
JG @@100
OR RBX,RBX
JS @@100
CMP RBX,TEXT_COLS
JGE @@100
OR RAX,RAX
JS @@100
ADD RAX,U8 TSS_WIN_TOP[RCX]
CMP RAX,U8 TSS_WIN_BOTTOM[RCX]
JG @@100
OR RAX,RAX
JS @@100
CMP RAX,TEXT_ROWS
JGE @@100
IMUL2 RAX,TEXT_COLS
ADD RBX,RAX
SHL RBX,2
ADD RBX,U8 [SYS_TEXTBASE]
MOV RAX,U8 SF_PARAM2[RBP]
MOV U4 [RBX],EAX
POP RBP
MOV RAX,1
RET
@@100: POP RBP
XOR EAX,EAX
RET
////**************************PROCEDURE*************************
ALIGN 8,OC_NOP
/*
BoolU4 PlotWinStr2(TssStruct *tss,I1 *s,I8 len,
U8 attr,I8 x,I8 y)
*/
ALIGN 8,OC_NOP
CP_PLOT_WIN_STR2::
PUSH RBP
MOV RBP,RSP
MOV R10,U8 [SYS_TEXTBASE]
PUSH RSI
PUSH RDI
MOV RBX,U8 SF_PARAM1[RBP]
MOV RSI,U8 SF_PARAM2[RBP]
MOV RDI,U8 SF_PARAM5[RBP]
MOV RCX,U8 SF_PARAM3[RBP]
OR RDI,RDI
JNS @@10
ADD RCX,RDI
SUB RSI,RDI
XOR EDI,EDI
@@10: ADD RDI,U8 TSS_WIN_LEFT[RBX]
MOV RDX,RCX
ADD RDX,RDI
DEC RDX
CMP RDX,U8 TSS_WIN_RIGHT[RBX]
JLE @@11
MOV RAX,RDX
SUB RAX,U8 TSS_WIN_RIGHT[RBX]
SUB RDX,RAX
SUB RCX,RAX
@@11: OR RDI,RDI
JNS @@12
ADD RCX,RDI
SUB RSI,RDI
XOR EDI,EDI
@@12: INC RDX
SUB RDX,TEXT_COLS
JLE @@13
SUB RCX,RDX
@@13: CMP RCX,1
JL @@100
MOV RAX,U8 SF_PARAM6[RBP]
OR RAX,RAX
JS @@100
ADD RAX,U8 TSS_WIN_TOP[RBX]
CMP RAX,U8 TSS_WIN_BOTTOM[RBX]
JG @@100
OR RAX,RAX
JS @@100
CMP RAX,TEXT_ROWS
JGE @@100
IMUL2 RAX,TEXT_COLS
ADD RDI,RAX
SHL RDI,2
ADD RDI,R10
MOV RAX,U8 SF_PARAM4[RBP]
@@20: LODSB
STOSD
LOOP @@20
POP RDI
POP RSI
POP RBP
MOV RAX,TRUE
RET
@@100: POP RDI
POP RSI
POP RBP
XOR EAX,EAX
RET
////**************************PROCEDURE*************************
ALIGN 8,OC_NOP
/*
BoolU4 PlotAttr(TssStruct *tss,I8 len,
U8 attr,I8 x,I8 y)
*/
ALIGN 8,OC_NOP
CP_PLOT_ATTR::
PUSH RBP
MOV RBP,RSP
MOV R10,U8 [SYS_TEXTBASE]
PUSH RSI
PUSH RDI
MOV RBX,U8 SF_PARAM1[RBP]
MOV RDI,U8 SF_PARAM4[RBP]
MOV RCX,U8 SF_PARAM2[RBP]
OR RDI,RDI
JNS @@10
ADD RCX,RDI
XOR EDI,EDI
@@10: ADD RDI,U8 TSS_WIN_LEFT[RBX]
MOV RDX,RCX
ADD RDX,RDI
DEC RDX
CMP RDX,U8 TSS_WIN_RIGHT[RBX]
JLE @@11
MOV RAX,RDX
SUB RAX,U8 TSS_WIN_RIGHT[RBX]
SUB RDX,RAX
SUB RCX,RAX
@@11: OR RDI,RDI
JNS @@12
ADD RCX,RDI
XOR EDI,EDI
@@12: INC RDX
SUB RDX,TEXT_COLS
JLE @@13
SUB RCX,RDX
@@13: CMP RCX,1
JL @@100
MOV RAX,U8 SF_PARAM5[RBP]
OR RAX,RAX
JS @@100
ADD RAX,U8 TSS_WIN_TOP[RBX]
CMP RAX,U8 TSS_WIN_BOTTOM[RBX]
JG @@100
OR RAX,RAX
JS @@100
CMP RAX,TEXT_ROWS
JGE @@100
IMUL2 RAX,TEXT_COLS
ADD RDI,RAX
SHL RDI,2
ADD RDI,R10
MOV RBX,U8 SF_PARAM3[RBP]
MOV RSI,RDI
@@20: LODSD
OR AL,AL
JNZ @@21
MOV RAX,RBX
STOSD
LOOP @@20
@@21: POP RDI
POP RSI
POP RBP
MOV RAX,TRUE
RET
@@100: POP RDI
POP RSI
POP RBP
XOR EAX,EAX
RET
////**************************PROCEDURE*************************
ALIGN 8,OC_NOP
CP_PLOT_BORDER_I1::
PUSH RBP
MOV RBP,RSP
MOV R10,U8 [SYS_TEXTBASE]
MOV RBX,U8 SF_PARAM3[RBP]
MOV RAX,U8 SF_PARAM4[RBP]
MOV RCX,U8 SF_PARAM1[RBP]
MOV RDX,-1
CMP RBX,RDX
JL @@100
ADD RBX,U8 TSS_WIN_LEFT[RCX]
MOV RDX,U8 TSS_WIN_RIGHT[RCX]
INC RDX
CMP RBX,RDX
JG @@100
OR RBX,RBX
JS @@100
CMP RBX,TEXT_COLS
JGE @@100
MOV RDX,-1
CMP RAX,RDX
JL @@100
ADD RAX,U8 TSS_WIN_TOP[RCX]
MOV RDX,U8 TSS_WIN_BOTTOM[RCX]
INC RDX
CMP RAX,RDX
JG @@100
OR RAX,RAX
JS @@100
CMP RAX,TEXT_ROWS
JGE @@100
IMUL2 RAX,TEXT_COLS
ADD RBX,RAX
SHL RBX,2
ADD RBX,R10
MOV RAX,U8 SF_PARAM2[RBP]
MOV U4 [RBX],EAX
POP RBP
MOV RAX,TRUE
RET
@@100: POP RBP
XOR EAX,EAX
RET
////**************************PROCEDURE*************************
ALIGN 8,OC_NOP
/*
GrXorLineU8(&dst3,&src,&src2,d5b,vga_image,reverse_table);
for (col=0;col<d5a;col++) {
*dst3=*src^*src2;
dst3+=8;
src+=8;
src2+=8;
}
*/
GR_XOR_LINE_U8::
PUSH RBP
MOV RBP,RSP
PUSH RSI
PUSH RDI
MOV RAX,U8 SF_PARAM2[RBP]
MOV RDX,U8 [RAX]
MOV RAX,U8 SF_PARAM3[RBP]
MOV RSI,U8 [RAX] //rsi=src2
MOV RBX,U8 SF_PARAM6[RBP] //rbx=reverse table
MOV RCX,U8 SF_PARAM4[RBP] //rcx=d5
MOV RAX,U8 SF_PARAM5[RBP]
MOV RDI,U8 [RAX] //rdi=vga image
MOV RAX,U8 SF_PARAM1[RBP]
MOV R8,U8 [RAX] //rbp=vga dst
@@5: MOV RAX,U8 [RDX]
XOR RAX,U8 [RSI]
CMP U8 [RDI],RAX
JE @@7
MOV U8 [RDI],RAX
XLATB
ROR RAX,8
XLATB
ROR RAX,8
XLATB
ROR RAX,8
XLATB
ROR RAX,8
XLATB
ROR RAX,8
XLATB
ROR RAX,8
XLATB
ROR RAX,8
XLATB
ROR RAX,8
MOV U8 [R8],RAX
@@7: ADD RDI,8
ADD R8,8
ADD RSI,8
ADD RDX,8
LOOP @@5
MOV RAX,U8 SF_PARAM1[RBP]
MOV U8 [RAX],R8
MOV RAX,U8 SF_PARAM5[RBP]
MOV U8 [RAX],RDI
MOV RAX,U8 SF_PARAM3[RBP]
MOV U8 [RAX],RSI
MOV RAX,U8 SF_PARAM2[RBP]
MOV U8 [RAX],RDX
POP RDI
POP RSI
POP RBP
RET
////**************************PROCEDURE*************************
GR_XOR_BITMAP_U8::
PUSH RBP
MOV RBP,RSP
PUSH RSI
PUSH RDI
MOV RSI,SF_PARAM2[RBP]
MOV RDI,SF_PARAM1[RBP]
MOV RCX,SF_PARAM3[RBP]
@@1: LODSQ
XOR RAX,U8 [RDI]
STOSQ
LOOP @@1
POP RDI
POP RSI
POP RBP
RET
////**************************PROCEDURE*************************
ALIGN 8,OC_NOP
/*
GrPlotChar(font_ptr,cur_ch.u1[1],&dst2,d1,d2);
for (plane=0x01;plane!=0x10;plane<<=1) {
font_ptr2=font_ptr;
if (cur_ch.u1[1] & plane) {
for (ch_line=0;ch_line<FONT_HEIGHT;ch_line++) {
*dst2|=*font_ptr2++;
dst2+=d1;
}
} else {
for (ch_line=0;ch_line<FONT_HEIGHT;ch_line++) {
*dst2&=~*font_ptr2++;
dst2+=d1;
}
}
dst2+=d2;
}
*/
GR_PLOT_CHAR::
PUSH RBP
MOV RBP,RSP
PUSH RSI
PUSH RDI
MOV RDX,1 //EDX=plane
MOV RBX,U8 SF_PARAM4[RBP] //RBX=d1
MOV RAX,U8 SF_PARAM3[RBP]
MOV RDI,U8 [RAX] //RDI=dst2
@@10: MOV RSI,U8 SF_PARAM1[RBP] //RSI=font_ptr2
TEST U8 SF_PARAM2[RBP],RDX
JZ @@30
@@20: LODSQ
OR U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
OR U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
OR U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
OR U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
OR U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
OR U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
OR U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
OR U1 [RDI],AL
ADD RDI,RBX
JMP @@40
@@30: LODSQ
NOT RAX
AND U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
AND U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
AND U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
AND U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
AND U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
AND U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
AND U1 [RDI],AL
ADD RDI,RBX
ROR RAX,8
AND U1 [RDI],AL
ADD RDI,RBX
@@40: ADD RDI,U8 SF_PARAM5[RBP]
SHL1 RDX
CMP RDX,0x10
JNE U4 @@10
MOV RAX,U8 SF_PARAM3[RBP]
MOV U8 [RAX],RDI
POP RDI
POP RSI
POP RBP
RET
////**************************PROCEDURE*************************
ALIGN 8,OC_NOP
/*
GrPlotBackground(cur_ch.u1[1],&dst,d1,d2);
for (plane=0x10;plane!=0x100;plane=plane<<1) {
d=(cur_ch.u1[1] & plane) ? 0xFF:0x00;
for (ch_line=0;ch_line<FONT_HEIGHT;ch_line++) {
*dst=d;
dst+=d1;
}
dst+=d2;
}
*/
GR_PLOT_BACKGROUND::
PUSH RBP
MOV RBP,RSP
PUSH RDI
MOV RDX,0x10 //EDX=plane
MOV RBX,U8 SF_PARAM3[RBP] //RBX=d1
MOV RAX,U8 SF_PARAM2[RBP] //RDI=dst
MOV RDI,U8 [RAX] //RDI=dst
@@10: XOR EAX,EAX
TEST U8 SF_PARAM1[RBP],RDX
JZ @@20
DEC RAX
@@20: MOV U1 [RDI],AL
ADD RDI,RBX
MOV U1 [RDI],AL
ADD RDI,RBX
MOV U1 [RDI],AL
ADD RDI,RBX
MOV U1 [RDI],AL
ADD RDI,RBX
MOV U1 [RDI],AL
ADD RDI,RBX
MOV U1 [RDI],AL
ADD RDI,RBX
MOV U1 [RDI],AL
ADD RDI,RBX
MOV U1 [RDI],AL
ADD RDI,RBX
ADD RDI,U8 SF_PARAM4[RBP]
SHL1 RDX
CMP RDX,0x100
JNE @@10
MOV RAX,U8 SF_PARAM2[RBP]
MOV U8 [RAX],RDI
POP RDI
POP RBP
RET
/*****
BoolU4 IsPixelCovered(TssStruct *tss,I8 x,I8 y)
{
if (tss==sys_update_screen_tss) return FALSE;
tss=tss->next_tss;
while (tss!=sys_update_screen_tss) {
if (Bt(&tss->crt_flags,CRTf_SHOW)) { //no short circuit logic
if (x>=tss->win_border_pixel_left) {
if (x<=tss->win_border_pixel_right) {
if (y>=tss->win_border_pixel_top) {
if (y<=tss->win_border_pixel_bottom) {
return TRUE;
}}}}}
tss=tss->next_tss;
}
return FALSE;
}
*********/
CP_IS_PIXEL_COVERED::
PUSH RBP
MOV RBP,RSP
MOV RAX,U8 SF_PARAM1[RBP]
MOV RBX,U8 SF_PARAM2[RBP]
MOV RCX,U8 SF_PARAM3[RBP]
MOV RDX,U8 [sys_update_screen_tss]
BT U4 TSS_CRT_FLAGS[RAX],CRTf_ON_TOP
JC @@100
PUSHFD
CLI
MOV RAX,U8 TSS_NEXT_TSS[RAX]
JMP @@30
@@1: BT U4 TSS_CRT_FLAGS[RAX],CRTf_SHOW
JNC @@20
CMP RBX,U8 TSS_WIN_BORDER_PIXEL_LEFT[RAX]
JL @@20
CMP RCX,U8 TSS_WIN_BORDER_PIXEL_TOP[RAX]
JL @@20
CMP RBX,U8 TSS_WIN_BORDER_PIXEL_RIGHT[RAX]
JG @@20
CMP RCX,U8 TSS_WIN_BORDER_PIXEL_BOTTOM[RAX]
JG @@20
POPFD
MOV RAX,TRUE
POP RBP
RET
@@20: MOV RAX,U8 TSS_NEXT_TSS[RAX]
@@30: CMP RAX,RDX
JNE @@1
POPFD
@@100: XOR EAX,EAX
POP RBP
RET
Binary file not shown.
-19
View File
@@ -1,19 +0,0 @@
#help_index "Graphics"
public LTextern CP_IS_PIXEL_COVERED BoolU4 IsPixelCovered(TssStruct *tss,I8 x,I8 y);
LTextern GR_XOR_LINE_U8 void GrXorLineU8(U8 **dst3,U8 **src,U8 **src2,U8 d5b,
void **vga,U1 *reverse_bit_tab);
LTextern GR_XOR_BITMAP_U8 void GrXorBitMapU8(U8 *b1,U8 *b2,U8 cnt);
LTextern GR_PLOT_CHAR void GrPlotChar(U1 *font_ptr,U1 attr,U1 **dst2,U8 d1,U8 d2);
LTextern GR_PLOT_BACKGROUND void GrPlotBackground(U1 attr,U1 **dst,U8 d1,U8 d2);
//The callback is void Plot(aux_data,x,y,z)
#help_index "Graphics/Char"
public LTextern CP_PLOT_SCREEN_I1 BoolU4 PlotScreenChar(U8 w,I8 x,I8 y);
public LTextern CP_PLOT_WIN_I1 BoolU4 PlotWinChar(TssStruct *tss,U8 w,I8 x,I8 y);
public LTextern CP_PLOT_WIN_STR2 BoolU4 PlotWinStr2(
TssStruct *tss,I1 *s,I8 len,U8 attr,I8 x,I8 y);
public LTextern CP_PLOT_ATTR BoolU4 PlotWinAttr(
TssStruct *tss,I8 len,U8 attr,I8 x,I8 y);
public LTextern CP_PLOT_BORDER_I1 BoolU4 PlotBorderChar(TssStruct *tss,U8 w,I8 x,I8 y);
#help_index ""
Binary file not shown.
Binary file not shown.
-397
View File
@@ -1,397 +0,0 @@
#help_index "Hash/Reports"
class HashRepStruct
{
SysHashEntry *h;
I1 *index;
};
I8 CompareHashEntries(HashRepStruct *h1,HashRepStruct *h2)
{
return StrCmp(h1->h->str,h2->h->str);
}
I8 CompareHashEntries2(HashRepStruct *h1,HashRepStruct *h2)
{
ClassStruct *tempc1=h1->h,*tempc2=h2->h;
I8 i1=0,i2=0;
if (tempc1->type & HTT_FUNCTION)
i1=tempc1->executable_address;
if (tempc2->type & HTT_FUNCTION)
i2=tempc2->executable_address;
return i1-i2;
}
I8 HelpIndexCnt(I1 *ptr,I1 *index)
{
I1 cnt=0,ch;
I8 index_len=StrLen(index);
while (*ptr) {
if (!StrNCmp(ptr,index,index_len))
cnt++;
while (ch=*ptr++)
if (ch==';')
break;
if (!ch)
ptr--;
}
return cnt;
}
I1 *HelpIndexStr(I1 **ptr_,I1 *index)
{
I1 *ptr=*ptr_,*ptr2,ch,*result;
I8 index_len=StrLen(index);
while (*ptr) {
ptr2=ptr;
while (ch=*ptr++)
if (ch==';')
break;
if (!ch)
ptr--;
*ptr_=ptr;
if (!StrNCmp(ptr2,index,index_len)) {
if (ch==';')
ptr--;
*ptr=0;
result=NewStr(ptr2);
*ptr=ch;
return result;
}
}
return NULL;
}
I8 CompareHashEntries3(HashRepStruct *h1,HashRepStruct *h2)
{
I8 i,i1=0,i2=0;
i=StrCmp(h1->index,h2->index);
if (i)
return i;
else {
if (h1->h->type&HTT_HELP_FILE)
i1=1;
if (h2->h->type&HTT_HELP_FILE)
i2=1;
i=i2-i1;
if (i)
return i;
else
return StrCmp(h1->h->str,h2->h->str);
}
}
//Possible choices for first parameter, "h" include
// "adam_tss->hash_table"
// "Fs->hash_table"
public void HashRep(SysHashTable *h=NULL,
U8 mask=HTT_ALL,I1 *outname=NULL,I1 *flags=NULL,I1 mapfile_drive=0,I1 *index=NULL,
Ltf *l_=NULL)
{
SysHashTable *tempht;
SysHashEntry *ptr,*temph;
HashRepStruct *list;
U8 cnt,i,j,k,size,f=0;
I1 buf[512],*buf4,*last_index=NewStr(""),*cur_index;
Ltf *l,*l1;
BoolU4 recurse,publics,map;
LtfBinEntry *tempb;
DbgInfo *dbg;
BoolU4 old_preempt=Preempt(OFF);
GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),"+r+p");
GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),flags);
recurse=Bt(&f,FUf_RECURSE);
publics=Bt(&f,FUf_PUBLIC);
map =Bt(&f,FUf_MAP);
if (!h) h=Fs->hash_table;
if (outname) {
l=LtfNew;
l->flags|=LTFF_NO_CURSOR;
StrCpy(l->filename.name,outname);
} else
l=NULL;
if (l_)
l=l_;
cnt=0;
tempht=h;
while (tempht) {
for (i=0;i<=tempht->mask;i++) {
temph=tempht->body[i];
while (temph) {
if (!(temph->type & (HTT_IMPORT | HTT_PRIVATE)) &&
temph->type & mask &&
(temph->type & HTT_PUBLIC || !publics))
if (!index)
cnt++;
else
if (cur_index=temph->index)
cnt+=HelpIndexCnt(cur_index,index);
temph=temph->next;
}
}
if (recurse)
tempht=tempht->next;
else
break;
}
if (!cnt) goto end_hash;
list=MAllocZ(cnt*sizeof(HashRepStruct));
j=0;
tempht=h;
while (tempht) {
for (i=0;i<=tempht->mask;i++) {
temph=tempht->body[i];
while (temph) {
if (!(temph->type & (HTT_IMPORT | HTT_PRIVATE)) &&
temph->type & mask &&
(temph->type & HTT_PUBLIC || !publics))
if (!index)
list[j++].h=temph;
else
if (cur_index=temph->index)
if (k=HelpIndexCnt(cur_index,index)) {
while (k--) {
list[j].index=HelpIndexStr(&cur_index,index);
list[j++].h=temph;
}
}
temph=temph->next;
}
}
if (recurse)
tempht=tempht->next;
else
break;
}
Preempt(old_preempt);
if (map)
QSort(list,cnt,sizeof(HashRepStruct),&CompareHashEntries2);
else if (index)
QSort(list,cnt,sizeof(HashRepStruct),&CompareHashEntries3);
else
QSort(list,cnt,sizeof(HashRepStruct),&CompareHashEntries);
for (i=0;i<cnt;i++) {
ptr=list[i].h;
dbg=NULL;
if (index)
if (cur_index=list[i].index) {
if (StrCmp(cur_index,last_index)) {
Free(last_index);
last_index=NewStr(cur_index);
if (l)
LtfPrintF(l,"$$FG,GREEN$$%s$$FG$$\r\n",cur_index);
else
PrintF("$$FG,GREEN$$%s$$FG$$\r\n",cur_index);
}
}
if (index && ptr->type & HTT_HELP_FILE) {
if (l) {
l1=LtfRead(ptr->str);
EditInsertLtf(l,l1);
LtfDel(l1);
} else
Type(ptr->str);
} else {
if (ptr->source_link) {
buf4=NewStr(ptr->source_link);
if (mapfile_drive && StrLen(buf4)>3)
buf4[3]=mapfile_drive;
if (l && ptr->type & HTT_FUNCTION) {
dbg=ptr><(ClassStruct *)->debug;
if (dbg) {
size=offset(DbgInfo.body)+
sizeof(void *)*
(dbg->max_line-dbg->min_line+2);
if (size>MSize(dbg)) {
coutln "Corrupt Map Entry";
dbg=NULL;
} else {
if (dbg->min_line<=dbg->max_line) {
tempb=MAllocZ(sizeof(LtfBinEntry));
tempb->type=LTFBT_GENERIC_DATA;
tempb->size=size;
tempb->data=MAlloc(size);
MemCpy(tempb->data,dbg,size);
tempb->num=l->cur_bin_num;
tempb->use_cnt=1;
InsQue(tempb,l->bin_root.last);
} else
dbg=NULL;
}
}
}
if (dbg)
SPrintF(buf,"$$LK+BI,\"%-18s \",\"%s\",%d$$",
ptr->str,buf4,l->cur_bin_num++);
else
SPrintF(buf,"$$LK,\"%-18s \",\"%s\"$$",
ptr->str,buf4);
Free(buf4);
} else
SPrintF(buf,"%-18ts ",ptr->str);
if (l)
LtfPutSExt(l,buf);
else
PutS(buf);
if (!index) {
if (ptr->type & HTT_FUNCTION)
SPrintF(buf,"%08X",ptr><(ClassStruct *)->executable_address);
else if (ptr->type & HTT_STR_CONST)
SPrintF(buf,"%-8tQ",ptr><(StrConstStruct *)->data);
else if (ptr->type & HTT_GLBL_VAR)
SPrintF(buf,"%08X",ptr><(GlblVarStruct *)->data_address);
else if (ptr->type & HTT_SYSTEXT)
SPrintF(buf,"%-8tQ %04tX",ptr->user_data0,ptr->user_data1);
else
SPrintF(buf,"%08X",ptr->user_data0);
SPrintF(buf+StrLen(buf)," %04X ",ptr->use_cnt);
} else
*buf=0;
k=ptr->type;
if (publics)
k&=~HTT_PUBLIC;
for (j=0;j<32;j++)
if (Bt(&k,j))
SPrintF(buf+StrLen(buf),"%Z ",j,"ST_HTT_TYPES");
StrCat(buf,"\r\n");
if (l)
LtfPutSExt(l,buf);
else
PutS(buf);
}
Free(list[i].index);
}
Free(list);
end_hash:
if (l) {
if (!l_) {
LtfWrite(l);
LtfDel(l);
} else {
if (l->dummy.next==l)
LtfPutSExt(l,"No Match");
}
}
Free(last_index);
}
public void HFunsRep(I1 *flags="",I1 *index=NULL)
{
HashRep(Fs->hash_table,HTT_FUNCTION,NULL,flags,0,index);
}
public void HMapRep(I1 *flags="-p+m",I1 *index=NULL)
{
HashRep(Fs->hash_table,HTT_FUNCTION,NULL,flags,0,index);
}
public void HVarsRep(I1 *flags="",I1 *index=NULL)
{
HashRep(Fs->hash_table,HTT_GLBL_VAR,NULL,flags,0,index);
}
public void HClassesRep(I1 *flags="-p",I1 *index=NULL)
{
HashRep(Fs->hash_table,HTT_CLASS,NULL,flags,0,index);
}
public void HDefinesRep(I1 *flags="-p",I1 *index=NULL)
{
HashRep(Fs->hash_table,HTT_STR_CONST,NULL,flags,0,index);
}
public void HSymsRep(I1 *flags="-p",I1 *index=NULL)
{
HashRep(Fs->hash_table,HTT_SYS_SYMBOL,NULL,flags,0,index);
}
public void HSysTextsRep(I1 *flags="-p",I1 *index=NULL)
{
HashRep(Fs->hash_table,HTT_SYSTEXT,NULL,flags,0,index);
}
public void HAllRep(I1 *index=NULL)
{
HashRep(Fs->hash_table,HTT_ALL,NULL,"-p",0,index);
}
public void LtfHelpIndex(Ltf *l,I1 *index)
{
HashRep(Fs->hash_table,HTT_ALL,NULL,NULL,0,index,l);
}
public void PopUpHelpIndex(I1 *index,TssStruct *parent=NULL)
{
I1 *buf;
buf=MSPrintF("LtfHelpIndex(Fs->cur_ltf,\"%s\");View;",index);
PopUp(buf,parent);
Free(buf);
}
#help_index "Hash"
public void LoadMapFile(I1 *filename)
{
I1 *st,*name=DefaultExtension(filename,"MPZ");
I1 *absname=AbsoluteFileName(name);
Ltf *l=LtfRead(name);
LtfEntry *cl;
SysHashEntry *temph;
U8 i,j,base=0;
DbgInfo *dbg;
RemoveLastSeg(absname,".");
if (absname[1]==':' && StrLen(absname)>2) {
temph=FindLocalHash(absname+2,HTT_MODULE);
if (temph)
base=temph->user_data0;
}
if (!l) return;
cl=l->dummy.next;
while (cl!=l) {
if (cl->btype==LTFT_LINK) {
st=MStrUtil(cl->display,SU_REMOVE_TRAILING);
if (temph=FindLocalHash(st,HTT_ALL)) {
Free(temph->source_link);
temph->source_link=cl->aux_str;
cl->aux_str=NULL;
dbg=temph->debug;
if (!dbg && cl->bin_data) {
dbg=cl->bin_data->data;
if (dbg) {
if (cl->bin_data->size>MSize(dbg))
coutln "Corrupt Map Entry";
else {
cl->bin_data->data=NULL;
temph->debug=dbg;
for (i=dbg->min_line;i<=dbg->max_line+1;i++) {
j=i-dbg->min_line;
if (dbg->body[j])
dbg->body[j]=dbg->body[j]+base;
}
}
}
}
}
Free(st);
}
cl=cl->next;
}
LtfDel(l);
Free(name);
Free(absname);
}
#help_index ""
-311
View File
@@ -1,311 +0,0 @@
#help_index "Compression"
#define ICT_U2 1
#define ICT_U4 2
#define ICT_U8 3
class IncCompressStructU2
{
U2 match_start;
U2 match_size;
U2 diff_size;
U0 diff_data;
};
class IncCompressStructU4
{
U4 match_start;
U2 match_size;
U2 diff_size;
U0 diff_data;
};
class IncCompressStructU8
{
U8 match_start;
U2 match_size;
U2 diff_size;
U0 diff_data;
};
class IntermediateIncCompressStruct
{
IntermediateIncCompressStruct *next,*last;
U8 match_start_ref,match_start,match_size;
};
void IncCompressRange(U1 *ref,U8 ref_size,U1 *b,U8 range_start,U8 range_end,
IntermediateIncCompressStruct *root,U8 type_size)
{
I8 i,j,k,n,best_k=0,best_j,best_i;
IntermediateIncCompressStruct *tempc;
//$BK,1$TODO: improve this algorithm$BK,0$
for (i=range_start;i<range_end;i++) {
for (j=0;j<ref_size;j++) {
k=0;
n=(ref_size-j<range_end-i) ? ref_size-j:range_end-i;
while (ref[j+k]==b[i+k] && k<n)
k++;
if (k>best_k) {
best_k=k;
best_j=j;
best_i=i;
}
}
}
if (best_k>type_size) {
if (range_start+type_size<best_i)
IncCompressRange(ref,ref_size,b,range_start,best_i,root,type_size);
tempc=MAlloc(sizeof(IntermediateIncCompressStruct));
tempc->match_start_ref=best_j;
tempc->match_start=best_i;
tempc->match_size=best_k;
InsQue(tempc,root->last);
if (best_i+best_k+type_size<range_end)
IncCompressRange(ref,ref_size,b,best_i+best_k,range_end,root,type_size);
}
}
public IncCompressStructU2 *IncCompress(U1 *ref,U8 ref_size,U1 *b,U8 size)
//This is for incremental compression.
//In theory it works when only a few
//changes have been made. Might be
//better just to stick with $LK,"CompressBuf","MN:CompressBuf"$().
{
U8 i,j=0,l=0,m=0,ic_type;
U1 *u1,*result;
U2 *u2;
U4 *u4;
U8 *u8;
IntermediateIncCompressStruct root,*tempc,*tempc1;
IncCompressStructU2 *tempi2;
IncCompressStructU4 *tempi4;
IncCompressStructU8 *tempi8;
root.next=&root;
root.last=&root;
if (ref_size<=0xFFFF && size<=0xFFFF) {
ic_type=ICT_U2;
i=sizeof(U1)+size+2*sizeof(U2);
IncCompressRange(ref,ref_size,b,0,size,&root,sizeof(IncCompressStructU2));
if (root.next==&root)
i+=sizeof(IncCompressStructU2);
else {
tempc=root.next;
while (tempc!=&root) {
i-=tempc->match_size-sizeof(IncCompressStructU2);
tempc=tempc->next;
}
}
} else if (ref_size<=0xFFFFFFFF && size<=0xFFFFFFFF) {
ic_type=ICT_U4;
i=sizeof(U1)+size+2*sizeof(U4);
IncCompressRange(ref,ref_size,b,0,size,&root,sizeof(IncCompressStructU4));
if (root.next==&root)
i+=sizeof(IncCompressStructU4);
else {
tempc=root.next;
while (tempc!=&root) {
i-=tempc->match_size-sizeof(IncCompressStructU4);
tempc=tempc->next;
}
}
} else {
ic_type=ICT_U8;
i=sizeof(U1)+size+2*sizeof(U8);
IncCompressRange(ref,ref_size,b,0,size,&root,sizeof(IncCompressStructU8));
if (root.next==&root)
i+=sizeof(IncCompressStructU8);
else {
tempc=root.next;
while (tempc!=&root) {
i-=tempc->match_size-sizeof(IncCompressStructU8);
tempc=tempc->next;
}
}
}
result=MAlloc(i);
u1=result;
*u1=ic_type;
switch (ic_type) {
case ICT_U2:
u2=result+sizeof(U1);
*u2=i;
u2+=sizeof(U2);
*u2=size;
tempi2=u2+sizeof(U2);
tempc=root.next;
while (tempc!=&root) {
tempc1=tempc->next;
if (l || tempc->match_start-(j+l)) {
tempi2->match_start=m;
tempi2->match_size=l;
tempi2->diff_size=tempc->match_start-(j+l);
if (tempi2->diff_size)
MemCpy(&tempi2->diff_data,b+j+l,tempi2->diff_size);
tempi2+=sizeof(IncCompressStructU2)+tempi2->diff_size;
}
m=tempc->match_start_ref;
j=tempc->match_start;
l=tempc->match_size;
Free(tempc);
tempc=tempc1;
}
tempi2->match_start=m;
tempi2->match_size=l;
tempi2->diff_size=size-(j+l);
if (tempi2->diff_size)
MemCpy(&tempi2->diff_data,b+j+l,tempi2->diff_size);
break;
case ICT_U4:
u4=result+sizeof(U1);
*u4=i;
u4+=sizeof(U4);
*u4=size;
tempi4=u4+sizeof(U4);
//$BK,1$TODO: deal with >65536 matches and differences$BK,0$
tempc=root.next;
while (tempc!=&root) {
tempc1=tempc->next;
if (l || tempc->match_start-(j+l)) {
tempi4->match_start=m;
tempi4->match_size=l;
tempi4->diff_size=tempc->match_start-(j+l);
if (tempi4->diff_size)
MemCpy(&tempi4->diff_data,b+j+l,tempi4->diff_size);
tempi4+=sizeof(IncCompressStructU4)+tempi4->diff_size;
}
m=tempc->match_start_ref;
j=tempc->match_start;
l=tempc->match_size;
Free(tempc);
tempc=tempc1;
}
tempi4->match_start=m;
tempi4->match_size=l;
tempi4->diff_size=size-(j+l);
if (tempi4->diff_size)
MemCpy(&tempi4->diff_data,b+j+l,tempi4->diff_size);
break;
case ICT_U8:
u8=result+sizeof(U1);
*u8=i;
u8+=sizeof(U8);
*u8=size;
tempi8=u8+sizeof(U8);
//$BK,1$TODO: deal with >65536 matches and differences$BK,0$
tempc=root.next;
while (tempc!=&root) {
tempc1=tempc->next;
if (l || tempc->match_start-(j+l)) {
tempi8->match_start=m;
tempi8->match_size=l;
tempi8->diff_size=tempc->match_start-(j+l);
if (tempi8->diff_size)
MemCpy(&tempi8->diff_data,b+j+l,tempi8->diff_size);
tempi8+=sizeof(IncCompressStructU8)+tempi8->diff_size;
}
m=tempc->match_start_ref;
j=tempc->match_start;
l=tempc->match_size;
Free(tempc);
tempc=tempc1;
}
tempi8->match_start=m;
tempi8->match_size=l;
tempi8->diff_size=size-(j+l);
if (tempi8->diff_size)
MemCpy(&tempi8->diff_data,b+j+l,tempi8->diff_size);
break;
}
return result;
}
public U1 *IncExpand(U1 *ref,IncCompressStructU2 *b,U8 *size=NULL)
{
U1 *result,*dst,*u1=b,*b_end;
U2 *u2;
U4 *u4;
U8 *u8=b,s,ic_type;
IncCompressStructU2 *tempi2;
IncCompressStructU4 *tempi4;
IncCompressStructU8 *tempi8;
ic_type=*u1;
switch (ic_type) {
case ICT_U2:
u2=b+sizeof(U1);
b_end=b+*u2;
u2+=sizeof(U2);
s=*u2;
break;
case ICT_U4:
u4=b+sizeof(U1);
b_end=b+*u4;
u4+=sizeof(U4);
s=*u4;
break;
case ICT_U8:
u8=b+sizeof(U1);
b_end=b+*u8;
u8+=sizeof(U8);
s=*u8;
break;
}
result=MAlloc(s);
if (size) *size=s;
dst=result;
switch (ic_type) {
case ICT_U2:
tempi2=b+sizeof(U1)+2*sizeof(U2);
while (tempi2<b_end) {
if (tempi2->match_size) {
MemCpy(dst,ref+tempi2->match_start,tempi2->match_size);
dst+=tempi2->match_size;
}
if (tempi2->diff_size) {
MemCpy(dst,&tempi2->diff_data,tempi2->diff_size);
dst+=tempi2->diff_size;
}
tempi2+=sizeof(IncCompressStructU2)+tempi2->diff_size;
}
break;
case ICT_U4:
tempi4=b+sizeof(U1)+2*sizeof(U4);
while (tempi4<b_end) {
if (tempi4->match_size) {
MemCpy(dst,ref+tempi4->match_start,tempi4->match_size);
dst+=tempi4->match_size;
}
if (tempi4->diff_size) {
MemCpy(dst,&tempi4->diff_data,tempi4->diff_size);
dst+=tempi4->diff_size;
}
tempi4+=sizeof(IncCompressStructU4)+tempi4->diff_size;
}
break;
case ICT_U8:
tempi8=b+sizeof(U1)+2*sizeof(U8);
while (tempi8<b_end) {
if (tempi8->match_size) {
MemCpy(dst,ref+tempi8->match_start,tempi8->match_size);
dst+=tempi8->match_size;
}
if (tempi8->diff_size) {
MemCpy(dst,&tempi8->diff_data,tempi8->diff_size);
dst+=tempi8->diff_size;
}
tempi8+=sizeof(IncCompressStructU8)+tempi8->diff_size;
}
break;
}
return result;
}
#help_index ""
-21
View File
@@ -1,21 +0,0 @@
#help_index "Input Pointer"
#help_file "::/LT/Doc/InputPointer.TXZ"
#define IP_NULL 0
#define IP_JOYSTICK0 1
#define IP_JOYSTICK1 2
#define IP_MOUSE 3
public I8 ipx=0,ipy=0,ipz=0,ip_throttle=0;
public I8 ipx_snap=1,ipy_snap=1,ipz_snap=1;
public I8 ipx_snap_offset=0,ipy_snap_offset=0,ipz_snap_offset=0;
public double ip_speed=0;
public I8 ip_pointer_type=IP_NULL;
public I8 iptx=ipx/FONT_WIDTH,ipty=ipy/FONT_HEIGHT;
public BoolU4 ip_on=TRUE, //Show or hide cursor
ip_lb_last=FALSE,ip_rb_last=FALSE,
ip_lb=FALSE,ip_cb=FALSE,ip_rb=FALSE; //Left/center/right buttons
public BoolU4 ip_has_wheel=FALSE;
public LTDate last_ip_move_time=BootTime;
#help_index ""
Binary file not shown.
-738
View File
@@ -1,738 +0,0 @@
time_stamp_freq=SYS_TIMER_FREQ*(
GetTimeStamp-time_stamp_start)/
(ReadSysTimer-sys_timer_start);
time_stamp_kHz_freq=time_stamp_freq/1000;
#help_index "Char/Input"
U8Fifo *scan_code_fifo=NewU8Fifo(128);
U8 last_down_scan_code=0;
void KbdCmdSend(U8 port, U1 val,BoolU4 *btimeout=NULL)
{
LTDate timeout=BootTime+LTDATE_FREQ/10;
do {
if (!(InP(KEYB_CTRL)&2)) {
timeout=0;
break;
}
} while (BootTime<timeout);
if (!timeout) {
OutP(port, val);
if (btimeout) *btimeout=FALSE;
} else
if (btimeout) *btimeout=TRUE;
}
I8 KbdCmdRead(BoolU4 *btimeout=NULL)
{
LTDate timeout=BootTime+LTDATE_FREQ/10;
do {
if (InP(KEYB_CTRL) & 1) {
if (btimeout) *btimeout=FALSE;
return InP(KEYB_PORT);
}
} while (BootTime<timeout);
if (btimeout) *btimeout=TRUE;
return -1;
}
void KbdCmdFlush(I8 Hz=50)
{
LTDate timeout;
if (Hz) {
timeout=BootTime+LTDATE_FREQ/Hz;
do InP(KEYB_PORT);
while (BootTime<timeout);
} else
while (InP(KEYB_CTRL)&1)
InP(KEYB_PORT);
}
void KbdSetLEDs(U8 sc)
{
BoolU4 old_preempt=Preempt(OFF);
U1 v=0;
AssignBit(&v,0,Bt(&sc,SCf_SCROLL));
AssignBit(&v,1,Bt(&sc,SCf_NUM));
AssignBit(&v,2,Bt(&sc,SCf_CAPS));
KbdCmdSend(KEYB_PORT,0xED);
KbdCmdSend(KEYB_PORT,v);
Preempt(old_preempt);
}
void KbdMouseCmdAck(U1 val,BoolU4 *btimeout=NULL)
{
U8 timeout=5;
BoolU4 my_btimeout=FALSE;
do {
KbdCmdSend(KEYB_CTRL,0xD4,&my_btimeout);
if (my_btimeout) goto here;
KbdCmdSend(KEYB_PORT,val,&my_btimeout);
if (my_btimeout) goto here;
if (KbdCmdRead==0xFA)
break;
here:
if (my_btimeout)
KbdCmdFlush;
} while (--timeout);
if (timeout) {
if (btimeout) *btimeout=FALSE;
} else {
if (btimeout) *btimeout=TRUE;
}
}
I1 ScanCodeToASCII(U8 sc)
{
I1 *table=NORMAL_KEY_SCAN_DECODE_TABLE;
if (sc & SCF_E0_PREFIX)
return 0;
if (sc & SCF_CTRL)
table=CTRL_KEY_SCAN_DECODE_TABLE;
else if (sc & SCF_SHIFT) {
if (!(sc & SCF_CAPS))
table=SHIFT_KEY_SCAN_DECODE_TABLE;
} else {
if (sc & SCF_CAPS)
table=SHIFT_KEY_SCAN_DECODE_TABLE;
}
sc&=0x7F;
if (sc>=0x50)
return 0;
else
return table[sc];
}
U1 scan_code_map[0x100]={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,SC_SHIFT,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,SC_CR,SC_CTRL,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0x35,0,0,SC_ALT,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,SC_HOME,SC_CURSOR_UP,SC_PAGE_UP,0,SC_CURSOR_LEFT,0,SC_CURSOR_RIGHT,0,SC_END,
SC_CURSOR_DOWN,SC_PAGE_DOWN,SC_INSERT,SC_DELETE,0,0,0,0,0,0,0,0,SC_GUI,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
U1 num_lock_map[0x100]={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,8,9,10,0,5,6,7,0,2,
3,4,11,0x34,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,SC_CR,SC_CTRL,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0x35,0,0,SC_ALT,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,SC_HOME,SC_CURSOR_UP,SC_PAGE_UP,0,SC_CURSOR_LEFT,0,SC_CURSOR_RIGHT,0,SC_END,
SC_CURSOR_DOWN,SC_PAGE_DOWN,SC_INSERT,SC_DELETE,0,0,0,0,0,0,0,0,SC_GUI,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
public void SetTypeMatic(U1 delay)
{
KbdCmdSend(KEYB_CTRL,0xA7); //Disable Mouse
KbdCmdSend(KEYB_CTRL,0xAE); //Enable Keyboard
KbdCmdSend(KEYB_PORT,0xF3);
KbdCmdSend(KEYB_PORT,delay); //Typematic rate
KbdCmdSend(KEYB_CTRL,0xA8); //Enable Mouse
}
#help_index "Char/Conversion"
public I1 *ASCIIToKeyName(I8 ch,BoolU4 include_ctrl=TRUE)
{
I8 i;
I1 buf[64];
*buf=0;
if (ch) {
if (ch<26) {
if (ch==CH_CR)
StrCat(buf,"ENTER");
else if (ch==CH_ESC)
StrCat(buf,"ESC");
else if (ch==CH_BACKSPACE)
StrCat(buf,"BACKSPACE");
else if (ch==CH_TAB)
StrCat(buf,"TAB");
else if (ch==CH_CURSOR)
StrCat(buf,"CURSOR");
else {
if (include_ctrl)
StrCat(buf,"CTRL ");
buf[i=StrLen(buf)]=ch-1+'A';
buf[i+1]=0;
}
} else if (Bt(printable_chars_bitmap,ch)) {
if (ch==CH_SPACE)
StrCat(buf,"SPACE");
else if (ch==CH_SHIFT_SPACE)
StrCat(buf,"SHIFT_SPACE");
else {
buf[i=StrLen(buf)]=ch;
buf[i+1]=0;
}
}
}
return NewStr(buf);
}
public I1 *ScanCodeToKeyName(I8 sc)
{
I8 ch=ScanCodeToASCII(sc);
I1 buf[64],*st;
*buf=0;
if (sc&SCF_CTRL)
StrCat(buf,"CTRL ");
if (sc&SCF_ALT)
StrCat(buf,"ALT ");
if (sc&SCF_SHIFT)
StrCat(buf,"SHIFT ");
if (ch) {
st=ASCIIToKeyName(ch,FALSE);
StrCpy(buf+StrLen(buf),st);
Free(st);
} else {
switch (sc.u1[0]) {
case SC_BACKSPACE:StrCat(buf,"BACK"); break;
case SC_CAPS: StrCat(buf,"CAPS"); break;
case SC_NUM: StrCat(buf,"NUM"); break;
case SC_SCROLL: StrCat(buf,"SCROLL"); break;
case SC_CURSOR_UP:StrCat(buf,"UP"); break;
case SC_CURSOR_DOWN:StrCat(buf,"DOWN"); break;
case SC_CURSOR_LEFT:StrCat(buf,"LEFT"); break;
case SC_CURSOR_RIGHT:StrCat(buf,"RIGHT"); break;
case SC_PAGE_UP:StrCat(buf,"PAGE_UP"); break;
case SC_PAGE_DOWN:StrCat(buf,"PAGE_DOWN"); break;
case SC_HOME: StrCat(buf,"HOME"); break;
case SC_END: StrCat(buf,"END"); break;
case SC_INSERT: StrCat(buf,"INSERT"); break;
case SC_DELETE: StrCat(buf,"DELETE"); break;
case SC_F1: StrCat(buf,"F1"); break;
case SC_F2: StrCat(buf,"F2"); break;
case SC_F3: StrCat(buf,"F3"); break;
case SC_F4: StrCat(buf,"F4"); break;
case SC_F5: StrCat(buf,"F5"); break;
case SC_F6: StrCat(buf,"F6"); break;
case SC_F7: StrCat(buf,"F7"); break;
case SC_F8: StrCat(buf,"F8"); break;
case SC_F9: StrCat(buf,"F9"); break;
case SC_F10: StrCat(buf,"F10"); break;
case SC_F11: StrCat(buf,"F11"); break;
case SC_F12: StrCat(buf,"F12"); break;
case SC_GUI: StrCat(buf,"WINDOWS"); break;
case SC_PRTSCRN1: StrCat(buf,"PRTSCRN1"); break;
case SC_PRTSCRN2: StrCat(buf,"PRTSCRN2"); break;
}
}
return NewStr(buf);
}
#help_index "Training"
I8 display_keys_row=TEXT_ROWS/2;
public BoolU4 kbd_display_special_keys=FALSE;
void DisplayKeysPopUp()
{
I8 i;
I1 *st;
InitLocalTask;
Fs->win_left=TEXT_COLS/2-8;
Fs->win_top=display_keys_row;
Fs->win_right=TEXT_COLS/2+8;
Fs->win_bottom=Fs->win_top;
Fs->text_attribute=(YELLOW<<4)+BLACK;
Fs->border_attribute=(YELLOW<<4)+BLACK;
Btr(&Fs->crt_flags,CRTf_HAS_CLOSE_WIN);
UseConsoleLtf(NULL);
Fs->cur_ltf->flags&=~LTFF_ATTR_BY_PARTITION;
Fs->aux_ltf->flags&=~LTFF_ATTR_BY_PARTITION;
Fs->cur_ltf->start_text_attribute=(YELLOW<<4)+BLACK;
Fs->aux_ltf->start_text_attribute=(YELLOW<<4)+BLACK;
st=ScanCodeToKeyName(last_down_scan_code);
PrintF("%s",st);
Free(st);
LtfRecalc(Fs->cur_ltf);
Bts(&Fs->crt_flags,CRTf_SHOW);
display_keys_row+=4;
for (i=0;i<1000;i++) {
WinToTop(Fs);
Sleep(1);
}
display_keys_row-=4;
}
void DisplaySpecialKeys(I8 sc)
{
I8 ch;
if (!(sc&SCF_KEY_UP) &&
sc&SCF_NEW_KEY ) {
ch=ScanCodeToASCII(sc);
if (!ch || (ch<CH_SPACE+1 && ch!=CH_CR && ch!=CH_ESC) ||
sc & (SCF_ALT|SCF_CTRL)) {
switch (sc.u1[0]) {
case SC_CTRL:
case SC_ALT:
case SC_SHIFT:
break;
case SC_BACKSPACE:
case SC_INSERT:
case SC_DELETE:
case SC_CURSOR_UP:
case SC_CURSOR_DOWN:
case SC_CURSOR_LEFT:
case SC_CURSOR_RIGHT:
case SC_PAGE_UP:
case SC_PAGE_DOWN:
if (sc&(SCF_CTRL|SCF_ALT|SCF_SHIFT))
Spawn(&DisplayKeysPopUp,"DISPLAY KEY");
break;
default:
Spawn(&DisplayKeysPopUp,"DISPLAY KEY");
}
}
}
}
#help_index "Char/Input"
void InitKbd()
{
sys_cur_scan_code=0;
KbdCmdFlush;
KbdCmdSend(KEYB_CTRL,0xA7); //Disable Mouse
KbdCmdSend(KEYB_CTRL,0xAE); //Enable Keyboard
KbdCmdSend(KEYB_PORT,0xF0);
KbdCmdSend(KEYB_PORT,0x02);
KbdSetLEDs(sys_cur_scan_code);
Btr(&sys_semas[SYS_SEMA_KEY_PRESSED],0);
OutP(0x21,InP(0x21)&~2);
}
void KbdHandler()
{
U8 ch,sc,sc2=0,sc3,sc_raw;
U1FifoRemove(kbdmouse_fifo,&sc2);
if (sc2==0xE0) {
U1FifoRemove(kbdmouse_fifo,&sc2);
AssignBit(&sc2,SCf_KEY_UP,sc2 & 0x80);
Bts(&sc2,SCf_E0_PREFIX);
} else {
AssignBit(&sc2,SCf_KEY_UP,sc2 & 0x80);
Btr(&sc2,SCf_E0_PREFIX);
}
sc=sys_cur_scan_code.u4[0]&~0x1FF;
sc_raw=sc2;
if (sc & SCF_NUM) {
if (sc3=num_lock_map[sc2.u1[0]])
sc2.u1[0]=sc3;
} else {
if (sc3=scan_code_map[sc2.u1[0]])
sc2.u1[0]=sc3;
}
if (sc2==SC_SHIFT) {
sc|=SCF_SHIFT;
goto new_key_done;
}
if (sc2==SC_SHIFT+SCF_KEY_UP) {
sc&=~SCF_SHIFT;
goto new_key_done;
}
if (sc2==SC_CTRL) {
sc|=SCF_CTRL;
goto new_key_done;
}
if (sc2==SC_CTRL+SCF_KEY_UP) {
sc&=~SCF_CTRL;
goto new_key_done;
}
if (sc2==SC_ALT) {
sc|=SCF_ALT;
goto new_key_done;
}
if (sc2==SC_ALT+SCF_KEY_UP) {
sc&=~SCF_ALT;
goto new_key_done;
}
if (sc2==SC_CAPS)
goto new_key_done;
if (sc2==SC_CAPS+SCF_KEY_UP) {
sc^=SCF_CAPS;
KbdSetLEDs(sc);
goto new_key_done;
}
if (sc2==SC_NUM)
goto new_key_done;
if (sc2==SC_NUM+SCF_KEY_UP) {
sc^=SCF_NUM;
KbdSetLEDs(sc);
goto new_key_done;
}
if (sc2==SC_SCROLL)
goto new_key_done;
if (sc2==SC_SCROLL+SCF_KEY_UP) {
sc^=SCF_SCROLL;
KbdSetLEDs(sc);
goto new_key_done;
}
if (sc & SCF_CTRL && sc & SCF_ALT) {
if (sc2==SC_DELETE) {
Bts(sys_flags,SYSf_CTRL_ALT_DEL);
goto mostly_done;
}
if (sc2==1) {
Bts(sys_flags,SYSf_CTRL_ALT_ESC);
goto mostly_done;
}
if (sc2==15) {
Bts(sys_flags,SYSf_CTRL_ALT_TAB);
goto mostly_done;
}
if (!(sc2 & SCF_KEY_UP)) {
if (ch=ScanCodeToASCII(sc2&0xFF)) {
if (ch>='a' && ch<='z') {
if (ctrl_alt_letter_routines[ch-'a']) {
CallInd(ctrl_alt_letter_routines[ch-'a']);
goto mostly_done;
}
}
}
}
}
new_key_done:
sc|=SCF_NEW_KEY;
mostly_done:
sys_cur_scan_code=sc|sc2|
(sc|sc_raw)<<32;
if (kbd_display_special_keys)
DisplaySpecialKeys(sys_cur_scan_code);
if (Btr(&sys_cur_scan_code,SCf_NEW_KEY)) {
Btr(&sys_cur_scan_code,32+SCf_NEW_KEY);
U8FifoInsert(scan_code_fifo,sys_cur_scan_code);
if (!(sys_cur_scan_code&SCF_KEY_UP))
last_down_scan_code=sys_cur_scan_code;
}
}
#help_index "Input Pointer"
public double mxx_scale=0.5,
myy_scale=0.5,
mzz_scale=1.0;
public I8 mxx_prescale=GR_WIDTH/mxx_scale/2.0,
myy_prescale=GR_HEIGHT/myy_scale/2.0,
mzz_prescale=0/mzz_scale;
public I8 mxx=GR_WIDTH>>1,
myy=GR_HEIGHT>>1,
mzz=0;
BoolU4 mouse_buttons[5];
BoolU4 mouse_installed=FALSE;
U8 mouse_install_attempts=0;
BoolU4 mouse_has_wheel=FALSE;
BoolU4 mouse_has_ext_buttons=FALSE;
BoolU4 mouse_evt=FALSE;
BoolU4 mouse_irqs_working=FALSE;
U8 mouse_pkt_size=3;
BoolU8 MouseGetDeviceType()
{
BoolU4 my_btimeout;
U1 b;
KbdMouseCmdAck(0xF2,&my_btimeout);
if (my_btimeout)
return FALSE;
b=KbdCmdRead;
if (b==3)
mouse_has_wheel=TRUE;
else if (b==4)
mouse_has_ext_buttons=TRUE;
return TRUE;
}
BoolU8 MouseReset()
{
I8 i;
BoolU4 my_btimeout,result=FALSE;
mouse_has_wheel=FALSE;
mouse_has_ext_buttons=FALSE;
KbdCmdFlush;
KbdCmdSend(KEYB_CTRL,0xAD,&my_btimeout); //Disable Kbd
if (my_btimeout) goto done;
KbdCmdSend(KEYB_CTRL,0xA8,&my_btimeout); //Enable Mouse
if (my_btimeout) goto done;
KbdMouseCmdAck(0xFF,&my_btimeout); //Reset
if (my_btimeout) goto done;
for (i=0;i<250;i++) {
KbdCmdRead(&my_btimeout);
if (!my_btimeout)
break;
}
KbdCmdRead(&my_btimeout);
KbdMouseCmdAck(0xF3,&my_btimeout);
if (my_btimeout) goto done;
KbdMouseCmdAck(200,&my_btimeout);
if (my_btimeout) goto done;
KbdMouseCmdAck(0xF3,&my_btimeout); // enable Mouse
if (my_btimeout) goto done;
KbdMouseCmdAck(100,&my_btimeout); // Set Rate
if (my_btimeout) goto done;
KbdMouseCmdAck(0xF3,&my_btimeout);
if (my_btimeout) goto done;
KbdMouseCmdAck(80,&my_btimeout); //Resolution
if (my_btimeout) goto done;
if (!MouseGetDeviceType) goto done; // enable Mouse
KbdMouseCmdAck(0xF3,&my_btimeout);
if (my_btimeout) goto done;
KbdMouseCmdAck(10,&my_btimeout);
if (my_btimeout) goto done;
if (!MouseGetDeviceType) goto done; // enable Mouse
KbdMouseCmdAck(0xE8,&my_btimeout); //Resolution
if (my_btimeout) goto done;
KbdMouseCmdAck(0x03,&my_btimeout);
if (my_btimeout) goto done;
KbdMouseCmdAck(0xE6,&my_btimeout);
if (my_btimeout) goto done;
KbdMouseCmdAck(0xF3,&my_btimeout); // Set Rate
if (my_btimeout) goto done;
KbdMouseCmdAck(100,&my_btimeout);
if (my_btimeout) goto done;
KbdMouseCmdAck(0xF4,&my_btimeout); // enable Mouse
if (my_btimeout) goto done;
result=TRUE;
done:
KbdCmdSend(KEYB_CTRL,0xAE); //Enable Keyboard
if (mouse_has_wheel || mouse_has_ext_buttons)
mouse_pkt_size=4;
else
mouse_pkt_size=3;
if (!result)
KbdCmdSend(KEYB_CTRL,0xA7); //Disable Mouse
return result;
}
void MouseHandler()
{
I8 i,dx,dy,dz,old_x=mxx,old_y=myy,old_z=mzz;
U1 mouse_buf[4];
BoolU4 old_buttons[5];
for (i=0;i<5;i++)
old_buttons[i]=mouse_buttons[i];
for (i=0;i<4;i++)
if (!U1FifoRemove(kbdmouse_fifo,&mouse_buf[i]))
mouse_buf[i]=0;
mouse_buttons[0] = mouse_buf[0] & 1;
mouse_buttons[1] = (mouse_buf[0] & 2) >> 1;
mouse_buttons[2] = (mouse_buf[0] & 4) >> 2;
mouse_buttons[3] = (mouse_buf[3] & 0x10) >> 4;
mouse_buttons[4] = (mouse_buf[3] & 0x20) >> 5;
if (mouse_buf[0] & 0x10)
dx=mouse_buf[1]-256;
else
dx=mouse_buf[1];
if (mouse_buf[0] & 0x20)
dy=256-mouse_buf[2];
else
dy=-mouse_buf[2];
if (mouse_buf[3] & 0x08)
dz=(mouse_buf[3]&7)-8;
else
dz=mouse_buf[3]&7;
mxx_prescale+=dx;
myy_prescale+=dy;
mzz_prescale+=dz;
mxx=mxx_prescale*mxx_scale;
myy=myy_prescale*myy_scale;
mzz=mzz_prescale*mzz_scale;
if (mxx < 0) {
mxx=0;
mxx_prescale=0;
}
if (mxx>=GR_WIDTH) {
mxx=GR_WIDTH-1;
mxx_prescale=mxx/mxx_scale;
}
if (myy < 0) {
myy=0;
myy_prescale=0;
}
if (myy>=GR_HEIGHT) {
myy=GR_HEIGHT-1;
myy_prescale=myy/myy_scale;
}
if (mxx!=old_x||myy!=old_y||mzz!=old_z)
mouse_evt=TRUE;
else
for (i=0;i<5;i++)
if (mouse_buttons[i]!=old_buttons[i]) {
mouse_evt=TRUE;
break;
}
}
U8 kbdmouse_timeout=0;
void ResetKbdMouse(I8 Hz=50)
{
Btr(&sys_semas[SYS_SEMA_KEY_PRESSED],0);
KbdCmdFlush(Hz);
U1FifoFlush(kbdmouse_fifo);
U8FifoFlush(scan_code_fifo);
kbdmouse_timeout=0;
OutP(0x21,InP(0x21)&~2);
}
BoolU8 InstallMouseDriver()
{
I8 i;
Preempt(ON);
mouse_installed=FALSE;
for(i=0;i<5;i++)
mouse_buttons[i]=0;
if (MouseReset)
mouse_installed=TRUE;
ResetKbdMouse;
mouse_install_attempts++;
mouse_evt=mouse_installed;
return mouse_installed;
}
void HandleKbdMouse()
{
U1 i;
if (U1FifoCnt(kbdmouse_fifo)) {
if (kbdmouse_timeout &&
GetTimeStamp>kbdmouse_timeout) {
ResetKbdMouse;
return;
}
if (Btr(&sys_semas[SYS_SEMA_KEY_PRESSED],0)) {
while (U1FifoCnt(kbdmouse_fifo)) {
if (U1FifoCnt(kbdmouse_fifo)==1) {
U1FifoPeek(kbdmouse_fifo,&i);
if (i==0xE0) {
if (!kbdmouse_timeout)
kbdmouse_timeout=GetTimeStamp+time_stamp_freq/50;
Bts(&sys_semas[SYS_SEMA_KEY_PRESSED],0);
return;
}
}
kbdmouse_timeout=0;
KbdHandler;
OutP(0x21,InP(0x21)&~2);
}
} else {
if (!mouse_installed)
U1FifoFlush(kbdmouse_fifo);
else {
if (U1FifoCnt(kbdmouse_fifo)>=mouse_pkt_size) {
kbdmouse_timeout=0;
mouse_evt_time=GetTimeStamp;
while (U1FifoCnt(kbdmouse_fifo)>=mouse_pkt_size)
MouseHandler;
} else
if (!kbdmouse_timeout)
kbdmouse_timeout=GetTimeStamp+time_stamp_freq/50;
}
}
} else
kbdmouse_timeout=0;
}
#define KBDMOUSE_POLL_RATE 500
U8 last_kbdmouse_poll_time=GetTimeStamp;
extern void PollKbdMouse();
TssStruct *poll_kbdmouse_tss=NULL;
void PollKbdMouseTsk()
{ //Poll for a minute
I8 i;
for (i=0;i<KBDMOUSE_POLL_RATE*60;i++) {
PollKbdMouse();
Sleep(1000/KBDMOUSE_POLL_RATE);
}
poll_kbdmouse_tss=NULL;
}
void PollKbdMouse()
{
U8 poll_time=GetTimeStamp;
if (poll_time-last_kbdmouse_poll_time<time_stamp_freq/KBDMOUSE_POLL_RATE)
return;
if (poll_time-last_kbdmouse_poll_time>time_stamp_freq/KBDMOUSE_POLL_RATE*4) {
last_kbdmouse_poll_time=poll_time;
ResetKbdMouse(0);
if (!poll_kbdmouse_tss)
poll_kbdmouse_tss=Spawn(&PollKbdMouseTsk,"Poll KbdMouse");
} else {
last_kbdmouse_poll_time=poll_time;
while (InP(KEYB_CTRL)&1) {
U1FifoInsert(kbdmouse_fifo,InP(KEYB_PORT));
HandleKbdMouse;
}
}
}
#help_index ""
InitKbd;
Spawn(&InstallMouseDriver);
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
-154
View File
@@ -1,154 +0,0 @@
LoadStr("ST_BIBLE_FILE","::/LT/Text/Bible.TXZ");
LoadList("ST_BIBLE_BOOKS",
"Genesis\0"
"Exodus\0"
"Leviticus\0"
"Numbers\0"
"Deuteronomy\0"
"Joshua\0"
"Judges\0"
"Ruth\0"
"1 Samuel\0"
"2 Samuel\0"
"1 Kings\0"
"2 Kings\0"
"1 Chronicles\0"
"2 Chronicles\0"
"Ezra\0"
"Nehemiah\0"
"Tobit\0"
"Judith\0"
"Esther\0"
"1 Maccabees\0"
"2 Maccabees\0"
"Job\0"
"Psalms\0"
"Proverbs\0"
"Ecclesiastes\0"
"Song of Songs\0"
"Wisdom\0"
"Sirach\0"
"Isaiah\0"
"Jeremiah\0"
"Lamentations\0"
"Baruch\0"
"Ezekiel\0"
"Daniel\0"
"Hosea\0"
"Joel\0"
"Amos\0"
"Obadiah\0"
"Jonah\0"
"Micah\0"
"Nahum\0"
"Habakkuk\0"
"Zephaniah\0"
"Haggai\0"
"Zechariah\0"
"Malachi\0"
"Matthew\0"
"Mark\0"
"Luke\0"
"John\0"
"Acts\0"
"Romans\0"
"1 Corinthians\0"
"2 Corinthians\0"
"Galatians\0"
"Ephesians\0"
"Philippians\0"
"Colossians\0"
"1 Thessalonians\0"
"2 Thessalonians\0"
"1 Timothy\0"
"2 Timothy\0"
"Titus\0"
"Philemon\0"
"Hebrews\0"
"James\0"
"1 Peter\0"
"2 Peter\0"
"1 John\0"
"2 John\0"
"3 John\0"
"Jude\0"
"Revelation\0"
"\0");
LoadList("ST_BIBLE_BOOK_LINES",
"297\0"
"5068\0"
"9123\0"
"12005\0"
"15977\0"
"19168\0"
"21329\0"
"23598\0"
"23902\0"
"26892\0"
"29345\0"
"32241\0"
"34961\0"
"37633\0"
"40756\0"
"41671\0"
"Tobit\0"
"Judith\0"
"42963\0"
"1 Maccabees\0"
"2 Maccabees\0"
"43605\0"
"46190\0"
"53793\0"
"56267\0"
"56966\0"
"Wisdom\0"
"Sirach\0"
"57332\0"
"61806\0"
"66736\0"
"Baruch\0"
"67217\0"
"71804\0"
"73189\0"
"73876\0"
"74130\0"
"74615\0"
"74697\0"
"74860\0"
"75241\0"
"75416\0"
"75604\0"
"75806\0"
"75932\0"
"76684\0"
"76908\0"
"79970\0"
"81941\0"
"85266\0"
"87803\0"
"90914\0"
"92110\0"
"93323\0"
"94088\0"
"94514\0"
"94869\0"
"95153\0"
"95402\0"
"95647\0"
"95772\0"
"96090\0"
"96320\0"
"96440\0"
"96500\0"
"97370\0"
"97687\0"
"97976\0"
"98163\0"
"98506\0"
"98552\0"
"98597\0"
"98684\0"
"\0");
-930
View File
@@ -1,930 +0,0 @@
#define LK_FILE 0
#define LK_FILE_ANCHOR 1
#define LK_FILE_FIND 2
#define LK_FILE_LINE 3
#define LK_MAN_PAGE 4
#define LK_PLAIN 5
#define LK_PLAIN_FIND 6
#define LK_PLAIN_LINE 7
#define LK_BIBLE_FIND 8
#define LK_DEF 9
#define LK_HELP_INDEX 10
#define LK_PLACE_ANCHOR 11
I8 PopUpLinkType(BoolU4 include_anchor)
{
I8 i;
Ltf *l=LtfNew;
LtfPutSExt(l,"$$MU,\"To file\",LK_FILE$$\r\n");
LtfPutSExt(l,"$$MU,\"To anchor in file\",LK_FILE_ANCHOR$$\r\n");
LtfPutSExt(l,"$$MU,\"To str in file\",LK_FILE_FIND$$\r\n");
LtfPutSExt(l,"$$MU,\"To line in file\",LK_FILE_LINE$$\r\n");
LtfPutSExt(l,"$$MU,\"To man page\",LK_MAN_PAGE$$\r\n");
LtfPutSExt(l,"$$MU,\"To plain-text file\",LK_PLAIN$$\r\n");
LtfPutSExt(l,"$$MU,\"To str in plain-text file\",LK_PLAIN_FIND$$\r\n");
LtfPutSExt(l,"$$MU,\"To line in plain-text file\",LK_PLAIN_LINE$$\r\n");
LtfPutSExt(l,"$$MU,\"To Bible chapter line and verse\",LK_BIBLE_FIND$$\r\n");
LtfPutSExt(l,"$$MU,\"To Dictionary Definition\",LK_DEF$$\r\n");
LtfPutSExt(l,"$$MU,\"To Help Index\",LK_HELP_INDEX$$\r\n");
if (include_anchor)
LtfPutSExt(l,"$$MU,\"Place Anchor\",LK_PLACE_ANCHOR$$\r\n");
LtfPutSExt(l,"$$MU,\"CANCEL\",-1$$");
i=PopUpMenu(l);
LtfDel(l);
return i;
}
class EditFileLinkStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
I1 file[132] fmtstr "$$DA-P,131,\"File :%s\"$$\r\n";
I1 aux[132];
I8 num;
BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n";
BoolU4 hide;
};
class EditFileAnchorLinkStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
I1 file[132] fmtstr "$$DA-P,131,\"File :%s\"$$\r\n";
I1 aux[132] fmtstr "$$DA-P,131,\"Anchor Label :%s\"$$\r\n";
I8 num;
BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n";
BoolU4 hide;
};
class EditFileFindLinkStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
I1 file[132] fmtstr "$$DA-P,131,\"File :%s\"$$\r\n";
I1 aux[132] fmtstr "$$DA-P,131,\"Str :%s\"$$\r\n";
I8 num fmtstr "$$DA-T,131,\"Occurrence Num:%04d\"$$\r\n";
BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n";
BoolU4 hide;
};
class EditFileLineLinkStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
I1 file[132] fmtstr "$$DA-P,131,\"File :%s\"$$\r\n";
I1 aux[132];
I8 num fmtstr "$$DA-T,131,\"Line Num :%04d\"$$\r\n";
BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n";
BoolU4 hide;
};
class EditManPageLinkStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
I1 file[132];
I1 aux[132] fmtstr "$$DA-P,131,\"Label :%s\"$$\r\n";
I8 num;
BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n";
BoolU4 hide;
};
class EditPlaceAnchorStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
I1 file[132];
I1 aux[132] fmtstr "$$DA-P,131,\"Anchor Label :%s\"$$\r\n";
I8 num;
BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n";
BoolU4 hide fmtstr "$$CB,\"Hide\"$$\r\n";
};
class EditBibleLinkStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
I1 file[132];
I1 aux[132] fmtstr "$$DA-P,131,\"Chapter Verse :%s\"$$\r\n";
I8 num;
BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n";
BoolU4 hide;
};
class EditDefLinkStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
I1 file[132];
I1 aux[132] fmtstr "$$DA-P,131,\"Word :%s\"$$\r\n";
I8 num fmtstr "$$DA-T,131,\"Def Num :%4d\"$$\r\n";
BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n";
BoolU4 hide;
};
I1 *ctrl_L_header="Press WINDOW's key for help\r\n\r\n";
BoolU8 PmtLink(I8 type,I1 **display,I1 **link,BoolU4 *quote)
{
I8 i;
BoolU4 result=FALSE;
if (quote) *quote=FALSE;
EditFileLinkStruct *el=MAllocZ(sizeof(EditFileLinkStruct));
if (type>=0) {
el->num=1;
switch (type) {
case LK_FILE:
if (DoForm(el,"EditFileLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
result=TRUE;
if (!el->display[0])
*display=NewStr(el->file);
else
*display=NewStr(el->display);
*link=MSPrintF("FI:%s",el->file);
}
break;
case LK_PLAIN:
if (DoForm(el,"EditFileLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
result=TRUE;
if (!el->display[0])
*display=NewStr(el->file);
else
*display=NewStr(el->display);
*link=MSPrintF("PI:%s",el->file);
}
break;
case LK_FILE_ANCHOR:
if (DoForm(el,"EditFileAnchorLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
result=TRUE;
if (!el->display[0])
*display=NewStr(el->aux);
else
*display=NewStr(el->display);
*link=MSPrintF("FA:%s,%s",el->file,el->aux);
}
break;
case LK_FILE_FIND:
if (DoForm(el,"EditFileFindLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
result=TRUE;
if (el->num==1) {
if (!el->display[0])
*display=NewStr(el->aux);
else
*display=NewStr(el->display);
*link=MSPrintF("FF:%s,%s",el->file,el->aux);
} else {
if (!el->display[0])
*display=NewStr(el->aux);
else
*display=NewStr(el->display);
*link=MSPrintF("FF:%s,%s:%d",el->file,el->aux,el->num);
}
}
break;
case LK_PLAIN_FIND:
if (DoForm(el,"EditFileFindLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
result=TRUE;
if (el->num==1) {
if (!el->display[0])
*display=NewStr(el->aux);
else
*display=NewStr(el->display);
*link=MSPrintF("PF:%s,%s",el->file,el->aux);
} else {
if (!el->display[0])
*display=NewStr(el->aux);
else
*display=NewStr(el->display);
*link=MSPrintF("PF:%s,%s:%d",el->file,el->aux,el->num);
}
}
break;
case LK_FILE_LINE:
if (DoForm(el,"EditFileLineLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
result=TRUE;
if (!el->display[0])
*display=NewStr(el->file);
else
*display=NewStr(el->display);
*link=MSPrintF("FL:%s,%d",el->file,el->num);
}
break;
case LK_PLAIN_LINE:
if (DoForm(el,"EditFileLineLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
result=TRUE;
if (!el->display[0])
*display=NewStr(el->file);
else
*display=NewStr(el->display);
*link=MSPrintF("PL:%s,%d",el->file,el->num);
}
break;
case LK_MAN_PAGE:
if (DoForm(el,"EditManPageLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
result=TRUE;
if (!el->display[0])
*display=NewStr(el->aux);
else
*display=NewStr(el->display);
*link=MSPrintF("MN:%s",el->aux);
}
break;
case LK_PLACE_ANCHOR:
if (DoForm(el,"EditPlaceAnchorStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
result=TRUE;
if (!el->display[0]) {
if (el->hide)
*display=NewStr("");
else
*display=NewStr(el->aux);
} else
*display=NewStr(el->display);
*link=NewStr(el->aux);
}
break;
case LK_BIBLE_FIND: //TODO
i=PopUpPickSysTextSub("ST_BIBLE_BOOKS");
if (i>=0) {
if (DoForm(el,"EditBibleLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
result=TRUE;
if (!el->display[0])
*display=MSPrintF("%Z,%s",i,"ST_BIBLE_BOOKS",el->aux);
else
*display=NewStr(el->display);
*link=MSPrintF("BF:%Z,%s",i,"ST_BIBLE_BOOKS",el->aux);
}
}
break;
case LK_DEF:
el->num=-1;
if (DoForm(el,"EditDefLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
result=TRUE;
if (!el->display[0])
*display=NewStr(el->aux);
else
*display=NewStr(el->display);
if (el->num<0)
*link=MSPrintF("DF:%s",el->aux);
else
*link=MSPrintF("DF:%s,%d",el->aux,el->num);
}
break;
case LK_HELP_INDEX:
if (DoForm(el,"EditManPageLinkStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
result=TRUE;
if (!el->display[0])
*display=NewStr(el->aux);
else
*display=NewStr(el->display);
*link=MSPrintF("HI:%s",el->aux);
}
break;
}
}
if (el->quote) *quote=TRUE;
Free(el);
return result;
}
void EditInsertLink()
{
I1 *display=NULL,*link=NULL,*st=NULL;
BoolU4 quote=FALSE;
I8 type=PopUpLinkType(TRUE);
if (type>=0) {
if (PmtLink(type,&display,&link,&quote)) {
if (type==LK_PLACE_ANCHOR)
st=MSPrintF("$$AN,\"%s\",\"%s\"$$",display,link);
else
st=MSPrintF("$$LK,\"%s\",\"%s\"$$",display,link);
}
}
if (st) {
if (quote)
PrintF("%Q",st);
else
PutS(st);
}
Free(display);
Free(link);
Free(st);
}
I8 PopUpColorType()
{
I8 i;
Ltf *l=LtfNew;
LtfPutSExt(l,"$$MU,\"Foreground\" LTFT_FOREGROUND_COLOR$$\r\n");
LtfPutSExt(l,"$$MU,\"Background\" LTFT_BACKGROUND_COLOR$$\r\n");
LtfPutSExt(l,"$$MU,\"Default Foreground\" LTFT_DEFAULT_FOREGROUND_COLOR$$\r\n");
LtfPutSExt(l,"$$MU,\"Default Background\" LTFT_DEFAULT_BACKGROUND_COLOR$$\r\n");
LtfPutSExt(l,"$$MU,\"Link Foreground\" LTFT_LINK_FOREGROUND$$\r\n");
LtfPutSExt(l,"$$MU,\"Link Background\" LTFT_LINK_BACKGROUND$$\r\n");
LtfPutSExt(l,"$$MU,\"Macro Foreground\" LTFT_MACRO_FOREGROUND$$\r\n");
LtfPutSExt(l,"$$MU,\"Macro Background\" LTFT_MACRO_BACKGROUND$$\r\n");
LtfPutSExt(l,"$$MU,\"Anchor Foreground\" LTFT_ANCHOR_FOREGROUND$$\r\n");
LtfPutSExt(l,"$$MU,\"Anchor Background\" LTFT_ANCHOR_BACKGROUND$$\r\n");
LtfPutSExt(l,"$$MU,\"Hidden Foreground\" LTFT_HIDDEN_FOREGROUND$$\r\n");
LtfPutSExt(l,"$$MU,\"Hidden Background\" LTFT_HIDDEN_BACKGROUND$$\r\n");
LtfPutSExt(l,"$$MU,\"Tree Foreground\" LTFT_TREE_FOREGROUND$$\r\n");
LtfPutSExt(l,"$$MU,\"Tree Background\" LTFT_TREE_BACKGROUND$$\r\n");
LtfPutSExt(l,"$$MU,\"User Foreground\" LTFT_USER_FOREGROUND$$\r\n");
LtfPutSExt(l,"$$MU,\"User Background\" LTFT_USER_BACKGROUND$$\r\n");
LtfPutSExt(l,"$$MU,\"CANCEL\" -1$$");
i=PopUpMenu(l);
LtfDel(l);
return i;
}
I8 PopUpPageSettingType()
{
I8 i;
Ltf *l=LtfNew;
LtfPutSExt(l,"$$MU,\"Page Length\",LTFT_PAGE_LENGTH$$\r\n");
LtfPutSExt(l,"$$MU,\"Page Header\",LTFT_HEADER$$\r\n");
LtfPutSExt(l,"$$MU,\"Page Footer\",LTFT_FOOTER$$\r\n");
LtfPutSExt(l,"$$MU,\"Left Margin\",LTFT_LEFT_MARGIN$$\r\n");
LtfPutSExt(l,"$$MU,\"Right Margin\",LTFT_RIGHT_MARGIN$$\r\n");
i=PopUpMenu(l);
LtfDel(l);
return i;
}
void EditInsertColor()
{
I8 type=PopUpColorType,col=LTF_DEFAULT;
if (type>=0) {
col=PopUpColor;
if (col==LTF_DEFAULT)
PrintF("$$%Z$$",type,"ST_LTF_CMDS");
else if (col>=0)
PrintF("$$%Z,%d$$",type,"ST_LTF_CMDS",col);
}
}
class EditPageSettingStruct
{
I1 value[132] fmtstr "$$DA -P 131 \"Setting Value:%s\"$$\r\n";
};
class EditPageSettingStruct2
{
I1 value[132] fmtstr "$$DA -P 131 \"Setting Value:%s\"$$\r\n";
BoolU4 winrel fmtstr "$$CB \"Win Relative\"$$\r\n";
};
void EditInsertPageSetting()
{
I8 type=PopUpPageSettingType;
EditPageSettingStruct *el=MAllocZ(sizeof(EditPageSettingStruct));
EditPageSettingStruct2 *el2=MAllocZ(sizeof(EditPageSettingStruct2));
if (type>=0) {
if (type==LTFT_RIGHT_MARGIN) {
if (DoForm(el2,"EditPageSettingStruct2")) {
if (el2->winrel) {
if (*el2->value)
PrintF("$$%Z+WR,%s$$",type,"ST_LTF_CMDS",el2->value);
else
PrintF("$$%Z+WR$$",type,"ST_LTF_CMDS");
} else {
if (*el2->value)
PrintF("$$%Z,%s$$",type,"ST_LTF_CMDS",el2->value);
else
PrintF("$$%Z$$",type,"ST_LTF_CMDS");
}
}
} else {
if (DoForm(el,"EditPageSettingStruct")) {
if (*el->value)
PrintF("$$%Z,%s$$",type,"ST_LTF_CMDS",el->value);
else
PrintF("$$%Z$$",type,"ST_LTF_CMDS");
}
}
}
Free(el2);
Free(el);
}
I8 PopUpDollarType()
{
I8 i;
Ltf *l=LtfNew;
LtfPutSExt(l,"$$MU,\"Link\" LTFT_LINK$$\r\n");
LtfPutSExt(l,"$$MU,\"Text\" LTFT_TEXT$$\r\n");
LtfPutSExt(l,"$$MU,\"Tree Branch\" LTFT_TREE$$\r\n");
LtfPutSExt(l,"$$MU,\"Color\" LTFT_FOREGROUND_COLOR$$\r\n");
LtfPutSExt(l,"$$MU,\"Page Settings\" LTFT_PAGE_LENGTH$$\r\n");
LtfPutSExt(l,"$$MU,\"Cursor Movement\" LTFT_CURSOR_MOVEMENT$$\r\n");
LtfPutSExt(l,"$$MU,\"Button\" LTFT_BUTTON$$\r\n");
LtfPutSExt(l,"$$MU,\"Check Box\" LTFT_CHECK_BOX$$\r\n");
LtfPutSExt(l,"$$MU,\"Macro\" LTFT_MACRO$$\r\n");
LtfPutSExt(l,"$$MU,\"Menu Value\" LTFT_MENU_VALUE$$\r\n");
LtfPutSExt(l,"$$MU,\"Button\" LTFT_BUTTON$$\r\n");
LtfPutSExt(l,"$$MU,\"Data\" LTFT_DATA$$\r\n");
LtfPutSExt(l,"$$MU,\"Hex Edit\" LTFT_HEX_EDIT$$\r\n");
LtfPutSExt(l,"$$MU,\"Hidden Widget\" LTFT_HIDE_START$$\r\n");
LtfPutSExt(l,"$$MU,\"Song\" LTFT_SONG$$\r\n");
LtfPutSExt(l,"$$MU,\"CANCEL\" -1$$");
i=PopUpMenu(l);
LtfDel(l);
return i;
}
class EditDollarTextStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
BoolU4 left_x fmtstr "$$CB,\"Left X\"$$\r\n";
BoolU4 center_x fmtstr "$$CB,\"Center X\"$$\r\n";
BoolU4 right_x fmtstr "$$CB,\"Right X\"$$\r\n";
BoolU4 margin_rel fmtstr "$$CB,\"Margin Rel X\"$$\r\n";
BoolU4 blink fmtstr "$$CB,\"Blink\"$$\r\n";
BoolU4 invert fmtstr "$$CB,\"Invert\"$$\r\n";
BoolU4 underline fmtstr "$$CB,\"Underline\"$$\r\n";
BoolU4 tree fmtstr "$$CB,\"Tree\"$$\r\n";
BoolU4 collapsed fmtstr "$$CB,\"Collapsed\"$$\r\n";
BoolU4 alias fmtstr "$$CB,\"Alias\"$$\r\n";
I1 scroll_x [132] fmtstr "$$DA-P,131,\"Scroll X Length Expression:%s\"$$\r\n";
I1 shift_x [132] fmtstr "$$DA-P,131,\"X Offset Expression :%s\"$$\r\n";
I1 shift_y [132] fmtstr "$$DA-P,131,\"Y Offset Expression :%s\"$$\r\n";
};
void EditInsertDollarText()
{
I1 *st,buf[132];
EditDollarTextStruct *dt=MAllocZ(sizeof(EditDollarTextStruct));
if (DoForm(dt,"EditDollarTextStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
*buf=0;
if (dt->left_x ) StrCat(buf,"+LX");
if (dt->center_x) StrCat(buf,"+CX");
if (dt->right_x ) StrCat(buf,"+RX");
if (dt->margin_rel) StrCat(buf,"+MRX");
if (dt->blink) StrCat(buf,"+BK");
if (dt->invert) StrCat(buf,"+IV");
if (dt->underline) StrCat(buf,"+UL");
if (dt->tree) StrCat(buf,"+TR");
if (dt->collapsed) StrCat(buf,"+C");
if (dt->alias) StrCat(buf,"+AL");
if (*dt->scroll_x) StrCat(buf,"+SCX");
if (*dt->shift_x) StrCat(buf,"+SX");
if (*dt->shift_y) StrCat(buf,"+SY");
st=MSPrintF("%q",dt->display);
PrintF("$$TX%s,\"%Q\"",buf,st);
Free(st);
if (*dt->shift_x)
PrintF(",%s",dt->shift_x);
if (*dt->shift_y)
PrintF(",%s",dt->shift_y);
if (*dt->scroll_x)
PrintF(",%s",dt->scroll_x);
PrintF("$$");
}
Free(dt);
}
class EditSongStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
I1 song[512] fmtstr "$$DA-P,511,\"Song :%s\"$$\r\n";
};
void EditInsertSong()
{
EditSongStruct *dt=MAllocZ(sizeof(EditSongStruct));
if (DoForm(dt,"EditSongStruct",CTRL_L_HELP,TRUE,ctrl_L_header))
PrintF("$$SO,\"%s\",\"%s\"$$",dt->display,dt->song);
Free(dt);
}
class EditMacroMenuStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text :%s\"$$\r\n";
I1 left_macro[512] fmtstr "$$DA-P,511,\"Left Click Macro :%s\"$$\r\n";
I1 left_exp[132] fmtstr "$$DA-P,131,\"Left Click Expression :%s\"$$\r\n";
BoolU4 popup fmtstr "$$CB,\"PopUp\"$$\r\n";
BoolU4 left_is_auto fmtstr "$$CB,\"Left is AutoStr\"$$\r\n";
BoolU4 left_x fmtstr "$$CB,\"Left X \"$$\r\n";
BoolU4 center_x fmtstr "$$CB,\"Center X \"$$\r\n";
BoolU4 right_x fmtstr "$$CB,\"Right X \"$$\r\n";
BoolU4 margin_rel fmtstr "$$CB,\"Margin Rel X\"$$\r\n";
BoolU4 blink fmtstr "$$CB,\"Blink\"$$\r\n";
BoolU4 invert fmtstr "$$CB,\"Invert\"$$\r\n";
BoolU4 underline fmtstr "$$CB,\"Underline\"$$\r\n";
BoolU4 escape fmtstr "$$CB,\"Escape\"$$\r\n";
I1 scroll_x[132] fmtstr "$$DA-P,131,\"Scroll X Length Expression:%s\"$$\r\n";
I1 shift_x[132] fmtstr "$$DA-P,131,\"X Offset Expression :%s\"$$\r\n";
I1 shift_y[132] fmtstr "$$DA-P,131,\"Y Offset Expression :%s\"$$\r\n";
};
void EditInsertMacroMenu(BoolU4 is_macro)
{
I1 *st,buf[132];
EditMacroMenuStruct *dt=MAllocZ(sizeof(EditMacroMenuStruct));
dt->underline=TRUE;
dt->escape=TRUE;
if (DoForm(dt,"EditMacroMenuStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
*buf=0;
if (is_macro && *dt->display) StrCat(buf,"+A ");
if (dt->popup) StrCat(buf,"+PU-X");
if (dt->left_x ) StrCat(buf,"+LX");
if (dt->center_x) StrCat(buf,"+CX");
if (dt->right_x ) StrCat(buf,"+RX");
if (dt->margin_rel) StrCat(buf,"+MRX");
if (dt->blink) StrCat(buf,"+BK");
if (dt->invert) StrCat(buf,"+IV");
if (!dt->underline) StrCat(buf,"-UL");
if (!dt->escape) StrCat(buf,"-X");
if (*dt->scroll_x) StrCat(buf,"+SCX");
if (*dt->shift_x) StrCat(buf,"+SX");
if (*dt->shift_y) StrCat(buf,"+SY");
if (is_macro) {
if (*dt->left_exp) StrCat(buf,"+LE");
if (!*dt->left_macro) StrCat(buf,"-LM");
} else {
if (!*dt->left_exp) StrCat(buf,"-LE");
if (*dt->left_macro) StrCat(buf,"+LM");
}
if (dt->left_is_auto) StrCat(buf,"+LA");
if (*dt->display || is_macro) {
if (is_macro) {
if (*dt->display) {
st=MSPrintF("%q",dt->display);
PrintF("$$MA %s,\"%Q\"",buf,st);
Free(st);
} else
PrintF("$$MA %s,",buf);
} else {
st=MSPrintF("%q",dt->display);
PrintF("$$MU %s,\"%Q\"",buf,st);
Free(st);
}
if (*dt->left_exp)
PrintF(",%s",dt->left_exp);
if (*dt->left_macro) {
st=MSPrintF("%q",dt->left_macro);
PrintF(",\"%Q\"",st);
Free(st);
}
if (*dt->shift_x)
PrintF(",%s",dt->shift_x);
if (*dt->shift_y)
PrintF(",%s",dt->shift_y);
if (*dt->scroll_x)
PrintF(",%s",dt->scroll_x);
PutS("$$");
}
}
Free(dt);
}
class EditButtonStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
BoolU4 popup fmtstr "$$CB,\"PopUp\"$$\r\n";
BoolU4 left_x fmtstr "$$CB,\"Left X \"$$\r\n";
BoolU4 center_x fmtstr "$$CB,\"Center X \"$$\r\n";
BoolU4 right_x fmtstr "$$CB,\"Right X \"$$\r\n";
BoolU4 margin_rel fmtstr "$$CB,\"Margin Rel X\"$$\r\n";
BoolU4 escape fmtstr "$$CB,\"Escape\"$$\r\n";
I1 left_macro [132] fmtstr "$$DA-P,131,\"Left Click Macro:%s\"$$\r\n";
BoolU4 left_is_auto fmtstr "$$CB,\"Left is AutoStr\"$$\r\n";
I1 left_exp [132] fmtstr "$$DA-P,131,\"Left Click Expression:%s\"$$\r\n";
BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n";
};
void EditInsertButton()
{
I1 *st,buf[132];
EditButtonStruct *dt=MAllocZ(sizeof(EditButtonStruct));
dt->escape=TRUE;
if (DoForm(dt,"EditButtonStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
*buf=0;
if (dt->popup) StrCat(buf,"+PU-X");
if (dt->left_x ) StrCat(buf,"+LX");
if (dt->center_x) StrCat(buf,"+CX");
if (dt->right_x ) StrCat(buf,"+RX");
if (dt->margin_rel) StrCat(buf,"+MRX");
if (!dt->escape) StrCat(buf,"-X");
if (!*dt->left_exp) StrCat(buf,"-LE");
if (*dt->left_macro) StrCat(buf,"+LM");
if (dt->left_is_auto) StrCat(buf,"+LA");
if (dt->display[0]) {
if (dt->quote) {
st=MSPrintF("%q",dt->display);
PrintF("$$$$BT%s,\\\"%Q\\\"",buf,st);
Free(st);
if (*dt->left_exp)
PrintF(",%s",dt->left_exp);
if (*dt->left_macro) {
st=MSPrintF("%q",dt->left_macro);
PrintF(",\\\"%Q\\\"",st);
Free(st);
}
PutS("$$$$");
} else {
st=MSPrintF("%q",dt->display);
PrintF("$$BT%s,\"%Q\"",buf,st);
Free(st);
if (*dt->left_exp)
PrintF(",%s",dt->left_exp);
if (*dt->left_macro) {
st=MSPrintF("%q",dt->left_macro);
PrintF(",\"%Q\"",st);
Free(st);
}
PutS("$$");
}
}
}
Free(dt);
}
class EditCursorMovementStruct
{
I1 left_exp[132] fmtstr "$$DA-P,131,\"X Expression:%s\"$$\r\n";
I1 right_exp[132] fmtstr "$$DA-P,131,\"Y Expression:%s\"$$\r\n";
BoolU4 left_x fmtstr "$$CB,\"Left X \"$$\r\n";
BoolU4 center_x fmtstr "$$CB,\"Center X \"$$\r\n";
BoolU4 right_x fmtstr "$$CB,\"Right X \"$$\r\n";
BoolU4 margin_rel fmtstr "$$CB,\"Margin Rel X\"$$\r\n";
BoolU4 top_y fmtstr "$$CB,\"Top Y \"$$\r\n";
BoolU4 center_y fmtstr "$$CB,\"Center Y \"$$\r\n";
BoolU4 bottom_y fmtstr "$$CB,\"Bottom Y \"$$\r\n";
BoolU4 page_rel fmtstr "$$CB,\"Page Rel Y\"$$\r\n";
BoolU4 quote fmtstr "$$CB,\"Quote\"$$\r\n";
};
void EditInsertCursorMovement()
{
I1 buf[132];
EditCursorMovementStruct *dt=MAllocZ(sizeof(EditCursorMovementStruct));
if (DoForm(dt,"EditCursorMovementStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
*buf=0;
if (dt->left_x ) StrCat(buf,"+LX");
if (dt->center_x) StrCat(buf,"+CX");
if (dt->right_x ) StrCat(buf,"+RX");
if (dt->margin_rel) StrCat(buf,"+MRX");
if (dt->top_y ) StrCat(buf,"+TY");
if (dt->center_y) StrCat(buf,"+CY");
if (dt->bottom_y) StrCat(buf,"+BY");
if (dt->page_rel) StrCat(buf,"+PRY");
if (!*dt->left_exp) StrCat(buf,"-LE");
if (!*dt->right_exp) StrCat(buf,"-RE");
if (dt->quote)
PutS("$$");
PrintF("$$CM%s",buf);
if (*dt->left_exp)
PrintF(",%s",dt->left_exp);
if (*dt->right_exp)
PrintF(",%s",dt->right_exp);
PutS("$$");
if (dt->quote)
PutS("$$");
}
Free(dt);
}
class EditDataStruct
{
I1 format_str [132] fmtstr "$$DA-P,131,\"Format Str:%s\"$$\r\n";
U8 len fmtstr "$$DA,256,\"Length:%d\"$$\r\n";
BoolU4 term fmtstr "$$CB,\"Terminator\"$$\r\n";
BoolU4 str fmtstr "$$CB,\"Str\"$$\r\n";
BoolU4 refresh fmtstr "$$CB,\"Refresh Data\"$$\r\n";
};
void EditInsertData()
{
I1 *st,buf[132];
EditDataStruct *dt=MAllocZ(sizeof(EditDataStruct));
dt->term=TRUE;
dt->len=256;
if (DoForm(dt,"EditDataStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
*buf=0;
if (dt->str) StrCat(buf,"-P");
if (!dt->term) StrCat(buf,"-T");
if (dt->refresh) StrCat(buf,"+RD");
st=MSPrintF("%q",dt->format_str);
PrintF("$$$$DA%s,%d,\\\"%Q\\\"$$$$",
buf,dt->len,st);
Free(st);
}
Free(dt);
}
class EditCheckBoxStruct
{
I1 label [132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
BoolU4 refresh fmtstr "$$CB,\"Refresh Data\"$$\r\n";
};
void EditInsertCheckBox()
{
I1 *st,buf[132];
EditCheckBoxStruct *dt=MAllocZ(sizeof(EditCheckBoxStruct));
if (DoForm(dt,"EditCheckBoxStruct",CTRL_L_HELP,TRUE)) {
*buf=0;
if (dt->refresh) StrCat(buf,"+RD");
st=MSPrintF("%q",dt->label);
PrintF("$$$$CB %s,\\\"%Q\\\"$$$$",
buf,st);
Free(st);
}
Free(dt);
}
class EditHexEditStruct
{
U8 cnt fmtstr "$$DA,256,\"Count:%d\"$$\r\n";
U8 cols fmtstr "$$DA,256,\"Columns:%d\"$$\r\n";
BoolU4 zero fmtstr "$$CB,\"Zero Based\"$$\r\n";
BoolU4 refresh fmtstr "$$CB,\"Refresh Data\"$$\r\n";
};
void EditInsertHexEdit()
{
I1 buf[132];
EditHexEditStruct *dt=MAllocZ(sizeof(EditHexEditStruct));
dt->cnt=128;
dt->cols=4;
dt->zero=TRUE;
if (DoForm(dt,"EditHexEditStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
*buf=0;
if (!dt->zero) StrCat(buf,"-Z");
if (dt->refresh) StrCat(buf,"+RD");
PrintF("$$$$HX %s,%d,%d$$$$",
buf,dt->cnt,dt->cols);
}
Free(dt);
}
class EditTreeStruct
{
I1 label[132] fmtstr "$$DA-P,131,\"Displayed Text:%s\"$$\r\n";
I8 indent fmtstr "$$DA,131,\"Indention:%d\"$$\r\n";
BoolU4 collapsed fmtstr "$$CB,\"Collapsed\"$$\r\n";
};
void EditInsertTree()
{
I1 *st,*st2,buf[132];
EditTreeStruct *dt=MAllocZ(sizeof(EditTreeStruct));
dt->collapsed=TRUE;
dt->indent=2;
if (DoForm(dt,"EditTreeStruct",CTRL_L_HELP,TRUE,ctrl_L_header)) {
*buf=0;
if (!dt->collapsed) StrCat(buf,"-C");
st=MSPrintF("%q",dt->label);
st2=MSPrintF("$$TR %s,\"%Q\"$$\r\n$$ID,%d$$*\r\n$$ID,%d$$",
buf,st,dt->indent,-dt->indent);
LtfSafeInsert(Fs->cur_ltf,st2);
Free(st);
Free(st2);
}
Free(dt);
}
void EditInsertHidden()
{
LtfSafeInsert(Fs->cur_ltf,"$$HS$$*$$HE$$");
}
void EditInsertDollarCmd()
{
I8 type=PopUpDollarType;
switch (type) {
case LTFT_FOREGROUND_COLOR:
EditInsertColor;
break;
case LTFT_PAGE_LENGTH:
EditInsertPageSetting;
break;
case LTFT_LINK:
EditInsertLink;
break;
case LTFT_TEXT:
EditInsertDollarText;
break;
case LTFT_TREE:
EditInsertTree;
break;
case LTFT_MACRO:
EditInsertMacroMenu(TRUE);
break;
case LTFT_MENU_VALUE:
EditInsertMacroMenu(FALSE);
break;
case LTFT_CURSOR_MOVEMENT:
EditInsertCursorMovement;
break;
case LTFT_BUTTON:
EditInsertButton;
break;
case LTFT_DATA:
EditInsertData;
break;
case LTFT_CHECK_BOX:
EditInsertCheckBox;
break;
case LTFT_HEX_EDIT:
EditInsertHexEdit;
break;
case LTFT_HIDE_START:
EditInsertHidden;
break;
case LTFT_SONG:
EditInsertSong;
break;
}
}
I8 PopUpPictureType()
{
I8 i;
Ltf *l=LtfNew;
LtfPutSExt(l,"$$MU,\"Just Picture\",1$$\r\n");
LtfPutSExt(l,"$$MU,\"Macro\",2$$\r\n");
LtfPutSExt(l,"$$MU,\"Menu Item\",3$$\r\n");
LtfPutSExt(l,"$$MU,\"Link\",4$$\r\n");
LtfPutSExt(l,"$$MU,\"CANCEL\",-1$$");
i=PopUpMenu(l);
LtfDel(l);
return i;
}
class EditJustPictureStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text :%s\"$$\r\n";
};
class EditMacroPictureStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text :%s\"$$\r\n";
I1 exp[512] fmtstr "$$DA-P,511,\"Macro :%s\"$$\r\n";
BoolU4 escape fmtstr "$$CB,\"Escape\"$$\r\n";
BoolU4 popup fmtstr "$$CB,\"PopUp\"$$\r\n";
BoolU4 is_auto fmtstr "$$CB,\"AutoStr\"$$\r\n";
};
class EditMenuPictureStruct
{
I1 display[132] fmtstr "$$DA-P,131,\"Displayed Text :%s\"$$\r\n";
I1 exp[512] fmtstr "$$DA-P,511,\"Expression :%s\"$$\r\n";
BoolU4 escape fmtstr "$$CB,\"Escape\"$$\r\n";
};
I1 *EditPictureLink()
{
I1 *result=NULL,*display=NULL,*link=NULL;
BoolU4 quote=FALSE;
I8 type=PopUpLinkType(FALSE);
if (type>=0) {
if (PmtLink(type,&display,&link,&quote))
result=MSPrintF("\"%s\",\"%s\"",display,link);
}
Free(display);
Free(link);
return result;
}
I1 *EditPicture()
{
I8 type=PopUpPictureType;
I1 *st,*st1=NULL,*st2=NULL,buf[132];
EditMacroPictureStruct *dt=MAllocZ(sizeof(EditMacroPictureStruct));
*buf=0;
switch (type) {
case 1:
if (DoForm(dt,"EditJustPictureStruct",CTRL_L_HELP,TRUE))
st1=MSPrintF("\"%Q\"",dt->display);
break;
case 2:
dt->escape=TRUE;
if (DoForm(dt,"EditMacroPictureStruct",CTRL_L_HELP,TRUE)) {
StrCat(buf,"+LM+UL");
if (dt->is_auto) StrCat(buf,"+LA");
if (dt->popup) StrCat(buf,"+PU");
if (dt->escape) StrCat(buf,"+X");
st=MSPrintF("%q",dt->exp);
st1=MSPrintF("\"%Q\",\"%Q\"",dt->display,st);
Free(st);
}
break;
case 3:
dt->escape=TRUE;
if (DoForm(dt,"EditMenuPictureStruct",CTRL_L_HELP,TRUE)) {
StrCat(buf,"+LE");
if (dt->escape) StrCat(buf,"+X");
st1=MSPrintF("\"%Q\",\"%Q\"",dt->display,dt->exp);
}
break;
case 4:
StrCat(buf,"+L+A");
st1=EditPictureLink;
break;
}
if (st1) {
st2=MSPrintF("$$PI%s,%s$$",buf,st1);
Free(st1);
}
Free(dt);
return st2;
}
File diff suppressed because it is too large Load Diff
-313
View File
@@ -1,313 +0,0 @@
public void LtfLoad(Ltf *l,I1 *src2,U8 size)
{
I8 i;
I1 *src;
LtfBinEntry *tempb;
if (src2) {
LtfPutSExt(l,src2);
src=src2+StrLen(src2)+1;
i=size-(offset(LtfBinEntry.data)-offset(LtfBinEntry.start));
while (src<=src2+i) {
tempb=MAllocZ(sizeof(LtfBinEntry),l->mem_tss);
MemCpy(&tempb->start,src,offset(LtfBinEntry.data)-offset(LtfBinEntry.start));
src+=offset(LtfBinEntry.data)-offset(LtfBinEntry.start);
tempb->data=MAlloc(tempb->size,l->mem_tss);
if (tempb->size) {
MemCpy(tempb->data,src,tempb->size);
src+=tempb->size;
}
InsQue(tempb,l->bin_root.last);
if (tempb->num>=l->cur_bin_num)
l->cur_bin_num=tempb->num+1;
}
}
if (!(l->flags & (LTFF_PLAIN_TEXT|LTFF_PLAIN_TEXT_WITH_TABS)))
LtfValidateBins(l);
l->recalc_start=l;
LtfRecalc(l);
}
public Ltf *LtfRead(I1 *name,U8 flags=0)
{
Ltf *l=LtfNew;
I1 *src,*name2;
U8 size=0;
l->flags|=flags;
name2=AbsoluteFileName(name);
StrCpy(l->filename.name,name2);
src=ReadFile(name2,&size,&l->file_attr);
Free(name2);
if (src) {
LtfLoad(l,src,size);
Free(src);
}
return l;
}
public void *LtfSave(Ltf *l,U8 *size=NULL)
{
LtfEntry *cl;
LtfBinEntry *b;
I1 *st;
U8 cnt=2; //cursor + terminator
I1 *result,*dst,*src,ch;
I8 i;
if (!(l->flags & (LTFF_PLAIN_TEXT|LTFF_PLAIN_TEXT_WITH_TABS)))
LtfValidateBins(l);
l->recalc_start=l;
LtfRecalc(l);
for (cl=l->dummy.next;cl!=l;cl=cl->next) {
if (!Bt(ltf_data_types,cl->btype)) {
if (cl->btype==LTFT_TEXT &&
!(cl->flags & ~(LTFLF_WORD_WRAP |LTFLF_UNDERLINED |
LTFLF_INVERTED | LTFLF_BLINK | LTFLF_SKIP))) {
cnt+=StrLen(cl->display);
if (!(l->flags & (LTFF_PLAIN_TEXT | LTFF_PLAIN_TEXT_WITH_TABS)))
cnt+=Occurrences(cl->display,'$$');
} else if (cl->btype==LTFT_TAB ||
cl->btype==LTFT_PAGE_BREAK)
cnt++;
else if (cl->btype==LTFT_CR)
cnt+=2;
else if (cl->btype==LTFT_PICWORD)
cnt+=StrLen(cl->aux_str);
else if (cl->btype!=LTFT_SOFT_CR &&
cl->btype!=LTFT_CURSOR &&
cl->btype!=LTFT_BPT) {
st=LtfToPlainText(l,cl);
cnt+=StrLen(st)+2;
Free(st,l->mem_tss);
}
}
}
for (b=l->bin_root.next;b!=&l->bin_root;b=b->next) {
if (b->use_cnt>b->temp_use_cnt)
cnt+=offset(LtfBinEntry.data)-
offset(LtfBinEntry.start)+b->size;
}
result=MAlloc(cnt);
dst=result;
for (cl=l->dummy.next;cl!=l;cl=cl->next) {
if (!Bt(ltf_data_types,cl->btype)) {
if (cl->btype==LTFT_TEXT &&
!(cl->flags & ~(LTFLF_WORD_WRAP |LTFLF_UNDERLINED |
LTFLF_INVERTED | LTFLF_BLINK | LTFLF_SKIP))) {
src=cl->display;
i=0;
while (ch=*src++) {
if (cl==l->cur_entry && i++==l->cur_data_col)
*dst++=CH_CURSOR;
*dst++=ch;
if (ch=='$$') {
if (!(l->flags & (LTFF_PLAIN_TEXT | LTFF_PLAIN_TEXT_WITH_TABS)))
*dst++=ch;
}
}
if (cl==l->cur_entry && i++==l->cur_data_col)
*dst++=CH_CURSOR;
} else {
if (cl==l->cur_entry)
*dst++=CH_CURSOR;
if (cl->btype==LTFT_TAB)
*dst++=CH_TAB;
else if (cl->btype==LTFT_PAGE_BREAK)
*dst++=CH_FORM_FEED;
else if (cl->btype==LTFT_CR) {
*dst++=CH_CR;
*dst++=CH_LINE_FEED;
} else if (cl->btype==LTFT_PICWORD) {
StrCpy(dst,cl->aux_str);
dst+=StrLen(cl->aux_str);
} else if (cl->btype!=LTFT_SOFT_CR &&
cl->btype!=LTFT_CURSOR &&
cl->btype!=LTFT_BPT) {
*dst++='$$';
st=LtfToPlainText(l,cl);
StrCpy(dst,st);
dst+=StrLen(st);
*dst++='$$';
Free(st,l->mem_tss);
}
}
}
}
*dst++=0;
b=l->bin_root.next;
if (b!=&l->bin_root) {
while (b!=&l->bin_root) {
if (b->use_cnt>b->temp_use_cnt) {
MemCpy(dst,&b->type,offset(LtfBinEntry.data)-offset(LtfBinEntry.start));
dst+=offset(LtfBinEntry.data)-offset(LtfBinEntry.start);
MemCpy(dst,b->data,b->size);
dst+=b->size;
}
b=b->next;
}
} else
cnt--;
if (size) *size=cnt;
return result;
}
public void LtfWrite(Ltf *l,BoolU4 prompt=FALSE)
{
U8 size;
I1 *buf=LtfSave(l,&size);
if (prompt) {
if (DoForm(&l->filename,"EditFileNameStruct"))
WriteFile(l->filename.name,buf,size,0,l->file_attr);
} else
WriteFile(l->filename.name,buf,size,0,l->file_attr);
Free(buf);
}
public void DelClipboard()
{
LtfReset(sys_clipboard_ltf,TRUE);
}
public void EditCopyToClipboard(Ltf *l)
{
Ltf *b=sys_clipboard_ltf;
LtfEntry *cl=l->dummy.next,*nl;
DelClipboard;
while (cl!=l) {
if (cl->type & LTFLT_SELECTED) {
cl->type&=~LTFLT_SELECTED;
if (!Bt(ltf_data_types,cl->btype)) {
nl=LtfCopyEntry(b,cl);
InsQue(nl,b->dummy.last);
}
}
cl=cl->next;
}
}
public void EditCutToClipboard(Ltf *l)
{
Ltf *b=sys_clipboard_ltf;
LtfEntry *cl=l->dummy.next,*cl1,*nl,*cl2=NULL;
DelClipboard;
while (cl!=l) {
cl1=cl->next;
if (cl->type & LTFLT_SELECTED) {
cl->type&=~LTFLT_SELECTED;
if (!Bt(ltf_data_types,cl->btype)) {
nl=LtfCopyEntry(b,cl);
InsQue(nl,b->dummy.last);
}
if (cl==l->cur_entry || cl==cl2)
cl2=cl->next;
LtfDelEntry(l,cl);
}
cl=cl1;
}
if (cl2) {
l->cur_entry=cl2;
l->cur_data_col=cl2->min_col;
}
l->recalc_start=l;
LtfRemoveSoftCRs(l,NULL);
}
public void EditInsertLtf(Ltf *l,Ltf *b)
{ //TODO: $LK,"LtfReset","MN:LtfReset"$
I1 *dst;
BoolU4 old_preempt=Preempt(OFF);
LtfEntry *nl,*cl=b->dummy.next;
LtfRemoveSoftCRs(l,NULL);
if (l->cur_entry->btype==LTFT_TEXT &&
l->cur_data_col>l->cur_entry->min_col) {
if (l->cur_data_col<l->cur_entry->max_col) {
nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss);
nl->type=LTFT_TEXT | l->cur_entry->type & 0xFFFFFF00;
nl->flags=l->cur_entry->flags;
nl->x=l->cur_entry->x;
nl->y=l->cur_entry->y;
nl->indent=l->cur_entry->indent;
nl->page_line_num=l->cur_entry->page_line_num;
nl->left_margin=l->cur_entry->left_margin;
nl->right_margin=l->cur_entry->right_margin;
dst=l->cur_entry->display+l->cur_data_col;
nl->display=NewStr(dst,l->mem_tss);
nl->max_col=StrLen(dst);
*dst=0;
l->cur_entry->max_col=l->cur_data_col;
InsQue(nl,l->cur_entry);
l->cur_entry=nl;
l->cur_data_col=nl->min_col;
} else
if (l->cur_entry!=l)
l->cur_entry=l->cur_entry->next;
}
while (cl!=b) {
if (cl->btype!=LTFT_SOFT_CR) {
nl=LtfCopyEntry(l,cl);
InsQue(nl,l->cur_entry->last);
}
cl=cl->next;
}
l->recalc_start=l;
Preempt(old_preempt);
}
BoolU4 LtfCaptureUndo(Ltf *l)
{
BoolU4 result=FALSE,old_preempt=Preempt(OFF);
U8 i=GetTimeStamp;
LtfUndo *u;
if (l->flags&LTFF_UNDO_DIRTY &&
i>l->undo_root.last->timestamp+15*time_stamp_freq &&
l->flags&LTFF_ALLOW_UNDO) {
u=MAllocZ(sizeof(LtfUndo),l->mem_tss);
u->timestamp=i;
u->body=LtfSave(l,&u->size);
InsQue(u,l->undo_root.last);
l->flags&=~LTFF_UNDO_DIRTY;
l->undo_cnt++;
u->ltf_flags=l->flags;
}
Preempt(old_preempt);
return result;
}
void LtfRestoreUndo(Ltf *l)
{
BoolU4 old_preempt=Preempt(OFF);
LtfUndo *u=l->undo_root.last,*u_next,*u_last;
Ltf *m;
if (u!=&l->undo_root) {
RemQue(u);
u_next=l->undo_root.next;
u_last=l->undo_root.last;
l->undo_root.next=&l->undo_root;
l->undo_root.last=&l->undo_root;
m=l->menu_ltf;
LtfReset(l,TRUE);
l->flags=u->ltf_flags;
LtfLoad(l,u->body,u->size);
LtfDelUndo(l,u);
l->undo_root.next=u_next;
l->undo_root.last=u_last;
l->menu_ltf=m;
}
LtfSetUndoCnt(l);
l->flags&=~LTFF_UNDO_DIRTY;
Preempt(old_preempt);
}
#help_index "File/Cmd Line (Typically);Ltf/Cmd Line (Typically)"
public void Type(I1 *name)
//Output a file to the command line.
//Even graphics and macros will be sent.
{
Ltf *l=LtfRead(name);
EditInsertLtf(Fs->cur_ltf,l);
LtfDel(l);
}
#help_index "Ltf"
-126
View File
@@ -1,126 +0,0 @@
I1 captured_macro_name[128];
*captured_macro_name=0;
I8 PopUpExitRecordPlayStopInsert()
{
I8 result=0;
I1 buf[80];
TssCmdStruct *tempc;
Ltf *l=LtfNew;
LtfEntry *ll;
ll=LtfPutSExt(l,"$$DA-P,127,\"Name:%s\"$$");
ll->data=captured_macro_name;
LtfFormatData(ll);
LtfPutSExt(l,"$$CM+LX+TY,2,4$$$$BT, \"RECORD\",1$$");
LtfPutSExt(l,"$$CM+LX+TY,18,4$$$$BT, \"PLAY\",2$$");
LtfPutSExt(l,"$$CM+LX+TY,2,7$$$$BT, \"STOP\",3$$");
LtfPutSExt(l,"$$CM+LX+TY,18,7$$$$BT, \"EXIT\",0$$");
LtfPutSExt(l,"$$CM+LX+TY,2,10$$$$BT, \"INSERT\",4$$");
l->flags|=LTFF_MIN_SIZE | LTFF_FORM;
SPrintF(buf,"DoMenu(0x%X);",l);
macro_util_tss=Spawn(&ServantUserCmdLine,"MACRO POPUP",Fs);
Fs->popup_tss=macro_util_tss;
tempc=QueueTaskRequest(macro_util_tss,Fs,buf,
1<<TSSCf_WAKE_MASTER | 1<<TSSCf_FOCUS_MASTER);
GetRequestResult(tempc,&result);
Fs->popup_tss=NULL;
Kill(macro_util_tss);
macro_util_tss=NULL;
LtfGetData(ll);
LtfDel(l);
return result;
}
void DelSysMacro()
{
TssCmdStruct *tempc,*tempc1;
tempc=sys_macro_queue.next;
while (tempc!=&sys_macro_queue) {
tempc1=tempc->next;
RemQue(tempc);
AFree(tempc);
tempc=tempc1;
}
}
I1 *SysMacro2Str()
{
TssCmdStruct *tempc;
I8 cnt=0;
I1 *ptr,*m;
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
tempc=sys_macro_queue.next;
while (tempc!=&sys_macro_queue) {
if (tempc->cmd_code==TSSCT_MSG)
cnt++;
tempc=tempc->next;
}
m=MAlloc(cnt*54+1);
ptr=m;
tempc=sys_macro_queue.next;
while (tempc!=&sys_macro_queue) {
if (tempc->cmd_code==TSSCT_MSG) {
SPrintF(ptr,"Msg(0x%08X,0x%016X,0x%016X);",
tempc->msg_code,tempc->p1,tempc->p2);
ptr+=54;
}
tempc=tempc->next;
}
return m;
}
void PlaySysMacro()
{
I1 *m=SysMacro2Str;
while (sys_cur_focus_task==Fs)
SwapInNext;
XTalkStrWithWait(sys_cur_focus_task,m);
Free(m);
}
void MacroTask()
{
I8 i;
StrCpy(captured_macro_name,"Click Here");
do {
i=PopUpExitRecordPlayStopInsert;
RefocusWin;
switch (i) {
case 1:
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
DelSysMacro;
LBts(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
break;
case 2:
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
PlaySysMacro;
break;
case 3:
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
break;
case 4:
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
if (sys_cur_focus_task)
QueueMsg(sys_cur_focus_task,0,
MSG_KEY_DOWN,0,SC_F2|SCF_SHIFT,0);
break;
}
} while (i>0);
}
void EditMacroUtil()
{
if (!macro_util_tss)
Spawn(&MacroTask,"MACRO TASK");
}
void EditInsertCapturedMacro()
{
BoolU4 old_preempt=Preempt(OFF);
I1 *st=SysMacro2Str;
PrintF("$$MA+A+LM+LA,\"%s\",\"%s\"$$",
captured_macro_name,st);
Free(st);
Preempt(old_preempt);
}
-677
View File
@@ -1,677 +0,0 @@
#help_index "Ltf/Cmd Line (Typically)"
public BoolU4 Edit(I1 *filename)
{
I1 *buf=NewStr(filename),
*buf2=NewStr(filename);
U8 num=1;
I1 *temp_filename=NewStr(filename),
*tfn_ptr=temp_filename;
SysHashEntry *temph;
I8 i;
BoolU4 cont,result=FALSE;
Ltf *l;
i=LK_FILE;
StrCpy(temp_filename,filename);
if (StrLen(filename)>3 && filename[2]==':') {
buf[2]=0;
i=MatchSysTextEntry(buf,"ST_LINK_TYPES",MLE_IGNORE_CASE);
tfn_ptr=temp_filename+3;
switch (i) {
case LK_MAN_PAGE:
temph=FindLocalHash(tfn_ptr,
HTT_GLBL_VAR|HTT_CLASS|HTT_FUNCTION|
HTT_STR_CONST|HTT_SYS_SYMBOL);
if (temph)
result=Edit(temph->source_link);
Free(temp_filename);
Free(buf);
Free(buf2);
return result;
case LK_DEF:
if (Occurrences(tfn_ptr,',')) {
RemoveLastSeg(tfn_ptr,",",buf);
i=AtoI(buf);
} else
i=-1;
WsdPopUpDef(tfn_ptr,i);
Free(temp_filename);
Free(buf);
Free(buf2);
return TRUE;
case LK_HELP_INDEX:
l=LtfNew;
LtfHelpIndex(l,tfn_ptr);
Free(temp_filename);
Free(buf);
Free(buf2);
DoLtf(l,TRUE);
LtfDel(l);
return TRUE;
case LK_BIBLE_FIND:
if (Occurrences(tfn_ptr,',')) {
RemoveLastSeg(tfn_ptr,",",buf);
} else
*buf=0;
num=AtoI(SysTextSub(
MatchSysTextEntry(tfn_ptr,"ST_BIBLE_BOOKS",MLE_IGNORE_CASE),
"ST_BIBLE_BOOK_LINES"));
tfn_ptr=SysText("ST_BIBLE_FILE");
break;
case LK_FILE_LINE:
case LK_PLAIN_LINE:
if (Occurrences(tfn_ptr,',')) {
RemoveLastSeg(tfn_ptr,",",buf);
num=AtoI(buf);
}
break;
case LK_FILE_ANCHOR:
*buf=0;
if (Occurrences(tfn_ptr,','))
RemoveLastSeg(tfn_ptr,",",buf);
break;
case LK_FILE_FIND:
case LK_PLAIN_FIND:
*buf=0;
*buf2=0;
if (Occurrences(tfn_ptr,','))
RemoveLastSeg(tfn_ptr,",",buf);
if (Occurrences(buf,':')) {
RemoveLastSeg(buf,":",buf2);
num=AtoI(buf2);
}
break;
}
}
tfn_ptr=NewStr(tfn_ptr);
cont=TRUE;
if (!IsTextFile(tfn_ptr)) {
if (!PopUpNoYes(ST_WARNING "Not Text File\r\n"
"Proceed anyway?\r\n\r\n"))
cont=FALSE;
}
if (cont)
result=LtfEditFile(i,tfn_ptr,buf,num);
ClearWinText(Fs);
Free(tfn_ptr);
Free(temp_filename);
Free(buf);
Free(buf2);
return result;
}
public void Plain(I1 *filename)
//Open a document in plain text mode,
//so that dollar signs are not special.
{
I1 *buf=MSPrintF("PI:%s",filename);
Edit(buf);
Free(buf);
}
#help_index "Ltf"
public Ltf *InitSysAuxLtf(BoolU4 has_menu)
{
BoolU4 old_preempt=Preempt(OFF);
LtfEntry *ll;
Ltf *aux;
aux=LtfNew;
LtfPutSExt(aux,"$$CM+H+BY+RX,-7,1$$");
ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$");
ll->display_cb=&EditPreemptCB;
LtfPutSExt(aux,"$$CM+H+BY+RX,-6,1$$");
ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$");
ll->user_data=Fs->cur_ltf;
ll->display_cb=&EditOverStrikeCB;
LtfPutSExt(aux,"$$CM+H+BY+RX,-5,1$$"); //gets merged without this
ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$");
ll->user_data=Fs->cur_ltf;
ll->display_cb=&EditDollarCB;
LtfPutSExt(aux,"$$CM+H+BY+RX,-4,1$$"); //gets merged without this
ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$");
ll->display_cb=&EditQuotesCB;
LtfPutSExt(aux,"$$CM+H+BY+RX,-3,1$$"); //gets merged without this
ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$");
ll->display_cb=&EditBracesCB;
LtfPutSExt(aux,"$$CM+H+BY+RX,-2,1$$"); //gets merged without this
ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$");
ll->display_cb=&EditSemicolonCB;
if (Fs->cur_ltf) {
LtfPutSExt(aux,"$$CM+H+BY+RX,-11,1$$");
ll=LtfPutSExt(aux,"$$TX+H+BD+DC,\" \"$$");
ll->user_data=Fs->cur_ltf;
ll->display_cb=&EditDollarTypeCB;
}
if (Fs->user_num)
LtfPrintF(aux,"$$CM+H+TY+LX,5,-1$$$$TX+H+BD,\"#%d\"$$",Fs->user_num);
LtfPutSExt(aux,"$$CM+H+TY,0,-1$$");
ll=LtfPutSExt(aux,"$$DA+H-T-P+BD+RD+CX+SCX+IV,140,\"%s...\",16$$");
ll->data=&Fs->task_descriptor;
LtfFormatData(ll);
LtfPrintF(aux,"$$CM+H,1,0$$$$TX+H+BD+IV,\"%X\"$$",Fs);
aux->text_attribute=Fs->border_attribute;
if (Bt(&Fs->crt_flags,CRTf_HAS_CLOSE_WIN))
LtfPutSExt(aux,"$$TX+H+RX+BD,\"[X]\"$$");
if (has_menu) {
LtfPutSExt(aux,"$$TX+H+LX+BD,\"MENU\"$$");
Bts(&Fs->crt_flags,CRTf_HAS_MENU);
}
Preempt(old_preempt);
return aux;
}
public void UseConsoleLtf(I1 *menu_file)
{
BoolU4 old_preempt=Preempt(OFF);
Ltf *l=LtfNew,*m;
Fs->cur_ltf=l;
l->RightClickLink=&ConsoleRightClickLink;
l->max_entries=4096;
l->flags|=LTFF_ATTR_BY_PARTITION;
if (menu_file) {
m=LtfRead(menu_file);
m->flags|=LTFF_ATTR_BY_PARTITION|LTFF_ALLOW_UNDO;
l->menu_ltf=m;
Fs->aux_ltf=InitSysAuxLtf(TRUE);
} else
Fs->aux_ltf=InitSysAuxLtf(FALSE);
Fs->update_win=&LtfUpdateBothLtf;
Fs->scroll_speed=7;
Preempt(old_preempt);
Raw(OFF);
}
#help_index "Ltf/Input"
public I1 *LtfGetLine(Ltf *l,LtfEntry *cl,I8 *cur_col=NULL)
{
LtfEntry *cl2=cl;
BoolU4 old_preempt=Preempt(OFF);
I1 *result,*dst,*src,*start;
U8 i=0;
if (*cur_col)
*cur_col=-1;
while (cl2!=l && cl2->btype!=LTFT_CR) {
if (Bt(ltf_display_types,cl2->btype)) {
if (cl2->btype==LTFT_PICWORD)
src=cl2->aux_str;
else
src=cl2->display;
i+=StrLen(src);
} else if (cl2->btype==LTFT_TAB)
i++;
cl2=cl2->next;
}
result=MAlloc(i+1);
dst=result;
while (cl!=l && cl->btype!=LTFT_CR) {
start=dst;
if (Bt(ltf_display_types,cl->btype)) {
if (cl->btype==LTFT_PICWORD)
src=cl->aux_str;
else
src=cl->display;
while (*src)
*dst++=*src++;
} else if (cl->btype==LTFT_TAB)
*dst++=CH_TAB;
if (cl==l->cur_entry && cur_col)
*cur_col=start-result+l->cur_data_col;
cl=cl->next;
}
*dst++=0;
if (cl==l->cur_entry && cur_col && !l->cur_data_col)
*cur_col=dst-1-result;
Preempt(old_preempt);
return result;
}
#help_index "Ltf/Output"
public void LtfDump(Ltf *l,U8 uS_delay=0)
{
I1 *st;
LtfEntry *cl;
cl=l->dummy.next;
while (cl!=l) {
st=LtfGetLine(l,cl);
PutS(st);
Free(st);
do cl=cl->next;
while (cl!=l && cl->btype!=LTFT_CR);
if (cl->btype==LTFT_CR) {
cl=cl->next;
CrLf;
BusyWait(uS_delay);
}
}
}
public BoolU4 View()
{
I8 ch=0;
U8 sc=0;
BoolU4 old_preempt=Preempt(OFF);
while (ch!=CH_ESC && ch!=CH_CTRLQ) {
Preempt(OFF);
if (ScanKey(&ch,&sc)) {
Preempt(old_preempt);
PutKey(ch,sc);
LtfRecalc(Fs->cur_ltf);
} else {
Fs->task_flags|=1<<TSSf_IDLE;
if (!Fs->rmt_chnl &&
!(Fs->parent_tss && Fs->parent_tss->popup_tss==Fs)) {
Fs->task_flags|=1<<TSSf_AWAITING_MSG;
SwapInNext;
Preempt(old_preempt);
} else {
Preempt(old_preempt);
WinSync;
}
Fs->task_flags&=~(1<<TSSf_IDLE);
}
}
Preempt(old_preempt);
return ch==CH_ESC;
}
public LtfEntry *LtfPutLine(LtfEntry *cl)
{
I1 ch,*ptr,*ptr2;
while (cl->btype!=LTFT_ERROR && cl->btype!=LTFT_CR) {
if (Bt(ltf_display_types,cl->btype)) {
if (cl->btype==LTFT_PICWORD)
ptr=cl->aux_str;
else
ptr=cl->display;
do {
ptr2=ptr;
while (ch=*ptr)
if (ch=='$$')
break;
else
ptr++;
*ptr=0;
PutS(ptr2);
*ptr=ch;
if (ch=='$$') {
PutS("$$$$");
ptr++;
}
} while (ch);
} else if (cl->btype==LTFT_TAB)
PutChar(CH_TAB);
cl=cl->next;
}
CrLf;
return (cl->btype==LTFT_ERROR) ? cl:cl->next;
}
#help_index "Ltf/Input"
public I1 *LtfMGetS()
{
Ltf *l=Fs->cur_ltf;
LtfEntry *cl;
BoolU4 old_preempt;
I1 *result;
U8 sc;
I8 ch;
old_preempt=Preempt(OFF);
PutS("$$FU$$$$BU$$");
do {
Preempt(OFF);
if (ScanKey(&ch,&sc)) {
if (ch==CH_ESC) {
if (l=Fs->aux_ltf) {
if (!l->best_d && l->cur_entry!=l) {
cl=LtfCopyEntry(l,l->cur_entry);
if (Fs->cur_ltf)
LtfBottom(Fs->cur_ltf);
LtfRunEntry(l,cl,TRUE,old_preempt);
LtfDelEntry(l,cl);
goto next;
}
}
if (l=Fs->cur_ltf) {
if (l->cur_entry!=l) {
cl=LtfCopyEntry(l,l->cur_entry);
LtfBottom(l);
LtfRunEntry(l,cl,TRUE,old_preempt);
LtfDelEntry(l,cl);
}
}
next:
} if (ch==CH_CTRLQ)
Exit;
else {
Preempt(old_preempt);
PutKey(ch,sc);
LtfRecalc(Fs->cur_ltf);
}
} else {
Fs->task_flags|=1<<TSSf_IDLE;
if (!Fs->rmt_chnl &&
!(Fs->parent_tss && Fs->parent_tss->popup_tss==Fs)) {
Fs->task_flags|=1<<TSSf_AWAITING_MSG;
SwapInNext;
Preempt(old_preempt);
} else {
Preempt(old_preempt);
WinSync;
}
Fs->task_flags&=~(1<<TSSf_IDLE);
}
//Ctrl shift <CR> is a blank line without entry
} while (ch!=CH_CR || sc & SCF_CTRL && (sc & SCF_SHIFT));
Preempt(OFF);
l=Fs->cur_ltf;
cl=l->cur_entry;
do cl=cl->last;
while (cl!=l && cl->btype!=LTFT_CR &&
cl->btype!=LTFT_USER_FOREGROUND && cl->btype!=LTFT_USER_BACKGROUND);
do cl=cl->last;
while (cl!=l && cl->btype!=LTFT_CR &&
cl->btype!=LTFT_USER_FOREGROUND && cl->btype!=LTFT_USER_BACKGROUND);
cl=cl->next;
result=LtfGetLine(l,cl,NULL);
PutS("$$FU$$$$FG$$$$BG$$");
Preempt(old_preempt);
return result;
}
#help_index "Char/Input"
public I8 PmtI8(I1 *msg,I8 default,I8 lo=MIN_I8,I8 hi=MAX_I8)
{
I8 result;
I1 *st;
while (TRUE) {
PrintF(msg,default);
st=MGetS;
if (!*st) {
Free(st);
return default;
}
result=AtoI(st);
Free(st);
if (result>=lo && result<=hi)
return result;
}
}
public double PmtDouble(I1 *msg,double default,double lo=MIN_double,double hi=MAX_double)
{
double result;
I1 *st;
while (TRUE) {
PrintF(msg,default);
st=MGetS;
if (!*st) {
Free(st);
return default;
}
result=A2Double(st);
Free(st);
if (result>=lo && result<=hi)
return result;
}
}
public I1 *PmtStr(I1 *msg,I1 *default=NULL)
{
I1 *st;
if (default)
PrintF(msg,default);
else
PrintF(msg);
st=MGetS;
if (!*st) {
Free(st);
if (default)
return NewStr(default);
else
return NewStr("");
}
return st;
}
public LTDate PmtLTDate(I1 *msg,LTDate default,LTDate lo=MIN_I8,LTDate hi=MAX_I8)
{
LTDate result;
I1 *st;
while (TRUE) {
PrintF(msg,default,default);
st=MGetS;
if (!*st) {
Free(st);
return default;
}
result=A2LTDate(st);
Free(st);
if (result>=lo && result<=hi)
return result;
}
}
#help_index "Ltf"
I8 PopUpCancelIncludeDelAuto(I1 *header=NULL,I1 *footer=NULL)
{
I8 i;
Ltf *l=LtfNew;
if (header) LtfPutSExt(l,header);
LtfPutSExt(l,"$$CM+LX,2,4 $$$$BT, \"INCLUDE (.CPZ)\",1$$");
LtfPutSExt(l,"$$CM+LX,26,0$$$$BT, \"DEBUG \",9$$");
LtfPutSExt(l,"$$CM+LX,2,3 $$$$BT, \"COMPILE (.SPZ)\",5$$");
LtfPutSExt(l,"$$CM+LX,26,0$$$$BT, \"LOAD (.BIZ)\",6$$");
LtfPutSExt(l,"$$CM+LX,2,3 $$$$BT, \"ADAM_INCLUDE (.APZ)\",4$$");
LtfPutSExt(l,"$$CM+LX,26,0$$$$BT, \"AUTOFILE (.AUZ)\",3$$");
LtfPutSExt(l,"$$CM+LX,2,3 $$$$BT, \"COPY \",7$$");
LtfPutSExt(l,"$$CM+LX,26,0$$$$BT, \"MOVE \",8$$");
LtfPutSExt(l,"$$CM+LX,2,3 $$$$BT, \"DELETE \",2$$");
LtfPutSExt(l,"$$CM+LX,26,0$$$$BT, \"CANCEL \",0$$");
if (footer) LtfPutSExt(l,footer);
i=PopUpMenu(l);
LtfDel(l);
return i;
}
void EditLeftClickLink(Ltf *l,LtfEntry *cl,U2 old_preempt2)
{
BoolU4 old_preempt=IsPreempt;
I1 *st;
nounusedwarn l;
if (cl->flags & LTFLF_AUX_STR)
st=NewStr(cl->aux_str);
else
st=NewStr(cl->display);
Preempt(old_preempt2);
Edit(st);
Preempt(old_preempt);
Free(st);
}
void ConsoleRightClickLink(Ltf *l,LtfEntry *cl,BoolU4 old_preempt2)
{
BoolU4 send_cr=FALSE,old_preempt=IsPreempt;
I1 *st2,*st;
I8 i;
EditFileNameStruct fn;
if (cl->flags & LTFLF_AUX_STR)
st2=NewStr(cl->aux_str);
else
st2=NewStr(cl->display);
st=(st2[2]==':') ? st2+3:st2;
i=PopUpCancelIncludeDelAuto(st);
Preempt(old_preempt2);
if (i>0) {
LtfBottom(l);
switch (i) {
case 1:
if (Occurrences(st,'.') && !WildCardMatch("*.CP?",st)) {
if (!PopUpNoYes(ST_WARNING "Not .CP? File\r\n"
"Proceed anyway?\r\n\r\n")) {
send_cr=TRUE;
break;
}
}
cout "#include \"",st,"\";\r\n$$FU$$$$FG$$$$BG$$";
ExecuteFile(st);
break;
case 2:
Del(st);
break;
case 3:
if (Occurrences(st,'.') && !WildCardMatch("*.AU?",st)) {
if (!PopUpNoYes(ST_WARNING "Not .AU? File\r\n"
"Proceed anyway?\r\n\r\n")) {
send_cr=TRUE;
break;
}
}
cout "AutoFile(\"",st,"\");\r\n$$FU$$$$FG$$$$BG$$";
AutoStr("%F\r",st);
break;
case 4:
if (Occurrences(st,'.') && !WildCardMatch("*.AP?",st)) {
if (!PopUpNoYes(ST_WARNING "Not .CP? File\r\n"
"Proceed anyway?\r\n\r\n")) {
send_cr=TRUE;
break;
}
}
cout "Adam(\"#include \\\"",st,"\\\"\" );\r\n$$FU$$$$FG$$$$BG$$";
Adam(";#include \"%s\"",st);
break;
case 5:
if (Occurrences(st,'.') && !WildCardMatch("*.SP?",st)) {
if (!PopUpNoYes(ST_WARNING "Not .SP? File\r\n"
"Proceed anyway?\r\n\r\n")) {
send_cr=TRUE;
break;
}
}
cout "CompileFile(\"",st,"\");\r\n$$FU$$$$FG$$$$BG$$";
CompileFile(st);
break;
case 6:
if (Occurrences(st,'.') && !WildCardMatch("*.BI?",st)) {
if (!PopUpNoYes(ST_WARNING "Not .BI? File\r\n"
"Proceed anyway?\r\n\r\n")) {
send_cr=TRUE;
break;
}
}
cout "Load(\"",st,"\");\r\n$$FU$$$$FG$$$$BG$$";
Load(st);
break;
case 7:
StrCpy(fn.name,st);
if (DoForm(fn.name,"EditFileNameStruct"))
Copy(st,fn.name);
break;
case 8:
StrCpy(fn.name,st);
if (DoForm(fn.name,"EditFileNameStruct"))
Move(st,fn.name);
break;
case 9:
if (Occurrences(st,'.') && !WildCardMatch("*.CP?",st)) {
if (!PopUpNoYes(ST_WARNING "Not .CP? File\r\n"
"Proceed anyway?\r\n\r\n")) {
send_cr=TRUE;
break;
}
}
cout "IDE(\"",st,"\");\r\n$$FU$$$$FG$$$$BG$$";
IDE(st);
break;
}
} else
send_cr=TRUE;
LtfBottom(l);
cout "$$FU$$$$FG$$$$BG$$";
if (send_cr)
PutChar(CH_CR);
Preempt(old_preempt);
Free(st2);
}
#help_index "Ltf/Cmd Line (Typically)"
public void Man(I1 *st)
//Enter the name of a symbol and this
//will jump to the source code.
{
I1 *name=MAlloc(3+StrLen(st)+1);
StrCpy(name,"MN:");
StrCat(name,st);
Edit(name);
Free(name);
}
#help_index "Debugging;Ltf/Cmd Line (Typically);Ltf/Output"
public void LtfDm(U1 *buf,U8 cnt=0x80)
//Dumps a chunk of memory, showing
//addresses. It is live and can be
//edited.
{
LtfEntry *ll;
BoolU4 old_preempt=Preempt(OFF);
Ltf *l=Fs->cur_ltf;
ll=LtfPrintF(l,"$$HX-Z,%d,16$$",cnt);
ll->data=buf;
l->cur_entry=ll->next;
LtfRecalc(l);
Preempt(old_preempt);
}
public void LtfD(U1 *buf,U8 cnt=0x80)
//Dumps a chunk of memory, showing
//offsets. It is live and can be
//edited.
{
LtfEntry *ll;
BoolU4 old_preempt=Preempt(OFF);
Ltf *l=Fs->cur_ltf;
ll=LtfPrintF(l,"$$HX,%d,16$$",cnt);
ll->data=buf;
l->cur_entry=ll->next;
LtfRecalc(l);
Preempt(old_preempt);
}
#help_index "Ltf/Output"
BoolU8 LtfPutS(I1 *st)
{
Ltf *l;
BoolU4 old_preempt=Preempt(OFF);
l=Fs->cur_ltf;
if (l)
LtfPutSPartial(l,st,old_preempt);
Preempt(old_preempt);
return FALSE;
}
AddKeyDev(&LtfPutKey,&LtfPutS,0x80000000);
ext[EXT_LTF_READ]=&LtfRead;
ext[EXT_LTF_WRITE]=&LtfWrite;
ext[EXT_LTF_NEW]=&LtfNew;
ext[EXT_LTF_RESET]=&LtfReset;
ext[EXT_LTF_DEL]=&LtfDel;
ext[EXT_MGETS]=&LtfMGetS;
#help_index "Ltf"
-505
View File
@@ -1,505 +0,0 @@
U8 ltf_display_types[1],ltf_nondisplay_invisible_types[1],
ltf_form_types[1],ltf_data_types[1];
U8 ltf_clean_scancodes[4]={0,0,0,0};
ltf_display_types[0]=
1<<LTFT_TEXT|
1<<LTFT_DATA|
1<<LTFT_MENU_VALUE|
1<<LTFT_HIDE_START |
1<<LTFT_TREE|
1<<LTFT_HIDE_END|
1<<LTFT_MACRO|
1<<LTFT_BUTTON|
1<<LTFT_CHECK_BOX|
1<<LTFT_LINK|
1<<LTFT_ANCHOR|
1<<LTFT_PICTURE|
1<<LTFT_PICWORD|
1<<LTFT_INSERT_BINARY|
1<<LTFT_INSERT_BINARY_TYPE|
1<<LTFT_INSERT_BINARY_SIZE|
1<<LTFT_SONG;
ltf_nondisplay_invisible_types[0]=
1<<LTFT_PAGE_LENGTH|
1<<LTFT_LEFT_MARGIN|
1<<LTFT_RIGHT_MARGIN|
1<<LTFT_HEADER|
1<<LTFT_FOOTER|
1<<LTFT_INDENT|
1<<LTFT_FOREGROUND_COLOR|
1<<LTFT_BACKGROUND_COLOR|
1<<LTFT_DEFAULT_FOREGROUND_COLOR|
1<<LTFT_DEFAULT_BACKGROUND_COLOR|
1<<LTFT_LINK_FOREGROUND|
1<<LTFT_LINK_BACKGROUND|
1<<LTFT_MACRO_FOREGROUND|
1<<LTFT_MACRO_BACKGROUND|
1<<LTFT_ANCHOR_FOREGROUND|
1<<LTFT_ANCHOR_BACKGROUND|
1<<LTFT_HIDDEN_FOREGROUND|
1<<LTFT_HIDDEN_BACKGROUND|
1<<LTFT_TREE_FOREGROUND|
1<<LTFT_TREE_BACKGROUND|
1<<LTFT_USER_FOREGROUND|
1<<LTFT_USER_BACKGROUND|
1<<LTFT_WORD_WRAP|
1<<LTFT_UNDERLINED|
1<<LTFT_INVERTED|
1<<LTFT_BLINK|
1<<LTFT_SHIFTED_X|
1<<LTFT_SHIFTED_Y|
1<<LTFT_PICTURE|
1<<LTFT_PICWORD|
1<<LTFT_TOP_LEFT_TOOLBAR|
1<<LTFT_TOP_RIGHT_TOOLBAR|
1<<LTFT_BPT;
ltf_form_types[0]=ltf_display_types[0] & ~(1<<LTFT_TEXT)|1<<LTFT_HEX_EDIT;
ltf_data_types[0]=1<<LTFT_DATA|
1<<LTFT_HEX_EDIT|
1<<LTFT_CHECK_BOX;
Bts(ltf_clean_scancodes,SC_CURSOR_RIGHT);
Bts(ltf_clean_scancodes,SC_CURSOR_LEFT);
Bts(ltf_clean_scancodes,SC_CURSOR_UP);
Bts(ltf_clean_scancodes,SC_CURSOR_DOWN);
Bts(ltf_clean_scancodes,SC_PAGE_UP);
Bts(ltf_clean_scancodes,SC_PAGE_DOWN);
Bts(ltf_clean_scancodes,SC_ALT);
Bts(ltf_clean_scancodes,SC_CTRL);
Bts(ltf_clean_scancodes,SC_SHIFT);
Bts(ltf_clean_scancodes,SC_CAPS);
Bts(ltf_clean_scancodes,SC_NUM);
Bts(ltf_clean_scancodes,SC_SCROLL);
Bts(ltf_clean_scancodes,SC_HOME);
Bts(ltf_clean_scancodes,SC_END);
Bts(ltf_clean_scancodes,SC_GUI);
Bts(ltf_clean_scancodes,SC_BACKSPACE); //Handled specially
LtfBinEntry *LtfFindBin(Ltf *l,U8 num)
{
LtfBinEntry *b=l->bin_root.next;
while (b!=&l->bin_root) {
if (b->num==num)
return b;
b=b->next;
}
return NULL;
}
void LtfValidateBins(Ltf *l)
{
LtfBinEntry *b=l->bin_root.next,*b1;
LtfEntry *cl=l->dummy.next,*cl2;
while (b!=&l->bin_root) {
b->use_cnt=0;
b->temp_use_cnt=0;
b=b->next;
}
while (cl!=l) {
cl2=cl->next;
if (cl->flags & LTFLF_HAS_BIN) {
if (cl->bin_data=LtfFindBin(l,cl->bin_num)) {
cl->bin_data->use_cnt++;
if (cl->btype==LTFT_PICWORD)
cl->bin_data->temp_use_cnt++;
} else {
DbgStr("Bin Not Found",3000);
RemQue(cl); //don't attempt to delete
}
}
cl=cl2;
}
b=l->bin_root.next;
l->cur_bin_num=1;
while (b!=&l->bin_root) {
b1=b->next;
if (!b->use_cnt) {
RemQue(b);
Free(b->data,l->mem_tss);
Free(b,l->mem_tss);
} else {
if (b->num>=l->cur_bin_num)
l->cur_bin_num=b->num+1;
}
b=b1;
}
}
void LtfDelBin(Ltf *l,LtfBinEntry *b)
{
b->use_cnt--;
if (!b->use_cnt) {
RemQue(b);
Free(b->data,l->mem_tss);
Free(b,l->mem_tss);
}
}
void LtfDelEntry(Ltf *l,LtfEntry *cl)
{
if (l==cl)
DbgStr("Ltf Del Header",10000);
else {
if (l->cur_entry==cl)
l->cur_entry=cl->next;
if (l->top_entry==cl)
l->top_entry=cl->next;
RemQue(cl);
if (Bt(ltf_display_types,cl->btype))
Free(cl->display,l->mem_tss);
if (cl->flags & LTFLF_LEFT_MACRO)
Free(cl->left_macro,l->mem_tss);
if (cl->flags & LTFLF_RIGHT_MACRO)
Free(cl->right_macro,l->mem_tss);
if (cl->flags & LTFLF_AUX_STR)
Free(cl->aux_str,l->mem_tss);
if (cl->flags & LTFLF_HAS_BIN)
LtfDelBin(l,cl->bin_data);
Free(cl,l->mem_tss);
}
}
void LtfDelUndo(Ltf *l,LtfUndo *u)
{
Free(u->body,l->mem_tss);
Free(u,l->mem_tss);
}
void LtfSetUndoCnt(Ltf *l)
{
BoolU4 old_preempt=Preempt(OFF);
LtfUndo *u=l->undo_root.next;
l->undo_cnt=0;
while (u!=&l->undo_root) {
l->undo_cnt++;
u=u->next;
}
Preempt(old_preempt);
}
BoolU8 LtfCheckBin(Ltf *l,LtfBinEntry *b)
{
if (MTss(b->data)!=l->mem_tss)
return FALSE;
if (MTss(b)!=l->mem_tss)
return FALSE;
return TRUE;
}
BoolU8 LtfCheckEntry(Ltf *l,LtfEntry *cl)
{
if (l==cl)
DbgStr("Ltf Del Header",10000);
else {
if (Bt(ltf_display_types,cl->btype))
if (MTss(cl->display)!=l->mem_tss)
return FALSE;
if (cl->flags & LTFLF_LEFT_MACRO)
if (MTss(cl->left_macro)!=l->mem_tss)
return FALSE;
if (cl->flags & LTFLF_RIGHT_MACRO)
if (MTss(cl->right_macro)!=l->mem_tss)
return FALSE;
if (cl->flags & LTFLF_AUX_STR)
if (MTss(cl->aux_str)!=l->mem_tss)
return FALSE;
if (cl->flags & LTFLF_HAS_BIN)
if (!LtfCheckBin(l,cl->bin_data))
return FALSE;
if (MTss(cl)!=l->mem_tss)
return FALSE;
}
return TRUE;
}
LtfEntry *LtfCopyEntry(Ltf *l,LtfEntry *cl)
{
LtfEntry *nl;
LtfBinEntry *tempb;
TssStruct *tss=l->mem_tss;
nl=MAllocIdentical(cl,tss);
nl->next=nl;
nl->last=nl;
if (Bt(ltf_display_types,cl->btype))
nl->display=MAllocIdentical(cl->display,tss);
if (cl->flags & LTFLF_AUX_STR)
nl->aux_str=MAllocIdentical(cl->aux_str,tss);
if (cl->flags & LTFLF_LEFT_MACRO)
nl->left_macro=MAllocIdentical(cl->left_macro,tss);
if (cl->flags & LTFLF_RIGHT_MACRO)
nl->right_macro=MAllocIdentical(cl->right_macro,tss);
if (cl->flags & LTFLF_HAS_BIN) {
tempb=MAllocIdentical(cl->bin_data,tss);
tempb->data=MAllocIdentical(cl->bin_data->data,tss);
nl->bin_num=l->cur_bin_num;
tempb->num=l->cur_bin_num++;
nl->bin_data=tempb;
InsQue(tempb,l->bin_root.last);
}
return nl;
}
void LtfFormForward(Ltf *l)
{
LtfEntry *cl=l->cur_entry,*cl1=cl->last,*cl2=cl;
if (l->flags & LTFF_FORM) {
while (cl!=cl1 && !Bt(ltf_form_types,cl->btype))
cl=cl->next;
}
while (cl->btype==LTFT_INDENT)
cl=cl->next;
if (cl!=cl2) {
l->cur_data_col=cl->min_col;
l->cur_entry=cl;
}
}
void LtfFormBackward(Ltf *l)
{
LtfEntry *cl=l->cur_entry,*cl1=cl->next,*cl2=cl;
if (l->flags & LTFF_FORM) {
while (cl!=cl1 && !Bt(ltf_form_types,cl->btype))
cl=cl->last;
}
while (cl->btype==LTFT_INDENT)
cl=cl->next;
if (cl!=cl2) {
l->cur_data_col=cl->min_col;
l->cur_entry=cl;
}
}
public void LtfHome(Ltf *l=NULL)
{
if (!l) {
l=Fs->cur_ltf;
if (!l) return;
}
l->cur_entry=l->dummy.next;
l->cur_data_col=l->cur_entry->min_col;
l->x=0;
l->y=0;
l->line_start_col=0;
l->cur_top_line_num=0;
LtfFormForward(l);
}
public BoolU4 LtfCheck(Ltf *l=NULL)
{
LtfEntry *cl,*cl1;
if (!l) {
l=Fs->cur_ltf;
if (!l) return FALSE;
}
cl=l->dummy.next;
while (cl!=l) {
cl1=cl->next;
if (!LtfCheckEntry(l,cl))
return FALSE;
cl=cl1;
}
return TRUE;
}
public void LtfReset(Ltf *l,BoolU4 is_old)
{
LtfEntry *cl,*cl1;
LtfUndo *u,*u1;
if (!l) {
l=Fs->cur_ltf;
if (!l) return;
}
if (is_old) {
cl=l->dummy.next;
while (cl!=l) {
cl1=cl->next;
LtfDelEntry(l,cl);
cl=cl1;
}
u=l->undo_root.next;
while (u!=&l->undo_root) {
u1=u->next;
LtfDelUndo(l,u);
u=u1;
}
}
//Check $LK,"EditInsertLtf","MN:EditInsertLtf"$
l->start_text_attribute=(WHITE<<4)+BLUE;
l->text_attribute=l->start_text_attribute;
l->link_attribute=(WHITE<<4)+RED;
l->macro_attribute=(WHITE<<4)+LTBLUE;
l->anchor_attribute=(WHITE<<4)+BLACK;
l->hidden_attribute=(WHITE<<4)+BLACK;
l->tree_attribute=(WHITE<<4)+PURPLE;
l->user_attribute=(WHITE<<4)+GREEN;
l->flags=0;
l->dummy.next=l;
l->dummy.last=l;
l->bin_root.next=&l->bin_root;
l->bin_root.last=&l->bin_root;
l->undo_root.next=&l->undo_root;
l->undo_root.last=&l->undo_root;
l->undo_root.timestamp=0;
l->undo_cnt=0;
l->cur_bin_num=1;
l->recalc_start=l;
l->menu_ltf=NULL;
l->dollar_buf_ptr=0;
l->cmd_I1=CH_SPACE;
l->indent=0;
l->page_line_num=0;
l->page_length=66;
l->left_margin=LTF_DEFAULT;
l->right_margin=LTF_DEFAULT;
l->header=LTF_DEFAULT;
l->footer=LTF_DEFAULT;
l->best_d=MAX_I8;
cl=&l->dummy;
cl->type=LTFT_ERROR;
cl->flags=0;
cl->x=0;
cl->y=0;
cl->min_col=0;
cl->max_col=0;
cl->indent=l->indent;
cl->page_line_num=l->page_line_num;
cl->left_margin=l->left_margin;
cl->right_margin=l->right_margin;
LtfHome(l);
}
public void LtfDel(Ltf *l)
{
Ltf *m;
if (!l) return;
m=l->menu_ltf;
LtfReset(l,TRUE);
Free(l->find_replace,l->mem_tss);
Free(l->dollar_buf,l->mem_tss);
LtfDel(m);
Free(l,l->mem_tss);
}
void LtfFormatData(LtfEntry *cl)
{
BoolU4 *b;
U8 *d;
I8 i;
if (cl->btype==LTFT_DATA) {
d=cl->data;
if (cl->flags & LTFLF_DATA_IS_PTR)
SPrintF(cl->display,cl->aux_str,*d,cl->my_format_data);
else
SPrintF(cl->display,cl->aux_str,d,cl->my_format_data);
if (cl->flags & LTFLF_HAS_TERMINATOR) {
i=StrLen(cl->display);
cl->display[i++]='_';
cl->display[i]=0;
}
cl->max_col=StrLen(cl->display);
} else if (cl->btype==LTFT_CHECK_BOX) {
if (cl->flags & LTFLF_DATA_IS_PTR)
b=cl->data;
else
b=&cl->data;
if (*b)
cl->flags|=LTFLF_CHECKED;
else
cl->flags&=~LTFLF_CHECKED;
}
}
void LtfGetData(LtfEntry *cl)
{
BoolU4 *b;
I8 i;
if (cl->btype==LTFT_DATA) {
i=StrLen(cl->display);
if (cl->flags & LTFLF_HAS_TERMINATOR)
cl->display[--i]=0;
if (i>cl->len+cl->min_col)
cl->display[cl->len+cl->min_col]=0;
if (cl->flags & LTFLF_DATA_IS_PTR)
GetF(cl->display,cl->aux_str,cl->data,cl->my_format_data);
else
GetF(cl->display,cl->aux_str,&cl->data,cl->my_format_data);
if (cl->flags & LTFLF_HAS_TERMINATOR)
cl->display[i]='_';
} else if (cl->btype==LTFT_CHECK_BOX) {
if (cl->flags & LTFLF_DATA_IS_PTR)
b=cl->data;
else
b=&cl->data;
if (cl->flags & LTFLF_CHECKED)
*b=TRUE;
else
*b=FALSE;
}
}
void LtfRemoveSoftCRs(Ltf *l=NULL,LtfEntry *cl=NULL)
{
LtfEntry *cl2,*saved_cl=cl;
BoolU4 old_preempt=Preempt(OFF);
if (!l) {
l=Fs->cur_ltf;
if (!l) return;
}
if (!cl) cl=l->dummy.next;
while (cl!=l) {
cl2=cl->next;
if (cl->btype==LTFT_SOFT_CR) {
if (l->cur_entry==cl) {
l->cur_entry=cl2;
l->cur_data_col=l->cur_entry->min_col;
}
LtfDelEntry(l,cl);
} else if (saved_cl && cl->btype==LTFT_CR)
break;
cl=cl2;
}
Preempt(old_preempt);
}
#help_index "Ltf/Cmd Line (Typically)"
public void LtfMax(U8 i=MAX_I4)
//Adjusts the size of the Ltf buffer.
//Normally, the command line deletes
//entries after a while.
{
Ltf *l=Fs->cur_ltf;
l->max_entries=i;
}
#help_index "Ltf"
public Ltf *LtfNew()
{
Ltf *l;
l=MAllocZ(sizeof(Ltf));
StrCpy(l->filename.name,sys_temp_filename);
l->file_attr=0;
l->find_replace=MAllocZ(sizeof(EditFindTextStruct));
l->find_replace->scan_forward=1;
l->find_replace->match_case=1;
l->LeftClickLink=&EditLeftClickLink;
l->dollar_buf_size=84;
l->dollar_buf=MAlloc(l->dollar_buf_size);
l->max_entries=MAX_I4;
l->ww_lines_back=32;
l->win_tss=Fs;
l->mem_tss=Fs;
LtfReset(l,FALSE);
return l;
}
sys_clipboard_ltf=LtfNew;
-688
View File
@@ -1,688 +0,0 @@
void ParseLtfFlags(LexStruct *l,U8 *flags,U4 *type)
{
I8 i;
BoolU4 turn_on;
while (l->token=='+' || l->token=='-') {
turn_on=(l->token=='+');
if (Lex(l)==TK_IDENT) {
i=MatchSysTextEntry(l->ident,"ST_LTF_FLAGS",MLE_EXACT);
if (i<0)
*type=LTFT_ERROR;
else {
AssignBit(flags,i,turn_on);
if (i==LTFLf_SELECTED)
AssignBit(type,30,turn_on);
else if (i==LTFLf_UNDERLINED)
AssignBit(type,31,turn_on);
else if (i==LTFLf_INVERTED)
AssignBit(type,29,turn_on);
else if (i==LTFLf_BLINK)
AssignBit(type,28,turn_on);
}
Lex(l); //skip flag
}
}
}
void LtfDefaultFlags(U4 *type,U8 *f1)
{
switch (*type & 255) {$AN,"default_flags","default_flags"$
case LTFT_TREE:
*f1=LTFLF_COLLAPSED|LTFLF_TREE;
*type|=LTFLT_UNDERLINE;
break;
case LTFT_DATA:
*f1=LTFLF_DATA_IS_PTR | LTFLF_HAS_TERMINATOR | LTFLF_AUX_STR;
break;
case LTFT_CURSOR_MOVEMENT:
*f1=LTFLF_LEFT_EXP | LTFLF_RIGHT_EXP;
break;
case LTFT_LINK:
*f1=LTFLF_LINK|LTFLF_AUX_STR;
*type|=LTFLT_UNDERLINE;
break;
case LTFT_ANCHOR:
*f1=LTFLF_AUX_STR;
break;
case LTFT_BUTTON:
*f1=LTFLF_ESC | LTFLF_LEFT_EXP | LTFLF_HAS_BORDER;
break;
case LTFT_CHECK_BOX:
*f1=LTFLF_DATA_IS_PTR;
break;
case LTFT_MACRO:
*f1=LTFLF_ESC | LTFLF_LEFT_MACRO;
*type|=LTFLT_UNDERLINE;
break;
case LTFT_MENU_VALUE:
*f1=LTFLF_ESC | LTFLF_LEFT_EXP;
*type|=LTFLT_UNDERLINE;
break;
case LTFT_HEX_EDIT:
*f1=LTFLF_DATA_IS_PTR | LTFLF_ZERO_BASED;
break;
case LTFT_PICWORD:
*f1=LTFLF_HAS_BIN|LTFLF_AUX_STR|LTFLF_FROM_START|LTFLF_WIDTH|LTFLF_HEIGHT;
break;
case LTFT_PICTURE:
*f1=LTFLF_HAS_BIN;
break;
case LTFT_TOP_LEFT_TOOLBAR:
*f1=LTFLF_HAS_BIN|LTFLF_TOP_LEFT_MENU|LTFLF_WIDTH|LTFLF_HEIGHT;
break;
case LTFT_TOP_RIGHT_TOOLBAR:
*f1=LTFLF_HAS_BIN|LTFLF_TOP_RIGHT_MENU|LTFLF_WIDTH|LTFLF_HEIGHT;
break;
case LTFT_INSERT_BINARY:
case LTFT_INSERT_BINARY_TYPE:
case LTFT_INSERT_BINARY_SIZE:
*f1=LTFLF_HAS_BIN;
break;
case LTFT_HIDE_START:
*f1=LTFLF_COLLAPSED;
*type|=LTFLT_UNDERLINE;
break;
case LTFT_SONG:
*f1=LTFLF_SONG;
break;
}
}
I1 *LtfToPlainText(Ltf *l,LtfEntry *ll)
{ //TODO: break strs
I8 i,j;
U8 type=ll->btype,f1=0,flags;
I1 *buf,*buf2;
buf=NewStr(SysTextSub(ll->btype,"ST_LTF_CMDS"));
if (ll->btype!=LTFT_ERROR) {
LtfDefaultFlags(&type,&f1);
flags=ll->flags & ~(LTFLF_WORD_WRAP |LTFLF_UNDERLINED |
LTFLF_INVERTED | LTFLF_BLINK | LTFLF_SKIP);
for (i=0;i<64;i++)
if (Bt(&f1,i)!=Bt(&flags,i)) {
if (Bt(&flags,i))
buf=Add2Str(buf,"+");
else
buf=Add2Str(buf,"-");
buf=Add2Str(buf,SysTextSub(i,"ST_LTF_FLAGS"));
}
for (i=28;i<32;i++)
if (Bt(&type,i)!=Bt(&ll->type,i)) {
if (Bt(&ll->type,i))
buf=Add2Str(buf,"+");
else
buf=Add2Str(buf,"-");
switch (i) {
case 28: j=LTFLf_BLINK; break;
case 29: j=LTFLf_INVERTED; break;
case 30: j=LTFLf_SELECTED; break;
case 31: j=LTFLf_UNDERLINED; break;
}
buf=Add2Str(buf,SysTextSub(j,"ST_LTF_FLAGS"));
}
buf=Add2Str(buf,",");
switch (ll->btype) {
case LTFT_TEXT:
case LTFT_LINK:
case LTFT_ANCHOR:
case LTFT_MENU_VALUE:
case LTFT_BUTTON:
case LTFT_CHECK_BOX:
case LTFT_TREE:
case LTFT_PICTURE:
case LTFT_PICWORD:
case LTFT_INSERT_BINARY:
case LTFT_INSERT_BINARY_TYPE:
case LTFT_INSERT_BINARY_SIZE:
case LTFT_SONG:
buf=Add2Str(buf,"\"");
if (i==LTFT_CHECK_BOX) {
buf=Add2Str(buf,ll->display+4);
} else {
if (ll->flags & LTFLF_TREE)
buf=Add2Str(buf,ll->display+3);
else
buf=Add2Str(buf,ll->display);
}
buf=Add2Str(buf,"\",");
break;
case LTFT_DATA:
buf2=MSPrintF("%s%d,",buf,ll->len);
Free(buf); buf=buf2;
break;
case LTFT_HEX_EDIT:
buf2=MSPrintF("%s%d,",buf,ll->len);
Free(buf); buf=buf2;
buf2=MSPrintF("%s%d,",buf,ll->hex_edit_width);
Free(buf); buf=buf2;
break;
case LTFT_PAGE_LENGTH:
case LTFT_LEFT_MARGIN:
case LTFT_RIGHT_MARGIN:
case LTFT_HEADER:
case LTFT_FOOTER:
case LTFT_INDENT:
case LTFT_FOREGROUND_COLOR:
case LTFT_BACKGROUND_COLOR:
case LTFT_DEFAULT_FOREGROUND_COLOR:
case LTFT_DEFAULT_BACKGROUND_COLOR:
case LTFT_LINK_FOREGROUND:
case LTFT_LINK_BACKGROUND:
case LTFT_MACRO_FOREGROUND:
case LTFT_MACRO_BACKGROUND:
case LTFT_ANCHOR_FOREGROUND:
case LTFT_ANCHOR_BACKGROUND:
case LTFT_HIDDEN_FOREGROUND:
case LTFT_HIDDEN_BACKGROUND:
case LTFT_TREE_FOREGROUND:
case LTFT_TREE_BACKGROUND:
case LTFT_USER_FOREGROUND:
case LTFT_USER_BACKGROUND:
case LTFT_WORD_WRAP:
case LTFT_UNDERLINED:
case LTFT_INVERTED:
case LTFT_BLINK:
case LTFT_SHIFTED_X:
case LTFT_SHIFTED_Y:
if (ll->attr!=LTF_DEFAULT) {
buf2=MSPrintF("%s%d,",buf,ll->attr);
Free(buf); buf=buf2;
}
break;
}
flags=ll->flags& (LTFLF_SCROLLING_X|LTFLF_SHIFTED_X|LTFLF_SCROLLING_Y|
LTFLF_AUX_STR|LTFLF_LEFT_EXP|LTFLF_LEFT_MACRO|
LTFLF_HAS_BIN|LTFLF_RIGHT_EXP|LTFLF_RIGHT_MACRO|
LTFLF_WIDTH|LTFLF_HEIGHT);
while (flags) {
j=Bsf(flags);
Btr(&flags,j);
switch (j) {
case LTFLf_SCROLLING_X:
buf2=MSPrintF("%s%d",buf,ll->scroll_len);
Free(buf); buf=buf2;
break;
case LTFLf_SHIFTED_X:
j=(ll->type.u2[1])&0x1F;
if (j&0x10) j|=0xFFFFFFF0;
buf2=MSPrintF("%s%d",buf,j);
Free(buf); buf=buf2;
break;
case LTFLf_SHIFTED_Y:
j=(ll->type>>21)&0x1F;
if (j&0x10) j|=0xFFFFFFF0;
buf2=MSPrintF("%s%d",buf,j);
Free(buf); buf=buf2;
break;
case LTFLf_AUX_STR:
buf2=MSPrintF("%s\"%Q\"",buf,ll->aux_str);
Free(buf); buf=buf2;
break;
case LTFLf_LEFT_EXP:
buf2=MSPrintF("%s%d",buf,ll->left_exp);
Free(buf); buf=buf2;
break;
case LTFLf_LEFT_MACRO:
buf2=MSPrintF("%s\"%Q\"",buf,ll->left_macro);
Free(buf); buf=buf2;
break;
case LTFLf_RIGHT_EXP:
buf2=MSPrintF("%s%d",buf,ll->right_exp);
Free(buf); buf=buf2;
break;
case LTFLf_RIGHT_MACRO:
buf2=MSPrintF("%s\"%Q\"",buf,ll->right_macro);
Free(buf); buf=buf2;
break;
case LTFLf_HAS_BIN:
buf2=MSPrintF("%s%d",buf,ll->bin_num);
Free(buf); buf=buf2;
break;
case LTFLf_WIDTH:
buf2=MSPrintF("%s%d",buf,ll->width);
Free(buf); buf=buf2;
break;
case LTFLf_HEIGHT:
buf2=MSPrintF("%s%d",buf,ll->height);
Free(buf); buf=buf2;
break;
}
buf=Add2Str(buf,",");
}
buf[StrLen(buf)-1]=0; //Kill last comma
}
buf2=NewStr(buf,l->mem_tss); //exact allocation
Free(buf);
return buf2;
}
LtfEntry *ParseDollarCmd(Ltf *l,I1 *st)
{
I8 i,j,size,flags;
I1 *ptr,*st2;
LtfEntry *ll=NULL;
LexStruct *lx=LexNew(st,LF_DONT_FREE_BUFFER,NULL);
Lex(lx);
if (lx->token==TK_IDENT) {
i=MatchSysTextEntry(lx->ident,"ST_LTF_CMDS",MLE_IGNORE_CASE);
if (i<0)
i=LTFT_ERROR;
Lex(lx); //skip cmd code
ll=MAllocZ(sizeof(LtfEntry),l->mem_tss);
ll->type=i;
LtfDefaultFlags(&ll->type,&ll->flags);
ParseLtfFlags(lx,&ll->flags,&ll->type);
if (lx->token==',')
Lex(lx);
switch (i) {
case LTFT_TEXT:
case LTFT_LINK:
case LTFT_ANCHOR:
case LTFT_MENU_VALUE:
case LTFT_BUTTON:
case LTFT_CHECK_BOX:
case LTFT_TREE:
case LTFT_PICTURE:
case LTFT_PICWORD:
case LTFT_INSERT_BINARY:
case LTFT_INSERT_BINARY_TYPE:
case LTFT_INSERT_BINARY_SIZE:
case LTFT_SONG:
if (lx->token==TK_STR) {
st2=LexExtendStr(lx,&size);
if (i==LTFT_CHECK_BOX) {
st=MSPrintF("[X] %s",st2);
Free(st2);
ll->min_col=1;
} else if (ll->flags & LTFLF_TREE) {
st=MSPrintF("+] %s",st2);
Free(st2);
ll->min_col=1;
} else
st=st2;
ll->display=NewStr(st,l->mem_tss);
Free(st);
} else {
if (i>=LTFT_PICTURE && i<=LTFT_INSERT_BINARY_SIZE ||
i==LTFT_SONG)
ll->display=NewStr("",l->mem_tss);
else {
ll->display=NULL;
ll->type=LTFT_ERROR;
}
}
break;
case LTFT_HIDE_START:
ll->display=NewStr("<-",l->mem_tss);
ll->min_col=1;
break;
case LTFT_HIDE_END:
ll->display=NewStr(">",l->mem_tss);
break;
case LTFT_DATA:
ll->flags|=LTFLF_AUX_STR; //don't allow switched off
ll->len=Expression(lx);
break;
case LTFT_HEX_EDIT:
ll->len=Expression(lx);
if (lx->token==',')
Lex(lx);
ll->hex_edit_width=Expression(lx);
break;
case LTFT_PAGE_LENGTH:
case LTFT_LEFT_MARGIN:
case LTFT_RIGHT_MARGIN:
case LTFT_HEADER:
case LTFT_FOOTER:
case LTFT_INDENT:
case LTFT_FOREGROUND_COLOR:
case LTFT_BACKGROUND_COLOR:
case LTFT_DEFAULT_FOREGROUND_COLOR:
case LTFT_DEFAULT_BACKGROUND_COLOR:
case LTFT_LINK_FOREGROUND:
case LTFT_LINK_BACKGROUND:
case LTFT_MACRO_FOREGROUND:
case LTFT_MACRO_BACKGROUND:
case LTFT_ANCHOR_FOREGROUND:
case LTFT_ANCHOR_BACKGROUND:
case LTFT_HIDDEN_FOREGROUND:
case LTFT_HIDDEN_BACKGROUND:
case LTFT_TREE_FOREGROUND:
case LTFT_TREE_BACKGROUND:
case LTFT_USER_FOREGROUND:
case LTFT_USER_BACKGROUND:
case LTFT_WORD_WRAP:
case LTFT_UNDERLINED:
case LTFT_INVERTED:
case LTFT_BLINK:
case LTFT_SHIFTED_X:
case LTFT_SHIFTED_Y:
if (!lx->token)
ll->attr=LTF_DEFAULT;
else
ll->attr=Expression(lx);
break;
case LTFT_ERROR:
ll->flags=0;
ll->type=LTFT_ERROR;
break;
}
flags=ll->flags& (LTFLF_SCROLLING_X|LTFLF_SHIFTED_X|LTFLF_SCROLLING_Y|
LTFLF_AUX_STR|LTFLF_LEFT_EXP|LTFLF_LEFT_MACRO|
LTFLF_HAS_BIN|LTFLF_RIGHT_EXP|LTFLF_RIGHT_MACRO|
LTFLF_WIDTH|LTFLF_HEIGHT);
while (flags) {
j=Bsf(flags);
Btr(&flags,j);
while (lx->token==',')
Lex(lx);
switch (j) { //TODO: Might check for expression errors
case LTFLf_SCROLLING_X:
ll->scroll_len=Expression(lx);
break;
case LTFLf_SHIFTED_X:
ll->type|=((Expression(lx) & 0x1F)<<16);
break;
case LTFLf_SHIFTED_Y:
ll->type|=((Expression(lx) & 0x1F)<<21);
break;
case LTFLf_AUX_STR:
if (lx->token==TK_STR) {
st2=LexExtendStr(lx,&size);
ll->aux_str=NewStr(st2,l->mem_tss);
Free(st2);
if (i==LTFT_MACRO && !ll->display)
ll->display=NewStr(ll->aux_str,l->mem_tss);
if (i==LTFT_DATA) {
if (ptr=StrStr(ll->aux_str,":"))
ll->min_col=ptr-ll->aux_str+1;
ll->display=MAlloc(ll->len+ll->min_col+2,l->mem_tss);
}
} else
ll->type=LTFT_ERROR;
break;
case LTFLf_LEFT_EXP:
ll->left_exp=Expression(lx);
break;
case LTFLf_LEFT_MACRO:
if (lx->token==TK_STR) {
st2=LexExtendStr(lx,&size);
ll->left_macro=NewStr(st2,l->mem_tss);
Free(st2);
if (i==LTFT_MACRO && !ll->display)
ll->display=NewStr(ll->left_macro,l->mem_tss);
} else
ll->type=LTFT_ERROR;
break;
case LTFLf_RIGHT_EXP:
ll->right_exp=Expression(lx);
break;
case LTFLf_RIGHT_MACRO:
if (lx->token==TK_STR) {
st2=LexExtendStr(lx,&size);
ll->right_macro=NewStr(st2,l->mem_tss);
Free(st2);
if (i==LTFT_MACRO && !ll->display)
ll->display=NewStr(ll->right_macro,l->mem_tss);
} else
ll->type=LTFT_ERROR;
break;
case LTFLf_HAS_BIN:
if (!lx->token)
ll->bin_num=0;
else
ll->bin_num=Expression(lx);
break;
case LTFLf_WIDTH:
ll->width=Expression(lx);
break;
case LTFLf_HEIGHT:
ll->height=Expression(lx);
break;
}
}
} else if (!ll) {
ll=MAllocZ(sizeof(LtfEntry),l->mem_tss);
ll->type=LTFT_ERROR;
}
LexDel(lx);
return ll;
}
void LtfInsert(Ltf *l,LtfEntry *ll)
{
I1 *dst;
LtfEntry *cl=l->cur_entry,*nl;
ll->x=cl->x;
ll->y=cl->y;
ll->indent=cl->indent;
ll->page_line_num=cl->page_line_num;
ll->left_margin=cl->left_margin;
ll->right_margin=cl->right_margin;
if (l->cur_data_col>0 &&
cl->btype==LTFT_TEXT &&
l->cur_data_col<cl->max_col) {
nl=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss);
nl->type=LTFT_TEXT|cl->type&-0x100;
nl->x=cl->x;
nl->y=cl->y;
nl->indent=cl->indent;
nl->page_line_num=cl->page_line_num;
nl->left_margin=cl->left_margin;
nl->right_margin=cl->right_margin;
nl->flags=cl->flags;
dst=cl->display+l->cur_data_col;
nl->display=NewStr(dst,l->mem_tss);
*dst=0;
cl->max_col=l->cur_data_col;
InsQue(nl,cl);
l->cur_data_col=0;
cl=nl;
cl->max_col=StrLen(cl->display);
}
if (cl->btype==LTFT_TEXT && l->cur_data_col>=cl->max_col) {
InsQue(ll,cl);
l->cur_entry=ll->next;
} else {
InsQue(ll,cl->last);
l->cur_entry=cl;
}
l->cur_data_col=l->cur_entry->min_col;
LtfRemoveSoftCRs(l,l->cur_entry);
}
#help_index "Ltf/Output"
public LtfEntry *LtfPutSExt(Ltf *l,I1 *st)
{
I1 ch,*ptr=st,*ptr2,*st2,*ptr3,*ptr4,*src;
BoolU4 old_preempt=Preempt(OFF);
LtfEntry *ll=NULL,*result=NULL,*cl=l->cur_entry;
l->recalc_start=l; //TODO:This might be optimized
if (!st) {
Preempt(old_preempt);
return NULL;
}
while (*ptr) {
ptr2=ptr;
ch=*ptr++;
while (TRUE) {
if (l->flags & LTFF_PLAIN_TEXT_WITH_TABS)
while (ch && ch!=CH_CR && ch!=CH_LINE_FEED && ch!=CH_CURSOR)
ch=*ptr++;
else if (l->flags & LTFF_PLAIN_TEXT)
while (ch && ch!=CH_CR && ch!=CH_LINE_FEED && ch!=CH_TAB && ch!=CH_CURSOR && ch!=CH_FORM_FEED)
ch=*ptr++;
else
while (ch && ch!=CH_CR && ch!=CH_LINE_FEED && ch!=CH_TAB && ch!=CH_CURSOR && ch!=CH_FORM_FEED && ch!='$$')
ch=*ptr++;
if (ch==CH_CURSOR) {
if (l->flags & LTFF_NO_CURSOR)
ch=*ptr++;
else
break;
} else
break;
}
ptr--;
if (!ch) {
if (ptr!=ptr2) {
ll=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss);
ll->type=LTFT_TEXT | l->text_attribute << 8;
if (l->flags & LTFF_NO_CURSOR) {
src=NewStr(ptr2);
StrUtil(src,SU_REMOVE_CTRL_CHARS);
} else
src=ptr2;
ll->display=NewStr(src,l->mem_tss);
ll->max_col=StrLen(src);
LtfInsert(l,ll);
if (l->flags & LTFF_NO_CURSOR)
Free(src);
}
} else {
if (ptr!=ptr2) {
*ptr=0;
ll=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss);
ll->type=LTFT_TEXT | l->text_attribute << 8;
if (l->flags & LTFF_NO_CURSOR) {
src=NewStr(ptr2);
StrUtil(src,SU_REMOVE_CTRL_CHARS);
} else
src=ptr2;
ll->display=NewStr(src,l->mem_tss);
ll->max_col=StrLen(src);
LtfInsert(l,ll);
if (l->flags & LTFF_NO_CURSOR)
Free(src);
*ptr=ch;
}
if (ch==CH_CURSOR) { //cursor
ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss);
ll->type=LTFT_CURSOR | l->text_attribute << 8;
LtfInsert(l,ll);
ptr++;
} else if (ch==CH_FORM_FEED) {
ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss);
ll->type=LTFT_PAGE_BREAK | l->text_attribute << 8;
LtfInsert(l,ll);
ptr++;
} else if (ch==CH_TAB) {
ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss);
ll->type=LTFT_TAB | l->text_attribute << 8;
LtfInsert(l,ll);
ptr++;
} else if (ch=='$$') {
ptr++; //skip first dollar
ptr2=ptr;
while (*ptr && *ptr!='$$')
ptr++;
if (*ptr) {
*ptr=0; //zero second dollar
if (ptr==ptr2) {
ll=MAllocZ(sizeof(LtfEntryBase)+sizeof(void *),l->mem_tss);
ll->type=LTFT_TEXT | l->text_attribute << 8;
ll->max_col=1;
if (l->flags & LTFF_DOUBLE_DOLLARS)
ll->display=NewStr("$$$$",l->mem_tss);
else
ll->display=NewStr("$$",l->mem_tss);
LtfInsert(l,ll);
} else {
st2=MAlloc(ptr-ptr2+1);
ptr3=ptr2;
ptr4=st2;
while (*ptr3) {
ch=*ptr3++;
if (ch==CH_CURSOR) {
ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss);
ll->type=LTFT_CURSOR | l->text_attribute << 8;
LtfInsert(l,ll);
} else if (ch==CH_FORM_FEED) {
ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss);
ll->type=LTFT_PAGE_BREAK | l->text_attribute << 8;
LtfInsert(l,ll);
} else
*ptr4++=ch;
}
*ptr4=0;
if (ll=ParseDollarCmd(l,st2)) {
result=ll;
LtfInsert(l,ll);
}
Free(st2);
}
*ptr++='$$';
}
} else {
ll=MAllocZ(sizeof(LtfEntryBase),l->mem_tss);
ll->type=LTFT_CR | l->text_attribute << 8;
LtfInsert(l,ll);
if (ch==CH_CR)
while (*ptr==CH_CR)
ptr++;
if (*ptr==CH_LINE_FEED)
ptr++;
while (*ptr==CH_CR)
ptr++;
}
}
}
Preempt(old_preempt);
return result;
}
public LtfEntry *LtfPrintF(Ltf *l,I1 *src,...)
{
LtfEntry *result;
I1 *buf=SPrintFJoin(NULL,src,argc,argv);
result=LtfPutSExt(l,buf);
Free(buf);
return result;
}
#help_index "PicWords"
#help_file "::/LT/Doc/PicWords.TXZ"
#help_index "PicWords;Ltf/Output"
public PicWordEntry *AddPicWord(I1 *st,GrElem *tempe,U8 size,I8 width=0,I8 height=0,I1 *txt=NULL)
{
//If you set $FG,4$txt$FG$, then include dollar signs
//$FG,4$$$PW,"padspaces","Word",%d,width,height$$$FG$
//
//If you want a macro picword
//$FG,4$$$PW+LM,"padspaces","Word","Macro",%d,width,height$$$FG$
//See $LK,"LtfWordsToPics","MN:LtfWordsToPics"$
I1 *st2;
I8 l;
PicWordEntry *temppw=MAllocZ(sizeof(PicWordEntry));
temppw->type=HTT_PIC_WORD;
temppw->use_cnt=0;
temppw->grelem=tempe;
temppw->size=size;
temppw->width=width;
temppw->height=height;
if (txt) {
l=StrLen(txt);
if (l>2) {
st2=MAlloc(l-2+1);
MemCpy(st2,txt+1,l-2);
st2[l-2]=0;
temppw->txt=st2;
}
}
temppw->source_link=NULL;
temppw->str=NewStr(st);
AddSysHashEntry(temppw,Fs->hash_table);
return temppw;
}
#help_index "Ltf"
-621
View File
@@ -1,621 +0,0 @@
public I8 LtfRunEntry(Ltf *l,LtfEntry *cl,BoolU4 exited,BoolU4 old_preempt)
{ //Call with preempt off
I8 result=-1;
I1 ch=l->cmd_I1,*st;
I8 cb(Ltf *l,LtfEntry *ll);
if (!exited) {
if (cl->flags & LTFLF_ESC) {
Msg(MSG_KEY_DOWN,CH_ESC,0,1<<TSSCf_DONT_FILTER);
return 0;
} if (cl->flags & LTFLF_QUIT) {
Msg(MSG_KEY_DOWN,CH_CTRLQ,0,1<<TSSCf_DONT_FILTER);
return 0;
}
}
l->best_d=MAX_I8;
if (cl->flags & LTFLF_LINK) {
try {
if (ch==CH_SPACE) {
if (l->LeftClickLink)
l->LeftClickLink(l,cl,old_preempt);
} else if (ch==CH_CR) {
if (l->RightClickLink)
l->RightClickLink(l,cl,old_preempt);
}
} catch
LtfBottom(l);
return 0;
}
if (ch==CH_SPACE && cl->flags & LTFLF_TREE || cl->btype==LTFT_HIDE_START)
cl->flags^=LTFLF_COLLAPSED;
if ((cl->btype>=LTFT_BUTTON && cl->btype<=LTFT_MENU_VALUE) ||
cl->btype==LTFT_PICTURE ||
cl->btype==LTFT_PICWORD ||
cl->btype==LTFT_TOP_LEFT_TOOLBAR ||
cl->btype==LTFT_TOP_RIGHT_TOOLBAR) {
if (cl->btype==LTFT_CHECK_BOX)
cl->flags^=LTFLF_CHECKED;
if (ch==CH_SPACE) {
if (cl->flags & LTFLF_LEFT_EXP) {
result=cl->left_exp;
Msg(MSG_CMD,result,0,1<<TSSCf_DONT_FILTER);
}
if (cl->flags & LTFLF_LEFT_CB) {
cb=cl->left_cb;
Preempt(old_preempt);
result=cb(l,cl);
Preempt(OFF);
Msg(MSG_CMD,result,0,1<<TSSCf_DONT_FILTER);
}
if (cl->flags & LTFLF_LEFT_MACRO) {
if (cl->flags & LTFLF_POPUP) {
st=NewStr(cl->left_macro);
Preempt(old_preempt);
PopUp(st,Fs);
Preempt(OFF);
Free(st);
} else {
if (cl->flags & LTFLF_LEFT_AUTO)
AutoStr("%s",cl->left_macro);
else
Auto(cl->left_macro);
}
}
} else if (ch==CH_CR) {
if (cl->flags & LTFLF_RIGHT_EXP) {
result=cl->right_exp;
Msg(MSG_CMD,result,0,1<<TSSCf_DONT_FILTER);
}
if (cl->flags & LTFLF_RIGHT_CB) {
cb=cl->right_cb;
Preempt(old_preempt);
result=cb(l,cl);
Preempt(OFF);
Msg(MSG_CMD,result,0,1<<TSSCf_DONT_FILTER);
}
if (cl->flags & LTFLF_RIGHT_MACRO) {
if (cl->flags & LTFLF_POPUP) {
st=NewStr(cl->right_macro);
Preempt(old_preempt);
PopUp(st,Fs);
Preempt(OFF);
Free(st);
} else {
if (cl->flags & LTFLF_RIGHT_AUTO)
AutoStr("%s",cl->right_macro);
else
Auto(cl->right_macro);
}
}
}
}
l->cmd_I1=CH_SPACE;
return result;
}
I1 *EditOverStrikeCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss)
{
Ltf *ltf=ll->user_data;
I1 *st=MAlloc(8,mem_tss);
nounusedwarn l;
st[0]=(ltf->flags & LTFF_OVERSTRIKE) ? 'O':130;
st[1]=0;
return st;
}
I1 *EditDollarCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss)
{
Ltf *ltf=ll->user_data;
I1 *st=MAlloc(8,mem_tss);
nounusedwarn l;
st[0]=(ltf->flags & LTFF_IN_DOLLAR) ? '$$':130;
st[1]=0;
return st;
}
I1 *EditQuotesCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss)
{
LexStruct *lx=mem_tss->last_lex;
I1 *st=MAlloc(8,mem_tss);
nounusedwarn l,ll;
st[0]=(lx->flags & LF_IN_QUOTES) ? '"':130;
st[1]=0;
return st;
}
I1 *EditBracesCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss)
{
LexStruct *lx=mem_tss->last_lex;
I1 *st=MAlloc(8,mem_tss);
nounusedwarn l,ll;
st[0]=(lx->braces_cnt) ? '}':130;
st[1]=0;
return st;
}
I1 *EditSemicolonCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss)
{
LexStruct *lx=mem_tss->last_lex;
I1 *st=MAlloc(8,mem_tss);
nounusedwarn l,ll;
st[0]=(lx->statement_cnt) ? ';':130;
st[1]=0;
return st;
}
I1 *EditPreemptCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss)
{
I1 *st=MAlloc(8,mem_tss);
nounusedwarn l,ll;
st[0]=Bt(&mem_tss->task_flags,TSSf_PREEMPT) ? 'P':130;
st[1]=0;
return st;
}
I1 *EditDollarTypeCB(Ltf *l,LtfEntry *ll,TssStruct *mem_tss)
{
Ltf *ltf=ll->user_data;
I1 *src=SysTextSub(ltf->cur_entry->btype,"ST_LTF_CMDS");
I1 *st=MAllocZ(8,mem_tss);
nounusedwarn l;
if (ltf->cur_entry==ltf) {
StrCpy(st,"EOF");
} else if (src) StrCpy(st,src);
return st;
}
public BoolU4 DoLtf(Ltf *l,BoolU4 home=TRUE,I1 *help=NULL,BoolU4 help_is_file=FALSE)
{
Ltf *menu=NULL,*old_ltf=Fs->cur_ltf,*old_aux=Fs->aux_ltf,*aux;
I8 old_attribute=Fs->text_attribute;
I8 ch=0;
U8 sc=0;
LtfEntry *ll;
void * old_update=Fs->update_win;
BoolU4 old_preempt;
if (help && !l->menu_ltf) {
if (help_is_file)
menu=LtfRead(help);
else {
menu=LtfNew;
menu->text_attribute=l->text_attribute;
LtfPutSExt(menu,help);
}
l->menu_ltf=menu;
}
l->win_tss=Fs;
aux=LtfNew;
aux->text_attribute=Fs->border_attribute;
LtfPutSExt(aux,"$$CM +TY,0,-1$$");
if (Bt(&Fs->crt_flags,CRTf_HAS_CLOSE_WIN))
LtfPutSExt(aux,"$$TX+RX+BD,\"[X]\"$$");
if (l->menu_ltf)
LtfPutSExt(aux,"$$TX+LX+BD,\"MENU\"$$");
ll=LtfPutSExt(aux,"$$DA-T-P+BD+RD+CX+SCX+IV,256,\"%s...\",16$$");
ll->data=&l->filename.name;
LtfFormatData(ll);
if (l->flags & LTFF_ALLOW_UNDO) {
LtfPutSExt(aux,"$$CM+BY+LX,0,1$$");
ll=LtfPutSExt(aux,"$$DA+BD+RD-T,32,\"Undo:%04d\"$$\r\n");
ll->data=&l->undo_cnt;
LtfFormatData(ll);
}
LtfPutSExt(aux,"$$CM+BY+RX,-24,1$$");
ll=LtfPutSExt(aux,"$$TX+BD+DC,\" \"$$");
ll->user_data=l;
ll->display_cb=&EditDollarTypeCB;
LtfPutSExt(aux,"$$CM+BY+RX,-21,1$$");
ll=LtfPutSExt(aux,"$$TX+BD+DC,\" \"$$");
ll->user_data=l;
ll->display_cb=&EditOverStrikeCB;
LtfPutSExt(aux,"$$CM+BY+RX,-20,1$$"); //gets merged without this
ll=LtfPutSExt(aux,"$$TX+BD+DC,\" \"$$");
ll->user_data=l;
ll->display_cb=&EditDollarCB;
ll=LtfPutSExt(aux,"$$DA+BD+RD-T,32,\"Line:%04d \"$$");
ll->data=&l->line;
LtfFormatData(ll);
ll=LtfPutSExt(aux,"$$DA+BD+RD-T,32,\"Col:%04d\"$$\r\n");
ll->data=&l->col;
LtfFormatData(ll);
old_preempt=Preempt(OFF);
aux->recalc_start=aux;
LtfRecalc(aux);
Fs->aux_ltf=aux;
l->recalc_start=l;
LtfRecalc(l);
if (home)
LtfHome(l);
Fs->cur_ltf=l;
Fs->text_attribute=l->text_attribute;
AssignBit(&Fs->crt_flags,CRTf_HAS_MENU,l->menu_ltf);
Fs->update_win=&LtfUpdateBothLtf;
Bts(&Fs->crt_flags,CRTf_SHOW);
do {
Preempt(OFF);
if (ScanKey(&ch,&sc)) {
Preempt(old_preempt);
PutKey(ch,sc);
LtfRecalc(Fs->cur_ltf);
} else {
Fs->task_flags|=1<<TSSf_IDLE;
if (!Fs->rmt_chnl &&
!(Fs->parent_tss && Fs->parent_tss->popup_tss==Fs)) {
Fs->task_flags|=1<<TSSf_AWAITING_MSG;
SwapInNext;
Preempt(old_preempt);
} else {
Preempt(old_preempt);
WinSync;
}
Fs->task_flags&=~(1<<TSSf_IDLE);
}
} while (ch!=CH_ESC && ch!=CH_CTRLQ);
Preempt(OFF);
Fs->cur_ltf=old_ltf;
Fs->aux_ltf=old_aux;
AssignBit(&Fs->crt_flags,CRTf_HAS_MENU,old_ltf->menu_ltf);
Fs->text_attribute=old_attribute;
Fs->update_win=old_update;
LtfDel(aux);
if (menu) {
l->menu_ltf=NULL;
LtfDel(menu);
}
Preempt(old_preempt);
return ch==CH_ESC;
}
#help_index "Ltf/Input"
public BoolU4 DoForm(U1 *D,I1 *class_name,
I1 *help=NULL,BoolU4 help_is_file=FALSE,
I1 *header=NULL,I1 *footer=NULL)
//Supply a class name that has fmtstr definitions
//and this routine will allow user input.
{
BoolU4 result=FALSE,old_preempt;
MemberListStruct *ml;
LtfEntry *ll;
I8 ch=0;
ClassStruct *cl=FindLocalHash(class_name,HTT_CLASS);
Ltf *l;
if (!cl) return FALSE;
l=LtfNew;
if (header) LtfPutSExt(l,header);
l->flags|=LTFF_OVERSTRIKE | LTFF_FORM;
ml=cl->member_list;
while (ml) {
if (ml->fmtstr) {
ll=LtfPutSExt(l,ml->fmtstr);
ll->data=D+ml->offset;
ll->my_format_data=ml->fmtdata;
LtfFormatData(ll);
}
ml=ml->next;
}
if (footer) LtfPutSExt(l,footer);
if (l->dummy.next!=l) {
l->flags&=~(LTFF_ATTR_BY_PARTITION | LTFF_ATTR_BY_FILENAME);
LtfRecalc(l);
if (DoLtf(l,TRUE,help,help_is_file)) {
old_preempt=Preempt(OFF);
ll=l->dummy.next;
while (ll!=l) {
if (ll->btype==LTFT_DATA || ll->btype==LTFT_CHECK_BOX)
LtfGetData(ll);
ll=ll->next;
}
ll=l->cur_entry;
if (ll!=l)
LtfRunEntry(l,ll,TRUE,old_preempt);
Preempt(old_preempt);
result=TRUE;
}
}
LtfDel(l);
return result;
}
void EndDoMenuCb()
{
WinToTop;
throw(EXCEPT_LOCAL);
}
public I8 DoMenu(Ltf *m,I1 *help=NULL,U8 flags=0)
{
void *old_end_cb=Fs->end_task_cb;
LtfEntry *ll;
I8 result=-1;
BoolU4 old_preempt;
Fs->end_task_cb=&EndDoMenuCb;
try {
if (m) {
m->flags&=~(LTFF_ATTR_BY_PARTITION | LTFF_ATTR_BY_FILENAME);
if (DoLtf(m,TRUE,help)) {
old_preempt=Preempt(OFF);
ll=m->cur_entry;
if (ll!=m)
result=LtfRunEntry(m,ll,TRUE,old_preempt);
Preempt(old_preempt);
}
}
} catch {
if (Fs->except_argc==1 && Fs->except_argv[0]==EXCEPT_LOCAL) {
if (!(flags & LTFPUF_INTERCEPT_TASK_END))
Exit;
Fs->catch_except=TRUE;
Preempt(old_preempt);
}
}
Fs->end_task_cb=old_end_cb;
return result;
}
#help_index "Ltf"
public I8 PopUp(I1 *msg,TssStruct *parent=NULL,TssStruct **pu_tss=NULL)
{
U8 result=0;
BoolU4 old_preempt=Preempt(OFF);
TssCmdStruct *tempc;
TssStruct *tss;
tss=Spawn(&ServantUserCmdLine,"SYSTEM TASK",parent);
if (!parent) {
QueueTaskRequest(tss,parent,msg,(1<<TSSCf_EXIT_ON_COMPLETE));
if (pu_tss) *pu_tss=tss;
Preempt(old_preempt);
return 0;
} else {
Fs->popup_tss=tss;
tempc=QueueTaskRequest(tss,parent,msg,
1<<TSSCf_WAKE_MASTER | 1<<TSSCf_FOCUS_MASTER);
GetRequestResult(tempc,&result);
Fs->popup_tss=NULL;
Kill(tss);
if (pu_tss) *pu_tss=NULL;
Preempt(old_preempt);
return result;
}
}
#help_index "Ltf/Output"
public TssStruct *PopUpViewLtf(Ltf *l,I1 *help=NULL)
{
I1 *buf=MSPrintF("Preempt(ON);DoLtf(0x%X,TRUE,0x%X);",l,help);
TssStruct *tss=Spawn(&ServantUserCmdLine,"View",Fs);
QueueTaskRequest(tss,NULL,buf,1<<TSSCf_EXIT_ON_COMPLETE);
Free(buf);
return tss;
}
void PopUpViewStrEndTsk()
{
LtfDel(Fs->user_data0);
Exit;
}
public TssStruct *PopUpViewStr(I1 *msg)
{
TssStruct *tss;
Ltf *l=LtfNew;
LtfPrintF(l,msg);
tss=PopUpViewLtf(l);
tss->user_data0=l;
tss->end_task_cb=&PopUpViewStrEndTsk;
return tss;
}
#help_index "Ltf/Input"
public I8 PopUpMenu(Ltf *l,I1 *help=NULL,U8 flags=0)
{
l->flags|=LTFF_MIN_SIZE | LTFF_FORM;
return ServantUser("DoMenu(0x%X,0x%X,0x%X);",l,help,flags);
}
void LTDirEntryToFileLtf(Ltf *l,LTDirEntry *tempm)
{
LtfEntry *ll;
while (tempm) {
if (tempm->attr & LT_ATTR_DIR) {
ll=LtfPrintF(l,"$$TR,\"%s\"$$",tempm->name);
ll->user_data=tempm;
LtfPutSExt(l,"\r\n$$ID,+2$$");
if (tempm->sub)
LTDirEntryToFileLtf(l,tempm->sub);
LtfPutSExt(l,"$$ID,-2$$");
} else
LtfPrintF(l,"$$MU,\"%s\",0x%08X$$\r\n",
tempm->name,tempm);
tempm=tempm->next;
}
}
public I1 *PopUpPickFile(I1 *mask="/*",I1 *flags=NULL)
{
I1 *result=NULL;
LTDirEntry *tempm,*tempm1;
U8 f=0;
Ltf *l=LtfNew;
GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),"+r");
GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),flags);
tempm=FindFiles(mask,f);
LtfPutSExt(l,"$$TR-C+AL,\"\"$$\r\n");
LtfPutSExt(l,"$$ID,+2$$");
LTDirEntryToFileLtf(l,tempm);
LtfPutSExt(l,"$$ID,-2$$");
tempm1=PopUpMenu(l);
if (tempm1<MAX_I4)
result=NewStr(tempm1->full_name);
else
result=NewStr("");
LtfDel(l);
DelLTDirList(tempm);
return result;
}
#help_index "Ltf/Output"
public void LTDirEntryToDirLtf(Ltf *l,LTDirEntry *tempm)
{
while (tempm) {
LtfPrintF(l,"$$TR,\"\"$$");
LtfPrintF(l,"$$MU,\"%s\",0x%08X$$\r\n",
tempm->name,tempm);
LtfPutSExt(l,"$$ID,+2$$");
if (tempm->sub)
LTDirEntryToDirLtf(l,tempm->sub);
LtfPutSExt(l,"$$ID,-2$$");
tempm=tempm->next;
}
}
#help_index "Ltf/Input"
public I1 *PopUpPickDir(I1 *mask="/*",I1 *flags=NULL)
{ //+r=recurse +D=just dirs
I1 *result=NULL;
LTDirEntry *tempm,*tempm1;
U8 f=0;
Ltf *l=LtfNew;
GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),"+r+D");
GetFFlags(&f,SysText("ST_FILE_UTIL_FLAGS"),flags);
tempm=FindFiles(mask,f);
LtfPutSExt(l,"$$TR-C+AL,\"\"$$\r\n");
LtfPutSExt(l,"$$ID,+2$$");
LTDirEntryToDirLtf(l,tempm);
LtfPutSExt(l,"$$ID,-2$$");
tempm1=PopUpMenu(l);
if (tempm1<MAX_I4)
result=NewStr(tempm1->full_name);
else
result=NewStr("");
LtfDel(l);
DelLTDirList(tempm);
return result;
}
#help_index "Ltf"
public BoolU4 PopUpCd()
{
I1 *st=PopUpPickDir;
BoolU4 result=Cd(st);
Free(st);
return result;
}
#help_index "Ltf/Input"
public I1 *PopUpPickListEntry(I1 *lst)
{
I8 i=0;
Ltf *l=LtfNew;
while (*lst) {
if (*lst=='@') { /* Check for '@' alias list entry*/
i--;
lst++;
}
LtfPrintF(l,"$$MU,\"%s\",0x%08X$$\r\n",
lst,i++);
lst+=StrLen(lst)+1;
}
LtfPrintF(l,"$$MU,\"CANCEL\",-1$$\r\n");
i=PopUpMenu(l);
LtfDel(l);
return i;
}
public I1 *PopUpPickSysTextSub(I1 *st)
{
return PopUpPickListEntry(SysText(st));
}
public BoolU4 PopUpDoForm(U1 *d,I1 *class_name,
I1 *help=NULL,BoolU4 help_is_file=FALSE)
{ //TODO: add header/footer
BoolU4 result;
result=ServantUser("DoForm(0x%X,\"%s\",0x%X,%d);",d,class_name,help,help_is_file);
return result;
}
public I8 PopUpOk(I1 *header=NULL,I1 *footer=NULL)
{
I8 i;
Ltf *l=LtfNew;
if (header) LtfPutSExt(l,header);
LtfPutSExt(l,"$$CM +CX,0,4$$$$BT, \"OKAY\" 1$$");
if (footer) LtfPutSExt(l,footer);
i=PopUpMenu(l);
LtfDel(l);
return i;
}
public I8 PopUpNoYes(I1 *header=NULL,I1 *footer=NULL)
{
I8 i;
Ltf *l=LtfNew;
if (header) LtfPutSExt(l,header);
LtfPutSExt(l,"$$CM +LX, 2,4$$$$BT, \"YES\",1$$");
LtfPutSExt(l,"$$CM +LX, 18,0$$$$BT, \"NO\",0$$");
if (footer) LtfPutSExt(l,footer);
i=PopUpMenu(l);
LtfDel(l);
return i;
}
public I8 PopUpCancelOk(I1 *header=NULL,I1 *footer=NULL)
{
I8 i;
Ltf *l=LtfNew;
if (header) LtfPutSExt(l,header);
LtfPutSExt(l,"$$CM +LX, 2,4$$$$BT, \"OK\",1$$");
LtfPutSExt(l,"$$CM +LX, 18,0$$$$BT, \"CANCEL\",0$$");
if (footer) LtfPutSExt(l,footer);
i=PopUpMenu(l);
LtfDel(l);
return i;
}
public I8 PopUpReplaceSkipAllCancel(I1 *header=NULL,I1 *footer=NULL)
{
I8 i;
Ltf *l=LtfNew;
if (header) LtfPutSExt(l,header);
LtfPutSExt(l,"$$CM +LX,2,4$$$$BT, \"REPLACE\",0$$");
LtfPutSExt(l,"$$CM +LX, 18,0$$$$BT, \"SKIP\",1$$");
LtfPutSExt(l,"$$CM +LX, 2,3$$$$BT, \"ALL\",2$$");
LtfPutSExt(l,"$$CM +LX, 18,0$$$$BT, \"CANCEL\",3$$");
if (footer) LtfPutSExt(l,footer);
i=PopUpMenu(l);
LtfDel(l);
return i;
}
#help_index "Ltf/Input;Input Pointer"
public I8 PopUpInputPointer()
{
I8 i;
Ltf *l=LtfNew;
LtfPutSExt(l,"$$CM+LX,2,4$$$$BT,\"Mouse\",IP_MOUSE$$");
LtfPutSExt(l,"$$CM+LX,18,0$$$$BT,\"JoyStick\",IP_JOYSTICK0$$");
i=PopUpMenu(l);
switch (i) {
case IP_MOUSE:
ip_pointer_type=i;
break;
case IP_JOYSTICK0:
ip_pointer_type=i;
LoadJoystickCalibration;
break;
}
LtfDel(l);
return i;
}
#help_index "Ltf"
File diff suppressed because it is too large Load Diff
-66
View File
@@ -1,66 +0,0 @@
#help_index "Math"
public double Abs(double i)
{
if (i<0)
return -i;
else
return i;
}
public double Sign(double i)
{
if (i<0)
return -1.0;
else if (!i)
return 0.0;
else
return 1.0;
}
public double Sqr(double d)
{
return d*d;
}
public void R2P(double *mag,double *arg,double x,double y)
{ //Rect to polar
*arg=Arg(x,y);
*mag=Sqrt(x*x+y*y);
}
public void P2R(double *x,double *y,double mag,double arg)
{ //Polar to Rect
*x=mag*Cos(arg);
*y=mag*Sin(arg);
}
public double Unwrap(double theta,double base=-pi)
{
double result=theta%pi2;
if (result<base) result+=pi2;
if (result>base+pi2) result-=pi2;
return result;
}
public I8 SignI8(I8 i)
{
if (i<0)
return -1;
else if (!i)
return 0;
else
return 1;
}
public I8 SqrI8(I8 i)
{
return i*i;
}
public I8 DistI8(I8 x1,I8 y1,I8 x2,I8 y2)
{
I8 dx=x1-x2,dy=y1-y2;
return dx*dx+dy*dy;
}
#help_index ""
-142
View File
@@ -1,142 +0,0 @@
#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 ""
-140
View File
@@ -1,140 +0,0 @@
#help_index "Sound"
I1 *cur_song=NULL;
TssStruct *cur_song_tss=NULL;
U8 music_octive;
double music_note_len;
U1 music_note_map[7]={0,2,3,5,7,8,10};
BoolU4 music_mute=FALSE;
//This is if you wish to sync with a
//note in a Play() string. 0 is the start
public I8 music_play_note_num=0;
public double music_tempo,music_stacatto_factor=1.0;
I1 *MusicSetOctive(I1 *st)
{
I1 ch=*st++;
while (ch>='0' && ch<='9') {
music_octive=ch-'0';
ch=*st++;
}
return --st;
}
I1 *MusicSetNoteLen(I1 *st)
{
BoolU4 cont=TRUE;
do {
switch (*st++) {
case 'w': music_note_len=4.0; break;
case 'h': music_note_len=2.0; break;
case 'q': music_note_len=1.0; break;
case 'e': music_note_len=0.5; break;
case 's': music_note_len=0.25; break;
case 't': music_note_len=2.0*music_note_len/3.0; break;
case '.': music_note_len=1.5*music_note_len; break;
default:
st--;
cont=FALSE;
}
} while (cont);
return st;
}
public double Note2Freq(I8 note,I8 octive=3)
{
return 2.0`(6+octive+(note-3)/12.0);
}
public void Play(I1 *st,I1 *words=NULL)
/*
Notes are entered with a capital letter.
Octives are entered with a digit and
stay set until changed.
Durations are entered with
'w' whole note
'h' half note
'q' quarter note
'e' eighth note
't' sets to 2/3rds the current duration
'.' sets to 1.5 times the current duration
durations stay set until changed.
Sharp and flat are done with '#' or 'b'.
The variable $FG,4$music_stacatto_factor$FG$ can
be set to a range from 0.0 to 1.0.
The variable $FG,4$music_tempo$FG$ defaults to
2.5 and gets faster when bigger.
*/
{
I1 *word;
U8 note,i=0;
double f;
music_play_note_num=0;
while (*st) {
st=MusicSetOctive(st);
st=MusicSetNoteLen(st);
st=MusicSetOctive(st);
if (!*st) break;
note=*st++-'A';
if (note<7) {
note=music_note_map[note];
if (*st=='b') {
note--;
st++;
} else if (*st=='#') {
note++;
st++;
}
f=Note2Freq(note,music_octive);
} else
f=0;
if (words) {
if (word=PointAtListEntry(i++,words))
if (StrCmp(word," "))
PutS(word);
}
if (!music_mute)
Sound(f);
Sleep(1000*music_stacatto_factor*music_note_len/music_tempo);
if (!music_mute)
Sound(0);
Sleep(1000*(1.0-music_stacatto_factor)*music_note_len/music_tempo);
music_play_note_num++;
}
}
void ResetMusicSettings()
{
music_stacatto_factor=1.0;
music_tempo=2.5;
music_octive=3;
music_note_len=1.0;
}
ResetMusicSettings;
void EndCurSong()
{
Sound(0);
Exit;
}
void CurSongTsk()
{
Preempt(ON);
Fs->end_task_cb=&EndCurSong;
while (TRUE)
Play(cur_song);
}
#help_index ""
-194
View File
@@ -1,194 +0,0 @@
#help_index "Math"
//This is taken from the book, $UL,1$Numeric Recipies in C$UL,0$
Ode *OdeNew(U8 n)
{
Ode *o=MAllocZ(sizeof(Ode));
o->n=n;
o->state=MAllocZ(n*sizeof(double));
o->internal_state=MAllocZ(n*sizeof(double));
o->base_t=GetTimeStamp*1.0/time_stamp_freq;
o->h=1.0e-6;
o->DstateDt=MAllocZ(n*sizeof(double));
o->state_scale=MAllocZ(n*sizeof(double));
o->initial_state=MAllocZ(n*sizeof(double));
o->tolerance_start=1.0e-6;
o->temp0=MAllocZ(n*sizeof(double));
o->temp1=MAllocZ(n*sizeof(double));
o->temp2=MAllocZ(n*sizeof(double));
o->temp3=MAllocZ(n*sizeof(double));
o->temp4=MAllocZ(n*sizeof(double));
o->temp5=MAllocZ(n*sizeof(double));
o->temp6=MAllocZ(n*sizeof(double));
o->temp7=MAllocZ(n*sizeof(double));
o->win_tss=Fs;
o->mem_tss=Fs;
return o;
}
void OdeDel(Ode *o)
{
Free(o->state);
Free(o->internal_state);
Free(o->DstateDt);
Free(o->state_scale);
Free(o->initial_state);
Free(o->temp0);
Free(o->temp1);
Free(o->temp2);
Free(o->temp3);
Free(o->temp4);
Free(o->temp5);
Free(o->temp6);
Free(o->temp7);
Free(o);
}
void OdeOneStep(Ode *o)
{
I8 i;
o->derivative(o,o->t+o->base_t,o->internal_state,o->DstateDt);
for (i=0;i<o->n;i++)
o->internal_state[i]+=o->h*o->DstateDt[i];
o->t+=o->h;
}
void OdeRK4OneStep(Ode *o)
{
I8 i,n=o->n;
double xh,hh,h6;
double *dym,*dyt,*yt,*DstateDt;
dym =o->temp0;
dyt =o->temp1;
yt =o->temp2;
DstateDt=o->temp3;
hh =0.5*o->h;
h6 =o->h / 6.0;
xh =o->t +o->base_t+ hh;
o->derivative(o,o->t+o->base_t,o->internal_state,o->DstateDt);
for (i=0;i<n;i++)
yt[i]=o->internal_state[i]+hh*DstateDt[i];
o->derivative(o,xh,yt,dyt);
for (i=0;i<n;i++)
yt[i]=o->internal_state[i]+hh*dyt[i];
o->derivative(o,xh,yt,dym);
for (i=0;i<n;i++) {
yt[i]=o->internal_state[i]+o->h*dym[i];
dym[i]+=dyt[i];
}
o->t+=o->h;
o->derivative(o,o->t+o->base_t,yt,dyt);
for (i=0;i<n;i++)
o->internal_state[i]+=h6*(DstateDt[i]+dyt[i]+2.0*dym[i]);
}
#define ODEa2 0.2
#define ODEa3 0.3
#define ODEa4 0.6
#define ODEa5 1.0
#define ODEa6 0.875
#define ODEb21 0.2
#define ODEb31 (3.0/40.0)
#define ODEb32 (9.0/40.0)
#define ODEb41 0.3
#define ODEb42 (-0.9)
#define ODEb43 1.2
#define ODEb51 (-11.0/54.0)
#define ODEb52 2.5
#define ODEb53 (-70.0/27.0)
#define ODEb54 (35.0/27.0)
#define ODEb61 (1631.0/55296.0)
#define ODEb62 (175.0/512.0)
#define ODEb63 (575.0/13824.0)
#define ODEb64 (44275.0/110592.0)
#define ODEb65 (253.0/4096.0)
#define ODEc1 (37.0/378.0)
#define ODEc3 (250.0/621.0)
#define ODEc4 (125.0/594.0)
#define ODEc6 (512.0/1771.0)
#define ODEdc1 (37.0/378.0-2825.0/27648.0)
#define ODEdc3 (250.0/621.0-18575.0/48384.0)
#define ODEdc4 (125.0/594.0-13525.0/55296.0)
#define ODEdc5 (-277.0/14336.0)
#define ODEdc6 (512.0/1771.0-0.25)
void OdeCashKarp(Ode *o)
{
I8 i,n=o->n;
double h=o->h,*state=o->internal_state,*DstateDt=o->DstateDt,*ak2,*ak3,*ak4,*ak5,*ak6,*tempstate,*stateerr,*outstate;
ak2=o->temp0;
ak3=o->temp1;
ak4=o->temp2;
ak5=o->temp3;
ak6=o->temp4;
tempstate=o->temp5;
outstate=o->temp6;
stateerr=o->temp7;
for (i=0;i<n;i++)
tempstate[i]=state[i]+ODEb21*h*DstateDt[i];
o->derivative(o,o->t+o->base_t+ODEa2*h,tempstate,ak2);
for (i=0;i<n;i++)
tempstate[i]=state[i]+h*(ODEb31*DstateDt[i]+ODEb32*ak2[i]);
o->derivative(o,o->t+o->base_t+ODEa3*h,tempstate,ak3);
for (i=0;i<n;i++)
tempstate[i]=state[i]+h*(ODEb41*DstateDt[i]+ODEb42*ak2[i]+ODEb43*ak3[i]);
o->derivative(o,o->t+o->base_t+ODEa4*h,tempstate,ak4);
for (i=0;i<n;i++)
tempstate[i]=state[i]+h*(ODEb51*DstateDt[i]+ODEb52*ak2[i]+ODEb53*ak3[i]+ODEb54*ak4[i]);
o->derivative(o,o->t+o->base_t+ODEa5*h,tempstate,ak5);
for (i=0;i<n;i++)
tempstate[i]=state[i]+h*(ODEb61*DstateDt[i]+ODEb62*ak2[i]+ODEb63*ak3[i]+ODEb64*ak4[i]+ODEb65*ak5[i]);
o->derivative(o,o->t+o->base_t+ODEa6*h,tempstate,ak6);
for (i=0;i<n;i++)
outstate[i]=state[i]+h*(ODEc1*DstateDt[i]+ODEc3*ak3[i]+ODEc4*ak4[i]+ODEc6*ak6[i]);
for (i=0;i<n;i++)
stateerr[i]=h*(ODEdc1*DstateDt[i]+ODEdc3*ak3[i]+ODEdc4*ak4[i]+ODEdc5*ak5[i]+ODEdc6*ak6[i]);
}
#define SAFETY (0.9)
#define PGROW (-0.2)
#define PSHRNK (-0.25)
#define ERRCON (1.89e-4)
void OdeRK5OneStep(Ode *o)
{
I8 i;
double errmax,temp;
double *tempstate=o->temp6,*stateerr=o->temp7;
while (TRUE) {
OdeCashKarp(o);
errmax=0.0;
for (i=0;i<o->n;i++) {
temp=Abs(stateerr[i]/o->state_scale[i]);
if (temp>errmax)
errmax=temp;
}
errmax/=o->tolerance;
if (errmax>1.0 && o->h>1.0e-64) {
temp=o->h*SAFETY*errmax`PSHRNK;
if (temp<0.1*o->h)
o->h*=0.1;
else
o->h=temp;
} else {
o->t+=o->h;
if (errmax>ERRCON)
o->h*=SAFETY*errmax`PGROW;
else
o->h*=5.0;
if (o->h>1.0e32)
o->h=1.0e32;
MemCpy(o->internal_state,tempstate,sizeof(double)*o->n);
break;
}
}
}
#help_index ""
Binary file not shown.
-798
View File
@@ -1,798 +0,0 @@
#help_index "Comm"
#define RMT_MAX_PKT_LEN 64 //Must be less then PKT_SYNC
#define RMT_PKT_ACK 0xA5
#define RMT_PKT_NACK 0x5A
#define RMT_PKT_SYNC 0xA3
#define RMT_PKT_SYNC2 0xA7
#define RMT_PKT_CHAR 0xA4
#define RMT_PKT_REQUEST 0xA6
#define RMT_PKT_RESET 0xA8
#define RMT_FILE_ACK 0x87566565
#define RMT_RQST_NONE 0x00
#define RMT_RQST_GETMSG 0x01
#define RMT_RQST_TX_FILE 0x02
#define RMT_RQST_RX_FILE 0x03
#define RMT_RQST_TX_BUF 0x04
#define RMT_RQST_RX_BUF 0x05
#define RMT_RQST_EXE_LOCAL 0x06
#define RMT_RQST_PUTS_CNT 0x07
#define RMT_NUM_RQST_TYPES 0x08
#define RMT_CHAR_DELAY (JIFFY_FREQ/50)
#define RMT_TX_TIMEOUT_DELAY (JIFFY_FREQ)
#define RMT_RX_TIMEOUT_DELAY (JIFFY_FREQ)
#define RMT_NULL_MSG_DELAY (JIFFY_FREQ/20)
public void RmtFlushRxFifo(LTChnl *chnl)
{
if (!chnl || !chnl->type) return;
U1FifoFlush(comm_Rx_fifos[chnl->port]);
if (Bt(&comm_flags[chnl->port],COMMf_INCOMING_XOFFED)) {
Bts(&comm_flags[chnl->port],COMMf_INCOMING_XOFFED2);
Bts(&comm_flags[chnl->port],COMMf_INCOMING_XOFFED3);
chnl->PutChar(chnl,CH_XON);
}
}
public I8 RmtTxFifoCnt(LTChnl *chnl)
{
if (!chnl || !chnl->type) return 0;
return U1FifoCnt(comm_Tx_fifos[chnl->port]);
}
public void RmtWaitTxDone(LTChnl *chnl)
{
U8 base=comm_base[chnl->port];
if (!chnl || !chnl->type) return;
while (RmtTxFifoCnt(chnl))
SwapInNext;
while (Bt(&comm_flags[chnl->port],COMMf_OUTGOING_XOFFED))
SwapInNext;
while (Bt(&comm_flags[chnl->port],COMMf_TX_XOFF))
SwapInNext;
while (Bt(&comm_flags[chnl->port],COMMf_TX_XON))
SwapInNext;
while (!(InP(base+UART_LSR) & 0x20))
SwapInNext;
}
public void RmtFlushTxFifo(LTChnl *chnl)
{
U8 base=comm_base[chnl->port];
if (!chnl || !chnl->type) return;
U1FifoFlush(comm_Tx_fifos[chnl->port]);
RmtWaitTxDone(chnl);
}
void RmtReset(LTChnl *chnl)
{
RmtFlushTxFifo(chnl);
RmtFlushRxFifo(chnl);
comm_flags[chnl->port]=0;
}
public void RmtPrintF(LTChnl *chnl,I1 *src,...)
{
I1 *buf,*ptr;
if (!chnl || !chnl->type) return;
buf=SPrintFJoin(NULL,src,argc,argv);
ptr=buf;
while (*ptr)
chnl->PutChar(chnl,*ptr++);
Free(buf);
}
public I8 RmtRxFifoCnt(LTChnl *chnl)
{
if (!chnl || !chnl->type) return 0;
return U1FifoCnt(comm_Rx_fifos[chnl->port]);
}
public U1 RmtGetChar(LTChnl *chnl)
{
if (!chnl || !chnl->type)
return 0;
return CommGetChar(chnl->port);
}
public BoolU4 RmtScanChar(LTChnl *chnl,U1 *ch)
{
if (!chnl || !chnl->type)
return 0;
return CommScanChar(chnl->port,ch);
}
U8 RmtTxPktU1(LTChnl *chnl,U1 b)
{
if (!chnl || !chnl->type) return 0;
if (b==CH_XOFF || b==CH_XON ||
b==CH_ESC || b==RMT_PKT_CHAR ||
b==RMT_PKT_REQUEST ||
b==RMT_PKT_RESET) {
chnl->PutChar(chnl,CH_ESC);
chnl->PutChar(chnl,b^0x80);
return 2;
} else {
chnl->PutChar(chnl,b);
return 1;
}
}
BoolU8 RmtRxPktU1(LTChnl *chnl,U1 *b,
U8 timeout_jiffies,BoolU4 *esc=NULL)
{
U1 b1;
U8 timeout;
*b=RMT_PKT_NACK;
if (esc)
*esc=FALSE;
if (!chnl || !chnl->type)
return FALSE;
timeout=Jiffies+timeout_jiffies;
while (Jiffies<timeout) {
if (chnl->ScanChar(chnl,&b1)) {
if (b1==CH_ESC) {
timeout=Jiffies+timeout_jiffies;
while (Jiffies<timeout) {
if (chnl->ScanChar(chnl,&b1)) {
*b=b1^0x80;
if (esc) *esc=TRUE;
return TRUE;
}
SwapInNext;
}
return FALSE;
} else {
if (b1==RMT_PKT_RESET) {
RmtReset(chnl);
throw(EXCP_RESET);
}
*b=b1;
return TRUE;
}
}
SwapInNext;
}
return FALSE;
}
#define ERR_DELAY 1
void RmtTxPkt(LTChnl *chnl,U1 *p,U8 size,U8 rqst=RMT_RQST_NONE,
U8 timeout_delay=0)
{ //zero timeout_delay=none
U1 b,xsum;
U8 i,timeout_jiffy;
if (!chnl || !chnl->type) return;
if (!timeout_delay && (Fs->rmt_chnl==chnl || Fs->local_chnl==chnl)) {
timeout_delay=RMT_TX_TIMEOUT_DELAY;
if (Fs->rmt_chnl==chnl &&
chnl->pkt_rx_jiffy+RMT_NULL_MSG_DELAY<<1<Jiffies)
timeout_delay=RMT_NULL_MSG_DELAY<<1;
}
if (timeout_delay)
timeout_jiffy=Jiffies+timeout_delay;
else
timeout_jiffy=MAX_I8;
if (rqst) {
rt_err1:
if (Jiffies>timeout_jiffy)
throw(EXCP_TIMEOUT);
RmtFlushTxFifo(chnl);
RmtFlushRxFifo(chnl);
chnl->PutChar(chnl,RMT_PKT_REQUEST);
RmtWaitTxDone(chnl);
if (RmtScanChar(chnl,&b)) {
Sleep(ERR_DELAY);
goto rt_err1;
}
RmtTxPktU1(chnl,rqst);
RmtWaitTxDone(chnl);
RmtRxPktU1(chnl,&b,RMT_CHAR_DELAY);
if (b!=(RMT_PKT_ACK^RMT_PKT_REQUEST^rqst)&0xFF) {
Sleep(ERR_DELAY);
goto rt_err1;
}
} else if (size==1) {
rt_err2:
if (Jiffies>timeout_jiffy)
throw(EXCP_TIMEOUT);
RmtFlushTxFifo(chnl);
RmtFlushRxFifo(chnl);
chnl->PutChar(chnl,RMT_PKT_CHAR);
RmtWaitTxDone(chnl);
if (RmtScanChar(chnl,&b)) {
Sleep(ERR_DELAY);
goto rt_err2;
}
RmtTxPktU1(chnl,p[0]);
RmtWaitTxDone(chnl);
RmtRxPktU1(chnl,&b,RMT_CHAR_DELAY);
if (b!=RMT_PKT_ACK^RMT_PKT_CHAR^p[0]) {
Sleep(ERR_DELAY);
goto rt_err2;
}
} else {
rt_err3:
if (Jiffies>timeout_jiffy)
throw(EXCP_TIMEOUT);
RmtFlushTxFifo(chnl);
RmtFlushRxFifo(chnl);
RmtTxPktU1(chnl,RMT_PKT_SYNC);
RmtWaitTxDone(chnl);
if (RmtScanChar(chnl,&b)) {
Sleep(ERR_DELAY);
goto rt_err3;
}
RmtTxPktU1(chnl,RMT_PKT_SYNC2);
RmtWaitTxDone(chnl);
RmtRxPktU1(chnl,&b,RMT_CHAR_DELAY);
if (b!=RMT_PKT_ACK^RMT_PKT_SYNC) {
Sleep(ERR_DELAY);
goto rt_err3;
}
if (RmtScanChar(chnl,&b)) {
Sleep(ERR_DELAY);
goto rt_err3;
}
RmtTxPktU1(chnl,size);
RmtWaitTxDone(chnl);
RmtRxPktU1(chnl,&b,RMT_CHAR_DELAY);
if (b!=(RMT_PKT_ACK^size)&0xFF) {
Sleep(ERR_DELAY);
goto rt_err3;
}
xsum=0x3A;
for (i=0;i<size;i++) {
RmtTxPktU1(chnl,p[i]);
if (RmtScanChar(chnl,&b)) {
Sleep(ERR_DELAY);
goto rt_err3;
}
xsum^=p[i];
}
while (RmtTxFifoCnt(chnl)) {
if (RmtScanChar(chnl,&b)) {
Sleep(ERR_DELAY);
goto rt_err3;
}
SwapInNext;
}
RmtTxPktU1(chnl,xsum);
RmtWaitTxDone(chnl);
RmtRxPktU1(chnl,&b,RMT_CHAR_DELAY);
if (b!=(RMT_PKT_ACK^xsum)&0xFF) {
Sleep(ERR_DELAY);
goto rt_err3;
}
}
chnl->pkt_tx_jiffy=Jiffies;
}
void RmtRxPkt(LTChnl *chnl,U1 *p,U8 *size=NULL,U8 *rqst=NULL,
U8 timeout_delay=0)
{ //zero timeout_delay=none
U1 b,b1,xsum;
U8 i=0,s,r,timeout_jiffy;
BoolU4 esc;
if (!chnl || !chnl->type) {
if (size) *size=0;
if (rqst) *rqst=0;
return;
}
if (!timeout_delay && (Fs->rmt_chnl==chnl || Fs->local_chnl==chnl)) {
timeout_delay=RMT_RX_TIMEOUT_DELAY;
if (Fs->rmt_chnl==chnl &&
chnl->pkt_rx_jiffy+RMT_NULL_MSG_DELAY<<1<Jiffies)
timeout_delay=RMT_NULL_MSG_DELAY<<1;
}
if (timeout_delay)
timeout_jiffy=Jiffies+timeout_delay;
else
timeout_jiffy=MAX_I8;
rr_start:
RmtFlushTxFifo(chnl);
if (RmtRxFifoCnt(chnl)>2)
RmtFlushRxFifo(chnl);
s=0;
r=0;
RmtRxPktU1(chnl,&b,RMT_CHAR_DELAY);
rr_cont:
if (Jiffies>timeout_jiffy)
throw(EXCP_TIMEOUT);
RmtRxPktU1(chnl,&b1,RMT_CHAR_DELAY,&esc);
if (b==RMT_PKT_REQUEST) {
if (b1>=RMT_NUM_RQST_TYPES) {
if (b1==RMT_PKT_REQUEST && !esc)
goto rr_cont;
else
goto rr_err;
}
r=b1;
s=0;
if (RmtScanChar(chnl,&b))
goto rt_err;
RmtTxPktU1(chnl,RMT_PKT_ACK^RMT_PKT_REQUEST^b1);
goto rr_exit;
} else if (b==RMT_PKT_CHAR) {
if (b1==RMT_PKT_CHAR && !esc)
goto rr_cont;
*p=b1;
s=1;
if (RmtScanChar(chnl,&b))
goto rt_err;
RmtTxPktU1(chnl,RMT_PKT_ACK^RMT_PKT_CHAR^b1);
goto rr_exit;
} else if (b==RMT_PKT_SYNC) {
if (b1!=RMT_PKT_SYNC2) {
if (b1==RMT_PKT_SYNC)
goto rr_cont;
else
goto rr_err;
}
if (RmtScanChar(chnl,&b))
goto rt_err;
RmtTxPktU1(chnl,RMT_PKT_ACK^RMT_PKT_SYNC);
RmtWaitTxDone(chnl);
RmtRxPktU1(chnl,&s,RMT_CHAR_DELAY);
if (s>RMT_MAX_PKT_LEN)
goto rr_err;
if (RmtScanChar(chnl,&b))
goto rt_err;
RmtTxPktU1(chnl,(RMT_PKT_ACK^s)&0xFF);
RmtWaitTxDone(chnl);
xsum=0x3A;
for (i=0;i<s;i++) {
if (!RmtRxPktU1(chnl,&p[i],RMT_CHAR_DELAY))
goto rr_err;
xsum^=p[i];
}
RmtRxPktU1(chnl,&b,RMT_CHAR_DELAY);
if (b!=xsum)
goto rr_err;
if (RmtScanChar(chnl,&b))
goto rt_err;
RmtTxPktU1(chnl,(RMT_PKT_ACK^xsum)&0xFF);
goto rr_exit;
} else {
if (++i & 3)
goto rr_start;
else
goto rr_err;
}
rr_err:
RmtFlushTxFifo(chnl);
RmtFlushRxFifo(chnl);
RmtTxPktU1(chnl,RMT_PKT_NACK);
RmtWaitTxDone(chnl);
goto rr_start;
rr_exit:
RmtWaitTxDone(chnl);
if (size) *size=s;
if (rqst) *rqst=r;
chnl->pkt_rx_jiffy=Jiffies;
}
public void RmtTxBlk(LTChnl *chnl,U1 *buf,I8 cnt)
{
U1 b[RMT_MAX_PKT_LEN];
U8 size;
if (!chnl || !chnl->type) return;
while (cnt>0) {
if (cnt<RMT_MAX_PKT_LEN)
size=cnt;
else
size=RMT_MAX_PKT_LEN;
MemCpy(b,buf,size);
RmtTxPkt(chnl,b,size);
cnt-=size;
buf+=size;
progress1=cnt;
}
}
public U1 *RmtRxBlk(LTChnl *chnl,I8 cnt)
{
U1 *result,*buf;
U1 b[RMT_MAX_PKT_LEN];
U8 size=0;
if (!chnl || !chnl->type) return NULL;
result=MAlloc(cnt);
buf=result;
while (cnt>0) {
RmtRxPkt(chnl,b,&size);
MemCpy(buf,b,size);
cnt-=size;
buf+=size;
progress1=cnt;
}
return result;
}
public U8 RmtGetMsg(LTChnl *chnl,I8 *p1,I8 *p2)
{
U8 cmd=0,size;
U1 b[RMT_MAX_PKT_LEN];
*p1=0;
*p2=0;
if (!chnl || !chnl->type)
return 0;
if (Jiffies<chnl->null_msg_jiffy)
return 0;
try {
RmtTxPkt(chnl,NULL,0,RMT_RQST_GETMSG);
RmtRxPkt(chnl,b,&size);
if (size==sizeof(U8)*3) {
cmd=b[0]><(U8);
*p1=b[8]><(U8);
*p2=b[16]><(U8);
}
} catch {
if (Fs->except_argc==1) {
if (Fs->except_argv[0]==EXCP_TIMEOUT)
Fs->catch_except=TRUE;
}
}
if (cmd)
chnl->null_msg_jiffy=0;
else
chnl->null_msg_jiffy=Jiffies+RMT_NULL_MSG_DELAY;
return cmd;
}
public void RmtSendMsg(LTChnl *chnl,U8 cmd,I8 p1,I8 p2)
{
U1 b[RMT_MAX_PKT_LEN];
if (!chnl || !chnl->type) return;
if (cmd) {
b[0]><(U8)=cmd;
b[8]><(U8)=p1;
b[16]><(U8)=p2;
RmtTxPkt(chnl,b,sizeof(U8)*3);
} else {
RmtTxPkt(chnl,b,1);
chnl->null_msg_cnt++;
}
}
public BoolU4 RmtPutKey(I8 ch,U8 sc)
{
nounusedwarn sc;
if (ch && Fs->rmt_chnl) {
try {
RmtTxPkt(Fs->rmt_chnl,&ch,1);
} catch {
if (Fs->except_argc==1) {
if (Fs->except_argv[0]==EXCP_TIMEOUT)
Fs->catch_except=TRUE;
}
}
}
return FALSE;
}
public void RmtTxBuf(LTChnl *chnl,U1 *buf,U8 size)
{
if (!chnl || !chnl->type) return;
if (buf) {
RmtTxBlk(chnl,&size,sizeof(U8));
RmtTxBlk(chnl,buf,size);
}
}
public U1 *RmtRxBuf(LTChnl *chnl,U8 *size=NULL)
{
U1 *buf;
U8 *size2;
if (size) *size=0;
if (!chnl || !chnl->type) return NULL;
size2=RmtRxBlk(chnl,sizeof(U8));
buf=RmtRxBlk(chnl,*size2);
if (size) *size=*size2;
Free(size2);
return buf;
}
public BoolU4 RmtTxFile(LTChnl *chnl,I1 *filename,
BoolU4 raw=TRUE)
{
U8 size,tries=3;
U1 *buf;
U4 *good;
U1 b[RMT_MAX_PKT_LEN];
LTDirEntry de;
if (!chnl || !chnl->type) return;
start_tx:
if (FindFile(filename,&de)) {
buf=ReadFile(filename,&size,NULL,raw);
if (buf) {
RmtTxBuf(chnl,&de.start,LT_DIR_ENTRY_SIZE);
RmtTxBuf(chnl,buf,size);
Free(buf);
}
}
RmtRxPkt(chnl,b,&size);
good=b;
if (size==4 && *good==RMT_FILE_ACK)
return TRUE;
else {
if (!--tries) {
coutln "Failed!";
return FALSE;
} else {
coutln "Retry";
goto start_tx;
}
}
}
public U8 RmtRxFile(LTChnl *chnl,I1 *filename,
BoolU4 raw=TRUE)
{
U8 size,tries=3;
U4 good;
U1 *buf,*buf1;
LTDirEntry *de;
if (!chnl || !chnl->type) return 0;
start_rx:
good=0;
buf1=RmtRxBuf(chnl);
de=buf1-offset(LTDirEntry.start);
if (buf=RmtRxBuf(chnl,&size)) {
good=RMT_FILE_ACK;
if (de->xsum) {
if ((de->xsum^ArcCheckSum(buf,de->size))!=LT_XSUM)
good=0;
}
if (good)
WriteFile(filename,buf,size,de->datetime,de->attr,raw);
else
coutln "Bad XSUM";
Free(buf);
}
Free(buf1);
RmtTxPkt(chnl,&good,sizeof(BoolU4));
if (!good) {
if (!--tries) {
coutln "Failed!";
return 0;
} else {
coutln "Retry";
goto start_rx;
}
} else
return size;
}
public void RmtTxPutS(LTChnl *chnl,I1 *st)
{
U8 len;
if (!chnl || !chnl->type) return;
if (st) {
len=StrLen(st);
if (len) {
if (len>RMT_MAX_PKT_LEN) {
RmtTxPkt(chnl,NULL,0,RMT_RQST_PUTS_CNT);
RmtTxBuf(chnl,st,len+1);
} else
RmtTxBlk(chnl,st,len);
}
}
}
public void RmtTxPutChar(LTChnl *chnl,I8 ch)
{
if (!chnl || !chnl->type) return;
if (ch)
RmtTxPkt(chnl,&ch,1);
}
public I1 *RmtRxPutS(LTChnl *chnl,U8 *rqst=NULL)
{
U1 b[RMT_MAX_PKT_LEN];
U8 size;
U1 *buf=NULL;
if (!chnl || !chnl->type) return NULL;
if (RmtRxFifoCnt(chnl)>=2) {
RmtRxPkt(chnl,b,&size,rqst);
if (size) {
buf=MAlloc(size+1);
MemCpy(buf,b,size);
buf[size]=0;
} else
buf=MAllocZ(1);
}
return buf;
}
public U1 *RmtRqstTxBuf()
{
//Remote must fill-in remote's chnl->tx_buf
//and remote's chnl->tx_size before calling.
LTChnl *chnl=Fs->rmt_chnl;
U1 *result;
if (!chnl || !chnl->type) return NULL;
RmtTxPkt(chnl,NULL,0,RMT_RQST_TX_BUF);
result=RmtRxBuf(chnl);
return result;
}
public void RmtRqstRxBuf(U1 *src_local_buf,U8 size)
{ //Dst buf address is placed in remote's chnl->rx_buf
LTChnl *chnl=Fs->rmt_chnl;
if (!chnl || !chnl->type) return;
RmtTxPkt(chnl,NULL,0,RMT_RQST_RX_BUF);
RmtTxBuf(chnl,src_local_buf,size);
}
public void RmtRqstTxFile(I1 *dst_local_filename,I1 *src_remote_filename)
{
LTChnl *chnl=Fs->rmt_chnl;
if (!chnl || !chnl->type) return;
RmtTxPkt(chnl,NULL,0,RMT_RQST_TX_FILE);
RmtTxBuf(chnl,src_remote_filename,StrLen(src_remote_filename)+1);
RmtRxFile(chnl,dst_local_filename);
}
public void RmtRqstRxFile(I1 *src_local_filename,I1 *dst_remote_filename)
{
LTChnl *chnl=Fs->rmt_chnl;
if (!chnl || !chnl->type) return;
RmtTxPkt(chnl,NULL,0,RMT_RQST_RX_FILE);
RmtTxBuf(chnl,dst_remote_filename,StrLen(dst_remote_filename)+1);
RmtTxFile(chnl,src_local_filename);
}
public void RmtRqstExeLocal(I1 *st)
{
LTChnl *chnl=Fs->rmt_chnl;
if (!chnl || !chnl->type) return;
RmtTxPkt(chnl,NULL,0,RMT_RQST_EXE_LOCAL);
RmtTxBuf(chnl,st,StrLen(st)+1);
}
public void TelnetHostOpen(LTChnl *chnl)
//Allows remote telnet user to control
//this task. Will still allow local
//control.
{
if (!chnl || !chnl->type) return;
Fs->rmt_chnl=chnl;
}
public void TelnetHostClose()
{
Fs->rmt_chnl=NULL;
}
public void TelnetGuestOpen(LTChnl *chnl)
{
U8 i,cmd,p1,p2,rqst;
U1 *st,*st2;
BoolU4 cont=TRUE,msg_sent=TRUE;
BoolU4 old_preempt=Preempt(OFF);
if (!chnl || !chnl->type) return;
Fs->local_chnl=chnl;
coutln "$$BK 1$$CTRL-ALT-B to break$$BK 0$$";
for (i=0;i<4;i++) {
chnl->PutChar(chnl,RMT_PKT_RESET);
chnl->PutChar(chnl,RMT_PKT_RESET);
Sleep(100);
}
while (cont) {
try {
Fs->task_flags&=~(1<<TSSf_IDLE);
SwapInNext;
RmtReset(chnl);
while (cont) {
Fs->task_flags&=~(1<<TSSf_IDLE);
if (st2=RmtRxPutS(chnl,&rqst)) {
if (rqst!=RMT_RQST_GETMSG)
chnl->null_msg_cnt=0;
switch (rqst) {
case RMT_RQST_NONE:
PutS(st2);
break;
case RMT_RQST_GETMSG:
if (msg_sent)
cmd=ScanMsg(&p1,&p2,
1<<MSG_KEY_DOWN|
1<<MSG_CMD|
1<<MSG_KEY_UP);
msg_sent=FALSE;
if (cmd) {
if (cmd==MSG_KEY_DOWN &&
p2&SCF_ALT && p2&SCF_CTRL &&
p1==CH_CTRLB) {
RmtSendMsg(chnl,0,0,0);
msg_sent=TRUE;
cont=FALSE;
break;
}
}
RmtSendMsg(chnl,cmd,p1,p2);
if (!cmd)
Fs->task_flags|=1<<TSSf_IDLE;
msg_sent=TRUE;
break;
case RMT_RQST_TX_FILE:
st=RmtRxBuf(chnl);
RmtTxFile(chnl,st);
Free(st);
break;
case RMT_RQST_RX_FILE:
st=RmtRxBuf(chnl);
RmtRxFile(chnl,st);
Free(st);
break;
case RMT_RQST_TX_BUF:
RmtTxBuf(chnl,chnl->tx_buf,chnl->tx_size);
break;
case RMT_RQST_RX_BUF:
chnl->rx_buf=RmtRxBuf(chnl);
break;
case RMT_RQST_EXE_LOCAL:
st=RmtRxBuf(chnl);
ExecuteStr(st);
Free(st);
break;
case RMT_RQST_PUTS_CNT:
Free(st2);
st2=RmtRxBuf(chnl);
PutS(st2);
break;
}
Free(st2);
st2=NULL;
} else {
Fs->task_flags|=1<<TSSf_IDLE;
SwapInNext;
}
}
} catch {
cont=FALSE;
if (Fs->except_argc==1) {
if (Fs->except_argv[0]==EXCP_TIMEOUT) {
Fs->catch_except=TRUE;
cont=TRUE;
}
}
if (!cont) {
Fs->local_chnl=NULL;
Preempt(old_preempt);
}
}
}
Fs->local_chnl=NULL;
Preempt(old_preempt);
}
BoolU8 RmtPutS(I1 *st)
{
if (Fs->rmt_chnl) {
try
RmtTxPutS(Fs->rmt_chnl,st);
catch {
if (Fs->except_argc==1) {
if (Fs->except_argv[0]==EXCP_TIMEOUT)
Fs->catch_except=TRUE;
}
}
}
return FALSE;
}
AddKeyDev(&RmtPutKey,&RmtPutS,0xA0000000);
#help_index ""
-445
View File
@@ -1,445 +0,0 @@
#help_index "File/Cmd Line (Typically)"
public U1 *PatchBlk(U8 blk,BoolU4 write=FALSE)
{
U1 *buf=MAlloc(BLK_SIZE);
RBlks(Fs->cur_partition,buf,blk,1,TRUE);
LtfD(buf,BLK_SIZE);
if (write) {
coutln "Edit and press ESC to write or ^Q";
if (View) {
coutln "Write";
WBlks(Fs->cur_partition,buf,blk,1,TRUE);
}
}
return buf;
}
public U1 *Patch(U8 c,BoolU4 write=FALSE)
{
U1 *buf=MAlloc(Fs->cur_partition->spc<<BLK_SIZE_BITS);
RClusters(Fs->cur_partition,buf,c,1,TRUE);
coutln "Cluster:",c;
LtfD(buf,Fs->cur_partition->spc<<BLK_SIZE_BITS);
if (write) {
coutln "Edit and press ESC to write or ^Q";
if (View) {
coutln "Write";
WClusters(Fs->cur_partition,buf,c,1,TRUE);
}
}
return buf;
}
#help_index "Memory"
void CorruptSysMemory()
{
Debugger;
}
void CorruptTaskMemory()
{
Debugger;
}
public U8 UnusedSysMem()
{
MemBlk *tempm;
U8 i,result=0,old_flags=GetFlags;
Cli;
tempm=mem_free_list;
while (tempm) {
if (tempm->signature!=MBS_UNUSED_SIGNATURE)
CorruptSysMemory;
result+=tempm->pages;
tempm=tempm->next;
}
SetFlags(old_flags);
Cli;
tempm=mem_free_2Meg_list;
while (tempm) {
if (tempm->signature!=MBS_UNUSED_SIGNATURE)
CorruptSysMemory;
result+=tempm->pages;
tempm=tempm->next;
}
SetFlags(old_flags);
for (i=0;i<FREE_PAGE_HASH_SIZE;i++) {
Cli;
tempm=free_page_hash[i];
while (tempm) {
if (tempm->signature!=MBS_UNUSED_SIGNATURE)
CorruptSysMemory;
result+=tempm->pages;
tempm=tempm->next;
}
SetFlags(old_flags);
}
for (i=0;i<64;i++) {
Cli;
tempm=free_page_hash2[i];
while (tempm) {
if (tempm->signature!=MBS_UNUSED_SIGNATURE)
CorruptSysMemory;
result+=tempm->pages;
tempm=tempm->next;
}
SetFlags(old_flags);
}
return result*PAGE_SIZE;
}
public U8 TaskAllocatedMem(TssStruct *tss=NULL)
{
MemBlk *m,*m1;
U8 result=0,old_flags=GetFlags;
if (!tss) tss=Fs;
Cli;
m=tss->next_mem_blk;
m1=&tss->next_mem_blk;
while (m!=m1) {
if (m->signature!=MBS_USED_SIGNATURE)
CorruptTaskMemory;
result+=m->pages*PAGE_SIZE;
m=m->next;
}
SetFlags(old_flags);
return result;
}
public U8 TaskUnusedAllocatedMem(TssStruct *tss=NULL)
{
U8 result=0,i,old_flags=GetFlags;
UnusedAllocatedMem *u;
if (!tss) tss=Fs;
Cli;
for (i=0;i<HEAP_HASH_SIZE>>3;i++) {
u=tss->heap_hash[i];
while (u) {
result+=u->size;
u=u->next;
}
}
u=tss->malloc_free_list;
while (u) {
result+=u->size;
u=u->next;
}
SetFlags(old_flags);
return result;
}
#help_index "Memory/Heap Ctrl"
public U8 UnusedHCMem(HeapCtrl *hc)
{
U8 result=0,i,old_flags=GetFlags;
MemBlk *tempm;
UnusedAllocatedMem *u;
Cli;
tempm=hc->mem_free_list;
while (tempm) {
if (tempm->signature!=MBS_UNUSED_SIGNATURE)
CorruptSysMemory;
result+=tempm->pages;
tempm=tempm->next;
}
SetFlags(old_flags);
for (i=0;i<FREE_PAGE_HASH_SIZE;i++) {
Cli;
tempm=hc->free_page_hash[i];
while (tempm) {
if (tempm->signature!=MBS_UNUSED_SIGNATURE)
CorruptSysMemory;
result+=tempm->pages;
tempm=tempm->next;
}
SetFlags(old_flags);
}
for (i=0;i<64;i++) {
Cli;
tempm=hc->free_page_hash2[i];
while (tempm) {
if (tempm->signature!=MBS_UNUSED_SIGNATURE)
CorruptSysMemory;
result+=tempm->pages;
tempm=tempm->next;
}
SetFlags(old_flags);
}
result*=PAGE_SIZE;
Cli;
for (i=0;i<HEAP_HASH_SIZE>>3;i++) {
u=hc->heap_hash[i];
while (u) {
result+=u->size;
u=u->next;
}
}
u=hc->malloc_free_list;
while (u) {
result+=u->size;
u=u->next;
}
SetFlags(old_flags);
return result;
}
#help_index "Memory;Debugging"
I8 CompareUamPtrs(UnusedAllocatedMem **e1,
UnusedAllocatedMem **e2)
{
return *e1-*e2;
}
I8 CompareUamSize(UnusedAllocatedMem **e1,
UnusedAllocatedMem **e2)
{
return (*e2)->size-(*e1)->size;
}
public void HeapRep(TssStruct *tss=NULL)
{
I8 i,cnt;
UnusedAllocatedMem *u;
U8 old_flags=GetFlags;
if (!tss) tss=Fs;
Cli;
for (i=0;i<HEAP_HASH_SIZE>>3;i++) {
cnt=0;
u=tss->heap_hash[i];
while (u) {
cnt+=u->size;
u=u->next;
}
if (cnt)
PrintF("%03X:%08X\r\n",i<<2,cnt);
}
u=tss->malloc_free_list;
while (u) {
PrintF("%08X\r\n",u->size);
u=u->next;
}
SetFlags(old_flags);
}
public BoolU4 IsInHeap(U1 *a,TssStruct *tss=NULL)
{
MemBlk *m;
U8 old_flags=GetFlags;
if (!tss) tss=Fs;
m=tss->next_mem_blk;
Cli;
while (m!=&tss->next_mem_blk) {
if (a>=m && a<m+m->pages*PAGE_SIZE) {
SetFlags(old_flags);
return TRUE;
}
m=m->next;
}
SetFlags(old_flags);
return FALSE;
}
public BoolU4 HeapWalk(TssStruct *tss=NULL)
//Detects just one type of error --
//a freed value, not valid.
{
I8 i;
UnusedAllocatedMem *u;
BoolU4 result=TRUE;
U8 old_flags=GetFlags;
if (!tss) tss=Fs;
if (!ValidateTss(tss)) return FALSE;
Cli;
for (i=0;i<HEAP_HASH_SIZE>>3;i++) {
u=tss->heap_hash[i];
while (u) {
if (!IsInHeap(u,tss))
result=FALSE;
u=u->next;
}
}
u=tss->malloc_free_list;
while (u) {
if (!IsInHeap(u,tss))
result=FALSE;
u=u->next;
}
SetFlags(old_flags);
return result;
}
#help_index "Memory"
//TODO:Crashes
///More of a heap check at the moment
void CollectFreedAllocatedMem(TssStruct *tss=NULL)
{
I8 i,cnt;
//I8 j;
UnusedAllocatedMem *u,**sort_buf;
U8 old_flags=GetFlags;
// U4 *dd;
if (!tss) tss=Fs;
Cli;
cnt=0;
for (i=0;i<HEAP_HASH_SIZE>>2;i++) {
u=tss->heap_hash[i];
while (u) {
cnt++;
u=u->next;
}
}
u=tss->malloc_free_list;
while (u) {
cnt++;
u=u->next;
}
SetFlags(old_flags);
//We might disturb the Free list and irq's might Free some
sort_buf=MAlloc(((cnt+512)&-0x100)*sizeof(void *));
Cli;
cnt=0;
for (i=0;i<HEAP_HASH_SIZE>>2;i++) {
u=tss->heap_hash[i];
while (u) {
sort_buf[cnt++]=u;
u=u->next;
}
tss->heap_hash[i]=NULL;
}
u=tss->malloc_free_list;
while (u) {
sort_buf[cnt++]=u;
u=u->next;
}
tss->malloc_free_list=NULL;
for (i=0;i<FREE_PAGE_HASH_SIZE;i++)
free_page_hash[i]=NULL;
for (i=0;i<32;i++)
free_page_hash2[i]=NULL;
SetFlags(old_flags);
QSort(sort_buf,cnt,sizeof(void *),&CompareUamPtrs);
for (i=0;i<cnt;i++) {
if (sort_buf[i]+sort_buf[i]->size>sort_buf[i+1])
cout "****";
coutln sort_buf[i]," ",sort_buf[i]->size;
}
/*
j=0;
for (i=0;i<cnt;i++) {
if (sort_buf[i]==sort_buf[j]+sort_buf[j]->size &&
sort_buf[j]->size+sort_buf[i]->size<HEAP_HASH_SIZE)
sort_buf[j]->size=sort_buf[j]->size+
sort_buf[i]->size;
else
sort_buf[++j]=sort_buf[i];
}
if (cnt) {
j++;
QSort(sort_buf,j,sizeof(void *),&CompareUamSize);
for (i=0;i<j;i++) {
sort_buf[i]->next=sort_buf[i]->size;
Free(sort_buf[i]+4,tss);
}
}
*/
Free(sort_buf);
}
#help_index "Task"
void TaskRepTask(TssStruct *tss,I8 indent)
{
TssStruct *tss1;
I1 *st,*desc=MSPrintF("%q",tss->task_descriptor);
st=MSPrintF("$$MA+A,\"%08X\",\"Kill(0x%X);\r\",$$",tss,tss,tss);
PrintF("%*s%s $$TX+SCX,\"%Q...\",16$$ Mem:%08X\r\n",
indent,"",st,desc,
TaskAllocatedMem(tss));
PrintF("%*s Flags:%04X:%04X %02X\r\n",
indent+2,"",tss->task_flags,tss->crt_flags,
ExceptDepth(tss));
PrintF("Time:%9.2fm\r\n",tss->total_time/60.0/time_stamp_freq);
Free(st);
Free(desc);
tss1=tss->next_child_tss;
while (tss1!=&tss->next_child_tss-offset(TssStruct.next_sibling_tss)) {
TaskRepTask(tss1,indent+2);
tss1=tss1->next_sibling_tss;
}
}
public void TaskRep()
{
U1 i;
U8 old_flags=GetFlags;
CPUStruct *c;
Cli;
for (i=0;i<mp_cnt;i++) {
c=mp_cpu_structs+sizeof(CPUStruct)*i;
coutln "$$FG,RED$$CPU:",i,"$$FG$$";
TaskRepTask(c->cain_tss,2);
}
SetFlags(old_flags);
}
void CtrlAltX()
{
Bts(sys_flags,SYSf_CTRL_ALT_X);
}
ctrl_alt_letter_routines['X'-'A']=&CtrlAltX;
void CtrlAltC()
{
Bts(sys_flags,SYSf_CTRL_ALT_C);
}
ctrl_alt_letter_routines['C'-'A']=&CtrlAltC;
#help_index "File/FileNames"
public BoolU4 IsTextFile(I1 *filename)
{
return WildFileNameList(TEXT_FILE_MASK,filename);
}
public BoolU4 IsSourceFile(I1 *filename)
{
return WildFileNameList(SOURCE_FILE_MASK,filename);
}
public BoolU4 IsCFile(I1 *filename)
{
return WildFileNameList(C_FILE_MASK,filename);
}
public BoolU4 IsAsmFile(I1 *filename)
{
return WildFileNameList(ASM_FILE_MASK,filename);
}
#help_index ""
Binary file not shown.
-1080
View File
File diff suppressed because it is too large Load Diff
-450
View File
@@ -1,450 +0,0 @@
I8 WsdNextCmd(I1 **ptr_)
{
I8 result=-1;
I1 ch,*ptr=*ptr_,*ptr2;
do {
do {
if (!(ch=*ptr++)) goto done;
} while (ch!='<');
ptr2=ptr;
do {
if (!(ch=*ptr2++)) goto done;
} while (ch!='>');
*--ptr2=0;
result=MatchListEntry(ptr,"h1\0/h1\0def\0/def\0hw\0/hw\0tt\0/tt\0"
"ety\0@fld\0@cd\0@blockquote\0@wordforms\0@note\0@altname\0@chform\0@cref\0@syn\0"
"/ety\0@/fld\0@/cd\0@/blockquote\0@/wordforms\0@/note\0@/altname\0@/chform\0@/cref\0@/syn\0");
*ptr2++='>';
ptr=ptr2;
} while (result<0);
done:
*ptr_=ptr;
return result;
}
I1 *WsdNextEntry(I1 **ptr_)
{
I1 *ignore,*result,ch,*ptr=*ptr_,buf[WSD_BLK_SIZE],*out_ptr=buf;
I8 l;
do {
do {
if (!(ch=*ptr++)) goto done;
if (ch!='<') {
*out_ptr++=ch;
if (ch=='$$')
*out_ptr++=ch;
} else
break;
} while (TRUE);
ignore="b>\0i>\0p>\0/b>\0/i>\0/p>\0"
"ets>\0col>\0spn>\0/ets>\0/col>\0/spn>\0er>\0as>\0cs>\0cd>\0ex>\0"
"/er>\0/as>\0/cs>\0/cd>\0/ex>\0"
"note>\0/note>\0blockquote>\0/blockquote>\0";
while (*ignore) {
l=StrLen(ignore);
if (!StrNCmp(ptr,ignore,l)) {
ptr+=l;
break;
} else
ignore+=l+1;
}
if (!*ignore)
break;
} while (TRUE);
done:
*out_ptr++=0;
result=NewStr(buf);
*ptr_=ptr-1;
return result;
}
I8 WsdCompareWords(I1 **e1,I1 **e2)
{
return StrCmp(*e1,*e2);
}
I1 *WsdSortWords(I1 *start,I8 size,I8 word_cnt)
{
I1 **ptr_array=MAlloc(sizeof(void *)*word_cnt),
*out_start=MAlloc(size),
*ptr=start,*ptr2;
I8 i=0;
while (*ptr) {
ptr_array[i++]=ptr;
ptr+=StrLen(ptr)+3;
}
coutln "Sorting..."; Sleep(100);
QSort(ptr_array,word_cnt,sizeof(void *),&WsdCompareWords);
coutln "Done..."; Sleep(100);
ptr=out_start;
for (i=0;i<word_cnt;i++) {
ptr2=ptr_array[i];
while (*ptr2)
*ptr++=*ptr2++;
*ptr++=*ptr2++; //zero
*ptr++=*ptr2++; //blk lo
*ptr++=*ptr2++; //blk hi
}
*ptr++=0;
return out_start;
}
void WsdCmpRawDictFile()
{
I8 cmd,size,word_cnt=0,largest_entry=0;
I1 *st,*in_ptr=ReadFile(WSD_RAW_FILENAME,&size),*in_start=in_ptr,
*out_ptr=MAlloc(size),*out_start=out_ptr,
*word_ptr=MAlloc(size),*word_start=word_ptr,
*last_word=NULL,*def_word_start=out_ptr,
*sorted_word_start;
U2 *d;
do {
cmd=WsdNextCmd(&in_ptr);
if (cmd==WSD_H1) {
next_word:
if (out_ptr-def_word_start>largest_entry)
largest_entry=out_ptr-def_word_start;
def_word_start=out_ptr;
if (st=WsdNextEntry(&in_ptr)) {
if (*st) {
if (StrICmp(st,last_word)) {
word_cnt++;
*word_ptr++=WSD_WORD_CHAR;
last_word=word_ptr;
StrCpy(word_ptr,st);
word_ptr+=StrLen(st)+1;
d=word_ptr;
*d=(out_ptr-out_start)/WSD_BLK_SIZE;
word_ptr+=2;
*out_ptr++=WSD_WORD_CHAR;
StrCpy(out_ptr,st);
out_ptr+=StrLen(st)+1;
}
Free(st);
do {
do {
cmd=WsdNextCmd(&in_ptr);
if (cmd==WSD_H1)
goto next_word;
} while (cmd>=0 && !(cmd==WSD_DEF||cmd==WSD_PRONUNCIATION||cmd==WSD_POS||cmd==WSD_EXTRA));
if (cmd==WSD_DEF) {
if(st=WsdNextEntry(&in_ptr)) {
if (*st) {
*out_ptr++=WSD_DEF_CHAR;
StrCpy(out_ptr,st);
out_ptr+=StrLen(st)+1;
}
Free(st);
}
} else if (cmd==WSD_PRONUNCIATION) {
if(st=WsdNextEntry(&in_ptr)) {
if (*st) {
*out_ptr++=WSD_PRONUNCIATION_CHAR;
StrCpy(out_ptr,st);
out_ptr+=StrLen(st)+1;
}
Free(st);
}
} else if (cmd==WSD_POS) {
if(st=WsdNextEntry(&in_ptr)) {
if (*st) {
*out_ptr++=WSD_POS_CHAR;
StrCpy(out_ptr,st);
out_ptr+=StrLen(st)+1;
}
Free(st);
}
} else if (cmd==WSD_EXTRA) {
if(st=WsdNextEntry(&in_ptr)) {
if (*st) {
*out_ptr++=WSD_EXTRA_CHAR;
StrCpy(out_ptr,st);
out_ptr+=StrLen(st)+1;
}
Free(st);
}
}
} while (cmd==WSD_DEF||cmd==WSD_PRONUNCIATION||cmd==WSD_POS||cmd==WSD_EXTRA);
} else
Free(st);
}
}
} while (cmd>=0);
*out_ptr++=WSD_END_CHAR;
*word_ptr++=WSD_END_CHAR;
Free(in_start);
PrintF("Blk Size :%d\r\n",WSD_BLK_SIZE);
PrintF("Blk Cnt :%04X\r\n",(out_ptr-out_start+WSD_BLK_SIZE-1)/WSD_BLK_SIZE);
PrintF("Largest Entry :%d\r\n",largest_entry);
PrintF("Word Count :%d\r\n",word_cnt);
WriteFile(WSD_DEF_FILENAME,out_start,out_ptr-out_start);
PrintF("Def File Size :%d\r\n",out_ptr-out_start);
sorted_word_start=WsdSortWords(word_start,word_ptr-word_start,word_cnt);
WriteFile(WSD_WORD_FILENAME,sorted_word_start,word_ptr-word_start);
PrintF("Word File Size:%d\r\n",word_ptr-word_start);
Free(out_start);
Free(word_start);
Free(sorted_word_start);
}
public void WsdLoadWords()
{
I8 size;
SysHashEntry *temph;
I1 *in_ptr,*in_start,*st2;
U2 *d;
ws_dict_num_words=0;
if (in_ptr=ReadFile(WSD_WORD_FILENAME,&size)) {
in_start=in_ptr;
ws_dict_word_list=AMAlloc(size);
MemCpy(ws_dict_word_list,in_start,size);
ws_dict_word_list_size=size;
while (in_ptr<in_start+size) {
if (*in_ptr==WSD_WORD_CHAR)
in_ptr++;
if (*in_ptr) {
st2=MStrUtil(in_ptr,SU_TO_UPPER);
temph=AMAllocZ(sizeof(SysHashEntry)+StrLen(st2)+1);
StrCpy(temph+sizeof(SysHashEntry),st2);
Free(st2);
in_ptr+=StrLen(in_ptr)+1;
temph->str=temph+sizeof(SysHashEntry);
temph->use_cnt=1;
temph->type=HTT_DICT_WORD;
d=in_ptr;
temph->user_data0=*d;
in_ptr+=2;
AddSysHashEntry(temph,ws_hash_table);
ws_dict_num_words++;
} else
in_ptr+=3;
}
Free(in_start);
}
}
public I1 *WsdGetDef(I1 *st,I8 def_num=1)
{
LTFile *f;
SysHashEntry *temph;
I1 *result=NULL,*buf,*in_ptr;
I1 *st2=MStrUtil(st,SU_TO_UPPER);
temph=FindHashEntry(st2,ws_hash_table,HTT_DICT_WORD);
Free(st2);
if (temph) {
if (f=FOpen(WSD_DEF_FILENAME,"r")) {
buf=MAlloc(WSD_BLK_SIZE*2+1);
buf[WSD_BLK_SIZE*2]=0; //terminate
FRBlks(f,buf,temph->user_data0*WSD_BLK_SIZE/BLK_SIZE,WSD_BLK_SIZE*2/BLK_SIZE);
FClose(f);
in_ptr=buf;
while (in_ptr<buf+WSD_BLK_SIZE*2) {
while (*in_ptr!=WSD_WORD_CHAR && in_ptr<buf+WSD_BLK_SIZE*2)
in_ptr++;
if (*in_ptr++==WSD_WORD_CHAR) {
if (!StrICmp(st,in_ptr)) {
while (def_num && *in_ptr!=WSD_WORD_CHAR
&& in_ptr<buf+WSD_BLK_SIZE*2) {
if (*in_ptr==WSD_DEF_CHAR) {
if (!--def_num)
break;
else
in_ptr++;
} else
in_ptr++;
}
if (*in_ptr++==WSD_DEF_CHAR) {
result=NewStr(in_ptr);
break;
}
}
}
}
Free(buf);
}
}
return result;
}
public I1 *WsdGetWord(I1 *st)
{
LTFile *f;
SysHashEntry *temph;
I1 *result=NULL,*buf,*in_ptr,*in_ptr2;
I1 *st2=MStrUtil(st,SU_TO_UPPER);
temph=FindHashEntry(st2,ws_hash_table,HTT_DICT_WORD);
Free(st2);
if (temph) {
if (f=FOpen(WSD_DEF_FILENAME,"r")) {
buf=MAlloc(WSD_BLK_SIZE*2+1);
buf[WSD_BLK_SIZE*2]=0; //terminate
FRBlks(f,buf,temph->user_data0*WSD_BLK_SIZE/BLK_SIZE,WSD_BLK_SIZE*2/BLK_SIZE);
FClose(f);
in_ptr=buf;
while (in_ptr<buf+WSD_BLK_SIZE*2) {
while (*in_ptr!=WSD_WORD_CHAR && in_ptr<buf+WSD_BLK_SIZE*2)
in_ptr++;
if (*in_ptr++==WSD_WORD_CHAR) {
if (!StrICmp(st,in_ptr)) {
in_ptr2=in_ptr;
in_ptr--;
while (*in_ptr2!=WSD_WORD_CHAR
&& in_ptr2<buf+WSD_BLK_SIZE*2) {
in_ptr2++;
}
result=MAlloc(in_ptr2+1-in_ptr);
MemCpy(result,in_ptr,in_ptr2-in_ptr);
result[in_ptr2-in_ptr]=WSD_END_CHAR;
break;
}
}
}
Free(buf);
}
}
return result;
}
public I1 *WsdPointAtWord(I1 *st,U8 n=0)
{
I1 *r=NULL,*r1,
*start=ws_dict_word_list,
*end=ws_dict_word_list+ws_dict_word_list_size;
if (!st)
return NULL;
if (!*st)
return ws_dict_word_list;
if (ws_dict_word_list_size) {
if (!n) n=StrLen(st);
while (start<end-4) {
r1=(start+end)>>1;
r=r1;
while (*r!=WSD_WORD_CHAR && r>ws_dict_word_list)
r--;
if (r[2]==WSD_WORD_CHAR)
r+=2;
else
if (r[1]==WSD_WORD_CHAR)
r++;
if (*r==WSD_WORD_CHAR)
r++;
if (StrNICmp(st,r,n)<=0)
end=r1;
else
start=r1;
}
if (r>ws_dict_word_list)
r--;
}
return r;
}
void WsdAddDictWords(Ltf *l,I1 *st=NULL)
{
I8 i;
I1 *ptr;
if (!st)
st=ws_cur_word;
if (st) {
if (ptr=WsdPointAtWord(st)) {
for (i=0;i<WSD_MAX_FILLINS;i++) {
if (*ptr++!=WSD_WORD_CHAR)
break;
wsd_fillins[i]=ptr-1;
LtfPrintF(l," '%d' %-20ts\r\n",i,ptr);
ptr+=StrLen(ptr)+3;
}
wsd_num_fillins=i;
}
}
}
void WsdFillin(I8 n)
{
I1 *s;
I8 len;
if (n>=0 && n<wsd_num_fillins) {
s=wsd_fillins[n]+1;
len=StrLen(s);
if (len>ws_partial_len)
Auto(s+ws_partial_len);
}
}
public void WsdDisplayDefs(Ltf *l,I1 *st,I8 num=-1)
{
I1 *st2,*st3,ch;
I8 i=0;
if (!st) return;
if (*st==WSD_WORD_CHAR)
st++;
LtfPrintF(l,"$$WW,1$$$$FG,RED$$%s:$$FG$$\r\n\r\n",st);
if (num<0) {
if (st3=WsdGetWord(st)) {
st2=st3;
while (ch=*st2++) {
switch (ch) {
case WSD_WORD_CHAR:
break;
case WSD_DEF_CHAR:
LtfPrintF(l,"$$FG,GREEN$$(%d)$$FG$$ %s\r\n",
++i,st2);
break;
case WSD_PRONUNCIATION_CHAR:
LtfPrintF(l,"$$FG,LTGREEN$$%s$$FG$$\r\n",st2);
break;
case WSD_POS_CHAR:
LtfPrintF(l,"$$FG,BLACK$$%s$$FG$$\r\n",st2);
break;
case WSD_EXTRA_CHAR:
LtfPrintF(l,"$$FG,LTBLUE$$%s$$FG$$\r\n",st2);
break;
}
st2+=StrLen(st2)+1;
}
Free(st3);
}
} else {
while (st2=WsdGetDef(st,++i)) {
if (i==num)
LtfPrintF(l,"$$FG,GREEN$$(%d)$$FG$$ %s\r\n",
i,st2);
Free(st2);
}
}
}
void WsdPopUpDef(I1 *st,I8 num=-1,TssStruct *parent=NULL)
{
I1 *buf;
buf=MSPrintF("WsdDisplayDefs(Fs->cur_ltf,\"%s\",%d);View;",st,num);
PopUp(buf,parent);
Free(buf);
}
void WsdDef(I8 n,TssStruct *parent=NULL)
{
if (n>=0 && n<wsd_num_fillins)
WsdPopUpDef(wsd_fillins[n],-1,parent);
}
-767
View File
@@ -1,767 +0,0 @@
void WsPutMatrix(WsMatrix *m)
{
I8 i,j;
WsMatrixSide *ms;
WsStruct *tempw;
coutln "n:",m->n;
for (i=0;i<ws_num_matrix_words;i++) {
ms=&m->side[i];
coutln "col:",i," rhits:",ms->row_hits," chits:",ms->col_hits;
tempw=ms->next;
while (tempw!=ms) {
coutln " substructs:",tempw->substructs,
" entries:",tempw->entries;
for (j=0;j<tempw->substructs;j++) {
PrintF("(%04X %04X) ",
tempw->subs[j].hits,
tempw->subs[j].repeats);
}
CrLf;
tempw=tempw->next;
}
}
View;
}
WsHashEntry *WsAddHash(I1 *w)
{
WsHashEntry *tempw=FindHashEntry(w,ws_hash_table,HTT_WORD);
if (tempw) {
tempw->hits++;
return tempw;
}
tempw=AMAllocZ(sizeof(WsHashEntry));
tempw->word=ANewStr(w);
tempw->type=HTT_WORD;
tempw->use_cnt=1;
tempw->hits=1;
tempw->num=-1;
AddSysHashEntry(tempw,ws_hash_table);
ws_num_words++;
return tempw;
}
void WsInitSides(WsMatrix *m)
{
I8 i;
WsStruct *tempa;
m->n=0;
for (i=0;i<WS_MAX_MATRIX_WORDS;i++) {
m->side[i].next=&m->side[i].next;
m->side[i].last=&m->side[i].next;
m->side[i].const_minus_one=-1;
m->side[i].row_hits=0;
m->side[i].col_hits=0;
tempa=AMAlloc(sizeof(WsStruct));
tempa->subs[0].hits=0;
tempa->subs[0].repeats=ws_num_matrix_words;
tempa->entries=ws_num_matrix_words;
tempa->substructs=1;
InsQue(tempa,m->side[i].last);
}
}
WsStruct *WsFindStruct(WsMatrix *m,I8 col,I8 row,
I8 *row_base,I8 *substruct)
{
WsStruct *tempa;
if (row>=ws_num_matrix_words ||
col>=ws_num_matrix_words)
return NULL;
if (row<ws_num_matrix_words>>1) {
tempa=m->side[col].next;
*row_base=0;
while (row>=tempa->entries) {
row-=tempa->entries;
*row_base+=tempa->entries;
tempa=tempa->next;
}
for (*substruct=0;row>=tempa->subs[*substruct].repeats;*substruct=*substruct+1) {
row-=tempa->subs[*substruct].repeats;
*row_base+=tempa->subs[*substruct].repeats;
}
} else {
row=ws_num_matrix_words-row;
tempa=m->side[col].last;
*row_base=ws_num_matrix_words;
while (row>tempa->entries) {
row-=tempa->entries;
*row_base-=tempa->entries;
tempa=tempa->last;
}
for (*substruct=tempa->substructs-1;row>tempa->subs[*substruct].repeats;
*substruct=*substruct-1) {
row-=tempa->subs[*substruct].repeats;
*row_base-=tempa->subs[*substruct].repeats;
}
*row_base-=tempa->subs[*substruct].repeats;
}
return tempa;
}
public I8 WsGetHits(WsMatrix *m,I8 col,I8 row)
{
I8 row_base,substruct;
WsStruct *tempa;
if (row>=ws_num_matrix_words ||
col>=ws_num_matrix_words)
return 0;
tempa=WsFindStruct(m,col,row,
&row_base,&substruct);
return tempa->subs[substruct].hits;
}
WsSubstruct *WsNext(WsSubstruct *s,WsStruct **parent)
{
I8 i=(s-&(*parent)->subs)>>WS_SUBSTRUCT_SIZE_BITS+1;
if (i>=(*parent)->substructs) {
i=0;
*parent=(*parent)->next;
if ((*parent)->substructs==-1)
return NULL;
}
return &(*parent)->subs[i];
}
WsSubstruct *WsLast(WsSubstruct *s,WsStruct **parent)
{
I8 i=(s-&(*parent)->subs)>>WS_SUBSTRUCT_SIZE_BITS-1;
if (i<0) {
*parent=(*parent)->last;
if ((*parent)->substructs==-1)
return NULL;
i=(*parent)->substructs-1;
}
return &(*parent)->subs[i];
}
void WsRemove(WsSubstruct *s,WsStruct *parent)
{
I8 i=(s-&parent->subs)>>WS_SUBSTRUCT_SIZE_BITS;
if (i<0 || i>=WS_SUBSTRUCTS_PER_STRUCT || parent->substructs<1)
return;
if (parent->substructs==1) {
RemQue(parent);
AFree(parent);
} else {
parent->entries-=s->repeats;
parent->substructs--;
MemCpy(&parent->subs[i],&parent->subs[i+1],
(parent->substructs-i)*sizeof(WsSubstruct));
}
}
WsSubstruct *WsInsert(WsSubstruct *s,WsStruct **parent,WsSubstruct *last)
{
WsStruct *tempa,*p=*parent;
I8 j,k,i=(last-&p->subs)>>WS_SUBSTRUCT_SIZE_BITS+1;
if (i>=WS_SUBSTRUCTS_PER_STRUCT) {
i=0;
p=p->next;
*parent=p;
if (p->substructs==-1) {
tempa=AMAlloc(sizeof(WsStruct));
InsQue(tempa,p->last);
p=tempa;
*parent=p;
tempa->entries=0;
tempa->substructs=0;
}
}
if (p->substructs==WS_SUBSTRUCTS_PER_STRUCT) {
tempa=p->next;
if (tempa->substructs==-1 || tempa->substructs==WS_SUBSTRUCTS_PER_STRUCT) {
tempa=AMAlloc(sizeof(WsStruct));
tempa->entries=0;
tempa->substructs=0;
InsQue(tempa,p);
k=0;
for (j=i;j<p->substructs;j++) {
MemCpy(&tempa->subs[k],&p->subs[j],sizeof(WsSubstruct));
tempa->entries+=tempa->subs[k++].repeats;
tempa->substructs++;
}
p->entries-=tempa->entries;
p->substructs-=tempa->substructs;
} else {
for (j=tempa->substructs-1;j>=0;j--)
MemCpy(&tempa->subs[j+1],&tempa->subs[j],sizeof(WsSubstruct));
MemCpy(&tempa->subs[0],
&p->subs[WS_SUBSTRUCTS_PER_STRUCT-1],
sizeof(WsSubstruct));
p->entries-=tempa->subs[0].repeats;
p->substructs--;
tempa->entries+=tempa->subs[0].repeats;
tempa->substructs++;
for (j=WS_SUBSTRUCTS_PER_STRUCT-2;j>=i;j--)
MemCpy(&p->subs[j+1],
&p->subs[j],sizeof(WsSubstruct));
}
} else {
for (j=p->substructs-1;j>=i;j--)
MemCpy(&p->subs[j+1],
&p->subs[j],sizeof(WsSubstruct));
}
p->entries+=s->repeats;
p->substructs++;
MemCpy(&p->subs[i],s,sizeof(WsSubstruct));
return &p->subs[i];
}
WsSubstruct *WsCondense(WsSubstruct *s,WsStruct **parent)
{
WsSubstruct *temps,*temps_l,*temps_n;
WsStruct *tempa_l,*tempa_n;
if ((*parent)->substructs==-1)
return NULL;
temps=s;
tempa_l=*parent;
temps_l=WsLast(temps,&tempa_l);
if (temps_l && temps_l->hits==temps->hits) {
temps_l->repeats+=temps->repeats;
tempa_l->entries+=temps->repeats;
WsRemove(temps,*parent);
*parent=tempa_l;
temps=temps_l;
}
tempa_n=*parent;
temps_n=WsNext(temps,&tempa_n);
if (temps_n && temps_n->hits==temps->hits) {
temps->repeats=temps->repeats+temps_n->repeats;
(*parent)->entries=(*parent)->entries+temps_n->repeats;
WsRemove(temps_n,tempa_n);
}
return temps;
}
I8 WsIncHits(WsMatrix *m,I8 col,I8 row)
{
I8 row_base,substruct,repeats;
WsSubstruct sn,*temps,*temps1,*temps_l;
WsStruct *tempa,*tempa1,*tempa_l;
if (row>=ws_num_matrix_words ||
col>=ws_num_matrix_words)
return 0;
tempa=WsFindStruct(m,col,row,&row_base,&substruct);
temps=&tempa->subs[substruct];
repeats=temps->repeats;
if (repeats==1) {
temps->hits++;
temps=WsCondense(temps,&tempa);
} else {
if (row==row_base) {
temps->repeats--;
tempa->entries--;
sn.hits=1;
sn.repeats=1;
tempa_l=tempa;
if (!(temps_l=WsLast(&tempa->subs[substruct],&tempa_l))) {
tempa_l=tempa->last; //header
temps_l=&tempa_l->subs[WS_SUBSTRUCTS_PER_STRUCT-1];
}
temps=WsInsert(&sn,&tempa_l,temps_l);
temps=WsCondense(temps,&tempa_l);
} else if (row==repeats-1+row_base) {
temps->repeats--;
tempa->entries--;
sn.hits=1;
sn.repeats=1;
temps=WsInsert(&sn,&tempa,temps);
temps=WsCondense(temps,&tempa);
} else {
tempa->entries-=repeats;
sn.hits=temps->hits+1;
sn.repeats=1;
tempa1=tempa;
temps1=temps;
temps=WsInsert(&sn,&tempa1,temps1);
temps1->repeats=row-row_base;
tempa->entries+=temps1->repeats;
sn.repeats=row_base+repeats-(row+1);
sn.hits=temps1->hits;
WsInsert(&sn,&tempa1,temps);
}
}
m->n++;
m->side[col].col_hits++;
m->side[row].row_hits++;
return temps->hits;
}
void WsAddSingleFile(LTDirEntry *tempd,BoolU4 compile)
{
I1 ch,ch1,*buf,*ptr,*ptr2;
WsHashEntry *cur_ptr,*last_ptr=NULL;
I8 k=0;
buf=ReadTextFile(tempd->full_name);
ptr=buf;
while (ch=*ptr++) {
while (ch && !Bt(alpha_numeric_bitmap,ch))
ch=*ptr++;
if (!ch) break;
ptr--;
ptr2=ptr;
do ch=*ptr2++;
while (Bt(alpha_numeric_bitmap,ch));
ptr2--;
ch1=*ptr2;
*ptr2=0;
if (*ptr) {
if (!compile)
WsAddHash(ptr);
else {
cur_ptr=FindHashEntry(ptr,ws_hash_table,HTT_WORD);
if (cur_ptr->num<0)
cur_ptr=NULL;
else
if (last_ptr)
WsIncHits(ws_matrix,last_ptr->num,cur_ptr->num);
last_ptr=cur_ptr;
}
ptr=ptr2+1;
}
if (!ch1) break;
*ptr2=ch1;
}
Free(buf);
}
void WsAddGlossFile(LTDirEntry *tempd)
{
LtfEntry *ll;
WsHashEntry *temph;
Ltf *l=LtfRead(tempd->full_name);
I1 *temp;
ll=l->dummy.next;
while (ll!=l) {
if (ll->btype==LTFT_ANCHOR) {
if (temph=FindHashEntry(ll->aux_str,
ws_hash_table,HTT_WORD)) {
temp=MSPrintF("FA:%s,%s",
tempd->full_name,ll->aux_str);
AFree(temph->glossary);
temph->glossary=ANewStr(temp);
Free(temp);
}
}
ll=ll->next;
}
LtfDel(l);
}
I8 WsSort(WsHashEntry **e1,WsHashEntry **e2)
{
I8 r;
if (!(r=(*e2)->hits - (*e1)->hits))
r=StrCmp((*e1)->word,(*e2)->word);
return r;
}
I8 WsSkipCrap(I1 *src,I8 len)
{
I8 j;
j=len-1;
while (j>=0) {
if (Bt(alpha_numeric_bitmap,src[j]))
break;
else
j--;
}
return j+1;
}
I8 WsPriorWordInStr(I1 *src,I1 *dst,I8 len,I8 buf_size)
{
I8 i,j=0,k;
BoolU4 cont=TRUE;
i=len-1;
while (i>=0 && cont) {
if (!Bt(alpha_numeric_bitmap,src[i]))
cont=FALSE;
else
i--;
}
if (i>=-1 && len>0)
for (k=i+1;k<len && j<buf_size-1;k++)
dst[j++]=src[k];
dst[j]=0;
return i+1;
}
BoolU8 WsPartialMatch(I1 *partial,I1 *complete)
{
I8 i,l=StrLen(partial);
for (i=0;i<l;i++)
if (partial[i]!=complete[i])
return FALSE;
return TRUE;
}
void WsFillin(I8 n)
{
I1 *s;
I8 len;
n--;
if (n>=0 && n<ws_num_fillins) {
s=ws_sorted_words[ws_fillin_matches[n]]->word;
len=StrLen(s);
if (len>ws_partial_len)
Auto(s+ws_partial_len);
}
}
void WsMan(I8 n,TssStruct *parent=NULL)
{
I1 *buf;
WsHashEntry *tempw;
SysHashEntry *temph;
BoolU4 old_preempt=Preempt(OFF);
n--;
if (n>=0 && n<ws_num_fillins) {
if (tempw=ws_sorted_words[ws_fillin_matches[n]]) {
buf=tempw->glossary;
if (temph=FindHashEntry(tempw->word,Fs->hash_table,HTT_ALL)) {
if (temph->source_link)
buf=temph->source_link;
}
if (buf) {
buf=MSPrintF("Edit(\"%s\");",buf);
Preempt(old_preempt);
PopUp(buf,parent);
Free(buf);
}
}
}
Preempt(old_preempt);
}
void WsAddFillin(I8 i,I8 j,I8 old_num_fillins)
{
BoolU4 cont;
I8 k;
if (ws_num_fillins<WS_MAX_FILLINS || i>ws_fillin_scores[ws_num_fillins-1] ||
i==ws_fillin_scores[ws_num_fillins-1] && ws_sorted_words[j]->hits>ws_fillin_hits[ws_num_fillins-1]) {
cont=TRUE;
for (k=ws_num_fillins-1;k>=old_num_fillins && cont;k--)
if (i<=ws_fillin_scores[k] || i==ws_fillin_scores[k] && ws_sorted_words[j]->hits<=ws_fillin_hits[k]) {
cont=FALSE;
k++; //offset k--
} else {
ws_fillin_scores[k+1]=ws_fillin_scores[k];
ws_fillin_matches[k+1]=ws_fillin_matches[k];
ws_fillin_hits[k+1]=ws_fillin_hits[k];
}
if (ws_num_fillins<WS_MAX_FILLINS)
ws_num_fillins++;
ws_fillin_scores[k+1]=i;
ws_fillin_hits[k+1]=ws_sorted_words[j]->hits;
ws_fillin_matches[k+1]=j;
}
}
void WsPutChoices(Ltf *l,Ltf *aux,Ltf *focus_l,LtfEntry *ll,TssStruct *focus_tss)
{
I8 i,j,k,data_col;
I1 ch=0,*buf,*buf1,*src=NULL,*st;
WsHashEntry *w2;
U8 timeout_jiffies=Jiffies+JIFFY_FREQ*20/1000;
SysHashEntry *temph;
src=LtfGetLine(focus_l,ll,&data_col);
i=StrLen(src);
buf=MAlloc(i+1);
buf1=MAlloc(i+1);
if (data_col==-1)
data_col=StrLen(i);
data_col=WsPriorWordInStr(src,buf,data_col,256);
ws_partial_len=StrLen(buf);
data_col=WsSkipCrap(src,data_col);
data_col=WsPriorWordInStr(src,buf1,data_col,256);
if (ws_cur_word) {
if (!StrCmp(ws_cur_word,buf))
goto done;
}
st=ws_cur_word;
ws_cur_word=ANewStr(buf);
AFree(st);
Preempt(ON);
if (StrLen(buf1))
w2=FindHashEntry(buf1,ws_hash_table,HTT_WORD);
else
w2=NULL;
ws_num_fillins=0;
if (w2 && w2->num<ws_num_matrix_words)
for (j=0;j<ws_num_matrix_words && Jiffies<timeout_jiffies;j++)
if (WsPartialMatch(ws_cur_word,ws_sorted_words[j]->word)) {
i=WsGetHits(ws_matrix,w2->num,ws_sorted_words[j]->num);
WsAddFillin(i,j,0);
}
k=ws_num_fillins;
for (j=0;j<ws_num_words && Jiffies<timeout_jiffies;j++)
if (WsPartialMatch(ws_cur_word,ws_sorted_words[j]->word))
WsAddFillin(0,j,k);
Preempt(OFF);
done:
LtfReset(l,TRUE);
l->flags|=LTFF_MIN_SIZE;
l->start_text_attribute=(LTBLUE<<4)+BLACK;
aux->start_text_attribute=(LTBLUE<<4)+BLACK;
Fs->text_attribute=l->start_text_attribute;
Fs->border_attribute=l->start_text_attribute;
LtfPrintF(l,"Word:%-20ts\r\n",ws_cur_word);
for (i=0;i<ws_num_fillins;i++) {
st=ws_sorted_words[ws_fillin_matches[i]]->word;
if (ws_sorted_words[ws_fillin_matches[i]]->glossary)
ch='#';
else
ch=CH_SPACE;
if (focus_tss) {
temph=FindHashEntry(st,focus_tss->hash_table,HTT_ALL);
if (temph) {
if (temph->source_link)
ch='*';
}
}
LtfPrintF(l,"%cF%02d %-20ts\r\n",ch,i+1,st);
}
WsdAddDictWords(l);
LtfRecalc(l);
Bts(&Fs->crt_flags,CRTf_SHOW);
WinToTop(Fs);
Free(src);
Free(buf);
Free(buf1);
}
void WsTsk()
{
TssStruct *focus_tss;
Ltf *l;
LtfEntry *ll;
InitLocalTask;
UseConsoleLtf(NULL);
Fs->win_left=50;
do {
Sleep(333);
if (Bt(&ws_flags,WSf_ENABLE)) {
focus_tss=sys_cur_focus_task;
while (Bt(&focus_tss->task_flags,TSSf_INPUT_FILTER_TASK))
focus_tss=focus_tss->parent_tss;
if (ValidateTss(focus_tss)) {
l=focus_tss->cur_ltf;
if (l && focus_tss!=Fs) {
ll=l->cur_entry;
if (ll) {
if (ll==l) ll=ll->last;
while (ll->last!=l && (ll->btype==LTFT_CR ||
ll->btype==LTFT_SOFT_CR))
ll=ll->last;
while ((ll->last->btype)!=LTFT_CR && ll->last!=l)
ll=ll->last;
if (Bt(&ws_flags,WSf_ENABLE))
WsPutChoices(Fs->cur_ltf,Fs->aux_ltf,l,ll,focus_tss);
}
}
}
}
} while (!ScanKey);
ws_task=NULL;
}
void WsTraverseMainFilelist(WsFilemaskEntry *tempfm,BoolU4 compile)
{
WsFilemaskEntry *tempfm1;
LTDirEntry *tempm;
I8 i;
while (tempfm) {
tempfm1=tempfm->next;
if (!compile) {
tempm=FindFiles(tempfm->mask,1<<FUf_RECURSE);
tempfm->flist=OrderFiles(tempm,&tempfm->cnt);
}
for (i=0;i<tempfm->cnt;i++) {
tempm=tempfm->flist[i];
if (IsTextFile(tempm->name)) {
coutln tempm->full_name;
WsAddSingleFile(tempm,compile);
}
if (compile)
DelLTDirEntry(tempm);
}
if (compile) {
Free(tempfm->flist);
Free(tempfm);
}
tempfm=tempfm1;
}
}
void WsTraverseGlossFilelist(WsFilemaskEntry *tempfm)
{
WsFilemaskEntry *tempfm1;
LTDirEntry *tempm;
I8 i;
while (tempfm) {
tempfm1=tempfm->next;
tempm=FindFiles(tempfm->mask,1<<FUf_RECURSE);
tempfm->flist=OrderFiles(tempm,&tempfm->cnt);
for (i=0;i<tempfm->cnt;i++) {
tempm=tempfm->flist[i];
if (WildCardMatch("*.GL?",tempm->name)) {
coutln tempm->full_name;
WsAddGlossFile(tempm);
}
DelLTDirEntry(tempm);
}
Free(tempfm->flist);
Free(tempfm);
tempfm=tempfm1;
}
}
void WsDelMatrix(WsMatrix *m)
{
I8 i;
WsStruct *tempw,*tempw1,*tempw2;
if (!m) return;
for (i=0;i<WS_MAX_MATRIX_WORDS;i++) {
tempw1=&m->side[i];
tempw=tempw1->next;
while (tempw!=tempw1) {
tempw2=tempw->next;
AFree(tempw);
tempw=tempw2;
}
}
AFree(m);
}
public BoolU8 WordStat(BoolU8 val=ON)
{
BoolU4 old_wordstat=FALSE,
old_preempt=Preempt(OFF);
if (val) {
Bts(&ws_flags,WSf_ENABLE);
if (ValidateTss(ws_task))
old_wordstat=TRUE;
else
ws_task=Spawn(&WsTsk,"WordStat");
} else {
Btr(&ws_flags,WSf_ENABLE);
if (ValidateTss(ws_task)) {
old_wordstat=TRUE;
Kill(ws_task);
while (ValidateTss(ws_task))
SwapInNext;
ws_task=NULL;
}
Bts(&ws_flags,WSf_ENABLE);
}
Preempt(old_preempt);
return old_wordstat;
}
public void WsInit(I1 *mask)
// Separate directories with ';'
{
I1 *buf,buf2[512];
I8 i,j=0;
WsHashEntry *tempw;
BoolU4 old_wordstat;
WsFilemaskEntry *tempfm,*tempfm1;
while (Bts(&ws_flags,WSf_INIT_IN_PROGRESS))
SwapInNext;
old_wordstat=WordStat(OFF);
if (Fs==adam_tss)
DelHashTable(ws_hash_table);
else
Adam("DelHashTable(ws_hash_table);");
ws_hash_table=NewHashTable(0x4000,adam_tss);
ws_num_words=0;
ws_num_matrix_words=0;
AFree(ws_cur_word);
ws_cur_word=NULL;
tempfm1=NULL;
buf=NewStr(mask);
do {
RemoveFirstSeg(buf,";",buf2);
if (*buf2) {
tempfm=MAlloc(sizeof(WsFilemaskEntry));
tempfm->next=tempfm1;
tempfm1=tempfm;
tempfm->mask=NewStr(buf2);
tempfm->flist=NULL;
}
} while (*buf2);
Free(buf);
coutln "\r\n\r\nPass #1";
WsTraverseMainFilelist(tempfm1,FALSE);
AFree(ws_sorted_words);
ws_sorted_words=AMAlloc(sizeof(void *)*ws_num_words);
for (i=0;i<=ws_hash_table->mask;i++) {
tempw=ws_hash_table->body[i];
while (tempw) {
ws_sorted_words[j++]=tempw;
tempw=tempw->next;
}
}
QSort(ws_sorted_words,ws_num_words,sizeof(void *),&WsSort);
for (i=0;i<ws_num_words;i++)
ws_sorted_words[i]->num=i;
if (ws_num_words<=WS_MAX_MATRIX_WORDS)
ws_num_matrix_words=ws_num_words;
else
ws_num_matrix_words=WS_MAX_MATRIX_WORDS;
WsDelMatrix(ws_matrix);
ws_matrix=AMAlloc(sizeof(WsMatrix));
WsInitSides(ws_matrix);
coutln "\r\n\r\nPass #2";
WsTraverseMainFilelist(tempfm1,TRUE);
tempfm1=NULL;
buf=NewStr(mask);
do {
RemoveFirstSeg(buf,";",buf2);
if (*buf2) {
tempfm=MAlloc(sizeof(WsFilemaskEntry));
tempfm->next=tempfm1;
tempfm1=tempfm;
tempfm->mask=NewStr(buf2);
tempfm->flist=NULL;
}
} while (*buf2);
Free(buf);
coutln "\r\n\r\nGlossary Pass";
WsTraverseGlossFilelist(tempfm1);
AFree(ws_dict_word_list);
WsdLoadWords;
WordStat(old_wordstat);
Btr(&ws_flags,WSf_INIT_IN_PROGRESS);
}
-100
View File
@@ -1,100 +0,0 @@
#help_index "WordStat"
#help_file "::/LT/Doc/WordStat.TXZ"
#define WS_SUBSTRUCT_SIZE_BITS 3
class WsSubstruct
{
I4 hits,repeats;
};
#define WS_SUBSTRUCTS_PER_STRUCT 8
class WsStruct
{
WsStruct *next,*last;
I8 substructs, //-1 means WsMatrixSide
entries;
WsSubstruct subs[WS_SUBSTRUCTS_PER_STRUCT];
};
class WsMatrixSide
{
WsStruct *next,*last;
I8 const_minus_one, //-1 used to header in queue
row_hits,col_hits;
};
#define WS_MAX_MATRIX_WORDS 0x8000
class WsMatrix
{
I8 n;
WsMatrixSide side[WS_MAX_MATRIX_WORDS];
};
public I8 ws_num_words,ws_num_matrix_words;
SysHashTable *ws_hash_table=NULL;
public I1 *ws_cur_word=NULL;
#define WSf_ENABLE 0
#define WSf_INIT_IN_PROGRESS 1
U8 ws_flags=0;
public WsMatrix *ws_matrix=NULL;
public WsHashEntry **ws_sorted_words=NULL;
TssStruct *ws_task=NULL;
class WsFilemaskEntry
{
WsFilemaskEntry *next;
I1 *mask;
I8 cnt;
LTDirEntry **flist;
};
#define WS_MAX_FILLINS 10
I8 ws_partial_len=0,ws_fillin_matches[WS_MAX_FILLINS+1];
I8 ws_num_fillins=0,ws_fillin_scores[WS_MAX_FILLINS+1],ws_fillin_hits[WS_MAX_FILLINS+1];
/**************** Dictionary Stuff ************/
#define WSD_RAW_FILENAME "/Text/Dictionary.TTZ" //this is a file I got from project gutenburg
#define WSD_WORD_FILENAME "/LT/Adam/WordStat/WsWords.DTZ"
#define WSD_DEF_FILENAME "/LT/Adam/WordStat/WsDefs.DAT"
#define WSD_H1 0
#define WSD_H1_END 1
#define WSD_DEF 2
#define WSD_DEF_END 3
#define WSD_PRONUNCIATION 4
#define WSD_PRONUNCIATION_END 5
#define WSD_POS 6
#define WSD_POS_END 7
#define WSD_EXTRA 8
#define WSD_EXTRA_END 9
#define WSD_BLK_SIZE 0x4000
#define WSD_END_CHAR 0x00
#define WSD_WORD_CHAR 0x01
#define WSD_DEF_CHAR 0x02
#define WSD_PRONUNCIATION_CHAR 0x03
#define WSD_POS_CHAR 0x04
#define WSD_EXTRA_CHAR 0x05
I1 *ws_dict_word_list=NULL;
I8 ws_dict_word_list_size=0,
ws_dict_num_words=0;
extern void WsdLoadWords();
extern void WsdAddDictWords(Ltf *l,I1 *st=NULL);
#define WSD_MAX_FILLINS 10
I1 *wsd_fillins[WSD_MAX_FILLINS];
I8 wsd_num_fillins=0;
/******************************************/
#include "WSMain.APZ"
#include "WSDict.APZ"
#help_index ""
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,23 +0,0 @@
void EndTsk()
{
Sound(0);
Exit;
}
void Song()
{
Fs->end_task_cb=&EndTsk;
music_tempo=2.5;
try {
while (!ScanKey) {
Play("3sFGFGetBFFDARqEC2G3FC");
Play("sFGFGetBFFDARqEC2G3FC");
Play("2eG3GetDB2G3qFDAReECsCRCR");
Play("2eG3GetDB2G3qFDAReECsCRCR");
}
} catch
Fs->catch_except=TRUE;
Sound(0);
}
Song;
Binary file not shown.
-36
View File
@@ -1,36 +0,0 @@
void EndTsk()
{
Sound(0);
Exit;
}
void Song()
{
TssStruct *tss;
Fs->end_task_cb=&EndTsk;
tss=PopUpViewStr(
"$$LK-A,\"BF:Acts,9:3\"$$\r\n"
);
WaitTskIdle(tss);
tss->win_right=Fs->win_right;
tss->win_left=Fs->win_left;
tss->win_top=Fs->win_bottom+3;
tss->win_bottom=tss->win_top+12;
music_tempo=2.5;
try {
while (!ScanKey) {
Play("3qEeACA2G3qCEC2G3E",
"Now... \0 \0 \0 \0 \0I \0see \0the \0light.\r\n\0 \0");
Play("EeACA2G3qCEC2G3E",
"Now... \0 \0 \0 \0 \0I \0see \0the \0light.\r\n\0 \0");
Play("GCGBEeDFCAqD",
"It's \0 \0quite \0 \0bright.\r\n\0 \0 \0 \0 \0 \0");
Play("GCGBEeDFCAqD",
"It's \0 \0quite \0 \0bright.\r\n\0 \0 \0 \0 \0 \0");
}
} catch
Fs->catch_except=TRUE;
Sound(0);
}
Song;
Binary file not shown.
Binary file not shown.
Binary file not shown.
-36
View File
@@ -1,36 +0,0 @@
void EndTsk()
{
Sound(0);
Exit;
}
void Song()
{
TssStruct *tss;
Fs->end_task_cb=&EndTsk;
music_tempo=2.5;
try {
tss=PopUpViewStr(
"$$LK-A,\"BF:Luke,12:16\"$$\r\n"
);
WaitTskIdle(tss);
tss->win_right=Fs->win_right;
tss->win_left=Fs->win_left;
tss->win_top=Fs->win_bottom+3;
tss->win_bottom=tss->win_top+12;
while (!ScanKey) {
Play("3etGREqDDBRGCB",
"It \0 \0de\0pends \0 \0on \0 \0the \0wea\0ther.\r\n\0");
Play("etGREqDDBRGCB",
"If \0 \0we \0reach \0 \0the \0 \0end \0ev\0er.\r\n\0");
Play("2sG3E2G3EqGsGBGBqDsFCFCqBRsCBCB",
"Hand \0 \0of \0 \0God, \0 \0just \0 \0might, \0 \0in\0 \0ter\0 \0cedes.\r\n\0 \0 \0 \0 \0 \0");
Play("2G3E2G3EqGsGBGBqDsFCFCqBRsCBCB",
"If \0 \0it's \0 \0not \0 \0deemed \0 \0right, \0 \0won't \0 \0suc\0 \0ceed.\r\n\0 \0 \0 \0 \0 \0");
}
} catch
Fs->catch_except=TRUE;
Sound(0);
}
Song;
@@ -1,20 +0,0 @@
//star
void EndTsk()
{
Sound(0);
Exit;
}
void Song()
{
Fs->end_task_cb=&EndTsk;
music_tempo=2.5;
while (TRUE) {
Play("etCCBetGGDetBBFeGCetBABeAAqEqF");
Play("etCCBetGGDetBBFeGCetBABeAAqEqF");
Play("eCGqFqDqDqCeDGqCqB");
Play("eCGqFqDqDqCeDGqCqB");
}
}
Song;
-22
View File
@@ -1,22 +0,0 @@
//has words,star,star
void EndTsk()
{
Sound(0);
Exit;
}
void Song()
{
Fs->end_task_cb=&EndTsk;
music_tempo=2.5;
while (TRUE) {
Play("et2G32G3Gq2G3qCq2G3sFAFAq2G3etGDAqA",
"Don't \0 \0need \0 \0help. \0 \0Got \0 \0it \0 \0all \0figured \0 \0 \0out.\r\n\0");
Play("et2G32G3Gq2G3qCq2G3sFAFAq2G3etGDAqA",
"Don't \0 \0need \0 \0help. \0 \0Got \0 \0it \0 \0all \0figured \0 \0 \0out.\r\n\0");
Play("etCCCq2G3qDeDFetCF2G3qBeGFsAGAG");
Play("etCCCq2G3qDeDFetCF2G3qBeGFsAGAG");
}
}
Song;
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More