Browse Source

TempleOSCD_150720.ISO

v6
Terry A. Davis 7 years ago committed by minexew
parent
commit
f8c05f98f4
  1. BIN
      0000Boot/0000Kernel.BIN.C
  2. 11
      Adam.CPP
  3. 21
      Adam/ADbg.CPP
  4. 52
      Adam/ADefine.CPP
  5. 30
      Adam/AExts.HPP
  6. 107
      Adam/AHash.CPP
  7. 4
      Adam/AMath.CPP
  8. 62
      Adam/AMathODE.CPP
  9. 47
      Adam/ARegistry.CPP
  10. 23
      Adam/AUtils.CPP
  11. BIN
      Adam/AutoComplete/ACDefs.DAT
  12. 28
      Adam/AutoComplete/ACDict.CPP
  13. 99
      Adam/AutoComplete/ACDictGen.CPP
  14. 33
      Adam/AutoComplete/ACMain.CPP
  15. BIN
      Adam/AutoComplete/ACWords.DAT
  16. 4
      Adam/AutoComplete/AutoComplete.CPP
  17. 17
      Adam/AutoFile.CPP
  18. 11
      Adam/Boot/Boot.CPP
  19. 3
      Adam/Boot/BootCD.CPP
  20. 3
      Adam/Boot/BootHD.CPP
  21. 44
      Adam/Boot/BootIns.CPP
  22. 3
      Adam/Boot/BootMHD.CPP
  23. 3
      Adam/Boot/BootMHD2.CPP
  24. 68
      Adam/Boot/DskISOFile.CPP
  25. 82
      Adam/Ctrls/CtrlsA.CPP
  26. 20
      Adam/Ctrls/CtrlsButton.CPP
  27. 25
      Adam/Ctrls/CtrlsSlider.CPP
  28. 18
      Adam/DevInfo.CPP
  29. 50
      Adam/DolDoc/Doc.CPP
  30. 216
      Adam/DolDoc/DocCodeTools.CPP
  31. 159
      Adam/DolDoc/DocCtrlL.CPP
  32. 324
      Adam/DolDoc/DocEdA.CPP
  33. 76
      Adam/DolDoc/DocEdB.CPP
  34. 67
      Adam/DolDoc/DocFile.CPP
  35. 91
      Adam/DolDoc/DocFind.CPP
  36. 7
      Adam/DolDoc/DocHighlight.CPP
  37. 32
      Adam/DolDoc/DocInit.CPP
  38. 36
      Adam/DolDoc/DocMacro.CPP
  39. 62
      Adam/DolDoc/DocMain.CPP
  40. 55
      Adam/DolDoc/DocNew.CPP
  41. 27
      Adam/DolDoc/DocOpt.CPP
  42. 209
      Adam/DolDoc/DocPlain.CPP
  43. 195
      Adam/DolDoc/DocPopUp.CPP
  44. 20
      Adam/DolDoc/DocRecalcA.CPP
  45. 183
      Adam/DolDoc/DocRecalcB.CPP
  46. 98
      Adam/DolDoc/DocTree.CPP
  47. 61
      Adam/Dsk/ADskA.CPP
  48. 66
      Adam/Dsk/ADskB.CPP
  49. 30
      Adam/Dsk/ChkDsk.CPP
  50. 31
      Adam/Dsk/FileMgr.CPP
  51. 6
      Adam/God/GodBible.CPP
  52. 79
      Adam/God/GodDoodle.CPP
  53. 6
      Adam/God/GodExt.CPP
  54. 2
      Adam/God/GodSong.CPP
  55. 2
      Adam/God/HSNotes.TXT
  56. 19
      Adam/God/HolySpirit.CPP
  57. 9388
      Adam/God/Vocab.TXT
  58. 26
      Adam/Gr/Gr.CPP
  59. 8
      Adam/Gr/GrAsm.CPP
  60. 334
      Adam/Gr/GrBitMap.CPP
  61. 51
      Adam/Gr/GrComposites.CPP
  62. 192
      Adam/Gr/GrDC.CPP
  63. 2
      Adam/Gr/GrEnd.CPP
  64. 6
      Adam/Gr/GrGlbls.CPP
  65. 16
      Adam/Gr/GrInit.CPP
  66. 230
      Adam/Gr/GrMath.CPP
  67. 86
      Adam/Gr/GrPalette.CPP
  68. 176
      Adam/Gr/GrPrimatives.CPP
  69. 195
      Adam/Gr/GrScreen.CPP
  70. 104
      Adam/Gr/GrSpritePlot.CPP
  71. 33
      Adam/Gr/GrTextBase.CPP
  72. 39
      Adam/Gr/SpriteBitMap.CPP
  73. 321
      Adam/Gr/SpriteCode.CPP
  74. 155
      Adam/Gr/SpriteEd.CPP
  75. 76
      Adam/Gr/SpriteMain.CPP
  76. 269
      Adam/Gr/SpriteMesh.CPP
  77. 90
      Adam/Gr/SpriteNew.CPP
  78. 75
      Adam/Menu.CPP
  79. 15
      Adam/Snd/SndFile.CPP
  80. 8
      Adam/Snd/SndMath.CPP
  81. 46
      Adam/Snd/SndMusic.CPP
  82. 8
      Adam/TaskSettings.CPP
  83. 22
      Adam/Training.CPP
  84. 50
      Adam/Utils/Diff.CPP
  85. 202
      Adam/Utils/FileBMP.CPP
  86. 98
      Adam/Utils/Find.CPP
  87. 3
      Adam/Utils/HeapLog.CPP
  88. 9
      Adam/Utils/LineRep.CPP
  89. 36
      Adam/Utils/MemRep.CPP
  90. 2
      Adam/Utils/Merge.CPP
  91. 2
      Adam/Utils/Profiler.CPP
  92. 53
      Adam/Utils/S2T.CPP
  93. 200
      Adam/Utils/StrUtils.CPP
  94. 107
      Adam/Utils/ToHtml.CPP
  95. 6
      Adam/Utils/ToTXT.CPP
  96. BIN
      Adam/WallPaper.CPP
  97. 46
      Adam/WinA.CPP
  98. 111
      Adam/WinB.CPP
  99. 26
      AdamKeyPlugIns.CPP
  100. 10
      AdamPkgs.CPP
  101. Some files were not shown because too many files have changed in this diff Show More

BIN
0000Boot/0000Kernel.BIN.C

Binary file not shown.

11
Adam.CPP

@ -23,7 +23,7 @@ HashTablePurge(adam_task->hash_table);
//Use Dbg("Type 'G;'"); to debug before window mgr is running.
public F64 os_version=3.03;//Operating system version.
public F64 os_version=3.07;//Operating system version.
#include "AExts.HPP"
#include "AMath"
@ -56,7 +56,7 @@ Cd("::/Adam/Ctrls");;
Cd("::/Adam");;
#include "AutoFile"
#include "Acct"
#include "ARegistry"
Cd("::/Adam/AutoComplete");;
#include "AutoComplete"
@ -75,16 +75,17 @@ DocTermNew;
WinVert(2,10);
sys_winmgr_task=Spawn(&WinMgrTask,NULL,"Window Mgr");
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_BORDER-WIF_SELF_GRAB_SCROLL-WIF_SELF_CTRLS;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_BORDER
-WIF_SELF_GRAB_SCROLL-WIF_SELF_CTRLS;
LBts(&Fs->display_flags,DISPLAYf_CHILDREN_NOT_ON_TOP);
LBts(&Fs->display_flags,DISPLAYf_SHOW);
RegistryInit;
RegInit;
LBts(&sys_run_level,RLf_REGISTRY);
Cd("::/Adam");;
#include "WallPaper"
if (IsDrvWritable)
if (DrvIsWritable)
MkDir("/Temp"); //Good to have a Temp
#exe {OptOff(OPTf_WARN_PAREN);};

21
Adam/ADbg.CPP

@ -1,5 +1,6 @@
#help_index "Debugging/Dump"
Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,I64 depth,I64 max_depth,Bool dynamic,I64 types=HTT_CLASS,I64 offset=0)
Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,
I64 depth,I64 max_depth,Bool dynamic,I64 types=HTT_CLASS,I64 offset=0)
{//See $LK,"::/Demo/LastClass.CPP"$.
I64 i,j,stars,*ptr;
CMemberLst *ml;
@ -15,7 +16,8 @@ Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,I64 depth,I64 max_depth
DocPrint(doc,"Bad Ptr:%016X\n",_d);
return FALSE;
}
if (tempc->base_class && !ClassRep2(doc,_d,tempc->base_class->str,depth,max_depth,dynamic,types,offset))
if (tempc->base_class && !ClassRep2(doc,_d,tempc->base_class->str,
depth,max_depth,dynamic,types,offset))
return FALSE;
unlock=DocLock(doc);
DocPrint(doc,"Class:\"%s\"\n",class_name);
@ -149,7 +151,8 @@ Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,I64 depth,I64 max_depth
return TRUE;
}
public U0 ClassRep(U8 *_d,U8 *class_name=lastclass,I64 max_depth=2,Bool fun=FALSE,I64 offset=0)
public U0 ClassRep(U8 *_d,U8 *class_name=lastclass,
I64 max_depth=2,Bool fun=FALSE,I64 offset=0)
{//Displays members of a record by using the compiler's info.
CDoc *doc;
Bool old_preempt;
@ -157,7 +160,7 @@ public U0 ClassRep(U8 *_d,U8 *class_name=lastclass,I64 max_depth=2,Bool fun=FALS
doc=DocNew;
} else {
DocMax;
old_preempt=Preempt(OFF);
old_preempt=Preempt;
doc=DocPut;
}
if (fun)
@ -173,7 +176,8 @@ public U0 ClassRep(U8 *_d,U8 *class_name=lastclass,I64 max_depth=2,Bool fun=FALS
Preempt(old_preempt);
}
public U0 ClassRepD(U8 *_d,U8 *class_name=lastclass,I64 max_depth=2,Bool fun=FALSE,I64 offset=0)
public U0 ClassRepD(U8 *_d,U8 *class_name=lastclass,
I64 max_depth=2,Bool fun=FALSE,I64 offset=0)
{//Dynamic ClassRep. Uses hex_ed widgit for live changes.
CDoc *doc;
Bool old_preempt;
@ -181,7 +185,7 @@ public U0 ClassRepD(U8 *_d,U8 *class_name=lastclass,I64 max_depth=2,Bool fun=FAL
doc=DocNew;
} else {
DocMax;
old_preempt=Preempt(OFF);
old_preempt=Preempt;
doc=DocPut;
}
if (fun)
@ -220,7 +224,7 @@ public U0 FunRep(U8 *st,U8 *rbp=NULL,I64 max_depth=2,CTask *task=NULL)
if (tempf) {
if (rbp) {
if (task) {
//tempf->size is negative. It's the bottom
//tempf->size is negative. It's the bottom
//of the fun local var space relative to RBP .
size=tempf->arg_cnt*8-tempf->size+16;
@ -255,7 +259,8 @@ public U0 Uf(U8 *st)
if (tempf->type&HTT_FUN)
FunRep(st);
if (dbg_info=tempf->dbg_info) {
i=dbg_info->body[dbg_info->max_line+1-dbg_info->min_line]-dbg_info->body[0];
i=dbg_info->body[dbg_info->max_line+1-dbg_info->min_line]
-dbg_info->body[0];
Un(dbg_info->body[0],i);
"Code Size:%04X\n",i;
} else

52
Adam/ADefine.CPP

@ -4,48 +4,36 @@ U0 LoadDocDefines()
{
CBinFile *bfh=sys_boot_base-sizeof(CBinFile);
DefinePrint(
"DD_OS_NAME_VERSION","TempleOS V%0.2f",os_version);
DefinePrint(
"DD_TEMPLEOS_AGE","%0.1f",(Now-Str2Date("8/1/2003"))/ToF64(1<<32)/CDATE_YEAR_DAYS);
DefinePrint("DD_OS_NAME_VERSION","TempleOS V%0.2f",os_version);
DefinePrint("DD_TEMPLEOS_AGE","%0.1f",
(Now-Str2Date("8/1/2003"))/ToF64(1<<32)/CDATE_YEAR_DAYS);
//This is cut and replaced when I generate a distro.
//See $LK,"DD_TEMPLEOS_LOC",A="FF:::/Demo/AcctExample/TOSDistro.CPP,DD_TEMPLEOS_LOC"$.
$TR-C,"LineRep"$
$ID,4$DefinePrint("DD_TEMPLEOS_LOC","120,789");
DefinePrint("DD_TEMPLEOS_LOC_OFFICIAL","79,959");
$ID,4$DefinePrint("DD_TEMPLEOS_LOC","122,918");
DefinePrint("DD_TEMPLEOS_LOC_OFFICIAL","80,950");
$ID,-4$
DefinePrint(
"DD_KERNEL","%08X",bfh);
DefinePrint("DD_KERNEL","%08X",bfh);
bfh(I64)+=bfh->file_size-1;
DefinePrint(
"DD_KERNEL_END","%08X",bfh);
DefinePrint(
"DD_PROTECTED_LOW","%08X",MEM_PROTECTED_LOW_LIMIT);
DefinePrint("DD_KERNEL_END","%08X",bfh);
DefinePrint("DD_PROTECTED_LOW","%08X",MEM_PROTECTED_LOW_LIMIT);
//$LK,"DD_BOOT_HIGH_LOC_CD",A="FF:::/Adam/Boot/BootCD.CPP,DD_BOOT_HIGH_LOC_CD"$
DefinePrint(
"DD_MP_VECT","%08X",MP_VECT_ADDR);
DefinePrint(
"DD_MP_VECT_END","%08X",MP_VECT_ADDR+AP_16BIT_INIT_END-AP_16BIT_INIT-1);
DefinePrint("DD_MP_VECT","%08X",MP_VECT_ADDR);
DefinePrint("DD_MP_VECT_END","%08X",
MP_VECT_ADDR+AP_16BIT_INIT_END-AP_16BIT_INIT-1);
DefinePrint(
"DD_SYS_FIXED_AREA_BASE","%08X",SYS_FIXED_AREA);
DefinePrint(
"DD_SYS_FIXED_AREA_END","%08X",SYS_FIXED_AREA+sizeof(CSysFixedArea)-1);
DefinePrint(
"DD_SYS_HEAP_BASE","%08X",sys_heap_base);
DefinePrint(
"DD_SYS_HEAP_LIMIT","%08X",sys_heap_limit);
DefinePrint(
"DD_MEM_MIN_MEG","%d Meg",MEM_MIN_MEG);
DefinePrint(
"DD_MEM_MAPPED_SPACE_GIG","%d Gig",MEM_MAPPED_SPACE/0x40000000);
DefinePrint(
"DD_MEM_MAPPED_SPACE_END","%010X",MEM_MAPPED_SPACE-1);
DefinePrint(
"DD_JIFFY_HZ","%d Hz",JIFFY_FREQ);
DefinePrint("DD_SYS_FIXED_AREA_BASE","%08X",SYS_FIXED_AREA);
DefinePrint("DD_SYS_FIXED_AREA_END","%08X",
SYS_FIXED_AREA+sizeof(CSysFixedArea)-1);
DefinePrint("DD_SYS_HEAP_BASE","%08X",sys_heap_base);
DefinePrint("DD_SYS_HEAP_LIMIT","%08X",sys_heap_limit);
DefinePrint("DD_MEM_MIN_MEG","%d Meg",MEM_MIN_MEG);
DefinePrint("DD_MEM_MAPPED_SPACE_GIG","%d Gig",MEM_MAPPED_SPACE/0x40000000);
DefinePrint("DD_MEM_MAPPED_SPACE_END","%010X",MEM_MAPPED_SPACE-1);
DefinePrint("DD_JIFFY_HZ","%d Hz",JIFFY_FREQ);
}
LoadDocDefines;

30
Adam/AExts.HPP

@ -4,17 +4,15 @@ extern U0 ACDFillin(I64 n);
extern U0 ACFillIn(I64 n);
extern U0 ACFindMisspelled(CDoc *doc);
extern U0 ACMan(I64 n,CTask *parent=NULL);
extern U0 AcctOneTimePopUp(I64 flag_num,U8 *msg);
extern I64 AdamFile(U8 *filename,Bool warn_ext=TRUE);
extern Bool AutoComplete(Bool val=OFF);
extern I64 BMPWrite(U8 *filename,CDC *dc,I64 bits=4);
extern I64 CDFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,U8 *fu_flags=NULL,
U8 *_stage2_filename=NULL);
extern U0 ClipboardDel();
extern CCtrl *CtrlFindUnique(CTask *haystack_task,I64 needle_type);
extern Bool CtrlInside(CCtrl *c,I64 x,I64 y);
extern U8 *DC2Sprite(CDC *tempb);
extern U0 DocBMP(CDoc *doc=NULL,U8 *filename,Bool dither_probability=FALSE,Bool use_ms_paint_palette=FALSE);
extern U0 DocBMP(CDoc *doc=NULL,U8 *filename,
Bool dither_probability=FALSE,Bool use_ms_paint_palette=FALSE);
extern U0 DocBinDel(CDoc *doc,CDocBin *b);
extern U0 DocBinsValidate(CDoc *doc);
extern U0 DocBottom(CDoc *doc=NULL);
@ -27,7 +25,8 @@ extern U0 DocDel(CDoc *doc);
extern CDoc *DocDisplay(CTask *task=NULL);
extern U0 DocDump(CDoc *doc,I64 uS_delay=0);
extern CDocEntry *DocEntryCopy(CDoc *doc,CDocEntry *doc_e);
extern Bool DocFormDo(U8 *_d,U8 *class_name=lastclass,I64 dof_flags=0,U8 *header=NULL,U8 *footer=NULL);
extern Bool DocForm(U8 *_d,U8 *class_name=lastclass,
I64 dof_flags=0,U8 *header=NULL,U8 *footer=NULL);
extern U0 DocHelpIndex(CDoc *doc,U8 *index);
extern U0 DocInsDoc(CDoc *doc,CDoc *doc2);
extern U0 DocInsEntry(CDoc *doc,CDocEntry *doc_e);
@ -51,9 +50,11 @@ extern I64 EdCurU8(CDoc *doc);
extern U0 EdCursorLeft(CDoc *doc,I64 sc=MIN_I64);
extern U0 EdCursorRight(CDoc *doc,I64 sc=MIN_I64);
extern U8 *EdSprite(I64 bin_num);
extern I64 FindWiz();
extern I64 GetI64(U8 *msg,I64 dft,I64 lo=MIN_I64,I64 hi=MAX_I64);
extern U0 GrPlot0(CDC *dc,I64 x,I64 y);
extern I64 GrepWiz();
extern I64 ISOFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,
U8 *fu_flags=NULL,U8 *_stage2_filename=NULL);
extern CMenuEntry *MenuEntryFind(CMenu *m,U8 *full_name);
extern CMenu *MenuFilePush(U8 *filename);
extern U0 MenuPop();
@ -61,18 +62,22 @@ extern CMenu *MenuPush(U8 *st);
extern CTask *Noise(I64 mS,I64 min_freq,I64 max_freq);
extern Bool Plain(U8 *filename,I64 edf_dof_flags=0);
extern Bool PopUpCancelOk(U8 *header=NULL,U8 *footer=NULL);
extern I64 PopUpColor(U8 *header=NULL,Bool allow_transpant=TRUE,Bool allow_dft=TRUE);
extern I64 PopUpColor(U8 *header=NULL,
Bool allow_transpant=TRUE,Bool allow_dft=TRUE);
extern I64 PopUpColorDither(U8 *header=NULL);
extern I64 PopUpColorLighting(U8 *header=NULL);
extern I64 PopUpFile(U8 *filename,Bool warn_ext=TRUE,CTask *parent=NULL,CTask **_pu_task=NULL);
extern Bool PopUpForm(U8 *_d,U8 *class_name=lastclass,I64 dof_flags=DOF_MIN_SIZE,
U8 *header=NULL,U8 *footer=NULL);
extern I64 PopUpFile(U8 *filename,
Bool warn_ext=TRUE,CTask *parent=NULL,CTask **_pu_task=NULL);
extern Bool PopUpForm(U8 *_d,U8 *class_name=lastclass,
I64 dof_flags=DOF_MIN_SIZE,U8 *header=NULL,U8 *footer=NULL);
extern U8 *PopUpGetStr(U8 *header=NULL);
extern I64 PopUpMenu(CDoc *doc,I64 dof_flags=0);
extern Bool PopUpNoYes(U8 *header=NULL,U8 *footer=NULL);
extern Bool PopUpOk(U8 *header=NULL,U8 *footer=NULL);
extern I64 PopUpRangeI64(I64 lo,I64 hi,I64 step=1,U8 *header=NULL,U8 *footer=NULL);
extern I64 PopUpRangeI64(
I64 lo,I64 hi,I64 step=1,U8 *header=NULL,U8 *footer=NULL);
extern Bool PopUpTransform(I64 *r);
extern U0 RegOneTimePopUp(I64 flag_num,U8 *msg);
extern U0 SettingsPop(CTask *task=NULL,I64 flags=0);
extern CTaskSettings *SettingsPush(CTask *task=NULL,I64 flags=0);
extern U0 TemplateCtrlSlider(CDoc *doc);
@ -80,7 +85,8 @@ extern Bool View();
extern U0 ViewAnglesDel(CTask *task=NULL);
extern CCtrl *ViewAnglesNew(CTask *task=NULL);
extern Bool WinBorder(Bool val,CTask *task=NULL);
extern CDoc *WinCursorPosSet(CTask *task,I64 ip_text_x,I64 ip_text_y,Bool set_cursor=TRUE);
extern CDoc *WinCursorPosSet(
CTask *task,I64 ip_text_x,I64 ip_text_y,Bool set_cursor=TRUE);
extern Bool WinHorz(I64 left,I64 right,CTask *task=NULL);
extern U0 WinMax(CTask *task=NULL);
extern U0 WinMgrSync(I64 cnt=1,Bool force=FALSE);

107
Adam/AHash.CPP

@ -1,4 +1,4 @@
#help_index "Info;Hash;Cmd Line (Typically)"
#help_index "Info;Hash/System;Cmd Line (Typically)"
class CWho
{
CHashGeneric *h;
@ -80,11 +80,17 @@ U8 *HelpComment(CTask *task,CHash *temph,U8 *_src_link)
doc=DocPut(task);
doc_e=doc->cur_entry;
if (temph->type&HTT_FUN && !Bt(&temph(CHashFun *)->flags,Ff__EXTERN) &&
!Bt(&temph(CHashFun *)->flags,Ff_INTERNAL))
while (doc_e!=doc &&
(!(doc_e->de_flags&DOCEF_TAG)||!StrOcc(doc_e->tag,'{')))
doc_e=doc_e->next;
if (temph->type&HTT_FUN) {
if (Bt(&temph(CHashFun *)->flags,Ff__EXTERN) ||
Bt(&temph(CHashFun *)->flags,Ff_INTERNAL))
while (doc_e!=doc &&
(!(doc_e->de_flags&DOCEF_TAG)||!StrOcc(doc_e->tag,';')))
doc_e=doc_e->next;
else
while (doc_e!=doc &&
(!(doc_e->de_flags&DOCEF_TAG)||!StrOcc(doc_e->tag,'{')))
doc_e=doc_e->next;
}
if (doc_e!=doc) {
if (doc_e->de_flags&DOCEF_TAG) {
ptr=doc_e->tag;
@ -141,7 +147,7 @@ I64 HashEntriesCompare3(CWho *h1,CWho *h2)
}
public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
U8 *outname=NULL,U8 mapfile_drv=0,U8 *index=NULL,CDoc *_doc=NULL)
U8 *index=NULL,CDoc *doc=NULL)
{//Dump hash symbol table.
// "+p" for only public symbols
// "+m" to order by number (normally alphabetical)
@ -150,12 +156,9 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
CHashSrcSym *temph;
CHashGeneric *ptr;
CWho *lst;
I64 cnt,i,j,k,size,f=0,dbg_bin_num;
U8 buf[512],*st,*src_link,*last_index=StrNew(""),*cur_index,*comment;
CDoc *doc;
Bool recurse,publics,map,old_preempt=Preempt(OFF);
CDocBin *tempb;
CDbgInfo *dbg_info;
I64 cnt,i,j,k,f=0;
U8 buf[512],*st,*last_index=StrNew(""),*cur_index,*comment;
Bool recurse,publics,map,old_preempt=Preempt;
CTask *task;
ScanFlags(&f,Define("ST_FILE_UTIL_FLAGS"),"+r");
@ -168,14 +171,6 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
if (!h) h=Fs->hash_table;
if (_doc)
doc=_doc;
else if (outname) {
doc=DocNew(outname);
doc->flags|=DOCF_NO_CURSOR;
} else
doc=NULL;
if (index) {
task=User;
TaskWait(task);
@ -247,7 +242,6 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
for (i=0;i<cnt;i++) {
comment=NULL;
ptr=lst[i].h;
dbg_info=NULL;
if (index)
if (cur_index=lst[i].index) {
if (StrCmp(cur_index,last_index)) {
@ -265,38 +259,10 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
DocPrint(doc,"$$WW,0$$");
} else {
if (ptr->type&HTG_SRC_SYM && ptr(CHashSrcSym *)->src_link) {
src_link=StrNew(ptr(CHashSrcSym *)->src_link);
if (mapfile_drv && StrLen(src_link)>4 && buf[1]==':' && src_link[4]==':')
src_link[3]=mapfile_drv;
dbg_info=NULL;
if (outname && doc && ptr->type & HTT_FUN) {
if (dbg_info=ptr(CHashFun *)->dbg_info) {
size=offset(CDbgInfo.body)+sizeof(U32)*(dbg_info->max_line+2-dbg_info->min_line);
if (size>MSize(dbg_info)) {
"Corrupt Map Entry\n";
dbg_info=NULL;
} else {
if (dbg_info->min_line<=dbg_info->max_line) {
tempb=CAlloc(sizeof(CDocBin));
tempb->size=size;
tempb->data=MAlloc(size);
MemCpy(tempb->data,dbg_info,size);
dbg_bin_num=tempb->num=doc->cur_bin_num++;
tempb->use_cnt=1;
QueIns(tempb,doc->bin_root.last);
} else
dbg_info=NULL;
}
}
}
if (dbg_info)
DocPrint(doc,"$$LK,\"%-20s\",A=\"%s\",BI=%d$$",ptr->str,src_link,dbg_bin_num);
else {
DocPrint(doc,"$$LK,\"%-20s\",A=\"%s\"$$",ptr->str,src_link);
if (index)
comment=HelpComment(task,ptr,src_link);
}
Free(src_link);
DocPrint(doc,"$$LK,\"%-20s\",A=\"%s\"$$",
ptr->str,ptr(CHashSrcSym *)->src_link);
if (index)
comment=HelpComment(task,ptr,ptr(CHashSrcSym *)->src_link);
} else
DocPrint(doc,"%-20s",ptr->str);
@ -309,12 +275,9 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
else
StrPrint(buf,"%-10tQ %02X",st,j);
Free(st);
} else if (ptr->type & HTT_GLBL_VAR) {
if (outname)
StrPrint(buf,"%010X ",ptr(CHashGlblVar *)->data_addr_ip);
else
StrPrint(buf,"%010X ",ptr(CHashGlblVar *)->data_addr);
} else
} else if (ptr->type & HTT_GLBL_VAR)
StrPrint(buf,"%010X ",ptr(CHashGlblVar *)->data_addr);
else
StrPrint(buf,"%010X ",HashVal(ptr));
j=HashEntrySize(ptr);
if (j==-1)
@ -354,21 +317,17 @@ public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
wh_done:
Preempt(old_preempt);
if (doc) {
DocBinsValidate(doc);
if (!_doc) {
DocWrite(doc);
DocDel(doc);
} else {
if (doc->root.next==doc)
DocPrint(doc,"No Match");
else
DocRecalc(doc);
}
if (doc->root.next==doc)
DocPrint(doc,"No Match");
else
DocRecalc(doc);
}
Free(last_index);
Kill(task);
}
#help_index "Info;Hash;Cmd Line (Typically)"
#define HDR_MAX 16
public I64 HashDepthRep(CHashTable *table=NULL)
{//Hash table linked-list chain depth report.
@ -393,16 +352,16 @@ public I64 HashDepthRep(CHashTable *table=NULL)
if (a[i])
"%02d:%d\n",i,a[i];
"Size:%d Count:%d Longest:%d\n",
table->mask+1,cnt,longest;
table->mask+1,cnt,longest;
return longest;
}
#help_index "Help System;Training"
#help_index "Help System"
#help_file "::/Doc/HelpSystem"
public U0 DocHelpIndex(CDoc *doc,U8 *index)
{//Put to doc report for given help index.
Who("+p",,,,index,doc);
Who("+p",,index,doc);
}
public U0 PopUpHelpIndex(U8 *index,CTask *parent=NULL)
@ -413,7 +372,7 @@ public U0 PopUpHelpIndex(U8 *index,CTask *parent=NULL)
Free(buf);
}
#help_index "Hash"
#help_index "Hash/System"
public U0 MapFileLoad(U8 *filename)
{//Load map file so we have src line info.
U8 *st,*ptr,*name=DftExt(filename,"MAP.Z"),

4
Adam/AMath.CPP

@ -1,7 +1,7 @@
#help_index "Math"
public U0 R2P(F64 *_mag=NULL,F64 *_arg=NULL,F64 x,F64 y)
{//Rect to polar
//Returns angle in range (-ã,ã]
//Returns angle in range (-ã,ã]
if (_arg)
*_arg=Arg(x,y);
if (_mag)
@ -64,7 +64,7 @@ public F64 Cosh(F64 x)
return 0.5*(Exp(x)+Exp(-x));
}
#help_index "Math/Complex"
#help_index "Math/Complex;Data Types/Complex"
public Complex *CAdd(Complex *n1,Complex *n2,Complex *sum)
{//n1 + n2 -->sum
sum->x=n1->x+n2->x;

62
Adam/AMathODE.CPP

@ -30,10 +30,10 @@ U0 ODERstPtrs(CMathODE *ode)
public CMathODE *ODENew(I64 n,F64 max_tolerance=1e-6,I64 flags=0)
{//Make differential equation ctrl struct. See $LK,"flags",A="MN:ODEF_HAS_MASSES"$.
//The tolerance is not precise.
//You can min_tolerance and it will
//dynamically adjust tolerance to utilize
//the CPU.
//The tolerance is not precise.
//You can min_tolerance and it will
//dynamically adjust tolerance to utilize
//the CPU.
I64 s=n*sizeof(F64);
CMathODE *ode=MAlloc(sizeof(CMathODE));
@ -78,7 +78,7 @@ public I64 ODESize(CMathODE *ode)
U0 ODESetMassesPtrs(CMathODE *ode,F64 *state,F64 *DstateDt)
{
COrder2D3 *ptr1=state(F64 *)+ode->n,
*ptr2=DstateDt(F64 *)+ode->n;
*ptr2=DstateDt(F64 *)+ode->n;
CMass *tempm=ode->next_mass;
while (tempm!=&ode->next_mass) {
tempm->state=ptr1++;
@ -178,8 +178,8 @@ public CSpring *SpringFind(CMathODE *ode,F64 x,F64 y,F64 z=0)
temps=ode->next_spring;
while (temps!=&ode->next_spring) {
dd=Sqr((temps->end1->x+temps->end2->x)/2-x)+
Sqr((temps->end1->y+temps->end2->y)/2-y)+
Sqr((temps->end1->z+temps->end2->z)/2-z);
Sqr((temps->end1->y+temps->end2->y)/2-y)+
Sqr((temps->end1->z+temps->end2->z)/2-z);
if (dd<best_dd) {
best_dd=dd;
best_spring=temps;
@ -189,8 +189,9 @@ public CSpring *SpringFind(CMathODE *ode,F64 x,F64 y,F64 z=0)
return best_spring;
}
public U0 MassOrSpringFind(CMathODE *ode,CMass **result_mass,CSpring **result_spring,
F64 x,F64 y,F64 z=0)
public U0 MassOrSpringFind(
CMathODE *ode,CMass **result_mass,CSpring **result_spring,
F64 x,F64 y,F64 z=0)
{//Find spring or mass nearest x,y,z.
CMass *tempm,*best_mass=NULL;
CSpring *temps,*best_spring=NULL;
@ -209,8 +210,8 @@ public U0 MassOrSpringFind(CMathODE *ode,CMass **result_mass,CSpring **result_sp
temps=ode->next_spring;
while (temps!=&ode->next_spring) {
dd=Sqr((temps->end1->x+temps->end2->x)/2-x)+
Sqr((temps->end1->y+temps->end2->y)/2-y)+
Sqr((temps->end1->z+temps->end2->z)/2-z);
Sqr((temps->end1->y+temps->end2->y)/2-y)+
Sqr((temps->end1->z+temps->end2->z)/2-z);
if (dd<best_dd) {
best_dd=dd;
best_spring=temps;
@ -288,15 +289,15 @@ U0 ODECalcDrag(CMathODE *ode)
tempm=ode->next_mass;
while (tempm!=&ode->next_mass) {
if (!(tempm->flags & MSF_INACTIVE) &&
tempm->drag_profile_factor &&
(dd=D3NormSqr(&tempm->state->DxDt))) {
tempm->drag_profile_factor &&
(dd=D3NormSqr(&tempm->state->DxDt))) {
d=ode->drag_v;
if (ode->drag_v2)
d+=ode->drag_v2*Sqrt(dd);
if (ode->drag_v3)
d+=dd*ode->drag_v3;
D3SubEqu(&tempm->DstateDt->DxDt,
D3Mul(d*tempm->drag_profile_factor,&tempm->state->DxDt,&p));
D3Mul(d*tempm->drag_profile_factor,&tempm->state->DxDt,&p));
}
tempm=tempm->next;
}
@ -311,7 +312,7 @@ U0 ODEApplyAccelerationLimit(CMathODE *ode)
tempm=ode->next_mass;
while (tempm!=&ode->next_mass) {
if (!(tempm->flags & MSF_INACTIVE) &&
(d=D3Norm(&tempm->DstateDt->DxDt))>ode->acceleration_limit)
(d=D3Norm(&tempm->DstateDt->DxDt))>ode->acceleration_limit)
D3MulEqu(&tempm->DstateDt->DxDt,ode->acceleration_limit/d);
tempm=tempm->next;
}
@ -422,7 +423,9 @@ U0 ODERK4OneStep(CMathODE *ode)
U0 ODECashKarp(CMathODE *ode)
{
I64 i,n=ode->n_internal;
F64 h=ode->h,*state=ode->state_internal,*DstateDt=ode->DstateDt,*ak2,*ak3,*ak4,*ak5,*ak6,*tempstate,*stateerr,*outstate;
F64 h=ode->h,*state=ode->state_internal,
*DstateDt=ode->DstateDt,*ak2,*ak3,*ak4,*ak5,*ak6,
*tempstate,*stateerr,*outstate;
ak2=ode->temp0;
ak3=ode->temp1;
@ -443,15 +446,19 @@ U0 ODECashKarp(CMathODE *ode)
tempstate[i]=state[i]+h*(ODEb41*DstateDt[i]+ODEb42*ak2[i]+ODEb43*ak3[i]);
ODECallDerivative(ode,ode->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]);
tempstate[i]=state[i]+h*(ODEb51*DstateDt[i]+
ODEb52*ak2[i]+ODEb53*ak3[i]+ODEb54*ak4[i]);
ODECallDerivative(ode,ode->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]);
tempstate[i]=state[i]+h*(ODEb61*DstateDt[i]+
ODEb62*ak2[i]+ODEb63*ak3[i]+ODEb64*ak4[i]+ODEb65*ak5[i]);
ODECallDerivative(ode,ode->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]);
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]);
stateerr[i]=h*(ODEdc1*DstateDt[i]+ODEdc3*ak3[i]+
ODEdc4*ak4[i]+ODEdc5*ak5[i]+ODEdc6*ak6[i]);
}
#define SAFETY 0.9
@ -504,15 +511,11 @@ it has a timeout.
I64 i;
F64 d,start_time,timeout_time,t_desired,t_initial,interpolation;
CMathODE *ode;
Bool old_suspend;
if (task->next_ode==&task->next_ode)
task->last_ode_time=0;
else if (!Bt(&task->win_inhibit,WIf_SELF_ODE)) {
//See $LK,"GrUpdateWins",A="MN:GrUpdateWins"$()
//TODO: Being preempted here woulds be bad
if (task!=Fs)
old_suspend=Suspend(task);
//See $LK,"GrUpdateTasks",A="MN:GrUpdateTasks"$() and $LK,"GrUpdateTaskODEs",A="MN:GrUpdateTaskODEs"$().
//We will not pick a time limit based on
//how busy the CPU is, what percent of the
//last refresh cycle was spent on ODE's
@ -536,7 +539,8 @@ it has a timeout.
ode->base_t+=t_desired-ode->t; //Slip
else if (ode->derivative) {
ODEState2Internal(ode);
MemCpy(ode->initial_state,ode->state_internal,ode->n_internal*sizeof(F64));
MemCpy(ode->initial_state,ode->state_internal,
ode->n_internal*sizeof(F64));
while (ode->t<t_desired) {
ode->h_max=t_desired-ode->t;
ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt);
@ -595,13 +599,11 @@ ode_done:
else
ode->tolerance_internal*=2.0`d;
}
ode->tolerance_internal=Clamp(ode->tolerance_internal,ode->min_tolerance,ode->max_tolerance);
ode->tolerance_internal=Clamp(ode->tolerance_internal,
ode->min_tolerance,ode->max_tolerance);
}
ode=ode->next;
}
winmgr.ode_time+=task->last_ode_time=tS-start_time;
//See $LK,"GrUpdateWins",A="MN:GrUpdateWins"$()
if (task!=Fs)
Suspend(task,old_suspend);
}
}

47
Adam/Acct.CPP → Adam/ARegistry.CPP

@ -1,25 +1,25 @@
#help_index "Misc/Accts"
#define ACCT_REGISTRY_FILENAME "::/Home/Registry.CPP.Z"
#help_index "Misc/Registry"
#define REGISTRY_FILENAME "::/Home/Registry.CPP.Z"
CDoc *sys_registry_doc=NULL;
I64 sys_msg_flags[1]={0};
F64 registry_version;
Bool AcctCacheRegistry()
Bool RegCache()
{
Bool old_silent;
if (!sys_registry_doc) {
old_silent=Silent;
sys_registry_doc=DocRead(ACCT_REGISTRY_FILENAME);
sys_registry_doc=DocRead(REGISTRY_FILENAME);
Silent(old_silent);
return FALSE;
} else
return TRUE;
}
public Bool AcctRegSetDftEntry(U8 *path,U8 *val,Bool is_adam_entry=FALSE)
public Bool RegSetDftEntry(U8 *path,U8 *val,Bool is_adam_entry=FALSE)
{//Add code doc tree branch to registry.
Bool result,unlock_doc;
AcctCacheRegistry;
RegCache;
unlock_doc=DocLock(sys_registry_doc);
if (!DocTreeFind(sys_registry_doc,path)) {
DocTreeMake(sys_registry_doc,path);
@ -30,7 +30,7 @@ public Bool AcctRegSetDftEntry(U8 *path,U8 *val,Bool is_adam_entry=FALSE)
else
Adam("%s",val);
}
if (IsDrvWritable(':'))
if (DrvIsWritable(':'))
DocWrite(sys_registry_doc);
result=FALSE;
} else
@ -40,24 +40,25 @@ public Bool AcctRegSetDftEntry(U8 *path,U8 *val,Bool is_adam_entry=FALSE)
return result;
}
public I64 AcctRegExeBranch(U8 *path)
public I64 RegExeBranch(U8 *path)
{//Execute doc tree branch in registry.
AcctCacheRegistry;
RegCache;
return DocTreeBranchExe(sys_registry_doc,path);
}
public Bool AcctRegWriteBranch(U8 *path,U8 *fmt,...)
public Bool RegWriteBranch(U8 *path,U8 *fmt,...)
{//Rewrite doc tree branch in registry.
Bool result,unlock_doc;
CDocEntry *tree_branch,*start_indent,*end_indent;
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
AcctCacheRegistry;
RegCache;
unlock_doc=DocLock(sys_registry_doc);
if (result=DocTreeFind(sys_registry_doc,path,&tree_branch,&start_indent,&end_indent))
if (result=DocTreeFind(sys_registry_doc,path,
&tree_branch,&start_indent,&end_indent))
DocCut(sys_registry_doc,tree_branch,end_indent);
DocTreeMake(sys_registry_doc,path);
DocPrint(sys_registry_doc,"%s",buf);
if (IsDrvWritable(':'))
if (DrvIsWritable(':'))
DocWrite(sys_registry_doc);
if (unlock_doc)
DocUnlock(sys_registry_doc);
@ -83,23 +84,23 @@ public Bool OneTimePopUp(U8 *_flags,I64 flag_num,U8 *msg)
return result;
}
U0 AcctOneTimePopUp(I64 flag_num,U8 *msg)
U0 RegOneTimePopUp(I64 flag_num,U8 *msg)
{//You're not supposed to make system pop-up flags, only me.
if (OneTimePopUp(sys_msg_flags,flag_num,msg))
AcctRegWriteBranch("Adam/SysMsgFlags","sys_msg_flags[0]=0x%X;\n",
sys_msg_flags[0]);
RegWriteBranch("Adam/SysMsgFlags","sys_msg_flags[0]=0x%X;\n",
sys_msg_flags[0]);
}
U0 RegistryInit()
U0 RegInit()
{
U8 buf[136];
U8 buf[STR_LEN];
Bool version_present;
AcctRegSetDftEntry("Adam/SysMsgFlags","sys_msg_flags[0]=0;\n",TRUE);
RegSetDftEntry("Adam/SysMsgFlags","sys_msg_flags[0]=0;\n",TRUE);
StrPrint(buf,"registry_version=%4.3f;\n",os_version);
version_present=AcctRegSetDftEntry("Adam/SysRegVer",buf,TRUE);
AcctRegExeBranch("Adam");
version_present=RegSetDftEntry("Adam/SysRegVer",buf,TRUE);
RegExeBranch("Adam");
if (registry_version!=os_version) {
AcctRegWriteBranch("Adam/SysRegVer",buf);
AcctRegExeBranch("Adam");
RegWriteBranch("Adam/SysRegVer",buf);
RegExeBranch("Adam");
}
}

23
Adam/AUtils.CPP

@ -25,6 +25,7 @@ public I64 TaskMemUsed(CTask *task=NULL,Bool override_validate=FALSE)
return 0;
}
#help_index "Memory/Task;Debugging/Heap"
public Bool HeapRep(CTask *task)
{//Report status of task's heap.
I64 i,cnt;
@ -86,7 +87,7 @@ public Bool HeapRep(CTask *task)
#help_index "Memory/HeapCtrl;Debugging/Heap"
public Bool IsInHeapCtrl(U8 *a,CHeapCtrl *hc,Bool lock=TRUE)
{//Check addr if on heap.
{//Check addr if in HeapCtrl.
CMemBlk *m;
PUSHFD
CLI
@ -134,7 +135,7 @@ public Bool HeapCtrlWalk(CHeapCtrl *hc)
uum=uum->next;
}
#if _CFG_HEAP_DBG
#if _CFG_HEAP_DBG
CMemUsed *um,*um1;
um1=(&hc->next_um)(U8 *)-offset(CMemUsed.next);
um=um1->next;
@ -149,7 +150,7 @@ public Bool HeapCtrlWalk(CHeapCtrl *hc)
POPFD
return TRUE;
hc_false:
hc_false:
LBtr(&hc->locked_flags,HClf_LOCKED);
POPFD
return FALSE;
@ -157,10 +158,11 @@ hc_false:
#help_index "Memory/Task;Debugging/Heap"
public Bool IsInHeap(U8 *a,CTask *task=NULL,Bool lock=TRUE)
{//Check addr if on heap.
{//Check addr if in task's heaps.
if (!task) task=Fs;
if (TaskValidate(task) && (IsInHeapCtrl(a,task->code_heap,lock)||
task->data_heap!=task->code_heap && IsInHeapCtrl(a,task->data_heap,lock)))
task->data_heap!=task->code_heap &&
IsInHeapCtrl(a,task->data_heap,lock)))
return TRUE;
else
return FALSE;
@ -170,7 +172,7 @@ public Bool HeapWalk(CTask *task=NULL)
{//Check integrity of task's heaps.
if (!task) task=Fs;
if (!TaskValidate(task) || !HeapCtrlWalk(task->code_heap) ||
task->data_heap!=task->code_heap && !HeapCtrlWalk(task->data_heap))
task->data_heap!=task->code_heap && !HeapCtrlWalk(task->data_heap))
return FALSE;
else
return TRUE;
@ -183,14 +185,15 @@ U0 TaskRepTask(CTask *task,I64 indent)
U8 *st,*desc=MStrUtil(task->task_title,SUF_SAFE_DOLLAR);
st=MStrPrint("$$MA,T=\"%08X\",LM=\"Kill(0x%X);\n\",$$",task,task,task);
"%h*c%s $$TX,\"%Q...\",SCX=16$$ Mem:%08X\n",indent,CH_SPACE,
st,desc,TaskMemAlloced(task);
st,desc,TaskMemAlloced(task);
"%h*cFlags:%04X:%04X Time:%0.2fm\n",indent+2,CH_SPACE,
task->task_flags,task->display_flags,
task->total_time/60.0/cnts.time_stamp_freq_initial;
task->task_flags,task->display_flags,
task->total_time/60.0/cnts.time_stamp_freq_initial;
Free(st);
Free(desc);
task1=task->next_child_task;
while (task1!=(&task->next_child_task)(U8 *)-offset(CTask.next_sibling_task)) {
while (task1!=(&task->next_child_task)(U8 *)
-offset(CTask.next_sibling_task)) {
TaskRepTask(task1,indent+2);
task1=task1->next_sibling_task;
}

BIN
Adam/AutoComplete/ACDefs.DAT

Binary file not shown.

28
Adam/AutoComplete/ACDict.CPP

@ -43,14 +43,15 @@ public U8 *ACDDefGet(U8 *st,I64 def_num=1)
CFile *f;
CHashGeneric *temph;
U8 *result=NULL,*buf,*in_ptr,
*st2=MStrUtil(st,SUF_TO_UPPER);
*st2=MStrUtil(st,SUF_TO_UPPER);
temph=HashFind(st2,ac.hash_table,HTT_DICT_WORD);
Free(st2);
if (temph) {
if (f=FOpen(ACD_DEF_FILENAME,"r")) {
buf=MAlloc(ACD_BLK_SIZE*2+1);
buf[ACD_BLK_SIZE*2]=0; //terminate
FRBlks(f,buf,temph->user_data0*ACD_BLK_SIZE/BLK_SIZE,ACD_BLK_SIZE*2/BLK_SIZE);
FRBlks(f,buf,temph->user_data0*ACD_BLK_SIZE/BLK_SIZE,
ACD_BLK_SIZE*2/BLK_SIZE);
FClose(f);
in_ptr=buf;
while (in_ptr<buf+ACD_BLK_SIZE*2) {
@ -59,7 +60,7 @@ public U8 *ACDDefGet(U8 *st,I64 def_num=1)
if (*in_ptr++==ACD_WORD_CHAR) {
if (!StrICmp(st,in_ptr)) {
while (def_num && *in_ptr!=ACD_WORD_CHAR
&& in_ptr<buf+ACD_BLK_SIZE*2) {
&& in_ptr<buf+ACD_BLK_SIZE*2) {
if (*in_ptr==ACD_DEF_CHAR) {
if (!--def_num)
break;
@ -86,14 +87,15 @@ public U8 *ACDDefsGet(U8 *st)
CFile *f;
CHashGeneric *temph;
U8 *result=NULL,*buf,*in_ptr,*in_ptr2,
*st2=MStrUtil(st,SUF_TO_UPPER);
*st2=MStrUtil(st,SUF_TO_UPPER);
temph=HashFind(st2,ac.hash_table,HTT_DICT_WORD);
Free(st2);
if (temph) {
if (f=FOpen(ACD_DEF_FILENAME,"r")) {
buf=MAlloc(ACD_BLK_SIZE*2+1);
buf[ACD_BLK_SIZE*2]=0; //terminate
FRBlks(f,buf,temph->user_data0*ACD_BLK_SIZE/BLK_SIZE,ACD_BLK_SIZE*2/BLK_SIZE);
FRBlks(f,buf,temph->user_data0*ACD_BLK_SIZE/BLK_SIZE,
ACD_BLK_SIZE*2/BLK_SIZE);
FClose(f);
in_ptr=buf;
while (in_ptr<buf+ACD_BLK_SIZE*2) {
@ -104,7 +106,7 @@ public U8 *ACDDefsGet(U8 *st)
in_ptr2=in_ptr;
in_ptr--;
while (*in_ptr2!=ACD_WORD_CHAR
&& in_ptr2<buf+ACD_BLK_SIZE*2) {
&& in_ptr2<buf+ACD_BLK_SIZE*2) {
in_ptr2++;
}
result=MAlloc(in_ptr2+1-in_ptr);
@ -129,7 +131,7 @@ public U8 *ACDWordPtAt(U8 *st)
{//Point to word in word list.
I64 i;
U8 *start=acd.word_lst,*r=start,
*end=acd.word_lst+acd.word_lst_size;
*end=acd.word_lst+acd.word_lst_size;
if (!st || !*st)
return acd.word_lst;
if (acd.word_lst_size) {
@ -219,7 +221,7 @@ public U0 ACDDefsPut(CDoc *doc=NULL,U8 *st,I64 num=-1)
break;
case ACD_DEF_CHAR:
DocPrint(doc,"$$GREEN$$(%d)$$FG$$ %s\n",
++i,st2);
++i,st2);
break;
case ACD_PRONUNCIATION_CHAR:
DocPrint(doc,"$$LTGREEN$$%s$$FG$$\n",st2);
@ -239,7 +241,7 @@ public U0 ACDDefsPut(CDoc *doc=NULL,U8 *st,I64 num=-1)
while (st2=ACDDefGet(st,++i)) {
if (i==num)
DocPrint(doc,"$$GREEN$$(%d)$$FG$$ %s\n",
i,st2);
i,st2);
Free(st2);
}
}
@ -263,22 +265,22 @@ U0 ACFindMisspelled(CDoc *doc)
{
Bool unlock=DocLock(doc);
CDocEntry *doc_e=doc->cur_entry;
I64 col=doc->cur_data_col,col2,ch;
I64 col=doc->cur_col,col2,ch;
do {
if (doc_e!=doc && doc_e->de_flags&DOCEF_TAG) {
while (col<doc_e->max_col) {
while (col<doc_e->max_col && !Bt(chars_bitmap_word,doc_e->tag[col]))
while (col<doc_e->max_col && !Bt(chars_bmp_word,doc_e->tag[col]))
col++;
if (col<doc_e->max_col) {
col2=col;
while (col2<doc_e->max_col && Bt(chars_bitmap_word,doc_e->tag[col2]))
while (col2<doc_e->max_col && Bt(chars_bmp_word,doc_e->tag[col2]))
col2++;
ch=doc_e->tag[col2];
doc_e->tag[col2]=0;
if (StrICmp(&doc_e->tag[col],ACDWordPtAt(&doc_e->tag[col])+1)) {
doc_e->tag[col2]=ch;
doc->cur_entry=doc_e;
doc->cur_data_col=col;
doc->cur_col=col;
goto fm_done;
}
doc_e->tag[col2]=ch;

99
Adam/AutoComplete/ACDictGen.CPP

@ -4,19 +4,59 @@ which will regenerate processed dictionary
files from a raw Project Gutenberg
dictionary file.
Supply the raw dictionary filename in
the call at the bottom of this file
and #include this file.
I ran $LK,"::/Misc/ToDolDoc.CPP"$ on it, first.
$TX,"http://www.templeos.org/files/DICTIONARY.TXT",HTML="http://www.templeos.org/files/DICTIONARY.TXT"$
See $LK,"::/Doc/Credits.TXT"$.
*/
U0 ACDPreprocess(U8 *in_name,U8 *out_name)
{/*
<cr><nl>--> <nl>
$$ --> $$$$
\'89 -->
*/
I64 ch,i;
U8 *src,*dst;
CDoc *doc;
CDocEntry *doc_e;
if (doc=DocRead(in_name,DOCF_PLAIN_TEXT_WITH_TABS|DOCF_DBL_DOLLARS)) {
doc_e=doc->root.next;
while (doc_e!=doc) {
if (doc_e->type_u8==DOCT_TEXT) {
src=dst=doc_e->tag;
while (ch=*src++) {
if (ch=='\\' && *src=='\'') {
src++;
i=0;
ch=ToUpper(*src++);
if ('0'<=ch<='9')
i+=ch-'0';
else if ('A'<=ch<='F')
i+=ch-'A'+10;
i<<=4;
ch=ToUpper(*src++);
if ('0'<=ch<='9')
i+=ch-'0';
else if ('A'<=ch<='F')
i+=ch-'A'+10;
*dst++=i;
} else
*dst++=ch;
}
*dst=0;
}
doc_e=doc_e->next;
}
StrCpy(doc->filename.name,out_name);
DocWrite(doc);
DocDel(doc);
}
}
I64 ACDNextCmd(U8 **_ptr)
{
U8 ch,*ptr=*_ptr,*ptr2;
I64 result=-1;
U8 *ptr=*_ptr,*ptr2;
I64 ch,result=-1;
do {
do {
if (!(ch=*ptr++)) goto ncmd_done;
@ -28,21 +68,22 @@ I64 ACDNextCmd(U8 **_ptr)
} while (ch!='>');
*--ptr2=0;
result=LstMatch(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");
"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);
ncmd_done:
ncmd_done:
*_ptr=ptr;
return result;
}
U8 *ACDNextEntry(U8 **_ptr)
{
U8 *result,*ignore,ch,*ptr=*_ptr,buf[ACD_BLK_SIZE],*out_ptr=buf;
I64 l;
U8 *result,*ignore,*ptr=*_ptr,buf[ACD_BLK_SIZE],*out_ptr=buf;
I64 ch,l;
while (TRUE) {
while (TRUE) {
if (!(ch=*ptr++)) goto nentry_done;
@ -54,9 +95,9 @@ U8 *ACDNextEntry(U8 **_ptr)
break;
}
ignore="b>\0i>\0ppp>\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";
"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)) {
@ -83,8 +124,8 @@ I64 ACDCompareWords(U8 *e1,U8 *e2)
U8 *ACDSortWords(U8 *start,I64 size,I64 word_cnt)
{
U8 **ptr_array=MAlloc(sizeof(U8 *)*word_cnt),
*out_start=MAlloc(size),
*ptr=start,*ptr2;
*out_start=MAlloc(size),
*ptr=start,*ptr2;
I64 i=0;
while (*ptr) {
ptr_array[i++]=ptr;
@ -107,14 +148,14 @@ U8 *ACDSortWords(U8 *start,I64 size,I64 word_cnt)
return out_start;
}
U0 ACDGen(U8 *raw_dict_filename)
U0 ACDGen(U8 *in_file)
{
I64 cmd,size,word_cnt=0,largest_entry=0;
U8 *st,*in_ptr=FileRead(raw_dict_filename,&size),*in_start=in_ptr,
*out_ptr=MAlloc(size),*out_start=out_ptr,
*word_ptr=MAlloc(size),*word_start=word_ptr,
*last_word="",*def_word_start=out_ptr,
*sorted_word_start;
U8 *st,*in_ptr=FileRead(in_file,&size),*in_start=in_ptr,
*out_ptr=MAlloc(size),*out_start=out_ptr,
*word_ptr=MAlloc(size),*word_start=word_ptr,
*last_word="",*def_word_start=out_ptr,
*sorted_word_start;
U16 *d;
if (!in_ptr) return;
do {
@ -137,7 +178,7 @@ next_word:
d=word_ptr;
*d=(out_ptr-out_start)/ACD_BLK_SIZE;
word_ptr+=2;
*out_ptr++=ACD_WORD_CHAR;
StrCpy(out_ptr,st);
out_ptr+=StrLen(st)+1;
@ -149,7 +190,8 @@ next_word:
cmd=ACDNextCmd(&in_ptr);
if (cmd==ACD_H1)
goto next_word;
} while (cmd>=0 && !(cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||cmd==ACD_POS||cmd==ACD_EXTRA));
} while (cmd>=0 && !(cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||
cmd==ACD_POS||cmd==ACD_EXTRA));
if (cmd==ACD_DEF) {
if(st=ACDNextEntry(&in_ptr)) {
if (*st) {
@ -187,7 +229,8 @@ next_word:
Free(st);