Initial (manual) import

This commit is contained in:
minexew committed 2017-01-22 20:26:44 +01:00
1 parent f39611c506
commit 895fe109de
661 files changed
+245862

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
U8 *tSCB(CDoc *,CDocEntry *,CTask *mem_task)
{//This is called by the window mgr.
//Things would get corrupted
//if the window mgr used it's own
//heap, so we use the owning task's heap.
U8 *st=MAlloc(64,mem_task);
CDate cdt=tS*CDATE_FREQ;
//Doesn't have to be fixed width!!
StrPrint(st,"%d=%T",cdt,cdt);
return st;
}
U8 *CurTimeCB(CDoc *,CDocEntry *,CTask *mem_task)
{
U8 *st=MAlloc(64,mem_task);
CDate cdt=Now;
StrPrint(st,"%D %T",cdt,cdt);
return st;
}
U0 DoIt()
{
CDoc *bdoc=DocBorder,*pdoc=DocPut;
CDocEntry *doc_e;
DocLock(bdoc);
DocBottom(bdoc); //Ins at the bottom
DocPrint(bdoc,"$$RED$$$$CM+BY+LX,5,-3$$");
//The $LK,"DocPrint",A="MN:DocPrint"$() routine returns the addr of the last entry.
doc_e=DocPrint(bdoc,"$$TX+TC,\" \"$$");
//The TC flag is "has tag callback".
//Flags are explained here:
//$LK,"::/Doc/DolDocOverview.DD"$ $LK,"::/Doc/Widget.DD"$
//$LK,"Dollar Flags",A="MN:DOCEf_TAG"$ $LK,"ST_DOC_FLAGS",A="FF:::/Adam/DolDoc/DocInit.HC,ST_DOC_FLAGS"$
doc_e->tag_cb=&tSCB;
DocPrint(bdoc,"$$FG$$");
DocUnlock(bdoc);
//$BK,1$WARNING:$BK,0$ If you use the put_doc you
//run the risk of the user pressing
//<CTRL-t> or using the clipboard, both
//of which will crash. So, you might want
//to use the border_doc.
DocLock(pdoc);
DocPrint(pdoc,"$$LTRED$$");
doc_e=DocPrint(pdoc,"$$TX+TC,\" \"$$");
doc_e->tag_cb=&CurTimeCB;
DocPrint(pdoc,"$$FG$$");
DocUnlock(pdoc);
//Send carriage return, new line, so
//that the timer string is not part
//of the next cmd on the cmd line.
'\n';
}
U0 UndoIt()
{//Clear-out entries without a +H hold flag.
DocClear(Fs->border_doc);
}
DoIt;
+47
View File
@@ -0,0 +1,47 @@
I64 MyLeftCB1(CDoc *,CDocEntry *)
{
I64 i;
for (i=500;i<1000;i+=25) {
Snd(Freq2Ona(i));
Sleep(10);
}
Snd;
return 0;
}
U0 ClickCallBack()
{
CDocEntry *doc_e;
DocLock(DocPut);
//The $LK,"DocPrint",A="MN:DocPrint"$() routine returns the addr of the last entry.
doc_e=DocPrint(DocPut,"\n$$MA+LC,\"Click Me\"$$ ");
//The LC flag is "has left callback".
//Flags are explained here:
//$LK,"::/Doc/DolDocOverview.DD"$ $LK,"::/Doc/Widget.DD"$
//$LK,"Dollar Flags",A="MN:DOCEf_TAG"$ $LK,"ST_DOC_FLAGS",A="FF:::/Adam/DolDoc/DocInit.HC,ST_DOC_FLAGS"$
"(Not preserved if you press <CTRL-t>.)\n\n";
doc_e->left_cb=&MyLeftCB1;
DocUnlock(DocPut);
}
ClickCallBack;
I64 MyLeftCB2(CDoc *,CDocEntry *)
{
return cnts.jiffies;
}
U0 PopUpJiffiesCallBack(I64 i)
{
CDoc *doc=DocNew;
CDocEntry *doc_e=DocPrint(doc,
"Click %d more times\n\n\n$$BT+LC,\"Jiffies\"$$\n\n\n",i);
doc_e->left_cb=&MyLeftCB2;
"Current Jiffies:%d\n",PopUpMenu(doc);
DocDel(doc);
}
PopUpJiffiesCallBack(3);
PopUpJiffiesCallBack(2);
PopUpJiffiesCallBack(1);
+38
View File
@@ -0,0 +1,38 @@
U0 CursorMovementDemo()
{
I64 i;
for (i=0;i<100;i++) {
"%03d ",i;
"$$CM,-4,1$$";
if (i%10==9)
"$$CM,4,-10$$";
}
//+LX is relative to left side.
//See <CTRL-l> with cursor-movement for all the flags.
//Check "Quote" to set-up a cmd for in quotes.
"$$CM+LX,0,+10$$\n";
}
CursorMovementDemo;
/*The word-wrap Off and On cmds are
$$WW,0$$ and $$WW,1$$.
You might need $LK,"DocMax",A="MN:DocMax"$() to adjust
the cmd line window buf size.
It counts cmds, not lines.
The +H flag will hold-onto an entry
so it doesn't get pushed-out of the document.
This is useful for a $$WW+H,1$$ cmd.
See $LK,"::/Doc/DolDocOverview.DD"$ for documentation on
all flags and cmds.
Note: the default page length is 66 lines
and branching back more than the page length
will rst the column to 1. So, set page
length to a large number if you want to
branch back a long distance.
*/
+63
View File
@@ -0,0 +1,63 @@
/*$$DA is the data widget.
-TRM flag is for var
width fields with a terminator
character.
+RD refreshes the data.
+UD updates the val when you edit it.
-P Means it is a string var, basically.
,32 sets the tag string width.
See $LK,"Data Tag Width",A="FA:::/Adam/DolDoc/DocPlain.HC,DataTagWidth"$.
,RT=I16 means the val is 2 bytes.
See $LK,"DocDataFmt",A="MN:DocDataFmt"$() and $LK,"DocDataScan",A="MN:DocDataScan"$().
*/
I16 i=0;
U8 buf[8];
U0 UpdateGlblTask(I64)
{
while (TRUE) {
i++;
Sleep(1);
}
}
U0 DataDemo()
{
CDocEntry *doc_e;
//This is the command line document.
CDoc *doc=DocPut;
//We do this to prevent access to
//doc_e->data before it is set.
Bool unlock=DocLock(doc);
//You might set the $LK,"DOCF_FORM",A="MN:DOCF_FORM"$ flag.
// doc->flags|=DOCF_FORM
//if you wish.
Spawn(&UpdateGlblTask,NULL,"Update Glbl",,Fs);
"Enter editor overstrike mode\n"
"and you can modify the val.\n"
"However, changes happen immediately,\n"
"so it's tricky.\n\n";
//Use <CTRL-l> for the $$DA...$$ format.
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=I16,A=\"%%7d\"$$\n");
doc_e->data=&i;
StrCpy(buf,"Terry");
doc_e=DocPrint(doc,"$$DA-P+RD+UD,LEN=7,A=\"Str:%%s\"$$\n");
doc_e->data=buf;
if (unlock)
DocUnlock(doc);
}
DataDemo;
//See $LK,"PopUpExtents",A="MN:PopUpExtents"$().
+22
View File
@@ -0,0 +1,22 @@
/*The +D flag causes a define-string
look-up and substitution.
It is available in the <CTRL-l> text-widget
menu under text entries for use in
documentation.
*/
DefineLoad("COMPANY","Acme Inc");
"Company: $$TX,\"\",D=\"COMPANY\"$$\n";
DefinePrint("COMPANY_TIME","%T",Now);
#exe {
StreamPrint(
"#define COMPANY_AGE %0.1f\n",
(Now-Str2Date("8/1/2003"))/ToF64(1<<32)/CDATE_YEAR_DAYS);
};
"Age : $$TX,\"\",D=\"COMPANY_AGE\"$$ years\n";
"Time: $$TX,\"\",D=\"COMPANY_TIME\"$$\n";
Binary file not shown.
+80
View File
@@ -0,0 +1,80 @@
public U0 DocProfile(U8 *filename,I64 flags)
{
I64 i,*cmd_stats=CAlloc(sizeof(I64)*DOCT_TYPES_NUM),
*flags_stats=CAlloc(sizeof(I64)*64),
*type_flags_stats=CAlloc(sizeof(I64)*64);
//Note: word wrap is determined by
//doc->win_task when a $LK,"CDoc",A="MN:CDoc"$ is recalculated
//use $LK,"DocRecalc",A="MN:DocRecalc"$().
CDoc *doc=DocRead(filename,flags);
//doc->head which is equ to doc is the
//header of the CQue and represents the end-of-file marker.
CDocEntry *doc_e=doc->head.next;
while (doc_e!=doc) {
cmd_stats[doc_e->type_u8]++;
for (i=0;i<64;i++)
if (Bt(&doc_e->de_flags,i))
flags_stats[i]++;
for (i=16;i<32;i++)
if (Bt(&doc_e->type,i))
type_flags_stats[i]++;
doc_e=doc_e->next;
}
DocDel(doc);
"$$PURPLE$$-------%s-------\n",filename;
"$$GREEN$$The lowest byte of the 32-bit 'doc_e->type', "
"'$$PURPLE$$doc_e->type.u8[0]$$GREEN$$', "
"is cmd and accessed with the union "
"'$$PURPLE$$doc_e->type_u8$$GREEN$$'. "
"See $$LK,\"CDocEntry\",A=\"MN:CDocEntry\"$$, "
"$$LK,\"Doc Type Defines\",A=\"MN:DOCT_TEXT\"$$ and "
"$$LK,\"Doc Type Codes\","
"A=\"FF:::/Adam/DolDoc/DocInit.HC,ST_DOC_CMDS\"$$.\n"
"$$FG$$";
for (i=0;i<DOCT_TYPES_NUM;i++)
if (cmd_stats[i])
"%4Z:%d\n",i,"ST_DOC_CMDS",cmd_stats[i];
"\n$$GREEN$$'$$PURPLE$$doc_e->type.u8[1]$$GREEN$$' is "
"the scrn color attr of the "
"entry. '$$PURPLE$$doc_e->type.u16[1]"
"$$GREEN$$' is some flags for blinking and "
"stuff. See $$LK,\"Doc Type Flag "
"Defines\",A=\"MN:DOCET_BLINK\"$$.\n$$FG$$";
for (i=16;i<32;i++)
if (type_flags_stats[i])
"%4d:%d\n",i,type_flags_stats[i];
"$$GREEN$$\n'$$PURPLE$$doc_e->de_flags$$GREEN$$' is 64-bit. "
"See $$LK,\"Doc Flag Defines\",A=\"MN:DOCEf_TAG\"$$ and "
"$$LK,\"Doc Flag Codes\","
"A=\"FF:::/Adam/DolDoc/DocInit.HC,ST_DOC_FLAGS\"$$.\n"
"$$FG$$";
for (i=0;i<64;i++)
if (flags_stats[i])
"%4Z:%d\n",i,"ST_DOC_FLAGS",flags_stats[i];
Free(cmd_stats);
Free(flags_stats);
PressAKey;
'\n';
}
/*See $LK,"TipOfDay",A="MN:TipOfDay"$.
Note: Not all $LK,"CDocEntry",A="MN:CDocEntry"$'s are full-sized nodes.
Some are $LK,"MAlloc",A="MN:MAlloc"$ed with a smaller size to save
mem. They all have at least the size $LK,"CDocEntryBase",A="MN:CDocEntryBase"$.
Note: $LK,"CDocEntry",A="MN:CDocEntry"$'s should be alloced from the
heap of the owning task, doc->mem_task.
The flag arrays $LK,"doldoc.type_flags_form",A="MN:CDolDocGlbls"$, etc
are useful.
*/
DocProfile("::/Doc/ChgLog.DD",0);
DocProfile("::/Doc/ChgLog.DD",DOCF_PLAIN_TEXT);
+51
View File
@@ -0,0 +1,51 @@
class FDStruct
{//Use <CTRL-l> and sel "Data", "List" or "Check Box"
//to generate the fmtstrs.
F64 num1 fmtstr "$$DA-TRM,A=\"Float 1:%12.8f\"$$\n";
F64 num2 fmtstr "$$DA-TRM,A=\"Float 2:%12e\"$$\n";
I64 num3 fmtstr "$$DA-TRM,A=\"Int 1:0x%016X\"$$\n";
I64 num4 fmtstr "$$DA-TRM,A=\"Int 2:%12d\"$$\n";
I64 type fmtstr "$$LS,D=\"ST_PERSON_TYPE\"$$\n";
U8 name[32] fmtstr "$$DA-P,A=\"Name :%s\"$$\n";
U8 *address1 fmtstr "$$DA+M,A=\"Address:%s\"$$\n"; //+M is unlimited len U8 *.
U8 *address2 fmtstr "$$DA+M,A=\"Address:%s\"$$\n"; //+M is unlimited len U8 *.
CDate datetime fmtstr "$$DA-TRM,A=\"Date :%8D\"$$\n";
Bool check fmtstr "$$CB,\"Check\"$$\n";
};
U0 FormDemo()
{
FDStruct fds;
DefineLstLoad("ST_PERSON_TYPE","Child\0Teen\0Adult\0");
fds.num1=12.3e-4; //Set defaults
fds.num2=4.5e3;
fds.num3=0x1234;
fds.num4=-567;
fds.type=1;
StrCpy(&fds.name,"John");
fds.address1=StrNew("1234 Pine St.");
fds.address2=NULL; //Init to NULL if empty.
fds.datetime=Now;
fds.check=TRUE;
if (DocForm(&fds)) {
"#1\t=%e\n",fds.num1;
"#2\t=%e\n",fds.num2;
"#3\t=%d\n",fds.num3;
"#4\t=%d\n",fds.num4;
"Type\t=%s\n",DefineSub(fds.type,"ST_PERSON_TYPE");
"Name\t=%s\n",fds.name;
"Address1=%s\n",fds.address1;
"Address2=%s\n",fds.address2;
"Date\t=%D\n",fds.datetime;
"Check\t=%d\n",fds.check;
} else
"Cancel\n";
"\n\nClassRep Example\n";
ClassRep(&fds);
Free(fds.address1);
Free(fds.address2);
//See also $LK,"ClassRepD",A="MN:ClassRepD"$().
}
FormDemo;
+75
View File
@@ -0,0 +1,75 @@
//This example shows bttns. Bttns return a menu val
//unless you rig them to send macros. Menu entries are
//about the same as bttns, but don't have a border.
I64 PopUpFreq()
{//See also $LK,"PopUpRangeI64",A="MN:PopUpRangeI64"$()
I64 i;
CDoc *doc=DocNew;
DocPrint(doc,"$$TX+CX,\"Set Freq\"$$\n" //Centered text
"$$CM+LX,2,4$$$$BT,\"100 Hz\",LE=100$$"
"$$CM+LX,18,0$$$$BT,\"200 Hz\",LE=200$$"
"$$CM+LX,2,4$$$$BT,\"400 Hz\",LE=400$$"
"$$CM+LX,18,0$$$$BT,\"800 Hz\",LE=800$$\n");
i=PopUpMenu(doc);
if (i<0) i=0; // <SHIFT-ESC>
DocDel(doc);
return i;
}
#define MU_NOTHING 0
#define MU_SET_FREQ 1
#define MU_SND_ON 2
#define MU_SND_OFF 3
U0 MenuBttn()
{
Bool done=FALSE;
I64 i,j=0,freq=100;
I64 old_flags=DocPut->flags;
//This allows keyboard navigation to skip nonselible entries.
DocPut->flags|=DOCF_FORM;
do {
DocClear;
//Use <CTRL-l> to generate cursor movement expressions and check "Quote".
"$$CM+CX-RE,-4$$Menu Demo\n\n";
"$$LM,8$$"; //Set left margin
//These are bttns that return a val from a menu selection.
if (!j)
"\n$$BT,\"Snd On\",LE=MU_SND_ON$$\n\n\n";
else
"\n$$BT,\"Snd Off\",LE=MU_SND_OFF$$\n\n\n";
"\n$$BT,\"Set Freq\",LE=MU_SET_FREQ$$\n\n\n"
"\n$$BT,\"Nothing\",LE=MU_NOTHING$$\n\n\n"
"\n$$BT,\"Done\",LE=DOCM_CANCEL$$\n\n\n";
i=DocMenu(DocPut);
DocBottom;
switch (i) {
case MU_NOTHING:
break;
case MU_SND_ON:
j=freq;
Snd(Freq2Ona(j));
break;
case MU_SND_OFF:
j=0;
Snd;
break;
case MU_SET_FREQ:
freq=PopUpFreq;
if (j) {
j=freq;
Snd(Freq2Ona(j));
}
break;
default:
done=TRUE;
}
} while (!done);
DocPut->flags=DocPut->flags&~DOCF_FORM |
old_flags & DOCF_FORM;
DocClear;
Snd;
}
MenuBttn;
Binary file not shown.
+29
View File
@@ -0,0 +1,29 @@
// This makes a new Bible file
//with line numbers.
U0 NumBible()
{
CDoc *doc_in=DocRead("::/Misc/Bible.TXT.Z",DOCF_PLAIN_TEXT_TABS),
*doc_out=DocNew("~/DemoNumBible.DD.Z");
CDocEntry *doc_e=doc_in->head.next;
while (doc_e!=doc_in) {
if (doc_e->type_u8==DOCT_TEXT) {
DocPrint(doc_out,"%05d %s",doc_e->y+1,doc_e->tag);
doc_e=doc_e->next;
if (doc_e->type_u8==DOCT_NEW_LINE) {
DocPrint(doc_out,"\n");
doc_e=doc_e->next;
}
} else if (doc_e->type_u8==DOCT_NEW_LINE) {
DocPrint(doc_out,"%05d\n",doc_e->y+1);
doc_e=doc_e->next;
} else
doc_e=doc_e->next;
}
doc_out->flags|=DOCF_NO_CURSOR;
DocWrite(doc_out);
DocDel(doc_out);
DocDel(doc_in);
}
NumBible;
+22
View File
@@ -0,0 +1,22 @@
"\nSuper : 3$$SY,-3$$2$$SY,0$$=9\n\n"
"Sub : H$$SY,3$$2$$SY,0$$O\n\n"
"Color : $$RED$$Test$$FG$$\n\n"
"Blink : $$BK,1$$Test$$BK,0$$\n\n"
"Invert : $$IV,1$$Test$$IV,0$$\n\n"
"UnderLine: $$UL,1$$Test$$UL,0$$\n\n"
"Link : $$LK,\"Genesis,1:1\",\"BF:Genesis,1:1\"$$\n\n\n"
"Bttn : $$BT-X,\"OKAY\",LE=1$$\n\n\n\n";
//You can do it this way if you like.
"\nSuper : 3$SY,-3$2$SY,0$=9\n\n"
"Sub : H$SY,3$2$SY,0$O\n\n"
//Can't see color because of syntax highlighting. Press <CTRL-t>
"Color : $FG,4$Test$FG$\n\n"
"Blink : $BK,1$Test$BK,0$\n\n"
"Invert : $IV,1$Test$IV,0$\n\n"
"UnderLine: $UL,1$Test$UL,0$\n\n"
//<CTRL-SHIFT-T> on this link to toggle individual commands.
"Link : $LK,"Genesis,1:1",A="BF:Genesis,1:1"$\n\n\n"
"Bttn : $BT,"OKAY",LE=1$\n\n\n\n";
+39
View File
@@ -0,0 +1,39 @@
U0 TreeSub(CDoc *doc,CDirEntry *tmpde)
{
CDirEntry *tmpde1;
while (tmpde) {
tmpde1=tmpde->next;
if (tmpde->attr & RS_ATTR_DIR) {
DocPrint(doc,"$$TR,\"\"$$");
DocPrint(doc,"$$MA,T=\"%s\",LM=\"Cd(\\\"%s\\\");Dir;\n\"$$\n",
tmpde->name,tmpde->full_name);
if (tmpde->sub) {
DocPrint(doc,"$$ID,+2$$");
TreeSub(doc,tmpde->sub);
DocPrint(doc,"$$ID,-2$$");
}
} else
DocPrint(doc,"$$LK,\"%s\",A=\"FI:%s\"$$\n",
tmpde->name,tmpde->full_name);
//Note there is also a routine
//to delete an entire CDirEntry tree.
//See $LK,"DirTreeDel",A="MN:DirTreeDel"$().
DirEntryDel(tmpde);
tmpde=tmpde1;
}
}
U0 TreeDemo()
{
I64 fuf_flags=0;
CDoc *doc=DocNew;
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r");
DocPrint(doc,"$$TR-C,\"\"$$\n");
DocPrint(doc,"$$ID,+2$$");
TreeSub(doc,FilesFind("/*",fuf_flags));
DocPrint(doc,"$$ID,-2$$");
DocInsDoc(DocPut,doc);
DocDel(doc);
}
TreeDemo;
+82
View File
@@ -0,0 +1,82 @@
/*Scans the sym table and checks
each $LK,"HTT_DEFINE_STR",A="MN:HTT_DEFINE_STR"$ entry to see if
it only occurs once in files.
It's a brute force solution, but
gets the job done... slowly.
$LK,"Find",A="MN:Find"$() returns a count of matches.
$LK,"FileOcc",A="MN:FileOcc"$() is $LK,"Find",A="MN:Find"$() with
output $LK,"Silent",A="MN:Silent"$().
*/
U0 UnusedDefineScan()
{
CDoc *old_put_doc,*old_display_doc,*doc;
I64 i,cnt=0;
CHashTable *table;
CHash *tmph;
CDocEntry *doc_e,*doc_e2;
Bool old_silent=IsSilent;
try {
table=Fs->hash_table;
while (table) {
for (i=0;i<=table->mask;i++) {
tmph=table->body[i];
while (tmph) {
if (tmph->type&HTT_DEFINE_STR)
cnt++;
tmph=tmph->next;
}
}
table=table->next;
}
progress1=0;
progress1_max=cnt;
StrCpy(progress1_desc,"Define Scan");
table=Fs->hash_table;
while (table) {
for (i=0;i<=table->mask;i++) {
tmph=table->body[i];
while (tmph) {
if (tmph->type&HTT_DEFINE_STR) {
progress1++;
if (FileOcc(tmph->str,"/*","+l-i+$$")==1) {
doc=DocNew;
old_put_doc=DocPut;
old_display_doc=DocDisplay;
Fs->put_doc=Fs->display_doc=doc;
Find(tmph->str,"/*","+l-i+$$");
Fs->put_doc=old_put_doc;
Fs->display_doc=old_display_doc;
doc_e=doc->head.next;
while (doc_e!=doc) {
if (doc_e->type_u8==DOCT_LINK) {
"%s ",tmph->str;
doc_e2=DocEntryCopy(doc,doc_e);
DocInsEntry(old_put_doc,doc_e2);
'\n';
}
doc_e=doc_e->next;
}
DocDel(doc);
}
}
tmph=tmph->next;
}
}
table=table->next;
}
} catch
PutExcept;
Silent(old_silent);
'\n';
ProgressBarsRst;
}
UnusedDefineScan;