mirror of
https://github.com/minexew/Shrine.git
synced 2026-05-26 05:48:36 +00:00
TempleOSCDV4.11.ISO
This commit is contained in:
Binary file not shown.
@@ -1,252 +0,0 @@
|
||||
#help_index "File/Cmd Line (Typically);Cmd Line (Typically)"
|
||||
public U8 *DBlk(I64 blk,Bool write=FALSE)
|
||||
{//Dump disk block. Optionally, write.
|
||||
//If you set write to TRUE, the block will
|
||||
//be written when you press <ESC>.
|
||||
//See $LK,"::/Demo/Dsk/DskRaw.CPP"$.
|
||||
U8 *buf=MAlloc(BLK_SIZE);
|
||||
|
||||
RBlks(Fs->cur_dv,buf,blk,1);
|
||||
DocD(buf,BLK_SIZE);
|
||||
if (write) {
|
||||
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
|
||||
if (View) {
|
||||
"Write\n";
|
||||
WBlks(Fs->cur_dv,buf,blk,1);
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
public U8 *DCluster(I64 c,Bool write=FALSE,I64 num=0)
|
||||
{//Dump disk cluster. Optionally, write.
|
||||
//If you set write to TRUE, the cluster will
|
||||
//be written when you press <ESC>.
|
||||
//See $LK,"::/Demo/Dsk/DskRaw.CPP"$.
|
||||
//Do $LK,"Dir",A="MN:Dir"$("*",TRUE); to get cluster numbers of files.
|
||||
U8 *buf=MAlloc(Fs->cur_dv->spc<<BLK_SIZE_BITS);
|
||||
c=ClusterNumNext(Fs->cur_dv,c,num);
|
||||
RClusters(Fs->cur_dv,buf,c,1);
|
||||
"Cluster:%X\n",c;
|
||||
DocD(buf,Fs->cur_dv->spc<<BLK_SIZE_BITS);
|
||||
if (write) {
|
||||
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
|
||||
if (View) {
|
||||
"Write\n";
|
||||
WClusters(Fs->cur_dv,buf,c,1);
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
public U8 *Dump(U8 *filename,Bool write=FALSE)
|
||||
{//Dump file. Optionally, write.
|
||||
//If you set write to TRUE, the file will
|
||||
//be written when you press <ESC>.
|
||||
U8 *buf;
|
||||
I64 size;
|
||||
if (buf=FileRead(filename,&size)) {
|
||||
DocD(buf,size);
|
||||
if (write) {
|
||||
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
|
||||
if (View) {
|
||||
"Write\n";
|
||||
FileWrite(filename,buf,size);
|
||||
}
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
public Bool Copy(U8 *src_files_find_mask,U8 *dst_files_find_mask=".")
|
||||
{//Copy files.
|
||||
//If the name ends in ".Z", it will
|
||||
//be stored compressed. If not ".Z"
|
||||
//it will be stored uncompressed.
|
||||
Bool res=TRUE;
|
||||
CDirContext *dirc;
|
||||
CDirEntry *tempde,*tempde1;
|
||||
U8 *st;
|
||||
if (!(tempde1=FilesFind(src_files_find_mask,FUF_CLUSTER_ORDER)))
|
||||
return FALSE;
|
||||
if (IsDir(dst_files_find_mask)) {
|
||||
if (dirc=DirContextNew(dst_files_find_mask,TRUE)) {
|
||||
tempde=tempde1;
|
||||
while (tempde) {
|
||||
if (!(tempde->attr & RS_ATTR_DIR)) {
|
||||
st=FileNameAbs(tempde->name);
|
||||
if (!CopySingle(tempde->full_name,st))
|
||||
res=FALSE;
|
||||
Free(st);
|
||||
}
|
||||
tempde=tempde->next;
|
||||
}
|
||||
DirContextDel(dirc);
|
||||
}
|
||||
DirTreeDel(tempde1);
|
||||
return res;
|
||||
} else {
|
||||
DirTreeDel(tempde1);
|
||||
return CopySingle(src_files_find_mask,dst_files_find_mask);
|
||||
}
|
||||
}
|
||||
|
||||
public Bool Move(U8 *f1,U8 *f2)
|
||||
{//Move files from one location to another or rename.
|
||||
if (Copy(f1,f2)) {
|
||||
Del(f1);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
I64 CopyTree2(CDirEntry *tempde,I64 src_dir_len,I64 dst_dir_len,U8 *dst_dir)
|
||||
{
|
||||
U8 *st;
|
||||
I64 res=1;
|
||||
while (tempde) {
|
||||
st=MAlloc(StrLen(tempde->full_name)+dst_dir_len+2);
|
||||
MemCpy(st,dst_dir,dst_dir_len);
|
||||
StrCpy(st+dst_dir_len,tempde->full_name+src_dir_len);
|
||||
if (tempde->attr & RS_ATTR_DIR) {
|
||||
MkDir(st,LinkedLstCnt(tempde->sub));
|
||||
res+=CopyTree2(tempde->sub,src_dir_len,dst_dir_len,dst_dir);
|
||||
} else
|
||||
if (CopySingle(tempde->full_name,st))
|
||||
res++;
|
||||
Free(st);
|
||||
tempde=tempde->next;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public I64 CopyTree(U8 *src_files_find_mask,U8 *dst_files_find_mask,
|
||||
Bool no_mask=TRUE)
|
||||
{//Copy directory tree.
|
||||
//Returns the count of copied files (not dirs).
|
||||
CDirContext *dirc;
|
||||
CDirEntry *tempde=NULL;
|
||||
I64 res=0,i1,i2;
|
||||
U8 *st1,*st2;
|
||||
|
||||
st1=DirNameAbs(src_files_find_mask);
|
||||
st2=DirNameAbs(dst_files_find_mask);
|
||||
i1=StrLen(st1);
|
||||
if (!StrNCmp(st1,st2,i1) && (st2[i1]=='/' || !st2[i1]) ) {
|
||||
Free(st1);
|
||||
Free(st2);
|
||||
return 0;
|
||||
}
|
||||
Free(st1);
|
||||
Free(st2);
|
||||
if (dirc=DirContextNew(src_files_find_mask,TRUE,,no_mask)) {
|
||||
tempde=FilesFind(dirc->mask,FUF_RECURSE);
|
||||
st1=CurDir;
|
||||
DirContextDel(dirc);
|
||||
i1=StrLen(st1);
|
||||
if (i1==3) i1--;
|
||||
if (dirc=DirContextNew(dst_files_find_mask,TRUE,TRUE)) {
|
||||
st2=CurDir;
|
||||
i2=StrLen(st2);
|
||||
if (i2==3) i2--;
|
||||
res=CopyTree2(tempde,i1,i2,st2);
|
||||
DirContextDel(dirc);
|
||||
Free(st2);
|
||||
}
|
||||
DirTreeDel(tempde);
|
||||
Free(st1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 DelTreeDirs(CDirEntry *tempde1)
|
||||
{
|
||||
I64 res=0;
|
||||
CDirEntry *tempde2;
|
||||
while (tempde1) {
|
||||
tempde2=tempde1->next;
|
||||
if (tempde1->attr & RS_ATTR_DIR) {
|
||||
if (tempde1->sub)
|
||||
res+=DelTreeDirs(tempde1->sub);
|
||||
res+=Del(tempde1->full_name,TRUE,TRUE);
|
||||
}
|
||||
DirEntryDel(tempde1);
|
||||
tempde1=tempde2;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
I64 DelTreeFiles(CDirEntry *tempde1)
|
||||
{
|
||||
I64 res=0;
|
||||
CDirEntry *tempde2;
|
||||
while (tempde1) {
|
||||
tempde2=tempde1->next;
|
||||
if (tempde1->attr & RS_ATTR_DIR) {
|
||||
if (tempde1->sub)
|
||||
res+=DelTreeFiles(tempde1->sub);
|
||||
} else
|
||||
res+=Del(tempde1->full_name,FALSE,TRUE);
|
||||
DirEntryDel(tempde1);
|
||||
tempde1=tempde2;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public I64 DelTree(U8 *files_find_mask,U8 *fu_flags=NULL)
|
||||
{//Delete directory tree.
|
||||
I64 res=0,fuf_flags=0;
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r");
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
|
||||
if (IsDir(files_find_mask)) {
|
||||
res=DelTreeDirs(FilesFind(files_find_mask,fuf_flags));
|
||||
res+=Del(files_find_mask,TRUE,TRUE);
|
||||
res+=Del(files_find_mask,FALSE,TRUE);
|
||||
} else
|
||||
res=DelTreeFiles(FilesFind(files_find_mask,fuf_flags));
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 TouchFile(U8 *filename,U8 *attr,CDate cdt=MIN_I64)
|
||||
{
|
||||
CDrv *dv=Let2Drv(*filename);
|
||||
CDirEntry de;
|
||||
U8 *cur_dir=StrNew(filename),buf[STR_LEN];
|
||||
if (FileFind(filename,&de,FUF_JUST_FILES)) {
|
||||
Free(de.full_name);
|
||||
if (!StrCmp(attr,"+?"))
|
||||
"%-48ts %s\n",filename,StrPrintFlags(buf,Define("ST_FILE_ATTRS"),de.attr);
|
||||
else {
|
||||
StrFirstRem(cur_dir,":");
|
||||
StrLastRem(cur_dir,"/");
|
||||
if (!*cur_dir)
|
||||
StrCpy(cur_dir,"/");
|
||||
ScanFlags(&de.attr,Define("ST_FILE_ATTRS"),attr);
|
||||
if (cdt==MIN_I64)
|
||||
de.datetime=Now;
|
||||
else
|
||||
de.datetime=cdt;
|
||||
DirNew(dv,cur_dir,&de,FALSE);
|
||||
}
|
||||
} else
|
||||
PrintErr("File not found.\n");
|
||||
Free(cur_dir);
|
||||
}
|
||||
public U0 Touch(U8 *files_find_mask="*",U8 *attr="+?",
|
||||
U8 *fu_flags=NULL,CDate cdt=MIN_I64)
|
||||
{/*Touch file attributes and DateTime.
|
||||
Default lists attributes.
|
||||
attr: "+?" =show current
|
||||
"+T" =resident
|
||||
$LK,"RS_ATTR_READ_ONLY",A="MN:RS_ATTR_READ_ONLY"$ $LK,"ST_FILE_ATTRS",A="MN:ST_FILE_ATTRS"$
|
||||
To Set DateL:
|
||||
Touch(filename,"",,datetime);
|
||||
*/
|
||||
I64 fuf_flags=0;
|
||||
CDirEntry *tempde,*tempde1;
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+f+F");
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
|
||||
tempde=tempde1=FilesFind(files_find_mask,fuf_flags);
|
||||
while (tempde) {
|
||||
TouchFile(tempde->full_name,attr,cdt);
|
||||
tempde=tempde->next;
|
||||
}
|
||||
DirTreeDel(tempde1);
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
#help_index "File/Cmd Line (Typically);Cmd Line (Typically)"
|
||||
public U8 *DBlk(I64 blk,Bool write=FALSE)
|
||||
{//Dump disk block. Optionally, write.
|
||||
//If you set write to TRUE, the block will
|
||||
//be written when you press <ESC>.
|
||||
//See $LK,"::/Demo/Dsk/DskRaw.HC"$.
|
||||
U8 *buf=MAlloc(BLK_SIZE);
|
||||
|
||||
RBlks(Fs->cur_dv,buf,blk,1);
|
||||
DocD(buf,BLK_SIZE);
|
||||
if (write) {
|
||||
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
|
||||
if (View) {
|
||||
"Write\n";
|
||||
WBlks(Fs->cur_dv,buf,blk,1);
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
public U8 *DCluster(I64 c,Bool write=FALSE,I64 num=0)
|
||||
{//Dump disk cluster. Optionally, write.
|
||||
//If you set write to TRUE, the cluster will
|
||||
//be written when you press <ESC>.
|
||||
//See $LK,"::/Demo/Dsk/DskRaw.HC"$.
|
||||
//Do $LK,"Dir",A="MN:Dir"$("*",TRUE); to get cluster numbers of files.
|
||||
U8 *buf=MAlloc(Fs->cur_dv->spc<<BLK_SIZE_BITS);
|
||||
c=ClusterNumNext(Fs->cur_dv,c,num);
|
||||
RClusters(Fs->cur_dv,buf,c,1);
|
||||
"Cluster:%X\n",c;
|
||||
DocD(buf,Fs->cur_dv->spc<<BLK_SIZE_BITS);
|
||||
if (write) {
|
||||
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
|
||||
if (View) {
|
||||
"Write\n";
|
||||
WClusters(Fs->cur_dv,buf,c,1);
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
public U8 *Dump(U8 *filename,Bool write=FALSE)
|
||||
{//Dump file. Optionally, write.
|
||||
//If you set write to TRUE, the file will
|
||||
//be written when you press <ESC>.
|
||||
U8 *buf;
|
||||
I64 size;
|
||||
if (buf=FileRead(filename,&size)) {
|
||||
DocD(buf,size);
|
||||
if (write) {
|
||||
"Edit and press <ESC> to write or <SHIFT-ESC>\n";
|
||||
if (View) {
|
||||
"Write\n";
|
||||
FileWrite(filename,buf,size);
|
||||
}
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
public Bool Copy(U8 *src_files_find_mask,U8 *dst_files_find_mask=".")
|
||||
{//Copy files.
|
||||
//If the name ends in ".Z", it will
|
||||
//be stored compressed. If not ".Z"
|
||||
//it will be stored uncompressed.
|
||||
Bool res=TRUE;
|
||||
CDirContext *dirc;
|
||||
CDirEntry *tempde,*tempde1;
|
||||
U8 *st;
|
||||
if (!(tempde1=FilesFind(src_files_find_mask,FUF_CLUSTER_ORDER)))
|
||||
return FALSE;
|
||||
if (IsDir(dst_files_find_mask)) {
|
||||
if (dirc=DirContextNew(dst_files_find_mask,TRUE)) {
|
||||
tempde=tempde1;
|
||||
while (tempde) {
|
||||
if (!(tempde->attr & RS_ATTR_DIR)) {
|
||||
st=FileNameAbs(tempde->name);
|
||||
if (!CopySingle(tempde->full_name,st))
|
||||
res=FALSE;
|
||||
Free(st);
|
||||
}
|
||||
tempde=tempde->next;
|
||||
}
|
||||
DirContextDel(dirc);
|
||||
}
|
||||
DirTreeDel(tempde1);
|
||||
return res;
|
||||
} else {
|
||||
DirTreeDel(tempde1);
|
||||
return CopySingle(src_files_find_mask,dst_files_find_mask);
|
||||
}
|
||||
}
|
||||
|
||||
public Bool Move(U8 *f1,U8 *f2)
|
||||
{//Move files from one location to another or rename.
|
||||
if (Copy(f1,f2)) {
|
||||
Del(f1);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
I64 CopyTree2(CDirEntry *tempde,I64 src_dir_len,I64 dst_dir_len,U8 *dst_dir)
|
||||
{
|
||||
U8 *st;
|
||||
I64 res=1;
|
||||
while (tempde) {
|
||||
st=MAlloc(StrLen(tempde->full_name)+dst_dir_len+2);
|
||||
MemCpy(st,dst_dir,dst_dir_len);
|
||||
StrCpy(st+dst_dir_len,tempde->full_name+src_dir_len);
|
||||
if (tempde->attr & RS_ATTR_DIR) {
|
||||
MkDir(st,LinkedLstCnt(tempde->sub));
|
||||
res+=CopyTree2(tempde->sub,src_dir_len,dst_dir_len,dst_dir);
|
||||
} else
|
||||
if (CopySingle(tempde->full_name,st))
|
||||
res++;
|
||||
Free(st);
|
||||
tempde=tempde->next;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public I64 CopyTree(U8 *src_files_find_mask,U8 *dst_files_find_mask,
|
||||
Bool no_mask=TRUE)
|
||||
{//Copy directory tree.
|
||||
//Returns the count of copied files (not dirs).
|
||||
CDirContext *dirc;
|
||||
CDirEntry *tempde=NULL;
|
||||
I64 res=0,i1,i2;
|
||||
U8 *st1,*st2;
|
||||
|
||||
st1=DirNameAbs(src_files_find_mask);
|
||||
st2=DirNameAbs(dst_files_find_mask);
|
||||
i1=StrLen(st1);
|
||||
if (!StrNCmp(st1,st2,i1) && (st2[i1]=='/' || !st2[i1]) ) {
|
||||
Free(st1);
|
||||
Free(st2);
|
||||
return 0;
|
||||
}
|
||||
Free(st1);
|
||||
Free(st2);
|
||||
if (dirc=DirContextNew(src_files_find_mask,TRUE,,no_mask)) {
|
||||
tempde=FilesFind(dirc->mask,FUF_RECURSE);
|
||||
st1=CurDir;
|
||||
DirContextDel(dirc);
|
||||
i1=StrLen(st1);
|
||||
if (i1==3) i1--;
|
||||
if (dirc=DirContextNew(dst_files_find_mask,TRUE,TRUE)) {
|
||||
st2=CurDir;
|
||||
i2=StrLen(st2);
|
||||
if (i2==3) i2--;
|
||||
res=CopyTree2(tempde,i1,i2,st2);
|
||||
DirContextDel(dirc);
|
||||
Free(st2);
|
||||
}
|
||||
DirTreeDel(tempde);
|
||||
Free(st1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 DelTreeDirs(CDirEntry *tempde1)
|
||||
{
|
||||
I64 res=0;
|
||||
CDirEntry *tempde2;
|
||||
while (tempde1) {
|
||||
tempde2=tempde1->next;
|
||||
if (tempde1->attr & RS_ATTR_DIR) {
|
||||
if (tempde1->sub)
|
||||
res+=DelTreeDirs(tempde1->sub);
|
||||
res+=Del(tempde1->full_name,TRUE,TRUE);
|
||||
}
|
||||
DirEntryDel(tempde1);
|
||||
tempde1=tempde2;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
I64 DelTreeFiles(CDirEntry *tempde1)
|
||||
{
|
||||
I64 res=0;
|
||||
CDirEntry *tempde2;
|
||||
while (tempde1) {
|
||||
tempde2=tempde1->next;
|
||||
if (tempde1->attr & RS_ATTR_DIR) {
|
||||
if (tempde1->sub)
|
||||
res+=DelTreeFiles(tempde1->sub);
|
||||
} else
|
||||
res+=Del(tempde1->full_name,FALSE,TRUE);
|
||||
DirEntryDel(tempde1);
|
||||
tempde1=tempde2;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public I64 DelTree(U8 *files_find_mask,U8 *fu_flags=NULL)
|
||||
{//Delete directory tree.
|
||||
I64 res=0,fuf_flags=0;
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r");
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
|
||||
if (IsDir(files_find_mask)) {
|
||||
res=DelTreeDirs(FilesFind(files_find_mask,fuf_flags));
|
||||
res+=Del(files_find_mask,TRUE,TRUE);
|
||||
res+=Del(files_find_mask,FALSE,TRUE);
|
||||
} else
|
||||
res=DelTreeFiles(FilesFind(files_find_mask,fuf_flags));
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 TouchFile(U8 *filename,U8 *attr,CDate cdt=MIN_I64)
|
||||
{
|
||||
CDrv *dv=Let2Drv(*filename);
|
||||
CDirEntry de;
|
||||
U8 *cur_dir=StrNew(filename),buf[STR_LEN];
|
||||
if (FileFind(filename,&de,FUF_JUST_FILES)) {
|
||||
Free(de.full_name);
|
||||
if (!StrCmp(attr,"+?"))
|
||||
"%-48ts %s\n",filename,StrPrintFlags(buf,Define("ST_FILE_ATTRS"),de.attr);
|
||||
else {
|
||||
StrFirstRem(cur_dir,":");
|
||||
StrLastRem(cur_dir,"/");
|
||||
if (!*cur_dir)
|
||||
StrCpy(cur_dir,"/");
|
||||
ScanFlags(&de.attr,Define("ST_FILE_ATTRS"),attr);
|
||||
if (cdt==MIN_I64)
|
||||
de.datetime=Now;
|
||||
else
|
||||
de.datetime=cdt;
|
||||
DirNew(dv,cur_dir,&de,FALSE);
|
||||
}
|
||||
} else
|
||||
PrintErr("File not found.\n");
|
||||
Free(cur_dir);
|
||||
}
|
||||
public U0 Touch(U8 *files_find_mask="*",U8 *attr="+?",
|
||||
U8 *fu_flags=NULL,CDate cdt=MIN_I64)
|
||||
{/*Touch file attributes and DateTime.
|
||||
Default lists attributes.
|
||||
attr: "+?" =show current
|
||||
"+T" =resident
|
||||
$LK,"RS_ATTR_READ_ONLY",A="MN:RS_ATTR_READ_ONLY"$ $LK,"ST_FILE_ATTRS",A="MN:ST_FILE_ATTRS"$
|
||||
To Set DateL:
|
||||
Touch(filename,"",,datetime);
|
||||
*/
|
||||
I64 fuf_flags=0;
|
||||
CDirEntry *tempde,*tempde1;
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+f+F");
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
|
||||
tempde=tempde1=FilesFind(files_find_mask,fuf_flags);
|
||||
while (tempde) {
|
||||
TouchFile(tempde->full_name,attr,cdt);
|
||||
tempde=tempde->next;
|
||||
}
|
||||
DirTreeDel(tempde1);
|
||||
}
|
||||
@@ -1,793 +0,0 @@
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
U0 DirFileDoc(CDoc *doc,CDirEntry *tempde)
|
||||
{
|
||||
while (tempde) {
|
||||
if (tempde->attr & RS_ATTR_DIR) {
|
||||
tempde->user_data=DocPrint(doc,"$$TR,\"%s\",U=0x%X$$",tempde->name,tempde);
|
||||
DocPrint(doc,"\n$$ID,+2$$");
|
||||
if (tempde->sub)
|
||||
DirFileDoc(doc,tempde->sub);
|
||||
DocPrint(doc,"$$ID,-2$$");
|
||||
} else {
|
||||
tempde->user_data=DocPrint(doc,"$$MU,\"%s\",U=0x%X$$",tempde->name,tempde);
|
||||
DocPrint(doc,"\n");
|
||||
}
|
||||
tempde=tempde->next;
|
||||
}
|
||||
}
|
||||
|
||||
#help_index "File/Cmd Line (Typically);Cmd Line (Typically)"
|
||||
|
||||
#define FM_NORMAL 0
|
||||
#define FM_PICK_FILE 1
|
||||
#define FM_PICK_DIR 2
|
||||
|
||||
class CFMUncollapsedLst
|
||||
{
|
||||
CFMUncollapsedLst *next;
|
||||
U8 *name;
|
||||
};
|
||||
|
||||
CFMUncollapsedLst *FMCollectUncollapsedLst(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_e=doc->head.next;
|
||||
CFMUncollapsedLst *res=NULL,*tempc;
|
||||
CDirEntry *tempde;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type_u8==DOCT_TREE) {
|
||||
if (!(doc_e->de_flags&DOCEF_CHECKED_COLLAPSED)) {
|
||||
if (tempde=doc_e->user_data) {
|
||||
tempc=MAlloc(sizeof(CFMUncollapsedLst));
|
||||
tempc->next=res;
|
||||
res=tempc;
|
||||
tempc->name=StrNew(tempde->full_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 FMMarkUncollapsed(CDoc *doc,CFMUncollapsedLst *tempc,
|
||||
U8 *cur_entry,U8 *next_entry)
|
||||
{
|
||||
CDocEntry *doc_e=doc->head.next;
|
||||
CFMUncollapsedLst *tempc1;
|
||||
CDirEntry *tempde;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type_u8==DOCT_TREE) {
|
||||
tempde=doc_e->user_data;
|
||||
tempc1=tempc;
|
||||
while (tempc1) {
|
||||
if (!StrCmp(tempc1->name,tempde->full_name)) {
|
||||
doc_e->de_flags&=~DOCEF_CHECKED_COLLAPSED;
|
||||
break;
|
||||
}
|
||||
tempc1=tempc1->next;
|
||||
}
|
||||
if (cur_entry) {
|
||||
if (!StrNCmp(cur_entry,tempde->full_name,StrLen(tempde->full_name))) {
|
||||
doc->cur_entry=doc_e;
|
||||
if (StrLen(tempde->full_name)==StrLen(cur_entry))
|
||||
cur_entry=NULL;
|
||||
} else if (next_entry) {
|
||||
if (!StrNCmp(next_entry,
|
||||
tempde->full_name,StrLen(tempde->full_name))) {
|
||||
doc->cur_entry=doc_e;
|
||||
if (StrLen(tempde->full_name)==StrLen(next_entry))
|
||||
cur_entry=NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (doc_e->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc_e->user_data;
|
||||
if (cur_entry) {
|
||||
if (!StrNCmp(cur_entry,tempde->full_name,StrLen(tempde->full_name))) {
|
||||
doc->cur_entry=doc_e;
|
||||
if (StrLen(tempde->full_name)==StrLen(cur_entry))
|
||||
cur_entry=NULL;
|
||||
} else if (next_entry) {
|
||||
if (!StrNCmp(next_entry,
|
||||
tempde->full_name,StrLen(tempde->full_name))) {
|
||||
doc->cur_entry=doc_e;
|
||||
if (StrLen(tempde->full_name)==StrLen(next_entry))
|
||||
cur_entry=NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMDelUncollapsedLst(CFMUncollapsedLst *tempc)
|
||||
{
|
||||
CFMUncollapsedLst *tempc1;
|
||||
while (tempc) {
|
||||
tempc1=tempc->next;
|
||||
Free(tempc->name);
|
||||
Free(tempc);
|
||||
tempc=tempc1;
|
||||
}
|
||||
}
|
||||
|
||||
CDirEntry *FMRebuildDocDrv(U8 drv_let,CDoc *doc,CDirEntry **_head,Bool init)
|
||||
{
|
||||
CDirEntry *tempde,*tempde1;
|
||||
U8 *st;
|
||||
tempde=CAlloc(sizeof(CDirEntry));
|
||||
tempde->full_name=MStrPrint("%C:/",drv_let);
|
||||
tempde->attr=RS_ATTR_DIR;
|
||||
st=MStrPrint("%c:/*",drv_let);
|
||||
if (init)
|
||||
tempde->sub=tempde1=FilesFind(st,FUF_RECURSE);
|
||||
else
|
||||
tempde1=NULL;
|
||||
Free(st);
|
||||
tempde->user_data=DocPrint(doc,"$$TR,\"%s\",U=0x%X$$",tempde->full_name,tempde);
|
||||
tempde->next=*_head;
|
||||
*_head=tempde;
|
||||
DocPrint(doc,"\n$$ID,+2$$");
|
||||
DocBottom(doc);
|
||||
if (init) {
|
||||
DirFileDoc(doc,tempde1);
|
||||
while (tempde1) {
|
||||
tempde1->parent=tempde;
|
||||
tempde1=tempde1->next;
|
||||
}
|
||||
}
|
||||
DocPrint(doc,"$$ID,-2$$");
|
||||
return tempde;
|
||||
}
|
||||
|
||||
U0 FMRebuildDoc(CDoc **_doc,CDirEntry **_head,I64 mode)
|
||||
{
|
||||
CDrv *dv;
|
||||
I64 i;
|
||||
CDoc *doc=*_doc,*doc2=sys_clipboard_doc,*parent_doc;
|
||||
CFMUncollapsedLst *tempc=NULL;
|
||||
U8 *cur_entry=NULL,*next_entry=NULL;
|
||||
CDocEntry *doc_ce;
|
||||
CDirEntry *tempde,*tempde1,*cur_tree_entry;
|
||||
if (!doc)
|
||||
parent_doc=DocPut;
|
||||
else {
|
||||
parent_doc=doc->parent_doc;
|
||||
Fs->put_doc=Fs->display_doc=NULL;
|
||||
DocUnlock(doc);
|
||||
WinMgrSync;
|
||||
DocLock(doc);
|
||||
cur_tree_entry=NULL;
|
||||
doc_ce=doc->cur_entry;
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
cur_tree_entry=doc_ce->user_data;
|
||||
if (cur_tree_entry)
|
||||
cur_entry=StrNew(cur_tree_entry->full_name);
|
||||
tempde=NULL;
|
||||
if (doc_ce!=doc)
|
||||
doc_ce=doc_ce->next;
|
||||
while (doc_ce!=doc) {
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=doc_ce->user_data;
|
||||
else
|
||||
tempde=NULL;
|
||||
if (tempde) {
|
||||
tempde1=tempde->parent;
|
||||
while (tempde1) {
|
||||
if (tempde1==cur_tree_entry) {
|
||||
tempde=NULL;
|
||||
break;
|
||||
} else
|
||||
tempde1=tempde1->parent;
|
||||
}
|
||||
if (tempde)
|
||||
break;
|
||||
}
|
||||
doc_ce=doc_ce->next;
|
||||
}
|
||||
if (tempde)
|
||||
next_entry=StrNew(tempde->full_name);
|
||||
|
||||
tempc=FMCollectUncollapsedLst(doc);
|
||||
DocDel(doc);
|
||||
}
|
||||
if (*_head) {
|
||||
DirTreeDel(*_head);
|
||||
*_head=NULL;
|
||||
}
|
||||
doc=DocNew;
|
||||
doc->desc='FileMan';
|
||||
doc->parent_doc=parent_doc;
|
||||
doc->flags|=DOCF_FORM;
|
||||
switch (mode) {
|
||||
case FM_NORMAL:
|
||||
DocPrint(doc,"$$PURPLE$$File Manager\n\n"
|
||||
"$$LK,\"Click for Help\",A=\"FI:::/Doc/FileMgr.TXT\"$$\n\n");
|
||||
break;
|
||||
case FM_PICK_FILE:
|
||||
DocPrint(doc,"$$PURPLE$$Pick file and press <ESC>\n\n");
|
||||
doc->flags|=DOCF_MIN_SIZE;
|
||||
break;
|
||||
case FM_PICK_DIR:
|
||||
DocPrint(doc,"$$PURPLE$$Pick directory and press <ESC>\n\n");
|
||||
doc->flags|=DOCF_MIN_SIZE;
|
||||
break;
|
||||
}
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
for (i=0;i<NUM_DRVS;i++) {
|
||||
dv=&blkdev.drvs[i];
|
||||
if (dv->bd->type==BDT_ATAPI) {
|
||||
if (dv->bd->flags&BDF_INITIALIZED)
|
||||
tempde=FMRebuildDocDrv(Drv2Let(dv),doc,_head,TRUE);
|
||||
else {
|
||||
tempde=FMRebuildDocDrv(Drv2Let(dv),doc,_head,FALSE);
|
||||
tempde->flags|=DEF_NOT_INITIALIZED;
|
||||
}
|
||||
} else if (dv->fs_type==FSt_REDSEA || dv->fs_type==FSt_FAT32)
|
||||
FMRebuildDocDrv(Drv2Let(dv),doc,_head,TRUE);
|
||||
}
|
||||
DocTop(doc);
|
||||
FMMarkUncollapsed(doc,tempc,cur_entry,next_entry);
|
||||
DocCenter(doc);
|
||||
DocRst(doc2,TRUE);
|
||||
FMDelUncollapsedLst(tempc);
|
||||
Free(cur_entry);
|
||||
Free(next_entry);
|
||||
*_doc=doc;
|
||||
DocLock(doc);
|
||||
Fs->put_doc=Fs->display_doc=doc;
|
||||
}
|
||||
|
||||
U0 FMRename(CDoc *doc)
|
||||
{
|
||||
CEdFileName fn;
|
||||
CDocEntry *doc_e=doc->cur_entry;
|
||||
CDirEntry *tempde=NULL,*parent;
|
||||
if (doc_e->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc_e->user_data;
|
||||
if (parent=tempde->parent) {
|
||||
Cd(parent->full_name);
|
||||
StrCpy(fn.name,tempde->name);
|
||||
if (DocForm(&fn)) {
|
||||
Silent;
|
||||
Move(tempde->name,fn.name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
} else if (doc_e->type_u8==DOCT_TREE) {
|
||||
tempde=doc_e->user_data;
|
||||
if (parent=tempde->parent) {
|
||||
Cd(parent->full_name);
|
||||
StrCpy(fn.name,tempde->name);
|
||||
if (DocForm(&fn)) {
|
||||
if (StrCmp(tempde->name,fn.name)) {
|
||||
Silent;
|
||||
if (CopyTree(tempde->name,fn.name))
|
||||
DelTree(tempde->name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMMkDir(CDoc *doc)
|
||||
{
|
||||
CEdFileName fn;
|
||||
CDocEntry *doc_e=doc->cur_entry;
|
||||
CDirEntry *tempde=NULL,*parent;
|
||||
*fn.name=0;
|
||||
if (doc_e->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc_e->user_data;
|
||||
if (parent=tempde->parent) {
|
||||
Cd(parent->full_name);
|
||||
if (DocForm(&fn)) {
|
||||
Silent;
|
||||
MkDir(fn.name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
} else if (doc_e->type_u8==DOCT_TREE) {
|
||||
tempde=doc_e->user_data;
|
||||
Cd(tempde->full_name);
|
||||
if (DocForm(&fn)) {
|
||||
Silent;
|
||||
MkDir(fn.name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMDelete(CDoc *doc)
|
||||
{
|
||||
U8 *st;
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
if (doc_ce->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc_ce->user_data;
|
||||
Silent;
|
||||
st=MStrPrint("Delete: %s",tempde->full_name);
|
||||
if (PopUpCancelOk(st))
|
||||
Del(tempde->full_name);
|
||||
Free(st);
|
||||
Silent(OFF);
|
||||
} else if (doc_ce->type_u8==DOCT_TREE) {
|
||||
tempde=doc_ce->user_data;
|
||||
Silent;
|
||||
st=MStrPrint("Delete: %s",tempde->full_name);
|
||||
if (PopUpCancelOk(st))
|
||||
DelTree(tempde->full_name);
|
||||
Free(st);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMChgDsk(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=doc_ce->user_data;
|
||||
else
|
||||
tempde=NULL;
|
||||
if (tempde) {
|
||||
while (tempde->parent)
|
||||
tempde=tempde->parent;
|
||||
Silent;
|
||||
ChgDsk(*tempde->full_name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMMountISO(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
if (doc_ce->type_u8==DOCT_MENU_VAL && (tempde=doc_ce->user_data))
|
||||
MountFile(tempde->full_name);
|
||||
}
|
||||
|
||||
U0 FMUnmount(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
I64 drv_let;
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=doc_ce->user_data;
|
||||
else
|
||||
tempde=NULL;
|
||||
if (tempde) {
|
||||
while (tempde->parent)
|
||||
tempde=tempde->parent;
|
||||
drv_let=*tempde->full_name;
|
||||
if (Let2BlkDev(drv_let)!=Let2BlkDev(':'))
|
||||
Unmount(drv_let);
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMFmtDrv(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
U8 *st=NULL;
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=doc_ce->user_data;
|
||||
else
|
||||
tempde=NULL;
|
||||
if (tempde) {
|
||||
while (tempde->parent)
|
||||
tempde=tempde->parent;
|
||||
st=MStrPrint("Format Drive '%c'?\nAre You Sure?\n",*tempde->full_name);
|
||||
if (PopUpCancelOk(st)) {
|
||||
Silent;
|
||||
Fmt(*tempde->full_name,,FALSE);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
|
||||
U0 FMMakeISO(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
U8 *st;
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=doc_ce->user_data;
|
||||
else
|
||||
tempde=NULL;
|
||||
if (tempde) {
|
||||
if (doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=tempde->parent;
|
||||
if (tempde && *tempde->full_name) {
|
||||
Silent;
|
||||
if (tempde->full_name[StrLen(tempde->full_name)-1]=='/')
|
||||
st=MStrPrint("%s*",tempde->full_name);
|
||||
else
|
||||
st=MStrPrint("%s/*",tempde->full_name);
|
||||
ISO9660ISO(,st);
|
||||
Free(st);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMBurnISO(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=doc_ce->user_data;
|
||||
else
|
||||
tempde=NULL;
|
||||
if (tempde) {
|
||||
while (tempde->parent)
|
||||
tempde=tempde->parent;
|
||||
Silent;
|
||||
DVDImageWrite(*tempde->full_name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMCopy(CDoc *doc)
|
||||
{
|
||||
CDoc *doc2=sys_clipboard_doc;
|
||||
U8 *st;
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_e;
|
||||
CDirEntry *tempde,*tempde1=NULL,*tempde2;
|
||||
Bool unlock_doc2=DocLock(doc2);
|
||||
doc_e=doc2->head.next;
|
||||
|
||||
tempde1=doc_ce->user_data;
|
||||
if (doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde1=tempde1->parent;
|
||||
else if (doc_ce->type_u8!=DOCT_TREE)
|
||||
tempde1=NULL;
|
||||
if (tempde1) {
|
||||
while (doc_e!=doc2) {
|
||||
if (doc_e->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc_e->user_data;
|
||||
tempde->flags|=DEF_PROCESSED;
|
||||
tempde2=tempde->parent;
|
||||
if (!tempde2 || !(tempde2->flags&DEF_PROCESSED)) {
|
||||
Silent;
|
||||
Copy(tempde->full_name,tempde1->full_name);
|
||||
Silent(OFF);
|
||||
}
|
||||
} else if (doc_e->type_u8==DOCT_TREE) {
|
||||
tempde=doc_e->user_data;
|
||||
tempde->flags|=DEF_PROCESSED;
|
||||
tempde2=tempde->parent;
|
||||
if (!tempde2 || !(tempde2->flags&DEF_PROCESSED)) {
|
||||
Silent;
|
||||
if (*tempde1->name)
|
||||
st=MStrPrint("%s/%s",tempde1->full_name,tempde->name);
|
||||
else
|
||||
st=MStrPrint("%s%s",tempde1->full_name,tempde->name);
|
||||
CopyTree(tempde->full_name,st);
|
||||
Free(st);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
}
|
||||
if (unlock_doc2)
|
||||
DocUnlock(doc2);
|
||||
}
|
||||
|
||||
#define FMR_INCLUDE 0
|
||||
#define FMR_ADAM_INCLUDE 1
|
||||
#define FMR_DELETE 2
|
||||
#define FMR_RENAME 3
|
||||
#define FMR_MKDIR 4
|
||||
#define FMR_PLAIN 5
|
||||
#define FMR_PASTE 6
|
||||
#define FMR_CHG_DSK 7
|
||||
#define FMR_FORMAT 8
|
||||
#define FMR_MOUNT_ISO 9
|
||||
#define FMR_UNMOUNT 10
|
||||
#define FMR_MAKE_ISO 11
|
||||
#define FMR_BURN_ISO 12
|
||||
#define FMR_HELP 13
|
||||
|
||||
I64 PopUpFMRight(U8 *header=NULL,U8 *footer=NULL)
|
||||
{
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
if (header) DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"$$CM+LX,1,1 $$$$BT,\"INCLUDE \",LE=FMR_INCLUDE$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"ADAM INCLUDE \",LE=FMR_ADAM_INCLUDE$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"DELETE \",LE=FMR_DELETE$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"RENAME \",LE=FMR_RENAME$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"MAKE DIRECTORY \",LE=FMR_MKDIR$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"PLAIN-TEXT EDIT \",LE=FMR_PLAIN$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"PASTE CLIPBOARD FILES \",LE=FMR_PASTE$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"CHANGE DISK(MOUNT IT) \",LE=FMR_CHG_DSK$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"FORMAT \",LE=FMR_FORMAT$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"MOUNT ISO.C FILE \",LE=FMR_MOUNT_ISO$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"UNMOUNT \",LE=FMR_UNMOUNT$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"MAKE ISO (CD/DVD) FILE\",LE=FMR_MAKE_ISO$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"BURN ISO (CD/DVD) FILE\",LE=FMR_BURN_ISO$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"HELP \",LE=FMR_HELP$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"CANCEL \",LE=DOCM_CANCEL$$\n");
|
||||
if (footer) DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
U0 FMRightClick()
|
||||
{
|
||||
switch (PopUpFMRight) {
|
||||
case FMR_INCLUDE:
|
||||
Msg(MSG_KEY_DOWN,0,0x3F0000003F);
|
||||
break;
|
||||
case FMR_ADAM_INCLUDE:
|
||||
Msg(MSG_KEY_DOWN,0,0x23F0000023F);
|
||||
break;
|
||||
case FMR_DELETE:
|
||||
Msg(MSG_KEY_DOWN,CH_CTRLY,0);
|
||||
break;
|
||||
case FMR_RENAME:
|
||||
Msg(MSG_KEY_DOWN,'r',0);
|
||||
break;
|
||||
case FMR_MKDIR:
|
||||
Msg(MSG_KEY_DOWN,'d',0);
|
||||
break;
|
||||
case FMR_PLAIN:
|
||||
Msg(MSG_KEY_DOWN,CH_SHIFT_SPACE,0);
|
||||
break;
|
||||
case FMR_PASTE:
|
||||
Msg(MSG_KEY_DOWN,0,SC_INS+SCF_SHIFT);
|
||||
break;
|
||||
case FMR_CHG_DSK:
|
||||
Msg(MSG_KEY_DOWN,'m',0);
|
||||
break;
|
||||
case FMR_FORMAT:
|
||||
Msg(MSG_KEY_DOWN,'f',0);
|
||||
break;
|
||||
case FMR_MOUNT_ISO:
|
||||
Msg(MSG_KEY_DOWN,'i',0);
|
||||
break;
|
||||
case FMR_UNMOUNT:
|
||||
Msg(MSG_KEY_DOWN,'u',0);
|
||||
break;
|
||||
case FMR_MAKE_ISO:
|
||||
Msg(MSG_KEY_DOWN,'M',0);
|
||||
break;
|
||||
case FMR_BURN_ISO:
|
||||
Msg(MSG_KEY_DOWN,'B',0);
|
||||
break;
|
||||
case FMR_HELP:
|
||||
Msg(MSG_KEY_DOWN,CH_CTRLM,0x43200000432);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
U8 *fm_ip_str=NULL;
|
||||
U0 (*fp_old_final_screen_update)(CDC *dc);
|
||||
|
||||
U0 FMFinalScreenUpdate(CDC *dc)
|
||||
{
|
||||
if (fm_ip_str) {
|
||||
dc->color=LTRED;
|
||||
GrPrint(dc,ip.pos.x,ip.pos.y,"%s",fm_ip_str);
|
||||
}
|
||||
(*fp_old_final_screen_update)(dc);
|
||||
}
|
||||
|
||||
public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
|
||||
{//File manager. Also, used to choose files and dirs.
|
||||
CDirEntry *head=NULL,*tempde,*tempde1,*tempde2;
|
||||
I64 sc,ch,a1,a2,msg_code;
|
||||
CDoc *doc=NULL,*old_put_doc=DocPut,*old_display_doc=DocDisplay;
|
||||
U8 *res=NULL,*st,*st2,*old_cur_dir=CurDir;
|
||||
CDocEntry *doc_ce=NULL,*doc_e;
|
||||
Bool okay;
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
fp_old_final_screen_update=gr.fp_final_screen_update;
|
||||
MenuFilePush("::/Doc/FileMgrPullDown.TXT");
|
||||
FMRebuildDoc(&doc,&head,mode);
|
||||
if (tempde1=Cd2DirEntry(head,old_cur_dir))
|
||||
doc->cur_entry=tempde1->user_data;
|
||||
while (tempde1) {
|
||||
if (tempde1->attr&RS_ATTR_DIR)
|
||||
tempde1->user_data(CDocEntry *)->de_flags&=~DOCEF_CHECKED_COLLAPSED;
|
||||
tempde1=tempde1->parent;
|
||||
}
|
||||
do {
|
||||
DocUnlock(doc);
|
||||
do msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
|
||||
1<<MSG_IP_R_UP);
|
||||
while (Fs!=sys_focus_task);
|
||||
DocLock(doc);
|
||||
switch (msg_code) {
|
||||
case MSG_IP_R_UP:
|
||||
DocUnlock(doc);
|
||||
FMRightClick;
|
||||
DocLock(doc);
|
||||
break;
|
||||
case MSG_IP_L_DOWN:
|
||||
doc_ce=doc->cur_entry;
|
||||
fm_ip_str=doc_ce->tag;
|
||||
gr.fp_final_screen_update=&FMFinalScreenUpdate;
|
||||
break;
|
||||
case MSG_IP_L_UP:
|
||||
if (doc_ce) {
|
||||
gr.fp_final_screen_update=fp_old_final_screen_update;
|
||||
if (WinCursorPosSet(Fs,a1+Fs->pix_left+Fs->scroll_x,
|
||||
a2+Fs->pix_top+Fs->scroll_y,TRUE)) {
|
||||
doc_e=doc->cur_entry;
|
||||
if (doc_e!=doc_ce) {
|
||||
st2=NULL;
|
||||
if (doc_e->type_u8==DOCT_MENU_VAL) {
|
||||
tempde1=doc_e->user_data;
|
||||
if (tempde1=tempde1->parent)
|
||||
st2=StrNew(tempde1->full_name);
|
||||
} else if (doc_e->type_u8==DOCT_TREE) {
|
||||
tempde1=doc_e->user_data;
|
||||
st2=StrNew(tempde1->full_name);
|
||||
}
|
||||
if (st2 && doc_ce->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc_ce->user_data;
|
||||
Silent;
|
||||
Move(tempde->full_name,st2);
|
||||
Silent(OFF);
|
||||
FMRebuildDoc(&doc,&head,mode);
|
||||
} else if (st2 && doc_ce->type_u8==DOCT_TREE) {
|
||||
tempde=doc_ce->user_data;
|
||||
okay=TRUE;
|
||||
tempde2=tempde1;
|
||||
while (tempde2) {
|
||||
if (tempde2!=tempde)
|
||||
tempde2=tempde2->parent;
|
||||
else {
|
||||
okay=FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (okay) {
|
||||
if (*tempde1->name)
|
||||
st=MStrPrint("%s/%s",tempde1->full_name,tempde->name);
|
||||
else
|
||||
st=MStrPrint("%s%s",tempde1->full_name,tempde->name);
|
||||
if (StrCmp(tempde->full_name,st)) {
|
||||
Silent;
|
||||
CopyTree(tempde->full_name,st);
|
||||
DelTree(tempde->full_name);
|
||||
Silent(OFF);
|
||||
FMRebuildDoc(&doc,&head,mode);
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
Free(st2);
|
||||
FlushMsgs;
|
||||
} else
|
||||
if (doc_e->type_u8==DOCT_MENU_VAL) {
|
||||
DocUnlock(doc);
|
||||
Ed(doc_e->user_data(CDirEntry *)->full_name);
|
||||
DocLock(doc);
|
||||
}
|
||||
doc_ce=NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSG_KEY_DOWN:
|
||||
doc_ce=NULL;
|
||||
ch=a1; sc=a2;
|
||||
if (sc.u8[0]==SC_DELETE && !(sc&(SCF_SHIFT|SCF_CTRL)))
|
||||
ch=CH_CTRLY;
|
||||
if (ch && sc&SCF_ALT) goto fm_regular_key;
|
||||
switch (ch) {
|
||||
case '\n':
|
||||
DocUnlock(doc);
|
||||
FMRightClick;
|
||||
DocLock(doc);
|
||||
break;
|
||||
start:
|
||||
DocUnlock(doc);
|
||||
case CH_CTRLV:
|
||||
FMCopy(doc);
|
||||
break;
|
||||
case 'r':
|
||||
FMRename(doc);
|
||||
break;
|
||||
case 'd':
|
||||
FMMkDir(doc);
|
||||
break;
|
||||
case CH_CTRLY:
|
||||
FMDelete(doc);
|
||||
break;
|
||||
case 'm':
|
||||
FMChgDsk(doc);
|
||||
break;
|
||||
case 'i':
|
||||
FMMountISO(doc);
|
||||
break;
|
||||
case 'u':
|
||||
FMUnmount(doc);
|
||||
break;
|
||||
case 'M':
|
||||
FMMakeISO(doc);
|
||||
break;
|
||||
case 'B':
|
||||
FMBurnISO(doc);
|
||||
break;
|
||||
case 'f':
|
||||
FMFmtDrv(doc);
|
||||
break;
|
||||
end:
|
||||
FMRebuildDoc(&doc,&head,mode);
|
||||
break;
|
||||
case CH_SHIFT_ESC:
|
||||
break;
|
||||
case CH_SPACE:
|
||||
if (doc->cur_entry->type_u8==DOCT_MENU_VAL) {
|
||||
DocUnlock(doc);
|
||||
Ed(doc->cur_entry->user_data(CDirEntry *)->full_name);
|
||||
DocLock(doc);
|
||||
} else
|
||||
goto fm_regular_key;
|
||||
break;
|
||||
case CH_SHIFT_SPACE:
|
||||
if (doc->cur_entry->type_u8==DOCT_MENU_VAL) {
|
||||
DocUnlock(doc);
|
||||
Plain(doc->cur_entry->user_data(CDirEntry *)->full_name);
|
||||
DocLock(doc);
|
||||
} else
|
||||
goto fm_regular_key;
|
||||
break;
|
||||
case CH_ESC:
|
||||
doc_ce=doc->cur_entry;
|
||||
tempde=doc_ce->user_data;
|
||||
if (mode==FM_PICK_FILE && doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
res=StrNew(tempde->full_name,mem_task);
|
||||
else if (mode==FM_PICK_DIR) {
|
||||
if (doc_ce->type_u8==DOCT_TREE)
|
||||
res=StrNew(tempde->full_name,mem_task);
|
||||
else if (doc_ce->type_u8==DOCT_MENU_VAL &&
|
||||
(tempde=tempde->parent))
|
||||
res=StrNew(tempde->full_name,mem_task);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (sc.u8[0]==SC_INS && sc&SCF_SHIFT && !(sc&SCF_CTRL)) {
|
||||
FMCopy(doc);
|
||||
FMRebuildDoc(&doc,&head,mode);
|
||||
} else if (sc.u8[0]==SC_F5) {
|
||||
if (doc->cur_entry->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc->cur_entry->user_data;
|
||||
DocUnlock(doc);
|
||||
if (sc&SCF_SHIFT)
|
||||
AdamFile(tempde->full_name);
|
||||
else
|
||||
PopUpFile(tempde->full_name);
|
||||
DocLock(doc);
|
||||
}
|
||||
} else {
|
||||
fm_regular_key:
|
||||
DocUnlock(doc);
|
||||
PutKey(ch,sc);
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while (ch!=CH_ESC && ch!=CH_SHIFT_ESC);
|
||||
gr.fp_final_screen_update=fp_old_final_screen_update;
|
||||
Fs->put_doc =old_put_doc;
|
||||
Fs->display_doc=old_display_doc;
|
||||
SettingsPop;
|
||||
DocDel(doc);
|
||||
DirTreeDel(head);
|
||||
Cd(old_cur_dir);
|
||||
Free(old_cur_dir);
|
||||
if (mode!=FM_NORMAL && !res)
|
||||
res=StrNew("",mem_task);
|
||||
MenuPop;
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,793 @@
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
U0 DirFileDoc(CDoc *doc,CDirEntry *tempde)
|
||||
{
|
||||
while (tempde) {
|
||||
if (tempde->attr & RS_ATTR_DIR) {
|
||||
tempde->user_data=DocPrint(doc,"$$TR,\"%s\",U=0x%X$$",tempde->name,tempde);
|
||||
DocPrint(doc,"\n$$ID,+2$$");
|
||||
if (tempde->sub)
|
||||
DirFileDoc(doc,tempde->sub);
|
||||
DocPrint(doc,"$$ID,-2$$");
|
||||
} else {
|
||||
tempde->user_data=DocPrint(doc,"$$MU,\"%s\",U=0x%X$$",tempde->name,tempde);
|
||||
DocPrint(doc,"\n");
|
||||
}
|
||||
tempde=tempde->next;
|
||||
}
|
||||
}
|
||||
|
||||
#help_index "File/Cmd Line (Typically);Cmd Line (Typically)"
|
||||
|
||||
#define FM_NORMAL 0
|
||||
#define FM_PICK_FILE 1
|
||||
#define FM_PICK_DIR 2
|
||||
|
||||
class CFMUncollapsedLst
|
||||
{
|
||||
CFMUncollapsedLst *next;
|
||||
U8 *name;
|
||||
};
|
||||
|
||||
CFMUncollapsedLst *FMCollectUncollapsedLst(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_e=doc->head.next;
|
||||
CFMUncollapsedLst *res=NULL,*tempc;
|
||||
CDirEntry *tempde;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type_u8==DOCT_TREE) {
|
||||
if (!(doc_e->de_flags&DOCEF_CHECKED_COLLAPSED)) {
|
||||
if (tempde=doc_e->user_data) {
|
||||
tempc=MAlloc(sizeof(CFMUncollapsedLst));
|
||||
tempc->next=res;
|
||||
res=tempc;
|
||||
tempc->name=StrNew(tempde->full_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 FMMarkUncollapsed(CDoc *doc,CFMUncollapsedLst *tempc,
|
||||
U8 *cur_entry,U8 *next_entry)
|
||||
{
|
||||
CDocEntry *doc_e=doc->head.next;
|
||||
CFMUncollapsedLst *tempc1;
|
||||
CDirEntry *tempde;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type_u8==DOCT_TREE) {
|
||||
tempde=doc_e->user_data;
|
||||
tempc1=tempc;
|
||||
while (tempc1) {
|
||||
if (!StrCmp(tempc1->name,tempde->full_name)) {
|
||||
doc_e->de_flags&=~DOCEF_CHECKED_COLLAPSED;
|
||||
break;
|
||||
}
|
||||
tempc1=tempc1->next;
|
||||
}
|
||||
if (cur_entry) {
|
||||
if (!StrNCmp(cur_entry,tempde->full_name,StrLen(tempde->full_name))) {
|
||||
doc->cur_entry=doc_e;
|
||||
if (StrLen(tempde->full_name)==StrLen(cur_entry))
|
||||
cur_entry=NULL;
|
||||
} else if (next_entry) {
|
||||
if (!StrNCmp(next_entry,
|
||||
tempde->full_name,StrLen(tempde->full_name))) {
|
||||
doc->cur_entry=doc_e;
|
||||
if (StrLen(tempde->full_name)==StrLen(next_entry))
|
||||
cur_entry=NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (doc_e->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc_e->user_data;
|
||||
if (cur_entry) {
|
||||
if (!StrNCmp(cur_entry,tempde->full_name,StrLen(tempde->full_name))) {
|
||||
doc->cur_entry=doc_e;
|
||||
if (StrLen(tempde->full_name)==StrLen(cur_entry))
|
||||
cur_entry=NULL;
|
||||
} else if (next_entry) {
|
||||
if (!StrNCmp(next_entry,
|
||||
tempde->full_name,StrLen(tempde->full_name))) {
|
||||
doc->cur_entry=doc_e;
|
||||
if (StrLen(tempde->full_name)==StrLen(next_entry))
|
||||
cur_entry=NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMDelUncollapsedLst(CFMUncollapsedLst *tempc)
|
||||
{
|
||||
CFMUncollapsedLst *tempc1;
|
||||
while (tempc) {
|
||||
tempc1=tempc->next;
|
||||
Free(tempc->name);
|
||||
Free(tempc);
|
||||
tempc=tempc1;
|
||||
}
|
||||
}
|
||||
|
||||
CDirEntry *FMRebuildDocDrv(U8 drv_let,CDoc *doc,CDirEntry **_head,Bool init)
|
||||
{
|
||||
CDirEntry *tempde,*tempde1;
|
||||
U8 *st;
|
||||
tempde=CAlloc(sizeof(CDirEntry));
|
||||
tempde->full_name=MStrPrint("%C:/",drv_let);
|
||||
tempde->attr=RS_ATTR_DIR;
|
||||
st=MStrPrint("%c:/*",drv_let);
|
||||
if (init)
|
||||
tempde->sub=tempde1=FilesFind(st,FUF_RECURSE);
|
||||
else
|
||||
tempde1=NULL;
|
||||
Free(st);
|
||||
tempde->user_data=DocPrint(doc,"$$TR,\"%s\",U=0x%X$$",tempde->full_name,tempde);
|
||||
tempde->next=*_head;
|
||||
*_head=tempde;
|
||||
DocPrint(doc,"\n$$ID,+2$$");
|
||||
DocBottom(doc);
|
||||
if (init) {
|
||||
DirFileDoc(doc,tempde1);
|
||||
while (tempde1) {
|
||||
tempde1->parent=tempde;
|
||||
tempde1=tempde1->next;
|
||||
}
|
||||
}
|
||||
DocPrint(doc,"$$ID,-2$$");
|
||||
return tempde;
|
||||
}
|
||||
|
||||
U0 FMRebuildDoc(CDoc **_doc,CDirEntry **_head,I64 mode)
|
||||
{
|
||||
CDrv *dv;
|
||||
I64 i;
|
||||
CDoc *doc=*_doc,*doc2=sys_clipboard_doc,*parent_doc;
|
||||
CFMUncollapsedLst *tempc=NULL;
|
||||
U8 *cur_entry=NULL,*next_entry=NULL;
|
||||
CDocEntry *doc_ce;
|
||||
CDirEntry *tempde,*tempde1,*cur_tree_entry;
|
||||
if (!doc)
|
||||
parent_doc=DocPut;
|
||||
else {
|
||||
parent_doc=doc->parent_doc;
|
||||
Fs->put_doc=Fs->display_doc=NULL;
|
||||
DocUnlock(doc);
|
||||
WinMgrSync;
|
||||
DocLock(doc);
|
||||
cur_tree_entry=NULL;
|
||||
doc_ce=doc->cur_entry;
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
cur_tree_entry=doc_ce->user_data;
|
||||
if (cur_tree_entry)
|
||||
cur_entry=StrNew(cur_tree_entry->full_name);
|
||||
tempde=NULL;
|
||||
if (doc_ce!=doc)
|
||||
doc_ce=doc_ce->next;
|
||||
while (doc_ce!=doc) {
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=doc_ce->user_data;
|
||||
else
|
||||
tempde=NULL;
|
||||
if (tempde) {
|
||||
tempde1=tempde->parent;
|
||||
while (tempde1) {
|
||||
if (tempde1==cur_tree_entry) {
|
||||
tempde=NULL;
|
||||
break;
|
||||
} else
|
||||
tempde1=tempde1->parent;
|
||||
}
|
||||
if (tempde)
|
||||
break;
|
||||
}
|
||||
doc_ce=doc_ce->next;
|
||||
}
|
||||
if (tempde)
|
||||
next_entry=StrNew(tempde->full_name);
|
||||
|
||||
tempc=FMCollectUncollapsedLst(doc);
|
||||
DocDel(doc);
|
||||
}
|
||||
if (*_head) {
|
||||
DirTreeDel(*_head);
|
||||
*_head=NULL;
|
||||
}
|
||||
doc=DocNew;
|
||||
doc->desc='FileMan';
|
||||
doc->parent_doc=parent_doc;
|
||||
doc->flags|=DOCF_FORM;
|
||||
switch (mode) {
|
||||
case FM_NORMAL:
|
||||
DocPrint(doc,"$$PURPLE$$File Manager\n\n"
|
||||
"$$LK,\"Click for Help\",A=\"FI:::/Doc/FileMgr.DD\"$$\n\n");
|
||||
break;
|
||||
case FM_PICK_FILE:
|
||||
DocPrint(doc,"$$PURPLE$$Pick file and press <ESC>\n\n");
|
||||
doc->flags|=DOCF_MIN_SIZE;
|
||||
break;
|
||||
case FM_PICK_DIR:
|
||||
DocPrint(doc,"$$PURPLE$$Pick directory and press <ESC>\n\n");
|
||||
doc->flags|=DOCF_MIN_SIZE;
|
||||
break;
|
||||
}
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
for (i=0;i<NUM_DRVS;i++) {
|
||||
dv=&blkdev.drvs[i];
|
||||
if (dv->bd->type==BDT_ATAPI) {
|
||||
if (dv->bd->flags&BDF_INITIALIZED)
|
||||
tempde=FMRebuildDocDrv(Drv2Let(dv),doc,_head,TRUE);
|
||||
else {
|
||||
tempde=FMRebuildDocDrv(Drv2Let(dv),doc,_head,FALSE);
|
||||
tempde->flags|=DEF_NOT_INITIALIZED;
|
||||
}
|
||||
} else if (dv->fs_type==FSt_REDSEA || dv->fs_type==FSt_FAT32)
|
||||
FMRebuildDocDrv(Drv2Let(dv),doc,_head,TRUE);
|
||||
}
|
||||
DocTop(doc);
|
||||
FMMarkUncollapsed(doc,tempc,cur_entry,next_entry);
|
||||
DocCenter(doc);
|
||||
DocRst(doc2,TRUE);
|
||||
FMDelUncollapsedLst(tempc);
|
||||
Free(cur_entry);
|
||||
Free(next_entry);
|
||||
*_doc=doc;
|
||||
DocLock(doc);
|
||||
Fs->put_doc=Fs->display_doc=doc;
|
||||
}
|
||||
|
||||
U0 FMRename(CDoc *doc)
|
||||
{
|
||||
CEdFileName fn;
|
||||
CDocEntry *doc_e=doc->cur_entry;
|
||||
CDirEntry *tempde=NULL,*parent;
|
||||
if (doc_e->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc_e->user_data;
|
||||
if (parent=tempde->parent) {
|
||||
Cd(parent->full_name);
|
||||
StrCpy(fn.name,tempde->name);
|
||||
if (DocForm(&fn)) {
|
||||
Silent;
|
||||
Move(tempde->name,fn.name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
} else if (doc_e->type_u8==DOCT_TREE) {
|
||||
tempde=doc_e->user_data;
|
||||
if (parent=tempde->parent) {
|
||||
Cd(parent->full_name);
|
||||
StrCpy(fn.name,tempde->name);
|
||||
if (DocForm(&fn)) {
|
||||
if (StrCmp(tempde->name,fn.name)) {
|
||||
Silent;
|
||||
if (CopyTree(tempde->name,fn.name))
|
||||
DelTree(tempde->name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMMkDir(CDoc *doc)
|
||||
{
|
||||
CEdFileName fn;
|
||||
CDocEntry *doc_e=doc->cur_entry;
|
||||
CDirEntry *tempde=NULL,*parent;
|
||||
*fn.name=0;
|
||||
if (doc_e->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc_e->user_data;
|
||||
if (parent=tempde->parent) {
|
||||
Cd(parent->full_name);
|
||||
if (DocForm(&fn)) {
|
||||
Silent;
|
||||
MkDir(fn.name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
} else if (doc_e->type_u8==DOCT_TREE) {
|
||||
tempde=doc_e->user_data;
|
||||
Cd(tempde->full_name);
|
||||
if (DocForm(&fn)) {
|
||||
Silent;
|
||||
MkDir(fn.name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMDelete(CDoc *doc)
|
||||
{
|
||||
U8 *st;
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
if (doc_ce->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc_ce->user_data;
|
||||
Silent;
|
||||
st=MStrPrint("Delete: %s",tempde->full_name);
|
||||
if (PopUpCancelOk(st))
|
||||
Del(tempde->full_name);
|
||||
Free(st);
|
||||
Silent(OFF);
|
||||
} else if (doc_ce->type_u8==DOCT_TREE) {
|
||||
tempde=doc_ce->user_data;
|
||||
Silent;
|
||||
st=MStrPrint("Delete: %s",tempde->full_name);
|
||||
if (PopUpCancelOk(st))
|
||||
DelTree(tempde->full_name);
|
||||
Free(st);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMChgDsk(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=doc_ce->user_data;
|
||||
else
|
||||
tempde=NULL;
|
||||
if (tempde) {
|
||||
while (tempde->parent)
|
||||
tempde=tempde->parent;
|
||||
Silent;
|
||||
ChgDsk(*tempde->full_name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMMountISO(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
if (doc_ce->type_u8==DOCT_MENU_VAL && (tempde=doc_ce->user_data))
|
||||
MountFile(tempde->full_name);
|
||||
}
|
||||
|
||||
U0 FMUnmount(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
I64 drv_let;
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=doc_ce->user_data;
|
||||
else
|
||||
tempde=NULL;
|
||||
if (tempde) {
|
||||
while (tempde->parent)
|
||||
tempde=tempde->parent;
|
||||
drv_let=*tempde->full_name;
|
||||
if (Let2BlkDev(drv_let)!=Let2BlkDev(':'))
|
||||
Unmount(drv_let);
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMFmtDrv(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
U8 *st=NULL;
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=doc_ce->user_data;
|
||||
else
|
||||
tempde=NULL;
|
||||
if (tempde) {
|
||||
while (tempde->parent)
|
||||
tempde=tempde->parent;
|
||||
st=MStrPrint("Format Drive '%c'?\nAre You Sure?\n",*tempde->full_name);
|
||||
if (PopUpCancelOk(st)) {
|
||||
Silent;
|
||||
Fmt(*tempde->full_name,,FALSE);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
|
||||
U0 FMMakeISO(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
U8 *st;
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=doc_ce->user_data;
|
||||
else
|
||||
tempde=NULL;
|
||||
if (tempde) {
|
||||
if (doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=tempde->parent;
|
||||
if (tempde && *tempde->full_name) {
|
||||
Silent;
|
||||
if (tempde->full_name[StrLen(tempde->full_name)-1]=='/')
|
||||
st=MStrPrint("%s*",tempde->full_name);
|
||||
else
|
||||
st=MStrPrint("%s/*",tempde->full_name);
|
||||
ISO9660ISO(,st);
|
||||
Free(st);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMBurnISO(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
CDirEntry *tempde;
|
||||
if (doc_ce->type_u8==DOCT_TREE || doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde=doc_ce->user_data;
|
||||
else
|
||||
tempde=NULL;
|
||||
if (tempde) {
|
||||
while (tempde->parent)
|
||||
tempde=tempde->parent;
|
||||
Silent;
|
||||
DVDImageWrite(*tempde->full_name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
|
||||
U0 FMCopy(CDoc *doc)
|
||||
{
|
||||
CDoc *doc2=sys_clipboard_doc;
|
||||
U8 *st;
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_e;
|
||||
CDirEntry *tempde,*tempde1=NULL,*tempde2;
|
||||
Bool unlock_doc2=DocLock(doc2);
|
||||
doc_e=doc2->head.next;
|
||||
|
||||
tempde1=doc_ce->user_data;
|
||||
if (doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
tempde1=tempde1->parent;
|
||||
else if (doc_ce->type_u8!=DOCT_TREE)
|
||||
tempde1=NULL;
|
||||
if (tempde1) {
|
||||
while (doc_e!=doc2) {
|
||||
if (doc_e->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc_e->user_data;
|
||||
tempde->flags|=DEF_PROCESSED;
|
||||
tempde2=tempde->parent;
|
||||
if (!tempde2 || !(tempde2->flags&DEF_PROCESSED)) {
|
||||
Silent;
|
||||
Copy(tempde->full_name,tempde1->full_name);
|
||||
Silent(OFF);
|
||||
}
|
||||
} else if (doc_e->type_u8==DOCT_TREE) {
|
||||
tempde=doc_e->user_data;
|
||||
tempde->flags|=DEF_PROCESSED;
|
||||
tempde2=tempde->parent;
|
||||
if (!tempde2 || !(tempde2->flags&DEF_PROCESSED)) {
|
||||
Silent;
|
||||
if (*tempde1->name)
|
||||
st=MStrPrint("%s/%s",tempde1->full_name,tempde->name);
|
||||
else
|
||||
st=MStrPrint("%s%s",tempde1->full_name,tempde->name);
|
||||
CopyTree(tempde->full_name,st);
|
||||
Free(st);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
}
|
||||
if (unlock_doc2)
|
||||
DocUnlock(doc2);
|
||||
}
|
||||
|
||||
#define FMR_INCLUDE 0
|
||||
#define FMR_ADAM_INCLUDE 1
|
||||
#define FMR_DELETE 2
|
||||
#define FMR_RENAME 3
|
||||
#define FMR_MKDIR 4
|
||||
#define FMR_PLAIN 5
|
||||
#define FMR_PASTE 6
|
||||
#define FMR_CHG_DSK 7
|
||||
#define FMR_FORMAT 8
|
||||
#define FMR_MOUNT_ISO 9
|
||||
#define FMR_UNMOUNT 10
|
||||
#define FMR_MAKE_ISO 11
|
||||
#define FMR_BURN_ISO 12
|
||||
#define FMR_HELP 13
|
||||
|
||||
I64 PopUpFMRight(U8 *header=NULL,U8 *footer=NULL)
|
||||
{
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
if (header) DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"$$CM+LX,1,1 $$$$BT,\"INCLUDE \",LE=FMR_INCLUDE$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"ADAM INCLUDE \",LE=FMR_ADAM_INCLUDE$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"DELETE \",LE=FMR_DELETE$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"RENAME \",LE=FMR_RENAME$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"MAKE DIRECTORY \",LE=FMR_MKDIR$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"PLAIN-TEXT EDIT \",LE=FMR_PLAIN$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"PASTE CLIPBOARD FILES \",LE=FMR_PASTE$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"CHANGE DISK(MOUNT IT) \",LE=FMR_CHG_DSK$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"FORMAT \",LE=FMR_FORMAT$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"MOUNT ISO.C FILE \",LE=FMR_MOUNT_ISO$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"UNMOUNT \",LE=FMR_UNMOUNT$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"MAKE ISO (CD/DVD) FILE\",LE=FMR_MAKE_ISO$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"BURN ISO (CD/DVD) FILE\",LE=FMR_BURN_ISO$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"HELP \",LE=FMR_HELP$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"CANCEL \",LE=DOCM_CANCEL$$\n");
|
||||
if (footer) DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
U0 FMRightClick()
|
||||
{
|
||||
switch (PopUpFMRight) {
|
||||
case FMR_INCLUDE:
|
||||
Msg(MSG_KEY_DOWN,0,0x3F0000003F);
|
||||
break;
|
||||
case FMR_ADAM_INCLUDE:
|
||||
Msg(MSG_KEY_DOWN,0,0x23F0000023F);
|
||||
break;
|
||||
case FMR_DELETE:
|
||||
Msg(MSG_KEY_DOWN,CH_CTRLY,0);
|
||||
break;
|
||||
case FMR_RENAME:
|
||||
Msg(MSG_KEY_DOWN,'r',0);
|
||||
break;
|
||||
case FMR_MKDIR:
|
||||
Msg(MSG_KEY_DOWN,'d',0);
|
||||
break;
|
||||
case FMR_PLAIN:
|
||||
Msg(MSG_KEY_DOWN,CH_SHIFT_SPACE,0);
|
||||
break;
|
||||
case FMR_PASTE:
|
||||
Msg(MSG_KEY_DOWN,0,SC_INS+SCF_SHIFT);
|
||||
break;
|
||||
case FMR_CHG_DSK:
|
||||
Msg(MSG_KEY_DOWN,'m',0);
|
||||
break;
|
||||
case FMR_FORMAT:
|
||||
Msg(MSG_KEY_DOWN,'f',0);
|
||||
break;
|
||||
case FMR_MOUNT_ISO:
|
||||
Msg(MSG_KEY_DOWN,'i',0);
|
||||
break;
|
||||
case FMR_UNMOUNT:
|
||||
Msg(MSG_KEY_DOWN,'u',0);
|
||||
break;
|
||||
case FMR_MAKE_ISO:
|
||||
Msg(MSG_KEY_DOWN,'M',0);
|
||||
break;
|
||||
case FMR_BURN_ISO:
|
||||
Msg(MSG_KEY_DOWN,'B',0);
|
||||
break;
|
||||
case FMR_HELP:
|
||||
Msg(MSG_KEY_DOWN,CH_CTRLM,0x43200000432);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
U8 *fm_ip_str=NULL;
|
||||
U0 (*fp_old_final_screen_update)(CDC *dc);
|
||||
|
||||
U0 FMFinalScreenUpdate(CDC *dc)
|
||||
{
|
||||
if (fm_ip_str) {
|
||||
dc->color=LTRED;
|
||||
GrPrint(dc,ip.pos.x,ip.pos.y,"%s",fm_ip_str);
|
||||
}
|
||||
(*fp_old_final_screen_update)(dc);
|
||||
}
|
||||
|
||||
public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
|
||||
{//File manager. Also, used to choose files and dirs.
|
||||
CDirEntry *head=NULL,*tempde,*tempde1,*tempde2;
|
||||
I64 sc,ch,a1,a2,msg_code;
|
||||
CDoc *doc=NULL,*old_put_doc=DocPut,*old_display_doc=DocDisplay;
|
||||
U8 *res=NULL,*st,*st2,*old_cur_dir=CurDir;
|
||||
CDocEntry *doc_ce=NULL,*doc_e;
|
||||
Bool okay;
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
fp_old_final_screen_update=gr.fp_final_screen_update;
|
||||
MenuFilePush("::/Doc/FileMgrPullDown.DD");
|
||||
FMRebuildDoc(&doc,&head,mode);
|
||||
if (tempde1=Cd2DirEntry(head,old_cur_dir))
|
||||
doc->cur_entry=tempde1->user_data;
|
||||
while (tempde1) {
|
||||
if (tempde1->attr&RS_ATTR_DIR)
|
||||
tempde1->user_data(CDocEntry *)->de_flags&=~DOCEF_CHECKED_COLLAPSED;
|
||||
tempde1=tempde1->parent;
|
||||
}
|
||||
do {
|
||||
DocUnlock(doc);
|
||||
do msg_code=GetMsg(&a1,&a2,1<<MSG_KEY_DOWN|1<<MSG_IP_L_DOWN|1<<MSG_IP_L_UP|
|
||||
1<<MSG_IP_R_UP);
|
||||
while (Fs!=sys_focus_task);
|
||||
DocLock(doc);
|
||||
switch (msg_code) {
|
||||
case MSG_IP_R_UP:
|
||||
DocUnlock(doc);
|
||||
FMRightClick;
|
||||
DocLock(doc);
|
||||
break;
|
||||
case MSG_IP_L_DOWN:
|
||||
doc_ce=doc->cur_entry;
|
||||
fm_ip_str=doc_ce->tag;
|
||||
gr.fp_final_screen_update=&FMFinalScreenUpdate;
|
||||
break;
|
||||
case MSG_IP_L_UP:
|
||||
if (doc_ce) {
|
||||
gr.fp_final_screen_update=fp_old_final_screen_update;
|
||||
if (WinCursorPosSet(Fs,a1+Fs->pix_left+Fs->scroll_x,
|
||||
a2+Fs->pix_top+Fs->scroll_y,TRUE)) {
|
||||
doc_e=doc->cur_entry;
|
||||
if (doc_e!=doc_ce) {
|
||||
st2=NULL;
|
||||
if (doc_e->type_u8==DOCT_MENU_VAL) {
|
||||
tempde1=doc_e->user_data;
|
||||
if (tempde1=tempde1->parent)
|
||||
st2=StrNew(tempde1->full_name);
|
||||
} else if (doc_e->type_u8==DOCT_TREE) {
|
||||
tempde1=doc_e->user_data;
|
||||
st2=StrNew(tempde1->full_name);
|
||||
}
|
||||
if (st2 && doc_ce->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc_ce->user_data;
|
||||
Silent;
|
||||
Move(tempde->full_name,st2);
|
||||
Silent(OFF);
|
||||
FMRebuildDoc(&doc,&head,mode);
|
||||
} else if (st2 && doc_ce->type_u8==DOCT_TREE) {
|
||||
tempde=doc_ce->user_data;
|
||||
okay=TRUE;
|
||||
tempde2=tempde1;
|
||||
while (tempde2) {
|
||||
if (tempde2!=tempde)
|
||||
tempde2=tempde2->parent;
|
||||
else {
|
||||
okay=FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (okay) {
|
||||
if (*tempde1->name)
|
||||
st=MStrPrint("%s/%s",tempde1->full_name,tempde->name);
|
||||
else
|
||||
st=MStrPrint("%s%s",tempde1->full_name,tempde->name);
|
||||
if (StrCmp(tempde->full_name,st)) {
|
||||
Silent;
|
||||
CopyTree(tempde->full_name,st);
|
||||
DelTree(tempde->full_name);
|
||||
Silent(OFF);
|
||||
FMRebuildDoc(&doc,&head,mode);
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
Free(st2);
|
||||
FlushMsgs;
|
||||
} else
|
||||
if (doc_e->type_u8==DOCT_MENU_VAL) {
|
||||
DocUnlock(doc);
|
||||
Ed(doc_e->user_data(CDirEntry *)->full_name);
|
||||
DocLock(doc);
|
||||
}
|
||||
doc_ce=NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MSG_KEY_DOWN:
|
||||
doc_ce=NULL;
|
||||
ch=a1; sc=a2;
|
||||
if (sc.u8[0]==SC_DELETE && !(sc&(SCF_SHIFT|SCF_CTRL)))
|
||||
ch=CH_CTRLY;
|
||||
if (ch && sc&SCF_ALT) goto fm_regular_key;
|
||||
switch (ch) {
|
||||
case '\n':
|
||||
DocUnlock(doc);
|
||||
FMRightClick;
|
||||
DocLock(doc);
|
||||
break;
|
||||
start:
|
||||
DocUnlock(doc);
|
||||
case CH_CTRLV:
|
||||
FMCopy(doc);
|
||||
break;
|
||||
case 'r':
|
||||
FMRename(doc);
|
||||
break;
|
||||
case 'd':
|
||||
FMMkDir(doc);
|
||||
break;
|
||||
case CH_CTRLY:
|
||||
FMDelete(doc);
|
||||
break;
|
||||
case 'm':
|
||||
FMChgDsk(doc);
|
||||
break;
|
||||
case 'i':
|
||||
FMMountISO(doc);
|
||||
break;
|
||||
case 'u':
|
||||
FMUnmount(doc);
|
||||
break;
|
||||
case 'M':
|
||||
FMMakeISO(doc);
|
||||
break;
|
||||
case 'B':
|
||||
FMBurnISO(doc);
|
||||
break;
|
||||
case 'f':
|
||||
FMFmtDrv(doc);
|
||||
break;
|
||||
end:
|
||||
FMRebuildDoc(&doc,&head,mode);
|
||||
break;
|
||||
case CH_SHIFT_ESC:
|
||||
break;
|
||||
case CH_SPACE:
|
||||
if (doc->cur_entry->type_u8==DOCT_MENU_VAL) {
|
||||
DocUnlock(doc);
|
||||
Ed(doc->cur_entry->user_data(CDirEntry *)->full_name);
|
||||
DocLock(doc);
|
||||
} else
|
||||
goto fm_regular_key;
|
||||
break;
|
||||
case CH_SHIFT_SPACE:
|
||||
if (doc->cur_entry->type_u8==DOCT_MENU_VAL) {
|
||||
DocUnlock(doc);
|
||||
Plain(doc->cur_entry->user_data(CDirEntry *)->full_name);
|
||||
DocLock(doc);
|
||||
} else
|
||||
goto fm_regular_key;
|
||||
break;
|
||||
case CH_ESC:
|
||||
doc_ce=doc->cur_entry;
|
||||
tempde=doc_ce->user_data;
|
||||
if (mode==FM_PICK_FILE && doc_ce->type_u8==DOCT_MENU_VAL)
|
||||
res=StrNew(tempde->full_name,mem_task);
|
||||
else if (mode==FM_PICK_DIR) {
|
||||
if (doc_ce->type_u8==DOCT_TREE)
|
||||
res=StrNew(tempde->full_name,mem_task);
|
||||
else if (doc_ce->type_u8==DOCT_MENU_VAL &&
|
||||
(tempde=tempde->parent))
|
||||
res=StrNew(tempde->full_name,mem_task);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (sc.u8[0]==SC_INS && sc&SCF_SHIFT && !(sc&SCF_CTRL)) {
|
||||
FMCopy(doc);
|
||||
FMRebuildDoc(&doc,&head,mode);
|
||||
} else if (sc.u8[0]==SC_F5) {
|
||||
if (doc->cur_entry->type_u8==DOCT_MENU_VAL) {
|
||||
tempde=doc->cur_entry->user_data;
|
||||
DocUnlock(doc);
|
||||
if (sc&SCF_SHIFT)
|
||||
AdamFile(tempde->full_name);
|
||||
else
|
||||
PopUpFile(tempde->full_name);
|
||||
DocLock(doc);
|
||||
}
|
||||
} else {
|
||||
fm_regular_key:
|
||||
DocUnlock(doc);
|
||||
PutKey(ch,sc);
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while (ch!=CH_ESC && ch!=CH_SHIFT_ESC);
|
||||
gr.fp_final_screen_update=fp_old_final_screen_update;
|
||||
Fs->put_doc =old_put_doc;
|
||||
Fs->display_doc=old_display_doc;
|
||||
SettingsPop;
|
||||
DocDel(doc);
|
||||
DirTreeDel(head);
|
||||
Cd(old_cur_dir);
|
||||
Free(old_cur_dir);
|
||||
if (mode!=FM_NORMAL && !res)
|
||||
res=StrNew("",mem_task);
|
||||
MenuPop;
|
||||
return res;
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
#help_index "Install;File/Cmd Line (Typically);Cmd Line (Typically);"
|
||||
I64 Mount2(U8 boot_drv_let,CDoc *_doc,Bool repartition)
|
||||
{//If _doc, called by $LK,"::/Kernel/KCfg.CPP"$ else called by $LK,"Mount",A="MN:Mount"$().
|
||||
I64 cnt,res=0,num_hints,drv_let,type,unit;
|
||||
U8 blks_buf[STR_LEN],addr_buf[STR_LEN],base0_buf[STR_LEN],base1_buf[STR_LEN],
|
||||
*filename=NULL,*filename2=NULL;
|
||||
CATARep *head=NULL,*tempha;
|
||||
Bool one_drv,make_free;
|
||||
CDoc *doc;
|
||||
boot_drv_let=ToUpper(boot_drv_let);
|
||||
do {
|
||||
cnt=0;
|
||||
if (!_doc)
|
||||
DrvRep;
|
||||
"\n****** Mount Drives ******\n"
|
||||
"$$GREEN$$A$$FG$$-$$GREEN$$B$$FG$$ are RAM drives.\n"
|
||||
"$$GREEN$$C$$FG$$-$$GREEN$$L$$FG$$ are ATA hard drives.\n"
|
||||
"$$GREEN$$M$$FG$$-$$GREEN$$P$$FG$$ are ISO file read drives.\n"
|
||||
"$$GREEN$$Q$$FG$$-$$GREEN$$S$$FG$$ are ISO file write drives.\n"
|
||||
"$$GREEN$$T$$FG$$-$$GREEN$$Z$$FG$$ are ATAPI CD/DVD drives.\n"
|
||||
"\nDrive Letter ($$PURPLE$$<ENTER>$$FG$$ to exit):";
|
||||
drv_let=ToUpper(GetChar);
|
||||
'\n';
|
||||
if (type=Let2BlkDevType(drv_let)) {
|
||||
one_drv=FALSE;
|
||||
if (_doc) { //Called by $LK,"::/Kernel/KCfg.CPP"$
|
||||
doc=_doc;
|
||||
make_free=FALSE;
|
||||
} else { //Called by $LK,"Mount",A="MN:Mount"$()
|
||||
doc=DocNew;
|
||||
DocPrint(doc,"CBlkDev *bd;\n");
|
||||
make_free=TRUE;
|
||||
}
|
||||
unit=0;
|
||||
switch (type) {
|
||||
case BDT_RAM:
|
||||
"Addr of RAM disk ($$PURPLE$$<ENTER>$$FG$$ to MAlloc):";
|
||||
GetS(addr_buf,STR_LEN);
|
||||
case BDT_ISO_FILE_WRITE:
|
||||
"Blks of 512 bytes:";
|
||||
GetS(blks_buf,STR_LEN);
|
||||
break;
|
||||
case BDT_ISO_FILE_READ:
|
||||
filename=GetStr("File Name:");
|
||||
break;
|
||||
case BDT_ATA:
|
||||
case BDT_ATAPI:
|
||||
num_hints=ATARep(,,&head);
|
||||
if (type==BDT_ATAPI && boot_drv_let)
|
||||
"<ENTER> to use booted CD/DVD\n"; //Only $LK,"::/Kernel/KCfg.CPP"$
|
||||
do {
|
||||
if (num_hints)
|
||||
"Enter dev number or\nport with $$PURPLE$$0x$$FG$$ prefix.\n"
|
||||
"I/O Port Base0:\n";
|
||||
else
|
||||
"Include $$PURPLE$$0x$$FG$$ prefix.\nI/O Port Base0:\n";
|
||||
GetS(base0_buf,STR_LEN);
|
||||
} while (!Str2I64(base0_buf) && (type!=BDT_ATAPI || !boot_drv_let));
|
||||
if (1<=Str2I64(base0_buf)<=num_hints) {
|
||||
tempha=ATARepFind(head,Str2I64(base0_buf));
|
||||
StrPrint(base0_buf,"0x%X",tempha->base0);
|
||||
StrPrint(base1_buf,"0x%X",tempha->base1);
|
||||
unit=tempha->unit;
|
||||
} else if (type!=BDT_ATAPI || *base0_buf) {
|
||||
if (type==BDT_ATAPI)
|
||||
StrCpy(base1_buf,"0");
|
||||
else
|
||||
do {
|
||||
"I/O Port Base1:\n";
|
||||
GetS(base1_buf,STR_LEN);
|
||||
} while (!Str2I64(base1_buf));
|
||||
do {
|
||||
"\t$$PURPLE$$0$$FG$$=Master\n\t$$PURPLE$$1$$FG$$=Slave\nUnit:";
|
||||
unit=GetChar-'0';
|
||||
} while (!(0<=unit<=1));
|
||||
'\n';
|
||||
}
|
||||
LinkedLstDel(head);
|
||||
break;
|
||||
}
|
||||
DocPrint(doc,"bd=BlkDevNextFreeSlot(\'%C\',%d);bd->unit=%d;\n",
|
||||
drv_let,type,unit);
|
||||
switch (type) {
|
||||
case BDT_RAM:
|
||||
if (!*addr_buf) StrCpy(addr_buf,"0");
|
||||
DocPrint(doc,"bd->RAM_dsk=%s;\n",addr_buf);
|
||||
case BDT_ISO_FILE_WRITE:
|
||||
if (!*blks_buf) StrCpy(blks_buf,"0");
|
||||
DocPrint(doc,"bd->max_blk=(%s)-1;\n",blks_buf);
|
||||
break;
|
||||
case BDT_ISO_FILE_READ:
|
||||
filename2=FileNameAbs(filename);
|
||||
DocPrint(doc,"bd->file_dsk_name=AStrNew(\"%s\");\n",filename2);
|
||||
DocPrint(doc,"bd->drv_offset=19<<2+"
|
||||
"(DVD_BLK_SIZE*2+DVD_BOOT_LOADER_SIZE)/BLK_SIZE;\n");
|
||||
break;
|
||||
case BDT_ATA:
|
||||
case BDT_ATAPI:
|
||||
if (type==BDT_ATAPI && !*base0_buf) {
|
||||
DocPrint(doc,"GetBaseUnit(bd);\n"); //Only $LK,"::/Kernel/KCfg.CPP"$
|
||||
if (drv_let==boot_drv_let)
|
||||
make_free=TRUE;
|
||||
} else
|
||||
DocPrint(doc,"bd->base0=%s;bd->base1=%s;\n",base0_buf,base1_buf);
|
||||
if (type==BDT_ATA && repartition) {
|
||||
"\nReformat WHOLE drive!";
|
||||
one_drv=YorN;
|
||||
}
|
||||
break;
|
||||
}
|
||||
DocPrint(doc,"BlkDevAdd(bd,%d,%d);\n",one_drv,make_free);
|
||||
if (_doc) //Called by $LK,"::/Kernel/KCfg.CPP"$
|
||||
cnt++;
|
||||
else { //Called by $LK,"Mount",A="MN:Mount"$()
|
||||
if ((cnt=ExeDoc(doc)) && one_drv)
|
||||
PrtDsk(drv_let);
|
||||
DocDel(doc);
|
||||
}
|
||||
}
|
||||
res+=cnt;
|
||||
} while (cnt || !res && _doc); //At least 1 if Called by $LK,"::/Kernel/KCfg.CPP"$
|
||||
Free(filename);
|
||||
Free(filename2);
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 Mount(Bool repartition=FALSE)
|
||||
{//Mount drives.
|
||||
return Mount2(0,NULL,repartition);
|
||||
}
|
||||
|
||||
public U0 Unmount(U8 drv_let=0)
|
||||
{//Unmount drive(s).
|
||||
BlkDevDel(Let2BlkDev(drv_let));
|
||||
}
|
||||
|
||||
public U8 MountFile(U8 *filename)
|
||||
{//Mount ISO.C file.
|
||||
U8 *filename2=DftExt(filename,"ISO.C"),*filename3=FileNameAbs(filename2);
|
||||
CDrv *dv=DrvMakeFreeSlot(DrvNextFreeLet('M')); //First $LK,"BDT_ISO_FILE_READ",A="MN:BDT_ISO_FILE_READ"$
|
||||
CBlkDev *bd=BlkDevNextFreeSlot(dv->drv_let,BDT_ISO_FILE_READ);
|
||||
bd->drv_offset=19<<2+(DVD_BLK_SIZE*2+DVD_BOOT_LOADER_SIZE)/BLK_SIZE;
|
||||
bd->file_dsk_name=AStrNew(filename3);
|
||||
BlkDevAdd(bd,TRUE,TRUE);
|
||||
Free(filename3);
|
||||
Free(filename2);
|
||||
return dv->drv_let;
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
#help_index "Install;File/Cmd Line (Typically);Cmd Line (Typically);"
|
||||
I64 Mount2(U8 boot_drv_let,CDoc *_doc,Bool repartition)
|
||||
{//If _doc, called by $LK,"::/Kernel/KCfg.HC"$ else called by $LK,"Mount",A="MN:Mount"$().
|
||||
I64 cnt,res=0,num_hints,drv_let,type,unit;
|
||||
U8 blks_buf[STR_LEN],addr_buf[STR_LEN],base0_buf[STR_LEN],base1_buf[STR_LEN],
|
||||
*filename=NULL,*filename2=NULL;
|
||||
CATARep *head=NULL,*tempha;
|
||||
Bool one_drv,make_free;
|
||||
CDoc *doc;
|
||||
boot_drv_let=ToUpper(boot_drv_let);
|
||||
do {
|
||||
cnt=0;
|
||||
if (!_doc)
|
||||
DrvRep;
|
||||
"\n****** Mount Drives ******\n"
|
||||
"$$GREEN$$A$$FG$$-$$GREEN$$B$$FG$$ are RAM drives.\n"
|
||||
"$$GREEN$$C$$FG$$-$$GREEN$$L$$FG$$ are ATA hard drives.\n"
|
||||
"$$GREEN$$M$$FG$$-$$GREEN$$P$$FG$$ are ISO file read drives.\n"
|
||||
"$$GREEN$$Q$$FG$$-$$GREEN$$S$$FG$$ are ISO file write drives.\n"
|
||||
"$$GREEN$$T$$FG$$-$$GREEN$$Z$$FG$$ are ATAPI CD/DVD drives.\n"
|
||||
"\nDrive Letter ($$PURPLE$$<ENTER>$$FG$$ to exit):";
|
||||
drv_let=ToUpper(GetChar);
|
||||
'\n';
|
||||
if (type=Let2BlkDevType(drv_let)) {
|
||||
one_drv=FALSE;
|
||||
if (_doc) { //Called by $LK,"::/Kernel/KCfg.HC"$
|
||||
doc=_doc;
|
||||
make_free=FALSE;
|
||||
} else { //Called by $LK,"Mount",A="MN:Mount"$()
|
||||
doc=DocNew;
|
||||
DocPrint(doc,"CBlkDev *bd;\n");
|
||||
make_free=TRUE;
|
||||
}
|
||||
unit=0;
|
||||
switch (type) {
|
||||
case BDT_RAM:
|
||||
"Addr of RAM disk ($$PURPLE$$<ENTER>$$FG$$ to MAlloc):";
|
||||
GetS(addr_buf,STR_LEN);
|
||||
case BDT_ISO_FILE_WRITE:
|
||||
"Blks of 512 bytes:";
|
||||
GetS(blks_buf,STR_LEN);
|
||||
break;
|
||||
case BDT_ISO_FILE_READ:
|
||||
filename=GetStr("File Name:");
|
||||
break;
|
||||
case BDT_ATA:
|
||||
case BDT_ATAPI:
|
||||
num_hints=ATARep(,,&head);
|
||||
if (type==BDT_ATAPI && boot_drv_let)
|
||||
"<ENTER> to use booted CD/DVD\n"; //Only $LK,"::/Kernel/KCfg.HC"$
|
||||
do {
|
||||
if (num_hints)
|
||||
"Enter dev number or\nport with $$PURPLE$$0x$$FG$$ prefix.\n"
|
||||
"I/O Port Base0:\n";
|
||||
else
|
||||
"Include $$PURPLE$$0x$$FG$$ prefix.\nI/O Port Base0:\n";
|
||||
GetS(base0_buf,STR_LEN);
|
||||
} while (!Str2I64(base0_buf) && (type!=BDT_ATAPI || !boot_drv_let));
|
||||
if (1<=Str2I64(base0_buf)<=num_hints) {
|
||||
tempha=ATARepFind(head,Str2I64(base0_buf));
|
||||
StrPrint(base0_buf,"0x%X",tempha->base0);
|
||||
StrPrint(base1_buf,"0x%X",tempha->base1);
|
||||
unit=tempha->unit;
|
||||
} else if (type!=BDT_ATAPI || *base0_buf) {
|
||||
if (type==BDT_ATAPI)
|
||||
StrCpy(base1_buf,"0");
|
||||
else
|
||||
do {
|
||||
"I/O Port Base1:\n";
|
||||
GetS(base1_buf,STR_LEN);
|
||||
} while (!Str2I64(base1_buf));
|
||||
do {
|
||||
"\t$$PURPLE$$0$$FG$$=Master\n\t$$PURPLE$$1$$FG$$=Slave\nUnit:";
|
||||
unit=GetChar-'0';
|
||||
} while (!(0<=unit<=1));
|
||||
'\n';
|
||||
}
|
||||
LinkedLstDel(head);
|
||||
break;
|
||||
}
|
||||
DocPrint(doc,"bd=BlkDevNextFreeSlot(\'%C\',%d);bd->unit=%d;\n",
|
||||
drv_let,type,unit);
|
||||
switch (type) {
|
||||
case BDT_RAM:
|
||||
if (!*addr_buf) StrCpy(addr_buf,"0");
|
||||
DocPrint(doc,"bd->RAM_dsk=%s;\n",addr_buf);
|
||||
case BDT_ISO_FILE_WRITE:
|
||||
if (!*blks_buf) StrCpy(blks_buf,"0");
|
||||
DocPrint(doc,"bd->max_blk=(%s)-1;\n",blks_buf);
|
||||
break;
|
||||
case BDT_ISO_FILE_READ:
|
||||
filename2=FileNameAbs(filename);
|
||||
DocPrint(doc,"bd->file_dsk_name=AStrNew(\"%s\");\n",filename2);
|
||||
DocPrint(doc,"bd->drv_offset=19<<2+"
|
||||
"(DVD_BLK_SIZE*2+DVD_BOOT_LOADER_SIZE)/BLK_SIZE;\n");
|
||||
break;
|
||||
case BDT_ATA:
|
||||
case BDT_ATAPI:
|
||||
if (type==BDT_ATAPI && !*base0_buf) {
|
||||
DocPrint(doc,"GetBaseUnit(bd);\n"); //Only $LK,"::/Kernel/KCfg.HC"$
|
||||
if (drv_let==boot_drv_let)
|
||||
make_free=TRUE;
|
||||
} else
|
||||
DocPrint(doc,"bd->base0=%s;bd->base1=%s;\n",base0_buf,base1_buf);
|
||||
if (type==BDT_ATA && repartition) {
|
||||
"\nReformat WHOLE drive!";
|
||||
one_drv=YorN;
|
||||
}
|
||||
break;
|
||||
}
|
||||
DocPrint(doc,"BlkDevAdd(bd,%d,%d);\n",one_drv,make_free);
|
||||
if (_doc) //Called by $LK,"::/Kernel/KCfg.HC"$
|
||||
cnt++;
|
||||
else { //Called by $LK,"Mount",A="MN:Mount"$()
|
||||
if ((cnt=ExeDoc(doc)) && one_drv)
|
||||
PrtDsk(drv_let);
|
||||
DocDel(doc);
|
||||
}
|
||||
}
|
||||
res+=cnt;
|
||||
} while (cnt || !res && _doc); //At least 1 if Called by $LK,"::/Kernel/KCfg.HC"$
|
||||
Free(filename);
|
||||
Free(filename2);
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 Mount(Bool repartition=FALSE)
|
||||
{//Mount drives.
|
||||
return Mount2(0,NULL,repartition);
|
||||
}
|
||||
|
||||
public U0 Unmount(U8 drv_let=0)
|
||||
{//Unmount drive(s).
|
||||
BlkDevDel(Let2BlkDev(drv_let));
|
||||
}
|
||||
|
||||
public U8 MountFile(U8 *filename)
|
||||
{//Mount ISO.C file.
|
||||
U8 *filename2=DftExt(filename,"ISO.C"),*filename3=FileNameAbs(filename2);
|
||||
CDrv *dv=DrvMakeFreeSlot(DrvNextFreeLet('M')); //First $LK,"BDT_ISO_FILE_READ",A="MN:BDT_ISO_FILE_READ"$
|
||||
CBlkDev *bd=BlkDevNextFreeSlot(dv->drv_let,BDT_ISO_FILE_READ);
|
||||
bd->drv_offset=19<<2+(DVD_BLK_SIZE*2+DVD_BOOT_LOADER_SIZE)/BLK_SIZE;
|
||||
bd->file_dsk_name=AStrNew(filename3);
|
||||
BlkDevAdd(bd,TRUE,TRUE);
|
||||
Free(filename3);
|
||||
Free(filename2);
|
||||
return dv->drv_let;
|
||||
}
|
||||
-270
@@ -1,270 +0,0 @@
|
||||
#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)
|
||||
{//See $LK,"::/Demo/LastClass.CPP"$.
|
||||
I64 i,j,stars,*ptr;
|
||||
CMemberLst *ml;
|
||||
CDocEntry *doc_e;
|
||||
Bool unlock;
|
||||
CHashClass *tempc,*tempc2;
|
||||
if (depth>=max_depth) return TRUE;
|
||||
if (!(tempc=HashFind(class_name,Fs->hash_table,types))) {
|
||||
DocPrint(doc,"Class Not Found.\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (!ChkPtr(_d) || !ChkPtr(_d(U8 *)+tempc->size)) {
|
||||
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))
|
||||
return FALSE;
|
||||
unlock=DocLock(doc);
|
||||
DocPrint(doc,"Class:\"%s\"\n",class_name);
|
||||
ml=tempc->member_lst_and_root;
|
||||
while (ml) {
|
||||
tempc2=ml->member_class;
|
||||
ptr=_d(U8 *)+ml->offset;
|
||||
DocPrint(doc,"%08X ",ptr(U8 *)+offset);
|
||||
stars=tempc2->ptr_stars_cnt;
|
||||
tempc2=OptClassFwd(tempc2);
|
||||
tempc2-=tempc2->ptr_stars_cnt;
|
||||
if (tempc2->type & HTT_INTERNAL_TYPE) {
|
||||
DocPrint(doc,"$$GREEN$$%-20ts:$$FG$$",ml->str);
|
||||
if (stars==1 && (tempc2->raw_type==RT_I8 || tempc2->raw_type==RT_U8)) {
|
||||
ptr=*ptr;
|
||||
if (ChkPtr(ptr)) {
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM-P+RD,LEN=64,A=\"%%40ts\"$$\n");
|
||||
doc_e->data=ptr;
|
||||
DocDataFmt(doc,doc_e);
|
||||
} else
|
||||
DocPrint(doc,"%40ts\n",ptr);
|
||||
}
|
||||
} else if (!stars) {
|
||||
j=MinI64(ml->dim.total_cnt,32);
|
||||
if (tempc2->raw_type==RT_I8 || tempc2->raw_type==RT_U8) {
|
||||
if (j==1) {
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=U8,A=\"%%c\"$$\n");
|
||||
doc_e->data=ptr;
|
||||
} else
|
||||
DocPrint(doc,"%c\n",*ptr(U8 *));
|
||||
} else {
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM-P+RD,LEN=64,A=\"%%40ts\"$$\n");
|
||||
doc_e->data=ptr;
|
||||
DocDataFmt(doc,doc_e);
|
||||
} else
|
||||
DocPrint(doc,"%40ts\n",ptr);
|
||||
}
|
||||
}
|
||||
for (i=0;i<j;i++) {
|
||||
switch (tempc2->raw_type) {
|
||||
case RT_I0:
|
||||
case RT_U0:
|
||||
break;
|
||||
case RT_I8:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=I8,A=\"%%02X\"$$ ");
|
||||
doc_e->data=ptr(I8 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%02X ",*ptr(I8 *)++);
|
||||
break;
|
||||
case RT_U8:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=U8,A=\"%%02X\"$$ ");
|
||||
doc_e->data=ptr(U8 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%02X ",*ptr(U8 *)++);
|
||||
break;
|
||||
case RT_I16:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=I16,A=\"%%04X\"$$ ");
|
||||
doc_e->data=ptr(I16 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%04X ",*ptr(I16 *)++);
|
||||
break;
|
||||
case RT_U16:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=U16,A=\"%%04X\"$$ ");
|
||||
doc_e->data=ptr(U16 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%04X ",*ptr(U16 *)++);
|
||||
break;
|
||||
case RT_I32:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=I32,A=\"%%08X\"$$ ");
|
||||
doc_e->data=ptr(I32 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%08X ",*ptr(I32 *)++);
|
||||
break;
|
||||
case RT_U32:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=U32,A=\"%%08X\"$$ ");
|
||||
doc_e->data=ptr(U32 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%08X ",*ptr(U32 *)++);
|
||||
break;
|
||||
case RT_U64:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=U64,A=\"%%08X\"$$ ");
|
||||
doc_e->data=ptr(U64 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%08X ",*ptr(U64 *)++);
|
||||
break;
|
||||
case RT_F64:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=F64,A=\"%%16g\"$$ ");
|
||||
doc_e->data=ptr(F64 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%16g ",*ptr(I64 *)++);
|
||||
break;
|
||||
default:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,A=\"%%016X\"$$ ");
|
||||
doc_e->data=ptr(I64 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%016X ",*ptr(I64 *)++);
|
||||
}
|
||||
if (dynamic)
|
||||
DocDataFmt(doc,doc_e);
|
||||
}
|
||||
if (j<ml->dim.total_cnt)
|
||||
DocPrint(doc,"...");
|
||||
} else
|
||||
DocPrint(doc,"%016X",*ptr);
|
||||
DocPrint(doc,"\n");
|
||||
} else {
|
||||
if (depth<2) {
|
||||
if (stars==1 && !ChkPtr(*ptr))
|
||||
DocPrint(doc,"%-20ts:%016X\n",ml->str,*ptr);
|
||||
else {
|
||||
DocPrint(doc,"$$TR,\"%s\"$$\n",ml->str);
|
||||
DocPrint(doc,"$$ID,2$$");
|
||||
if (!stars)
|
||||
ClassRep2(doc,ptr,tempc2->str,depth+1,max_depth,dynamic);
|
||||
else if (stars==1)
|
||||
ClassRep2(doc,*ptr,tempc2->str,depth+1,max_depth,dynamic);
|
||||
DocPrint(doc,"$$ID,-2$$");
|
||||
}
|
||||
} else
|
||||
DocPrint(doc,"%-20ts\n",ml->str);
|
||||
}
|
||||
ml=ml->next;
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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;
|
||||
if (IsRaw)
|
||||
doc=DocNew;
|
||||
else {
|
||||
DocMax;
|
||||
doc=DocPut;
|
||||
}
|
||||
if (fun)
|
||||
ClassRep2(doc,_d,class_name,0,max_depth,FALSE,HTT_FUN,offset);
|
||||
else
|
||||
ClassRep2(doc,_d,class_name,0,max_depth,FALSE,HTT_CLASS,offset);
|
||||
DocPrint(doc,"\n");
|
||||
DocRecalc(doc);
|
||||
if (IsRaw) {
|
||||
DocDump(doc,100000);
|
||||
DocDel(doc);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
if (IsRaw)
|
||||
doc=DocNew;
|
||||
else {
|
||||
DocMax;
|
||||
doc=DocPut;
|
||||
}
|
||||
if (fun)
|
||||
ClassRep2(doc,_d,class_name,0,max_depth,TRUE,HTT_FUN,offset);
|
||||
else
|
||||
ClassRep2(doc,_d,class_name,0,max_depth,TRUE,HTT_CLASS,offset);
|
||||
DocPrint(doc,"\n");
|
||||
DocRecalc(doc);
|
||||
if (IsRaw) {
|
||||
DocDump(doc,100000);
|
||||
DocDel(doc);
|
||||
}
|
||||
}
|
||||
|
||||
U0 UpdateRegVarImg(CHashFun *tempf,U8 *_b,CTask *task)
|
||||
{
|
||||
CMemberLst *ml;
|
||||
CHashClass *tempc;
|
||||
ml=tempf->member_lst_and_root;
|
||||
while (ml) {
|
||||
if (ml->reg!=REG_NONE) {
|
||||
tempc=OptClassFwd(ml->member_class);
|
||||
MemCpy(_b+ml->offset,TaskRegAddr(task,ml->reg),tempc->size);
|
||||
}
|
||||
ml=ml->next;
|
||||
}
|
||||
}
|
||||
|
||||
public U0 FunRep(U8 *st,U8 *rbp=NULL,I64 max_depth=2,CTask *task=NULL)
|
||||
{//Shows names and vals of a fun's local vars using compiler's info.
|
||||
I64 size;
|
||||
U8 *img;
|
||||
CHashFun *tempf=HashFind(st,Fs->hash_table,HTT_FUN);
|
||||
CMemberLst *tempm;
|
||||
if (tempf) {
|
||||
if (rbp) {
|
||||
if (task) {
|
||||
//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;
|
||||
|
||||
img=MAlloc(size);
|
||||
MemCpy(img,rbp+tempf->size,size);
|
||||
UpdateRegVarImg(tempf,img-tempf->size,task);
|
||||
ClassRep(img-tempf->size,st,max_depth,TRUE,rbp-img+tempf->size);
|
||||
Free(img);
|
||||
} else
|
||||
ClassRep(rbp,st,max_depth,TRUE);
|
||||
} else {
|
||||
tempm=tempf->member_lst_and_root;
|
||||
while (tempm) {
|
||||
if (0<=tempm->reg<NUM_REGS)
|
||||
"%08Z %s\n",tempm->reg,"ST_U64_REGS",tempm->str;
|
||||
else
|
||||
"%08tX %s\n",tempm->offset,tempm->str;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
"%08tX Stk Size\n",tempf->size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#help_index "Debugging/Unassemble"
|
||||
public U0 Uf(U8 *st)
|
||||
{//Unassembles a named fun
|
||||
I64 i;
|
||||
CHashSrcSym *tempf;
|
||||
CDbgInfo *dbg_info;
|
||||
if (tempf=HashFind(st,Fs->hash_table,HTT_FUN|HTT_EXPORT_SYS_SYM)) {
|
||||
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];
|
||||
Un(dbg_info->body[0],i);
|
||||
"Code Size:%04X\n",i;
|
||||
} else
|
||||
U(HashVal(tempf));
|
||||
}
|
||||
}
|
||||
+270
@@ -0,0 +1,270 @@
|
||||
#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)
|
||||
{//See $LK,"::/Demo/LastClass.HC"$.
|
||||
I64 i,j,stars,*ptr;
|
||||
CMemberLst *ml;
|
||||
CDocEntry *doc_e;
|
||||
Bool unlock;
|
||||
CHashClass *tempc,*tempc2;
|
||||
if (depth>=max_depth) return TRUE;
|
||||
if (!(tempc=HashFind(class_name,Fs->hash_table,types))) {
|
||||
DocPrint(doc,"Class Not Found.\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (!ChkPtr(_d) || !ChkPtr(_d(U8 *)+tempc->size)) {
|
||||
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))
|
||||
return FALSE;
|
||||
unlock=DocLock(doc);
|
||||
DocPrint(doc,"Class:\"%s\"\n",class_name);
|
||||
ml=tempc->member_lst_and_root;
|
||||
while (ml) {
|
||||
tempc2=ml->member_class;
|
||||
ptr=_d(U8 *)+ml->offset;
|
||||
DocPrint(doc,"%08X ",ptr(U8 *)+offset);
|
||||
stars=tempc2->ptr_stars_cnt;
|
||||
tempc2=OptClassFwd(tempc2);
|
||||
tempc2-=tempc2->ptr_stars_cnt;
|
||||
if (tempc2->type & HTT_INTERNAL_TYPE) {
|
||||
DocPrint(doc,"$$GREEN$$%-20ts:$$FG$$",ml->str);
|
||||
if (stars==1 && (tempc2->raw_type==RT_I8 || tempc2->raw_type==RT_U8)) {
|
||||
ptr=*ptr;
|
||||
if (ChkPtr(ptr)) {
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM-P+RD,LEN=64,A=\"%%40ts\"$$\n");
|
||||
doc_e->data=ptr;
|
||||
DocDataFmt(doc,doc_e);
|
||||
} else
|
||||
DocPrint(doc,"%40ts\n",ptr);
|
||||
}
|
||||
} else if (!stars) {
|
||||
j=MinI64(ml->dim.total_cnt,32);
|
||||
if (tempc2->raw_type==RT_I8 || tempc2->raw_type==RT_U8) {
|
||||
if (j==1) {
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=U8,A=\"%%c\"$$\n");
|
||||
doc_e->data=ptr;
|
||||
} else
|
||||
DocPrint(doc,"%c\n",*ptr(U8 *));
|
||||
} else {
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM-P+RD,LEN=64,A=\"%%40ts\"$$\n");
|
||||
doc_e->data=ptr;
|
||||
DocDataFmt(doc,doc_e);
|
||||
} else
|
||||
DocPrint(doc,"%40ts\n",ptr);
|
||||
}
|
||||
}
|
||||
for (i=0;i<j;i++) {
|
||||
switch (tempc2->raw_type) {
|
||||
case RT_I0:
|
||||
case RT_U0:
|
||||
break;
|
||||
case RT_I8:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=I8,A=\"%%02X\"$$ ");
|
||||
doc_e->data=ptr(I8 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%02X ",*ptr(I8 *)++);
|
||||
break;
|
||||
case RT_U8:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=U8,A=\"%%02X\"$$ ");
|
||||
doc_e->data=ptr(U8 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%02X ",*ptr(U8 *)++);
|
||||
break;
|
||||
case RT_I16:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=I16,A=\"%%04X\"$$ ");
|
||||
doc_e->data=ptr(I16 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%04X ",*ptr(I16 *)++);
|
||||
break;
|
||||
case RT_U16:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=U16,A=\"%%04X\"$$ ");
|
||||
doc_e->data=ptr(U16 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%04X ",*ptr(U16 *)++);
|
||||
break;
|
||||
case RT_I32:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=I32,A=\"%%08X\"$$ ");
|
||||
doc_e->data=ptr(I32 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%08X ",*ptr(I32 *)++);
|
||||
break;
|
||||
case RT_U32:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=U32,A=\"%%08X\"$$ ");
|
||||
doc_e->data=ptr(U32 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%08X ",*ptr(U32 *)++);
|
||||
break;
|
||||
case RT_U64:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=U64,A=\"%%08X\"$$ ");
|
||||
doc_e->data=ptr(U64 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%08X ",*ptr(U64 *)++);
|
||||
break;
|
||||
case RT_F64:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,RT=F64,A=\"%%16g\"$$ ");
|
||||
doc_e->data=ptr(F64 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%16g ",*ptr(I64 *)++);
|
||||
break;
|
||||
default:
|
||||
if (dynamic) {
|
||||
doc_e=DocPrint(doc,"$$DA-TRM+RD+UD,A=\"%%016X\"$$ ");
|
||||
doc_e->data=ptr(I64 *)++;
|
||||
} else
|
||||
DocPrint(doc,"%016X ",*ptr(I64 *)++);
|
||||
}
|
||||
if (dynamic)
|
||||
DocDataFmt(doc,doc_e);
|
||||
}
|
||||
if (j<ml->dim.total_cnt)
|
||||
DocPrint(doc,"...");
|
||||
} else
|
||||
DocPrint(doc,"%016X",*ptr);
|
||||
DocPrint(doc,"\n");
|
||||
} else {
|
||||
if (depth<2) {
|
||||
if (stars==1 && !ChkPtr(*ptr))
|
||||
DocPrint(doc,"%-20ts:%016X\n",ml->str,*ptr);
|
||||
else {
|
||||
DocPrint(doc,"$$TR,\"%s\"$$\n",ml->str);
|
||||
DocPrint(doc,"$$ID,2$$");
|
||||
if (!stars)
|
||||
ClassRep2(doc,ptr,tempc2->str,depth+1,max_depth,dynamic);
|
||||
else if (stars==1)
|
||||
ClassRep2(doc,*ptr,tempc2->str,depth+1,max_depth,dynamic);
|
||||
DocPrint(doc,"$$ID,-2$$");
|
||||
}
|
||||
} else
|
||||
DocPrint(doc,"%-20ts\n",ml->str);
|
||||
}
|
||||
ml=ml->next;
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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;
|
||||
if (IsRaw)
|
||||
doc=DocNew;
|
||||
else {
|
||||
DocMax;
|
||||
doc=DocPut;
|
||||
}
|
||||
if (fun)
|
||||
ClassRep2(doc,_d,class_name,0,max_depth,FALSE,HTT_FUN,offset);
|
||||
else
|
||||
ClassRep2(doc,_d,class_name,0,max_depth,FALSE,HTT_CLASS,offset);
|
||||
DocPrint(doc,"\n");
|
||||
DocRecalc(doc);
|
||||
if (IsRaw) {
|
||||
DocDump(doc,100000);
|
||||
DocDel(doc);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
if (IsRaw)
|
||||
doc=DocNew;
|
||||
else {
|
||||
DocMax;
|
||||
doc=DocPut;
|
||||
}
|
||||
if (fun)
|
||||
ClassRep2(doc,_d,class_name,0,max_depth,TRUE,HTT_FUN,offset);
|
||||
else
|
||||
ClassRep2(doc,_d,class_name,0,max_depth,TRUE,HTT_CLASS,offset);
|
||||
DocPrint(doc,"\n");
|
||||
DocRecalc(doc);
|
||||
if (IsRaw) {
|
||||
DocDump(doc,100000);
|
||||
DocDel(doc);
|
||||
}
|
||||
}
|
||||
|
||||
U0 UpdateRegVarImg(CHashFun *tempf,U8 *_b,CTask *task)
|
||||
{
|
||||
CMemberLst *ml;
|
||||
CHashClass *tempc;
|
||||
ml=tempf->member_lst_and_root;
|
||||
while (ml) {
|
||||
if (ml->reg!=REG_NONE) {
|
||||
tempc=OptClassFwd(ml->member_class);
|
||||
MemCpy(_b+ml->offset,TaskRegAddr(task,ml->reg),tempc->size);
|
||||
}
|
||||
ml=ml->next;
|
||||
}
|
||||
}
|
||||
|
||||
public U0 FunRep(U8 *st,U8 *rbp=NULL,I64 max_depth=2,CTask *task=NULL)
|
||||
{//Shows names and vals of a fun's local vars using compiler's info.
|
||||
I64 size;
|
||||
U8 *img;
|
||||
CHashFun *tempf=HashFind(st,Fs->hash_table,HTT_FUN);
|
||||
CMemberLst *tempm;
|
||||
if (tempf) {
|
||||
if (rbp) {
|
||||
if (task) {
|
||||
//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;
|
||||
|
||||
img=MAlloc(size);
|
||||
MemCpy(img,rbp+tempf->size,size);
|
||||
UpdateRegVarImg(tempf,img-tempf->size,task);
|
||||
ClassRep(img-tempf->size,st,max_depth,TRUE,rbp-img+tempf->size);
|
||||
Free(img);
|
||||
} else
|
||||
ClassRep(rbp,st,max_depth,TRUE);
|
||||
} else {
|
||||
tempm=tempf->member_lst_and_root;
|
||||
while (tempm) {
|
||||
if (0<=tempm->reg<NUM_REGS)
|
||||
"%08Z %s\n",tempm->reg,"ST_U64_REGS",tempm->str;
|
||||
else
|
||||
"%08tX %s\n",tempm->offset,tempm->str;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
"%08tX Stk Size\n",tempf->size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#help_index "Debugging/Unassemble"
|
||||
public U0 Uf(U8 *st)
|
||||
{//Unassembles a named fun
|
||||
I64 i;
|
||||
CHashSrcSym *tempf;
|
||||
CDbgInfo *dbg_info;
|
||||
if (tempf=HashFind(st,Fs->hash_table,HTT_FUN|HTT_EXPORT_SYS_SYM)) {
|
||||
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];
|
||||
Un(dbg_info->body[0],i);
|
||||
"Code Size:%04X\n",i;
|
||||
} else
|
||||
U(HashVal(tempf));
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
#help_index "Define;Char/Define"
|
||||
|
||||
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);
|
||||
|
||||
//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","121,488");
|
||||
DefinePrint("DD_TEMPLEOS_LOC_OFFICIAL","81,126");
|
||||
$ID,-4$
|
||||
DefinePrint("DD_KERNEL","%08X",bfh);
|
||||
bfh(I64)+=bfh->file_size-1;
|
||||
DefinePrint("DD_KERNEL_END","%08X",bfh);
|
||||
|
||||
//$LK,"DD_BOOT_HIGH_LOC_DVD",A="FF:::/Adam/Opt/Boot/BootDVD.CPP,DD_BOOT_HIGH_LOC_DVD"$
|
||||
|
||||
DefinePrint("DD_MP_VECT","%08X",MP_VECT_ADDR);
|
||||
DefinePrint("DD_MP_VECT_END","%08X",
|
||||
MP_VECT_ADDR+COREAP_16BIT_INIT_END-COREAP_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_UNCACHED_ALIAS","%010X",dev.uncached_alias);
|
||||
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;
|
||||
@@ -0,0 +1,39 @@
|
||||
#help_index "Define;Char/Define"
|
||||
|
||||
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);
|
||||
|
||||
//This is cut and replaced when I generate a distro.
|
||||
//See $LK,"DD_TEMPLEOS_LOC",A="FF:::/Demo/AcctExample/TOSDistro.HC,DD_TEMPLEOS_LOC"$.
|
||||
$TR-C,"LineRep"$
|
||||
$ID,4$DefinePrint("DD_TEMPLEOS_LOC","120,264");
|
||||
DefinePrint("DD_TEMPLEOS_LOC_OFFICIAL","81,209");
|
||||
$ID,-4$
|
||||
DefinePrint("DD_KERNEL","%08X",bfh);
|
||||
bfh(I64)+=bfh->file_size-1;
|
||||
DefinePrint("DD_KERNEL_END","%08X",bfh);
|
||||
|
||||
//$LK,"DD_BOOT_HIGH_LOC_DVD",A="FF:::/Adam/Opt/Boot/BootDVD.HC,DD_BOOT_HIGH_LOC_DVD"$
|
||||
|
||||
DefinePrint("DD_MP_VECT","%08X",MP_VECT_ADDR);
|
||||
DefinePrint("DD_MP_VECT_END","%08X",
|
||||
MP_VECT_ADDR+COREAP_16BIT_INIT_END-COREAP_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_UNCACHED_ALIAS","%010X",dev.uncached_alias);
|
||||
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;
|
||||
@@ -1,98 +0,0 @@
|
||||
extern U0 ACDDef(I64 n,CTask *parent=NULL);
|
||||
extern U0 ACDDefsPut(CDoc *doc,U8 *st,I64 num=-1);
|
||||
extern U0 ACDFillin(I64 n);
|
||||
extern U0 ACFillIn(I64 n);
|
||||
extern U0 ACMan(I64 n,CTask *parent=NULL);
|
||||
extern U0 ACMisspelledFind(CDoc *doc);
|
||||
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 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 DocBinDel(CDoc *doc,CDocBin *b);
|
||||
extern U0 DocBinsValidate(CDoc *doc);
|
||||
extern U0 DocBottom(CDoc *doc=NULL);
|
||||
extern U0 DocCenter(CDoc *doc=NULL,I64 recalc=RECALCt_NORMAL);
|
||||
extern U0 DocClear(CDoc *doc=NULL,Bool clear_holds=FALSE);
|
||||
extern Bool DocCursor(Bool show=OFF,CDoc *doc=NULL);
|
||||
extern U0 DocD(U8 *buf,I64 cnt=0x80);
|
||||
extern U0 DocDataFmt(CDoc *doc,CDocEntry *doc_e,I64 d=DOCM_CANCEL);
|
||||
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 U0 DocEntryDel(CDoc *doc,CDocEntry *doc_e);
|
||||
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 Bool DocHighlightCursor(Bool show=OFF,CDoc *doc=NULL);
|
||||
extern U0 DocInsDoc(CDoc *doc,CDoc *doc2);
|
||||
extern U0 DocInsEntry(CDoc *doc,CDocEntry *doc_e);
|
||||
extern Bool DocLock(CDoc *doc);
|
||||
extern U0 DocMax(I64 i=MAX_I32);
|
||||
extern CDoc *DocNew(U8 *filename=NULL,CTask *task=NULL);
|
||||
extern CDocEntry *DocPrint(CDoc *doc=NULL,U8 *src,...);
|
||||
extern CDoc *DocPut(CTask *task=NULL);
|
||||
extern CDoc *DocRead(U8 *name=NULL,I64 flags=0);
|
||||
extern Bool DocRecalc(CDoc *doc,I64 recalc_flags=RECALCt_NORMAL);
|
||||
extern U0 DocRst(CDoc *doc,Bool is_old);
|
||||
extern CDocEntry *DocSprite(CDoc *doc,U8 *elems,U8 *fmt=NULL);
|
||||
extern U0 DocTop(CDoc *doc=NULL);
|
||||
extern Bool DocUnlock(CDoc *doc);
|
||||
extern U0 DocUpdateTaskDocs(CTask *task);
|
||||
extern U0 DrawCtrls(CTask *task);
|
||||
extern Bool Ed(U8 *link_st,I64 edf_dof_flags=0);
|
||||
extern U0 EdCodeTools(CDoc *doc);
|
||||
extern U8 *EdSprite(I64 bin_num);
|
||||
extern I64 ExeDoc(CDoc *doc,I64 ccf_flags=0);
|
||||
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 ISO9660ISO(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();
|
||||
extern CMenu *MenuPush(U8 *st);
|
||||
extern I64 Mount(Bool repartition=FALSE);
|
||||
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 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 PopUpGetI64(U8 *msg,I64 dft,I64 lo=MIN_I64,I64 hi=MAX_I64);
|
||||
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 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);
|
||||
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 ipx,I64 ipy,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);
|
||||
extern U0 WinScrollNull(CTask *task,CD3I64 *s);
|
||||
extern U0 WinScrollRestore(CTask *task,CD3I64 *s);
|
||||
extern U0 WinScrollsInit(CTask *task);
|
||||
extern Bool WinToTop(CTask *task=NULL,Bool update_z_buf=TRUE);
|
||||
extern Bool WinVert(I64 top,I64 bottom,CTask *task=NULL);
|
||||
extern CWinMgrGlbls winmgr;
|
||||
@@ -0,0 +1,98 @@
|
||||
extern U0 ACDDef(I64 n,CTask *parent=NULL);
|
||||
extern U0 ACDDefsPut(CDoc *doc=NULL,U8 *st,I64 num=-1);
|
||||
extern U0 ACDFillin(I64 n);
|
||||
extern U0 ACFillIn(I64 n);
|
||||
extern U0 ACMan(I64 n,CTask *parent_task=NULL);
|
||||
extern U0 ACMisspelledFind(CDoc *doc);
|
||||
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 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 DocBinDel(CDoc *doc,CDocBin *b);
|
||||
extern U0 DocBinsValidate(CDoc *doc);
|
||||
extern U0 DocBottom(CDoc *doc=NULL);
|
||||
extern U0 DocCenter(CDoc *doc=NULL,I64 recalc_flags=RECALCt_NORMAL);
|
||||
extern U0 DocClear(CDoc *doc=NULL,Bool clear_holds=FALSE);
|
||||
extern Bool DocCursor(Bool show=OFF,CDoc *doc=NULL);
|
||||
extern U0 DocD(U8 *buf,I64 cnt=0x80);
|
||||
extern U0 DocDataFmt(CDoc *doc,CDocEntry *doc_e,I64 d=DOCM_CANCEL);
|
||||
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 U0 DocEntryDel(CDoc *doc,CDocEntry *doc_e);
|
||||
extern Bool DocForm(U8 *_d,U8 *class_name=lastclass,
|
||||
I64 dof_flags=0,U8 *header=NULL,U8 *footer=NULL);
|
||||
extern U0 DocHelpIdx(CDoc *doc,U8 *idx);
|
||||
extern Bool DocHighlightCursor(Bool show=OFF,CDoc *doc=NULL);
|
||||
extern U0 DocInsDoc(CDoc *doc=NULL,CDoc *doc2);
|
||||
extern U0 DocInsEntry(CDoc *doc,CDocEntry *doc_e);
|
||||
extern Bool DocLock(CDoc *doc);
|
||||
extern I64 DocMax(I64 i=MAX_I64);
|
||||
extern CDoc *DocNew(U8 *filename=NULL,CTask *task=NULL);
|
||||
extern CDocEntry *DocPrint(CDoc *doc=NULL,U8 *fmt,...);
|
||||
extern CDoc *DocPut(CTask *task=NULL);
|
||||
extern CDoc *DocRead(U8 *name=NULL,I64 flags=0);
|
||||
extern Bool DocRecalc(CDoc *doc,I64 recalc_flags=RECALCt_NORMAL);
|
||||
extern U0 DocRst(CDoc *doc,Bool is_old);
|
||||
extern CDocEntry *DocSprite(CDoc *doc=NULL,U8 *elems,U8 *fmt=NULL);
|
||||
extern U0 DocTop(CDoc *doc=NULL);
|
||||
extern Bool DocUnlock(CDoc *doc);
|
||||
extern U0 DocUpdateTaskDocs(CTask *task);
|
||||
extern U0 DrawCtrls(CTask *task);
|
||||
extern Bool Ed(U8 *link_st,I64 edf_dof_flags=0);
|
||||
extern U0 EdCodeTools(CDoc *doc);
|
||||
extern U8 *EdSprite(I64 bin_num);
|
||||
extern I64 ExeDoc(CDoc *doc,I64 ccf_flags=0);
|
||||
extern I64 FindWiz();
|
||||
extern I64 GetI64(U8 *msg=NULL,I64 dft=0,I64 lo=MIN_I64,I64 hi=MAX_I64);
|
||||
extern Bool GrPlot0(CDC *dc,I64 x,I64 y);
|
||||
extern I64 ISO9660ISO(U8 *_filename=NULL,U8 *src_files_find_mask,
|
||||
U8 *fu_flags=NULL,U8 *_stage2_filename=NULL);
|
||||
extern CMenuEntry *MenuEntryFind(CMenu *haystack_menu,U8 *needle_full_name);
|
||||
extern CMenu *MenuFilePush(U8 *filename);
|
||||
extern U0 MenuPop();
|
||||
extern CMenu *MenuPush(U8 *st);
|
||||
extern I64 Mount(Bool repartition=FALSE);
|
||||
extern CTask *Noise(I64 ms,F64 min_freq,F64 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_transparent=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 PopUpGetI64(U8 *msg,I64 dft,I64 lo=MIN_I64,I64 hi=MAX_I64);
|
||||
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 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);
|
||||
extern Bool View();
|
||||
extern U0 ViewAnglesDel(CTask *task=NULL);
|
||||
extern CCtrl *ViewAnglesNew(CTask *task=NULL);
|
||||
extern Bool WinBorder(Bool val=OFF,CTask *task=NULL);
|
||||
extern CDoc *WinCursorPosSet(CTask *task,I64 ipx,I64 ipy,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);
|
||||
extern U0 WinScrollNull(CTask *task,CD3I64 *s);
|
||||
extern U0 WinScrollRestore(CTask *task,CD3I64 *s);
|
||||
extern U0 WinScrollsInit(CTask *task);
|
||||
extern I64 WinToTop(CTask *task=NULL,Bool update_z_buf=TRUE);
|
||||
extern Bool WinVert(I64 top,I64 bottom,CTask *task=NULL);
|
||||
extern CWinMgrGlbls winmgr;
|
||||
-433
@@ -1,433 +0,0 @@
|
||||
#help_index "Info;Hash/System;Cmd Line (Typically)"
|
||||
class CWho
|
||||
{
|
||||
CHashGeneric *h;
|
||||
U8 *idx;
|
||||
};
|
||||
|
||||
I64 HashEntriesCompare(CWho *h1,CWho *h2)
|
||||
{
|
||||
I64 i1,i2;
|
||||
if (i1=StrCmp(h1->h->str,h2->h->str))
|
||||
return i1;
|
||||
i1=HashTypeNum(h1->h);
|
||||
i2=HashTypeNum(h2->h);
|
||||
return i1-i2;
|
||||
}
|
||||
|
||||
I64 HashEntriesCompare2(CWho *h1,CWho *h2)
|
||||
{
|
||||
CHashFun *tempf1=h1->h,*tempf2=h2->h;
|
||||
I64 i1=HashVal(tempf1),i2=HashVal(tempf2);
|
||||
if (i1==i2) {
|
||||
i1=HashTypeNum(tempf1);
|
||||
i2=HashTypeNum(tempf2);
|
||||
if (i1==i2)
|
||||
return StrCmp(tempf1->str,tempf2->str);
|
||||
}
|
||||
return i1-i2;
|
||||
}
|
||||
|
||||
I64 HelpIndexCnt(U8 *ptr,U8 *idx)
|
||||
{
|
||||
I64 cnt=0,ch,idx_len=StrLen(idx);
|
||||
while (*ptr) {
|
||||
if (!StrNCmp(ptr,idx,idx_len))
|
||||
cnt++;
|
||||
while (ch=*ptr++)
|
||||
if (ch==';')
|
||||
break;
|
||||
if (!ch)
|
||||
ptr--;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
U8 *HelpIndexStr(U8 **_ptr,U8 *idx)
|
||||
{
|
||||
U8 *ptr=*_ptr,*ptr2,*res;
|
||||
I64 ch,idx_len=StrLen(idx);
|
||||
while (*ptr) {
|
||||
ptr2=ptr;
|
||||
while (ch=*ptr++)
|
||||
if (ch==';')
|
||||
break;
|
||||
if (!ch)
|
||||
ptr--;
|
||||
*_ptr=ptr;
|
||||
if (!StrNCmp(ptr2,idx,idx_len)) {
|
||||
if (ch==';')
|
||||
ptr--;
|
||||
*ptr=0;
|
||||
res=StrNew(ptr2);
|
||||
*ptr=ch;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U8 *HelpComment(CTask *task,CHash *temph,U8 *_src_link)
|
||||
{
|
||||
CDoc *doc;
|
||||
CDocEntry *doc_e;
|
||||
U8 *res=NULL,*ptr,*ptr2,*src_link=StrNew(_src_link);
|
||||
|
||||
if (*src_link=='F' && src_link[2]==':')
|
||||
*src_link='P';
|
||||
XTalkWait(task,"Ed(0x%X,DOF_DONT_WINMGR_SYNC|DOF_DONT_SHOW);\n",src_link);
|
||||
Free(src_link);
|
||||
|
||||
doc=DocPut(task);
|
||||
doc_e=doc->cur_entry;
|
||||
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;
|
||||
if (ptr2=StrMatch("//",ptr))
|
||||
ptr=ptr2+2;
|
||||
else if (ptr2=StrMatch("/*",ptr))
|
||||
ptr=ptr2+2;
|
||||
else if (!StrNCmp(ptr,"public",6))
|
||||
ptr+=6;
|
||||
while (*ptr==CH_SPACE)
|
||||
ptr++;
|
||||
res=StrNew(ptr);
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
while (doc_e!=doc && doc_e->type_u8!=DOCT_NEW_LINE) {
|
||||
if (doc_e->type_u8==DOCT_TAB) {
|
||||
ptr=MStrPrint("%s ",res);
|
||||
Free(res);
|
||||
res=ptr;
|
||||
} else if (doc_e->de_flags&DOCEF_TAG) {
|
||||
ptr=MStrPrint("%s%s",res,doc_e->tag);
|
||||
Free(res);
|
||||
res=ptr;
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
}
|
||||
XTalkWait(task,"%c",CH_SHIFT_ESC);
|
||||
if (res) {
|
||||
ptr=MStrUtil(res,SUF_REM_TRAILING|SUF_REM_LEADING|SUF_SINGLE_SPACE);
|
||||
Free(res);
|
||||
res=ptr;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 HashEntriesCompare3(CWho *h1,CWho *h2)
|
||||
{
|
||||
I64 i,i1=0,i2=0;
|
||||
i=StrCmp(h1->idx,h2->idx);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
|
||||
U8 *idx=NULL,CDoc *doc=NULL)
|
||||
{//Dump hash symbol table.
|
||||
// "+p" for only public symbols
|
||||
// "+m" to order by number (normally alphabetical)
|
||||
// "-r" just local hash table
|
||||
CHashTable *table;
|
||||
CHashSrcSym *temph;
|
||||
CHashGeneric *ptr;
|
||||
CWho *lst;
|
||||
I64 cnt,i,j,k,f=0;
|
||||
U8 buf[512],*st,*last_idx=StrNew(""),*cur_idx,*comment;
|
||||
Bool recurse,publics,map;
|
||||
CTask *task;
|
||||
|
||||
ScanFlags(&f,Define("ST_FILE_UTIL_FLAGS"),"+r");
|
||||
ScanFlags(&f,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
|
||||
if (f&~(FUF_RECURSE|FUF_PUBLIC|FUF_MAP))
|
||||
throw('FUF');
|
||||
recurse=Bt(&f,FUf_RECURSE);
|
||||
publics=Bt(&f,FUf_PUBLIC);
|
||||
map =Bt(&f,FUf_MAP);
|
||||
|
||||
if (!h) h=Fs->hash_table;
|
||||
|
||||
if (idx) {
|
||||
task=User;
|
||||
TaskWait(task);
|
||||
LBtr(&task->display_flags,DISPLAYf_SHOW);
|
||||
} else
|
||||
task=NULL;
|
||||
|
||||
cnt=0;
|
||||
table=h;
|
||||
while (table) {
|
||||
for (i=0;i<=table->mask;i++) {
|
||||
temph=table->body[i];
|
||||
while (temph) {
|
||||
if (!(temph->type & (HTF_IMPORT | HTF_PRIVATE)) &&
|
||||
(temph->type & HTF_PUBLIC || !publics)) {
|
||||
if (!idx)
|
||||
cnt++;
|
||||
else if (temph->type&HTG_SRC_SYM && (cur_idx=temph->idx))
|
||||
cnt+=HelpIndexCnt(cur_idx,idx);
|
||||
}
|
||||
temph=temph->next;
|
||||
}
|
||||
}
|
||||
if (recurse)
|
||||
table=table->next;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (!cnt) goto wh_done;
|
||||
|
||||
lst=CAlloc(cnt*sizeof(CWho));
|
||||
j=0;
|
||||
table=h;
|
||||
while (table) {
|
||||
for (i=0;i<=table->mask;i++) {
|
||||
temph=table->body[i];
|
||||
while (temph) {
|
||||
if (!(temph->type & (HTF_IMPORT | HTF_PRIVATE)) &&
|
||||
(temph->type & HTF_PUBLIC || !publics))
|
||||
if (!idx)
|
||||
lst[j++].h=temph;
|
||||
else if (temph->type&HTG_SRC_SYM && (cur_idx=temph->idx) &&
|
||||
(k=HelpIndexCnt(cur_idx,idx)))
|
||||
while (k--) {
|
||||
lst[j].idx=HelpIndexStr(&cur_idx,idx);
|
||||
lst[j++].h=temph;
|
||||
}
|
||||
temph=temph->next;
|
||||
}
|
||||
}
|
||||
if (recurse)
|
||||
table=table->next;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (map)
|
||||
QSort(lst,cnt,sizeof(CWho),&HashEntriesCompare2);
|
||||
else if (idx)
|
||||
QSort(lst,cnt,sizeof(CWho),&HashEntriesCompare3);
|
||||
else
|
||||
QSort(lst,cnt,sizeof(CWho),&HashEntriesCompare);
|
||||
|
||||
if (idx) {
|
||||
progress1_max=cnt;
|
||||
progress1=0;
|
||||
}
|
||||
for (i=0;i<cnt;i++) {
|
||||
comment=NULL;
|
||||
ptr=lst[i].h;
|
||||
if (idx)
|
||||
if (cur_idx=lst[i].idx) {
|
||||
if (StrCmp(cur_idx,last_idx)) {
|
||||
Free(last_idx);
|
||||
last_idx=StrNew(cur_idx);
|
||||
if (i)
|
||||
DocPrint(doc,"\n\n");
|
||||
DocPrint(doc,"$$WW,0$$$$PURPLE$$$$TX+CX,\"%$$Q\"$$$$FG$$\n",cur_idx);
|
||||
}
|
||||
}
|
||||
|
||||
if (idx && ptr->type & HTT_HELP_FILE) {
|
||||
DocPrint(doc,"$$WW,1$$");
|
||||
DocType(doc,ptr->str);
|
||||
DocPrint(doc,"$$WW,0$$");
|
||||
} else {
|
||||
if (ptr->type&HTG_SRC_SYM && ptr(CHashSrcSym *)->src_link) {
|
||||
DocPrint(doc,"$$LK,\"%-20s\",A=\"%s\"$$",
|
||||
ptr->str,ptr(CHashSrcSym *)->src_link);
|
||||
if (idx)
|
||||
comment=HelpComment(task,ptr,ptr(CHashSrcSym *)->src_link);
|
||||
} else
|
||||
DocPrint(doc,"%-20s",ptr->str);
|
||||
|
||||
if (!idx) {
|
||||
if (ptr->type & HTT_DEFINE_STR) {
|
||||
st=MStrUtil(ptr(CHashDefineStr *)->data,SUF_SAFE_DOLLAR);
|
||||
j=ptr(CHashDefineStr *)->cnt;
|
||||
if (j==-1)
|
||||
StrPrint(buf,"%-10tQ ",st);
|
||||
else
|
||||
StrPrint(buf,"%-10tQ %02X",st,j);
|
||||
Free(st);
|
||||
} 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)
|
||||
CatPrint(buf," %04X ",ptr->use_cnt);
|
||||
else
|
||||
CatPrint(buf," %04X %010X ",ptr->use_cnt,j);
|
||||
} else
|
||||
*buf=0;
|
||||
|
||||
k=ptr->type;
|
||||
if (publics)
|
||||
k&=~HTF_PUBLIC;
|
||||
if (!(k&HTG_TYPE_MASK))
|
||||
CatPrint(buf,"NULL ");
|
||||
while (k) {
|
||||
j=Bsf(k);
|
||||
if (j<0)
|
||||
break;
|
||||
Btr(&k,j);
|
||||
CatPrint(buf,"%Z ",j,"ST_HTT_TYPES");
|
||||
}
|
||||
DocPrint(doc,"%s",buf);
|
||||
if (comment) {
|
||||
DocPrint(doc,"$$GREEN$$%s$$FG$$",comment);
|
||||
Free(comment);
|
||||
}
|
||||
DocPrint(doc,"\n");
|
||||
}
|
||||
Free(lst[i].idx);
|
||||
if (idx)
|
||||
progress1++;
|
||||
}
|
||||
Free(lst);
|
||||
if (idx)
|
||||
progress1=progress1_max=0;
|
||||
|
||||
wh_done:
|
||||
if (doc) {
|
||||
if (doc->head.next==doc)
|
||||
DocPrint(doc,"No Match");
|
||||
else
|
||||
DocRecalc(doc);
|
||||
}
|
||||
Free(last_idx);
|
||||
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.
|
||||
//Histogram of collision count.
|
||||
I64 i,j,longest=0,cnt=0,a[HDR_MAX];
|
||||
CHash *temph;
|
||||
if (!table) table=Fs->hash_table;
|
||||
MemSet(a,0,sizeof(a));
|
||||
for (i=0;i<=table->mask;i++) {
|
||||
temph=table->body[i];
|
||||
if (temph) {
|
||||
j=LinkedLstCnt(temph);
|
||||
if (j<HDR_MAX)
|
||||
a[j]++;
|
||||
cnt+=j;
|
||||
if (j>longest)
|
||||
longest=j;
|
||||
}
|
||||
}
|
||||
"Histogram\n";
|
||||
for (i=0;i<HDR_MAX;i++)
|
||||
if (a[i])
|
||||
"%02d:%d\n",i,a[i];
|
||||
"Size:%d Count:%d Longest:%d\n",
|
||||
table->mask+1,cnt,longest;
|
||||
return longest;
|
||||
}
|
||||
|
||||
#help_index "Help System"
|
||||
#help_file "::/Doc/HelpSystem"
|
||||
|
||||
public U0 DocHelpIndex(CDoc *doc,U8 *idx)
|
||||
{//Put to doc report for given help idx.
|
||||
Who("+p",,idx,doc);
|
||||
}
|
||||
|
||||
public U0 PopUpHelpIndex(U8 *idx,CTask *parent=NULL)
|
||||
{//PopUp win report for given help idx.
|
||||
U8 *buf;
|
||||
buf=MStrPrint("DocHelpIndex(DocPut,\"%s\");View;",idx);
|
||||
PopUp(buf,parent);
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
#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"),
|
||||
*absname=FileNameAbs(name);
|
||||
CDoc *doc=DocRead(name);
|
||||
CDocEntry *doc_e;
|
||||
CHashSrcSym *temph;
|
||||
I64 i,j,base=0;
|
||||
CDbgInfo *dbg_info;
|
||||
|
||||
FileExtRem(absname);
|
||||
if (absname[1]==':' && StrLen(absname)>2 &&
|
||||
(temph=HashSingleTableFind(absname+2,Fs->hash_table,HTT_MODULE)))
|
||||
base=temph(CHashGeneric *)->user_data0+sizeof(CBinFile);
|
||||
|
||||
if (!doc) return;
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type_u8==DOCT_LINK) {
|
||||
if (*doc_e->tag)
|
||||
st=MStrUtil(doc_e->tag,SUF_REM_TRAILING);
|
||||
else
|
||||
st=MStrUtil(doc_e->aux_str,SUF_REM_TRAILING);
|
||||
if (temph=HashSingleTableFind(st,Fs->hash_table,HTG_SRC_SYM)) {
|
||||
if (*doc_e->tag) {
|
||||
Free(temph->src_link);
|
||||
temph->src_link=doc_e->aux_str;
|
||||
ptr=temph->src_link;
|
||||
if (ptr[0] && ptr[1] && ptr[2]==':') {
|
||||
if (ptr[3]==':')
|
||||
ptr[3]=blkdev.boot_drv_let;
|
||||
else if (ptr[3]=='~')
|
||||
ptr[3]=*blkdev.home_dir;
|
||||
}
|
||||
doc_e->aux_str=NULL;
|
||||
}
|
||||
if (temph->type&(HTT_FUN|HTT_EXPORT_SYS_SYM) &&
|
||||
!(dbg_info=temph->dbg_info) && doc_e->bin_data &&
|
||||
(dbg_info=doc_e->bin_data->data)) {
|
||||
if (doc_e->bin_data->size>MSize(dbg_info))
|
||||
"Corrupt Map Entry\n";
|
||||
else {
|
||||
doc_e->bin_data->data=NULL;
|
||||
temph->dbg_info=dbg_info;
|
||||
for (i=dbg_info->min_line;i<=dbg_info->max_line+1;i++) {
|
||||
j=i-dbg_info->min_line;
|
||||
if (dbg_info->body[j])
|
||||
dbg_info->body[j]=dbg_info->body[j]+base;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
DocDel(doc);
|
||||
Free(name);
|
||||
Free(absname);
|
||||
}
|
||||
+433
@@ -0,0 +1,433 @@
|
||||
#help_index "Info;Hash/System;Cmd Line (Typically)"
|
||||
class CWho
|
||||
{
|
||||
CHashGeneric *h;
|
||||
U8 *idx;
|
||||
};
|
||||
|
||||
I64 HashEntriesCompare(CWho *h1,CWho *h2)
|
||||
{
|
||||
I64 i1,i2;
|
||||
if (i1=StrCmp(h1->h->str,h2->h->str))
|
||||
return i1;
|
||||
i1=HashTypeNum(h1->h);
|
||||
i2=HashTypeNum(h2->h);
|
||||
return i1-i2;
|
||||
}
|
||||
|
||||
I64 HashEntriesCompare2(CWho *h1,CWho *h2)
|
||||
{
|
||||
CHashFun *tempf1=h1->h,*tempf2=h2->h;
|
||||
I64 i1=HashVal(tempf1),i2=HashVal(tempf2);
|
||||
if (i1==i2) {
|
||||
i1=HashTypeNum(tempf1);
|
||||
i2=HashTypeNum(tempf2);
|
||||
if (i1==i2)
|
||||
return StrCmp(tempf1->str,tempf2->str);
|
||||
}
|
||||
return i1-i2;
|
||||
}
|
||||
|
||||
I64 HelpIndexCnt(U8 *ptr,U8 *idx)
|
||||
{
|
||||
I64 cnt=0,ch,idx_len=StrLen(idx);
|
||||
while (*ptr) {
|
||||
if (!StrNCmp(ptr,idx,idx_len))
|
||||
cnt++;
|
||||
while (ch=*ptr++)
|
||||
if (ch==';')
|
||||
break;
|
||||
if (!ch)
|
||||
ptr--;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
U8 *HelpIndexStr(U8 **_ptr,U8 *idx)
|
||||
{
|
||||
U8 *ptr=*_ptr,*ptr2,*res;
|
||||
I64 ch,idx_len=StrLen(idx);
|
||||
while (*ptr) {
|
||||
ptr2=ptr;
|
||||
while (ch=*ptr++)
|
||||
if (ch==';')
|
||||
break;
|
||||
if (!ch)
|
||||
ptr--;
|
||||
*_ptr=ptr;
|
||||
if (!StrNCmp(ptr2,idx,idx_len)) {
|
||||
if (ch==';')
|
||||
ptr--;
|
||||
*ptr=0;
|
||||
res=StrNew(ptr2);
|
||||
*ptr=ch;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U8 *HelpComment(CTask *task,CHash *temph,U8 *_src_link)
|
||||
{
|
||||
CDoc *doc;
|
||||
CDocEntry *doc_e;
|
||||
U8 *res=NULL,*ptr,*ptr2,*src_link=StrNew(_src_link);
|
||||
|
||||
if (*src_link=='F' && src_link[2]==':')
|
||||
*src_link='P';
|
||||
XTalkWait(task,"Ed(0x%X,DOF_DONT_WINMGR_SYNC|DOF_DONT_SHOW);\n",src_link);
|
||||
Free(src_link);
|
||||
|
||||
doc=DocPut(task);
|
||||
doc_e=doc->cur_entry;
|
||||
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;
|
||||
if (ptr2=StrMatch("//",ptr))
|
||||
ptr=ptr2+2;
|
||||
else if (ptr2=StrMatch("/*",ptr))
|
||||
ptr=ptr2+2;
|
||||
else if (!StrNCmp(ptr,"public",6))
|
||||
ptr+=6;
|
||||
while (*ptr==CH_SPACE)
|
||||
ptr++;
|
||||
res=StrNew(ptr);
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
while (doc_e!=doc && doc_e->type_u8!=DOCT_NEW_LINE) {
|
||||
if (doc_e->type_u8==DOCT_TAB) {
|
||||
ptr=MStrPrint("%s ",res);
|
||||
Free(res);
|
||||
res=ptr;
|
||||
} else if (doc_e->de_flags&DOCEF_TAG) {
|
||||
ptr=MStrPrint("%s%s",res,doc_e->tag);
|
||||
Free(res);
|
||||
res=ptr;
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
}
|
||||
XTalkWait(task,"%c",CH_SHIFT_ESC);
|
||||
if (res) {
|
||||
ptr=MStrUtil(res,SUF_REM_TRAILING|SUF_REM_LEADING|SUF_SINGLE_SPACE);
|
||||
Free(res);
|
||||
res=ptr;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 HashEntriesCompare3(CWho *h1,CWho *h2)
|
||||
{
|
||||
I64 i,i1=0,i2=0;
|
||||
i=StrCmp(h1->idx,h2->idx);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public U0 Who(U8 *fu_flags=NULL,CHashTable *h=NULL,
|
||||
U8 *idx=NULL,CDoc *doc=NULL)
|
||||
{//Dump hash symbol table.
|
||||
// "+p" for only public symbols
|
||||
// "+m" to order by number (normally alphabetical)
|
||||
// "-r" just local hash table
|
||||
CHashTable *table;
|
||||
CHashSrcSym *temph;
|
||||
CHashGeneric *ptr;
|
||||
CWho *lst;
|
||||
I64 cnt,i,j,k,f=0;
|
||||
U8 buf[512],*st,*last_idx=StrNew(""),*cur_idx,*comment;
|
||||
Bool recurse,publics,map;
|
||||
CTask *task;
|
||||
|
||||
ScanFlags(&f,Define("ST_FILE_UTIL_FLAGS"),"+r");
|
||||
ScanFlags(&f,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
|
||||
if (f&~(FUF_RECURSE|FUF_PUBLIC|FUF_MAP))
|
||||
throw('FUF');
|
||||
recurse=Bt(&f,FUf_RECURSE);
|
||||
publics=Bt(&f,FUf_PUBLIC);
|
||||
map =Bt(&f,FUf_MAP);
|
||||
|
||||
if (!h) h=Fs->hash_table;
|
||||
|
||||
if (idx) {
|
||||
task=User;
|
||||
TaskWait(task);
|
||||
LBtr(&task->display_flags,DISPLAYf_SHOW);
|
||||
} else
|
||||
task=NULL;
|
||||
|
||||
cnt=0;
|
||||
table=h;
|
||||
while (table) {
|
||||
for (i=0;i<=table->mask;i++) {
|
||||
temph=table->body[i];
|
||||
while (temph) {
|
||||
if (!(temph->type & (HTF_IMPORT | HTF_PRIVATE)) &&
|
||||
(temph->type & HTF_PUBLIC || !publics)) {
|
||||
if (!idx)
|
||||
cnt++;
|
||||
else if (temph->type&HTG_SRC_SYM && (cur_idx=temph->idx))
|
||||
cnt+=HelpIndexCnt(cur_idx,idx);
|
||||
}
|
||||
temph=temph->next;
|
||||
}
|
||||
}
|
||||
if (recurse)
|
||||
table=table->next;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (!cnt) goto wh_done;
|
||||
|
||||
lst=CAlloc(cnt*sizeof(CWho));
|
||||
j=0;
|
||||
table=h;
|
||||
while (table) {
|
||||
for (i=0;i<=table->mask;i++) {
|
||||
temph=table->body[i];
|
||||
while (temph) {
|
||||
if (!(temph->type & (HTF_IMPORT | HTF_PRIVATE)) &&
|
||||
(temph->type & HTF_PUBLIC || !publics))
|
||||
if (!idx)
|
||||
lst[j++].h=temph;
|
||||
else if (temph->type&HTG_SRC_SYM && (cur_idx=temph->idx) &&
|
||||
(k=HelpIndexCnt(cur_idx,idx)))
|
||||
while (k--) {
|
||||
lst[j].idx=HelpIndexStr(&cur_idx,idx);
|
||||
lst[j++].h=temph;
|
||||
}
|
||||
temph=temph->next;
|
||||
}
|
||||
}
|
||||
if (recurse)
|
||||
table=table->next;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (map)
|
||||
QSort(lst,cnt,sizeof(CWho),&HashEntriesCompare2);
|
||||
else if (idx)
|
||||
QSort(lst,cnt,sizeof(CWho),&HashEntriesCompare3);
|
||||
else
|
||||
QSort(lst,cnt,sizeof(CWho),&HashEntriesCompare);
|
||||
|
||||
if (idx) {
|
||||
progress1_max=cnt;
|
||||
progress1=0;
|
||||
}
|
||||
for (i=0;i<cnt;i++) {
|
||||
comment=NULL;
|
||||
ptr=lst[i].h;
|
||||
if (idx)
|
||||
if (cur_idx=lst[i].idx) {
|
||||
if (StrCmp(cur_idx,last_idx)) {
|
||||
Free(last_idx);
|
||||
last_idx=StrNew(cur_idx);
|
||||
if (i)
|
||||
DocPrint(doc,"\n\n");
|
||||
DocPrint(doc,"$$WW,0$$$$PURPLE$$$$TX+CX,\"%$$Q\"$$$$FG$$\n",cur_idx);
|
||||
}
|
||||
}
|
||||
|
||||
if (idx && ptr->type & HTT_HELP_FILE) {
|
||||
DocPrint(doc,"$$WW,1$$");
|
||||
DocType(doc,ptr->str);
|
||||
DocPrint(doc,"$$WW,0$$");
|
||||
} else {
|
||||
if (ptr->type&HTG_SRC_SYM && ptr(CHashSrcSym *)->src_link) {
|
||||
DocPrint(doc,"$$LK,\"%-20s\",A=\"%s\"$$",
|
||||
ptr->str,ptr(CHashSrcSym *)->src_link);
|
||||
if (idx)
|
||||
comment=HelpComment(task,ptr,ptr(CHashSrcSym *)->src_link);
|
||||
} else
|
||||
DocPrint(doc,"%-20s",ptr->str);
|
||||
|
||||
if (!idx) {
|
||||
if (ptr->type & HTT_DEFINE_STR) {
|
||||
st=MStrUtil(ptr(CHashDefineStr *)->data,SUF_SAFE_DOLLAR);
|
||||
j=ptr(CHashDefineStr *)->cnt;
|
||||
if (j==-1)
|
||||
StrPrint(buf,"%-10tQ ",st);
|
||||
else
|
||||
StrPrint(buf,"%-10tQ %02X",st,j);
|
||||
Free(st);
|
||||
} 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)
|
||||
CatPrint(buf," %04X ",ptr->use_cnt);
|
||||
else
|
||||
CatPrint(buf," %04X %010X ",ptr->use_cnt,j);
|
||||
} else
|
||||
*buf=0;
|
||||
|
||||
k=ptr->type;
|
||||
if (publics)
|
||||
k&=~HTF_PUBLIC;
|
||||
if (!(k&HTG_TYPE_MASK))
|
||||
CatPrint(buf,"NULL ");
|
||||
while (k) {
|
||||
j=Bsf(k);
|
||||
if (j<0)
|
||||
break;
|
||||
Btr(&k,j);
|
||||
CatPrint(buf,"%Z ",j,"ST_HTT_TYPES");
|
||||
}
|
||||
DocPrint(doc,"%s",buf);
|
||||
if (comment) {
|
||||
DocPrint(doc,"$$GREEN$$%s$$FG$$",comment);
|
||||
Free(comment);
|
||||
}
|
||||
DocPrint(doc,"\n");
|
||||
}
|
||||
Free(lst[i].idx);
|
||||
if (idx)
|
||||
progress1++;
|
||||
}
|
||||
Free(lst);
|
||||
if (idx)
|
||||
progress1=progress1_max=0;
|
||||
|
||||
wh_done:
|
||||
if (doc) {
|
||||
if (doc->head.next==doc)
|
||||
DocPrint(doc,"No Match");
|
||||
else
|
||||
DocRecalc(doc);
|
||||
}
|
||||
Free(last_idx);
|
||||
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.
|
||||
//Histogram of collision count.
|
||||
I64 i,j,longest=0,cnt=0,a[HDR_MAX];
|
||||
CHash *temph;
|
||||
if (!table) table=Fs->hash_table;
|
||||
MemSet(a,0,sizeof(a));
|
||||
for (i=0;i<=table->mask;i++) {
|
||||
temph=table->body[i];
|
||||
if (temph) {
|
||||
j=LinkedLstCnt(temph);
|
||||
if (j<HDR_MAX)
|
||||
a[j]++;
|
||||
cnt+=j;
|
||||
if (j>longest)
|
||||
longest=j;
|
||||
}
|
||||
}
|
||||
"Histogram\n";
|
||||
for (i=0;i<HDR_MAX;i++)
|
||||
if (a[i])
|
||||
"%02d:%d\n",i,a[i];
|
||||
"Size:%d Count:%d Longest:%d\n",
|
||||
table->mask+1,cnt,longest;
|
||||
return longest;
|
||||
}
|
||||
|
||||
#help_index "Help System"
|
||||
#help_file "::/Doc/HelpSystem"
|
||||
|
||||
public U0 DocHelpIdx(CDoc *doc,U8 *idx)
|
||||
{//Put to doc report for given help idx.
|
||||
Who("+p",,idx,doc);
|
||||
}
|
||||
|
||||
public U0 PopUpHelpIndex(U8 *idx,CTask *parent=NULL)
|
||||
{//PopUp win report for given help idx.
|
||||
U8 *buf;
|
||||
buf=MStrPrint("DocHelpIdx(DocPut,\"%s\");View;",idx);
|
||||
PopUp(buf,parent);
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
#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"),
|
||||
*absname=FileNameAbs(name);
|
||||
CDoc *doc=DocRead(name);
|
||||
CDocEntry *doc_e;
|
||||
CHashSrcSym *temph;
|
||||
I64 i,j,base=0;
|
||||
CDbgInfo *dbg_info;
|
||||
|
||||
FileExtRem(absname);
|
||||
if (absname[1]==':' && StrLen(absname)>2 &&
|
||||
(temph=HashSingleTableFind(absname+2,Fs->hash_table,HTT_MODULE)))
|
||||
base=temph(CHashGeneric *)->user_data0+sizeof(CBinFile);
|
||||
|
||||
if (!doc) return;
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type_u8==DOCT_LINK) {
|
||||
if (*doc_e->tag)
|
||||
st=MStrUtil(doc_e->tag,SUF_REM_TRAILING);
|
||||
else
|
||||
st=MStrUtil(doc_e->aux_str,SUF_REM_TRAILING);
|
||||
if (temph=HashSingleTableFind(st,Fs->hash_table,HTG_SRC_SYM)) {
|
||||
if (*doc_e->tag) {
|
||||
Free(temph->src_link);
|
||||
temph->src_link=doc_e->aux_str;
|
||||
ptr=temph->src_link;
|
||||
if (ptr[0] && ptr[1] && ptr[2]==':') {
|
||||
if (ptr[3]==':')
|
||||
ptr[3]=blkdev.boot_drv_let;
|
||||
else if (ptr[3]=='~')
|
||||
ptr[3]=*blkdev.home_dir;
|
||||
}
|
||||
doc_e->aux_str=NULL;
|
||||
}
|
||||
if (temph->type&(HTT_FUN|HTT_EXPORT_SYS_SYM) &&
|
||||
!(dbg_info=temph->dbg_info) && doc_e->bin_data &&
|
||||
(dbg_info=doc_e->bin_data->data)) {
|
||||
if (doc_e->bin_data->size>MSize(dbg_info))
|
||||
"Corrupt Map Entry\n";
|
||||
else {
|
||||
doc_e->bin_data->data=NULL;
|
||||
temph->dbg_info=dbg_info;
|
||||
for (i=dbg_info->min_line;i<=dbg_info->max_line+1;i++) {
|
||||
j=i-dbg_info->min_line;
|
||||
if (dbg_info->body[j])
|
||||
dbg_info->body[j]=dbg_info->body[j]+base;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
DocDel(doc);
|
||||
Free(name);
|
||||
Free(absname);
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,609 +0,0 @@
|
||||
#help_index "Math/ODE"
|
||||
#help_file "::/Doc/ODE"
|
||||
|
||||
//See $LK,"::/Doc/Credits.TXT"$.
|
||||
|
||||
F64 LowPass1(F64 a,F64 y0,F64 y,F64 dt=1.0)
|
||||
{//First order low pass filter
|
||||
dt=Exp(-a*dt);
|
||||
return y0*dt+y*(1.0-dt);
|
||||
}
|
||||
|
||||
U0 ODERstPtrs(CMathODE *ode)
|
||||
{
|
||||
I64 s=ode->n_internal*sizeof(F64);
|
||||
F64 *ptr=ode->array_base;
|
||||
ode->state_internal=ptr; ptr(I64)+=s;
|
||||
ode->state_scale=ptr; ptr(I64)+=s;
|
||||
ode->DstateDt=ptr; ptr(I64)+=s;
|
||||
ode->initial_state=ptr; ptr(I64)+=s;
|
||||
ode->temp0=ptr; ptr(I64)+=s;
|
||||
ode->temp1=ptr; ptr(I64)+=s;
|
||||
ode->temp2=ptr; ptr(I64)+=s;
|
||||
ode->temp3=ptr; ptr(I64)+=s;
|
||||
ode->temp4=ptr; ptr(I64)+=s;
|
||||
ode->temp5=ptr; ptr(I64)+=s;
|
||||
ode->temp6=ptr; ptr(I64)+=s;
|
||||
ode->temp7=ptr;
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
I64 s=n*sizeof(F64);
|
||||
CMathODE *ode=MAlloc(sizeof(CMathODE));
|
||||
|
||||
ode->t=0;
|
||||
ode->t_scale=1.0;
|
||||
ode->base_t=0;
|
||||
ode->flags=flags;
|
||||
ode->n_internal=ode->n=n;
|
||||
ode->h=1e-6;
|
||||
ode->h_min=1e-64;
|
||||
ode->h_max=1e32;
|
||||
ode->max_tolerance=ode->min_tolerance=ode->tolerance_internal=max_tolerance;
|
||||
ode->win_task=ode->mem_task=Fs;
|
||||
ode->derivative=NULL;
|
||||
QueInit(&ode->next_mass);
|
||||
QueInit(&ode->next_spring);
|
||||
ode->acceleration_limit=ode->drag_v=ode->drag_v2=ode->drag_v3=0;
|
||||
|
||||
ode->state=CAlloc(s);
|
||||
ode->array_base=MAlloc(12*s);
|
||||
ODERstPtrs(ode);
|
||||
return ode;
|
||||
}
|
||||
|
||||
public U0 ODEDel(CMathODE *ode)
|
||||
{//Free ODE node, but not masses or springs.
|
||||
if (!ode) return;
|
||||
Free(ode->state);
|
||||
Free(ode->array_base);
|
||||
Free(ode);
|
||||
}
|
||||
|
||||
public I64 ODESize(CMathODE *ode)
|
||||
{//Mem size of ode ctrl, but not masses and springs.
|
||||
if (!ode)
|
||||
return 0;
|
||||
else
|
||||
return MSize2(ode->state)+MSize2(ode->array_base)+MSize2(ode);
|
||||
}
|
||||
|
||||
U0 ODESetMassesPtrs(CMathODE *ode,F64 *state,F64 *DstateDt)
|
||||
{
|
||||
COrder2D3 *ptr1=state(F64 *)+ode->n,
|
||||
*ptr2=DstateDt(F64 *)+ode->n;
|
||||
CMass *tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
tempm->state=ptr1++;
|
||||
tempm->DstateDt=ptr2++;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ODEState2Internal(CMathODE *ode)
|
||||
{
|
||||
CMass *tempm;
|
||||
F64 *old_array_base;
|
||||
I64 mass_cnt;
|
||||
|
||||
if (ode->flags&ODEF_HAS_MASSES) {
|
||||
mass_cnt=0;
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
mass_cnt++;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
old_array_base=ode->array_base;
|
||||
ode->n_internal=ode->n+6*mass_cnt;
|
||||
ode->array_base=MAlloc(12*ode->n_internal*sizeof(F64),ode->mem_task);
|
||||
Free(old_array_base);
|
||||
ODERstPtrs(ode);
|
||||
|
||||
ODESetMassesPtrs(ode,ode->state_internal,ode->state_internal);
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
MemCpy(tempm->state,&tempm->saved_state,sizeof(COrder2D3));
|
||||
tempm=tempm->next;
|
||||
}
|
||||
}
|
||||
MemCpy(ode->state_internal,ode->state,ode->n*sizeof(F64));
|
||||
}
|
||||
|
||||
U0 ODEInternal2State(CMathODE *ode)
|
||||
{
|
||||
CMass *tempm;
|
||||
MemCpy(ode->state,ode->state_internal,ode->n*sizeof(F64));
|
||||
if (ode->flags&ODEF_HAS_MASSES) {
|
||||
ODESetMassesPtrs(ode,ode->state_internal,ode->state_internal);
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
MemCpy(&tempm->saved_state,tempm->state,sizeof(COrder2D3));
|
||||
tempm=tempm->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public U0 ODERenum(CMathODE *ode)
|
||||
{//Renumber masses and springs.
|
||||
I64 i;
|
||||
CSpring *temps;
|
||||
CMass *tempm;
|
||||
|
||||
i=0;
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
tempm->num=i++;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
|
||||
i=0;
|
||||
temps=ode->next_spring;
|
||||
while (temps!=&ode->next_spring) {
|
||||
temps->num=i++;
|
||||
temps->end1_num=temps->end1->num;
|
||||
temps->end2_num=temps->end2->num;
|
||||
temps=temps->next;
|
||||
}
|
||||
}
|
||||
|
||||
public CMass *MassFind(CMathODE *ode,F64 x,F64 y,F64 z=0)
|
||||
{//Search for mass nearest to x,y,z.
|
||||
CMass *tempm,*best_mass=NULL;
|
||||
F64 dd,best_dd=MAX_F64;
|
||||
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
dd=Sqr(tempm->x-x)+Sqr(tempm->y-y)+Sqr(tempm->z-z);
|
||||
if (dd<best_dd) {
|
||||
best_dd=dd;
|
||||
best_mass=tempm;
|
||||
}
|
||||
tempm=tempm->next;
|
||||
}
|
||||
return best_mass;
|
||||
}
|
||||
|
||||
public CSpring *SpringFind(CMathODE *ode,F64 x,F64 y,F64 z=0)
|
||||
{//Find spring midpoint nearest x,y,z.
|
||||
CSpring *temps,*best_spring=NULL;
|
||||
F64 dd,best_dd=MAX_F64;
|
||||
|
||||
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);
|
||||
if (dd<best_dd) {
|
||||
best_dd=dd;
|
||||
best_spring=temps;
|
||||
}
|
||||
temps=temps->next;
|
||||
}
|
||||
return best_spring;
|
||||
}
|
||||
|
||||
public U0 MassOrSpringFind(
|
||||
CMathODE *ode,CMass **res_mass,CSpring **res_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;
|
||||
F64 dd,best_dd=MAX_F64;
|
||||
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
dd=Sqr(tempm->x-x)+Sqr(tempm->y-y)+Sqr(tempm->z-z);
|
||||
if (dd<best_dd) {
|
||||
best_dd=dd;
|
||||
best_mass=tempm;
|
||||
}
|
||||
tempm=tempm->next;
|
||||
}
|
||||
|
||||
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);
|
||||
if (dd<best_dd) {
|
||||
best_dd=dd;
|
||||
best_spring=temps;
|
||||
best_mass=NULL;
|
||||
}
|
||||
temps=temps->next;
|
||||
}
|
||||
if (res_mass) *res_mass =best_mass;
|
||||
if (res_spring) *res_spring=best_spring;
|
||||
}
|
||||
|
||||
public CMass *MassFindNum(CMathODE *ode,I64 num)
|
||||
{//Return mass number N.
|
||||
CMass *tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
if (tempm->num==num)
|
||||
return tempm;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public U0 ODERstInactive(CMathODE *ode)
|
||||
{//Set all masses and springs to ACTIVE for new trial.
|
||||
CMass *tempm;
|
||||
CSpring *temps;
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
tempm->flags&=~MSF_INACTIVE;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
temps=ode->next_spring;
|
||||
while (temps!=&ode->next_spring) {
|
||||
temps->flags&=~SSF_INACTIVE;
|
||||
temps=temps->next;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ODECalcSprings(CMathODE *ode)
|
||||
{
|
||||
CSpring *temps=ode->next_spring;
|
||||
CMass *e1,*e2;
|
||||
F64 d;
|
||||
CD3 p;
|
||||
while (temps!=&ode->next_spring) {
|
||||
if (temps->flags&SSF_INACTIVE) {
|
||||
temps->displacement=0;
|
||||
temps->f=0;
|
||||
} else {
|
||||
e1=temps->end1;
|
||||
e2=temps->end2;
|
||||
d=D3Norm(D3Sub(&p,&e2->state->x,&e1->state->x));
|
||||
temps->displacement=d-temps->rest_len;
|
||||
temps->f=temps->displacement*temps->const;
|
||||
if (temps->f>0 && temps->flags&SSF_NO_TENSION)
|
||||
temps->f=0;
|
||||
else if (temps->f<0 && temps->flags&SSF_NO_COMPRESSION)
|
||||
temps->f=0;
|
||||
if (d>0) {
|
||||
D3MulEqu(&p,temps->f/d);
|
||||
D3AddEqu(&e1->DstateDt->DxDt,&p);
|
||||
D3SubEqu(&e2->DstateDt->DxDt,&p);
|
||||
}
|
||||
}
|
||||
temps=temps->next;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ODECalcDrag(CMathODE *ode)
|
||||
{
|
||||
CMass *tempm;
|
||||
F64 d,dd;
|
||||
CD3 p;
|
||||
if (ode->drag_v || ode->drag_v2 || ode->drag_v3) {
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
if (!(tempm->flags & MSF_INACTIVE) &&
|
||||
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(&p,d*tempm->drag_profile_factor,&tempm->state->DxDt));
|
||||
}
|
||||
tempm=tempm->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 ODEApplyAccelerationLimit(CMathODE *ode)
|
||||
{
|
||||
CMass *tempm;
|
||||
F64 d;
|
||||
if (ode->acceleration_limit) {
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
if (!(tempm->flags & MSF_INACTIVE) &&
|
||||
(d=D3Norm(&tempm->DstateDt->DxDt))>ode->acceleration_limit)
|
||||
D3MulEqu(&tempm->DstateDt->DxDt,ode->acceleration_limit/d);
|
||||
tempm=tempm->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 ODECallDerivative(CMathODE *ode,F64 t,F64 *state,F64 *DstateDt)
|
||||
{
|
||||
CMass *tempm;
|
||||
if (ode->flags&ODEF_HAS_MASSES) {
|
||||
ODESetMassesPtrs(ode,state,DstateDt);
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
if (!(tempm->flags&MSF_INACTIVE)) {
|
||||
D3Zero(&tempm->DstateDt->DxDt);
|
||||
D3Copy(&tempm->DstateDt->x,&tempm->state->DxDt);
|
||||
}
|
||||
tempm=tempm->next;
|
||||
}
|
||||
ODECalcSprings(ode);
|
||||
ODECalcDrag(ode);
|
||||
(*ode->derivative)(ode,t,state,DstateDt);
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
if (!(tempm->flags&MSF_INACTIVE)) {
|
||||
if (tempm->flags&MSF_FIXED) {
|
||||
D3Zero(&tempm->DstateDt->DxDt);
|
||||
D3Zero(&tempm->DstateDt->x);
|
||||
} else if (tempm->mass)
|
||||
D3DivEqu(&tempm->DstateDt->DxDt,tempm->mass);
|
||||
}
|
||||
tempm=tempm->next;
|
||||
}
|
||||
ODEApplyAccelerationLimit(ode);
|
||||
} else
|
||||
(*ode->derivative)(ode,t,state,DstateDt);
|
||||
}
|
||||
|
||||
U0 ODEOneStep(CMathODE *ode)
|
||||
{
|
||||
I64 i;
|
||||
ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt);
|
||||
for (i=0;i<ode->n_internal;i++)
|
||||
ode->state_internal[i]+=ode->h*ode->DstateDt[i];
|
||||
ode->t+=ode->h;
|
||||
}
|
||||
|
||||
U0 ODERK4OneStep(CMathODE *ode)
|
||||
{
|
||||
I64 i,n=ode->n_internal;
|
||||
F64 xh,hh,h6,*dym,*dyt,*yt,*DstateDt;
|
||||
|
||||
dym =ode->temp0;
|
||||
dyt =ode->temp1;
|
||||
yt =ode->temp2;
|
||||
DstateDt=ode->temp3;
|
||||
hh =0.5*ode->h;
|
||||
h6 =ode->h / 6.0;
|
||||
xh =ode->t + hh;
|
||||
|
||||
ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt);
|
||||
for (i=0;i<n;i++)
|
||||
yt[i]=ode->state_internal[i]+hh*DstateDt[i];
|
||||
ODECallDerivative(ode,xh,yt,dyt);
|
||||
for (i=0;i<n;i++)
|
||||
yt[i]=ode->state_internal[i]+hh*dyt[i];
|
||||
ODECallDerivative(ode,xh,yt,dym);
|
||||
for (i=0;i<n;i++) {
|
||||
yt[i]=ode->state_internal[i]+ode->h*dym[i];
|
||||
dym[i]+=dyt[i];
|
||||
}
|
||||
ode->t+=ode->h;
|
||||
ODECallDerivative(ode,ode->t,yt,dyt);
|
||||
for (i=0;i<n;i++)
|
||||
ode->state_internal[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)
|
||||
|
||||
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;
|
||||
|
||||
ak2=ode->temp0;
|
||||
ak3=ode->temp1;
|
||||
ak4=ode->temp2;
|
||||
ak5=ode->temp3;
|
||||
ak6=ode->temp4;
|
||||
tempstate=ode->temp5;
|
||||
outstate=ode->temp6;
|
||||
stateerr=ode->temp7;
|
||||
|
||||
for (i=0;i<n;i++)
|
||||
tempstate[i]=state[i]+ODEb21*h*DstateDt[i];
|
||||
ODECallDerivative(ode,ode->t+ODEa2*h,tempstate,ak2);
|
||||
for (i=0;i<n;i++)
|
||||
tempstate[i]=state[i]+h*(ODEb31*DstateDt[i]+ODEb32*ak2[i]);
|
||||
ODECallDerivative(ode,ode->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]);
|
||||
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]);
|
||||
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]);
|
||||
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]);
|
||||
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
|
||||
|
||||
U0 ODERK5OneStep(CMathODE *ode)
|
||||
{
|
||||
I64 i;
|
||||
F64 errmax,temp,*tempstate=ode->temp6,*stateerr=ode->temp7;
|
||||
while (TRUE) {
|
||||
ode->h=Clamp(ode->h,ode->h_min,ode->h_max);
|
||||
ODECashKarp(ode);
|
||||
errmax=0.0;
|
||||
for (i=0;i<ode->n_internal;i++) {
|
||||
temp=Abs(stateerr[i]/ode->state_scale[i]);
|
||||
if (temp>errmax)
|
||||
errmax=temp;
|
||||
}
|
||||
errmax/=ode->tolerance_internal;
|
||||
if (errmax<=1.0 || ode->h==ode->h_min) break;
|
||||
temp=ode->h*SAFETY*errmax`PSHRNK;
|
||||
if (temp<0.1*ode->h)
|
||||
ode->h*=0.1;
|
||||
else
|
||||
ode->h=temp;
|
||||
}
|
||||
ode->t+=ode->h;
|
||||
if (errmax>ERRCON)
|
||||
ode->h*=SAFETY*errmax`PGROW;
|
||||
else
|
||||
ode->h*=5.0;
|
||||
ode->h=Clamp(ode->h,ode->h_min,ode->h_max);
|
||||
MemCpy(ode->state_internal,tempstate,sizeof(F64)*ode->n_internal);
|
||||
}
|
||||
|
||||
F64 ode_alloced_factor=0.75;
|
||||
|
||||
U0 ODEsUpdate(CTask *task)
|
||||
{/* This routine is called by the $LK,"window mgr",A="FF:::/Adam/Gr/GrScreen.CPP,ODEsUpdate"$ on a continuous
|
||||
basis to allow real-time simulation. It is intended
|
||||
to provide ress good enough for games. It uses a runge-kutta
|
||||
integrator which is a better algorithm than doing it with Euler.
|
||||
|
||||
It is adaptive step-sized, so it slows down when an important
|
||||
event is taking place to improve accuracy, but in my implementation
|
||||
it has a timeout.
|
||||
*/
|
||||
I64 i;
|
||||
F64 d,start_time,timeout_time,t_desired,t_initial,interpolation;
|
||||
CMathODE *ode;
|
||||
|
||||
if (task->next_ode==&task->next_ode)
|
||||
task->last_ode_time=0;
|
||||
else if (!Bt(&task->win_inhibit,WIf_SELF_ODE)) {
|
||||
//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
|
||||
//and what the refresh cycle rate was.
|
||||
start_time=tS;
|
||||
d=1.0/winmgr.fps;
|
||||
timeout_time=start_time+
|
||||
(task->last_ode_time/d+0.1)/(winmgr.last_ode_time/d+0.1)*
|
||||
ode_alloced_factor*d;
|
||||
ode=task->next_ode;
|
||||
while (ode!=&task->next_ode) {
|
||||
t_initial=ode->t;
|
||||
d=tS;
|
||||
if (!(ode->flags&ODEF_STARTED)) {
|
||||
ode->base_t=d;
|
||||
ode->flags|=ODEF_STARTED;
|
||||
}
|
||||
d-=ode->base_t+t_initial;
|
||||
t_desired=ode->t_scale*d+t_initial;
|
||||
if (ode->flags&ODEF_PAUSED)
|
||||
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));
|
||||
while (ode->t<t_desired) {
|
||||
ode->h_max=t_desired-ode->t;
|
||||
ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt);
|
||||
for (i=0;i<ode->n_internal;i++)
|
||||
ode->state_scale[i]=Abs(ode->state_internal[i])+
|
||||
Abs(ode->DstateDt[i]*ode->h)+ode->tolerance_internal;
|
||||
ODERK5OneStep(ode);
|
||||
if (tS>timeout_time) {
|
||||
ode->base_t+=t_desired-ode->t; //Slip
|
||||
goto ode_done;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Interpolate if end time was not exact.
|
||||
if (ode->t!=t_desired) {
|
||||
if (interpolation=ode->t-t_initial) {
|
||||
interpolation=(t_desired-t_initial)/interpolation;
|
||||
if (interpolation!=1.0)
|
||||
for (i=0;i<ode->n_internal;i++)
|
||||
ode->state_internal[i]=(ode->state_internal[i]-
|
||||
ode->initial_state[i])*interpolation+
|
||||
ode->initial_state[i];
|
||||
}
|
||||
ode->t=t_desired;
|
||||
}
|
||||
ode_done:
|
||||
ODEInternal2State(ode);
|
||||
|
||||
//Convenience call to set vals
|
||||
ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt);
|
||||
}
|
||||
ode->base_t+=(1.0-ode->t_scale)*d;
|
||||
ode=ode->next;
|
||||
}
|
||||
|
||||
//Now, we will dynamically adjust tolerances.
|
||||
|
||||
//We will regulate the tolerances
|
||||
//to fill the time we decided was
|
||||
//okay to devote to ODE's.
|
||||
//Since we might have multiple ODE's
|
||||
//active we scale them by the same factor.
|
||||
|
||||
//This algorithm is probably not stable or very good, but it's something.
|
||||
|
||||
//Target is 75% of alloced time.
|
||||
d=(tS-start_time)/(timeout_time-start_time)-0.75;
|
||||
|
||||
ode=task->next_ode;
|
||||
while (ode!=&task->next_ode) {
|
||||
if (!(ode->flags&ODEF_PAUSED) && ode->derivative) {
|
||||
if (ode->min_tolerance!=ode->max_tolerance) {
|
||||
if (d>0)
|
||||
ode->tolerance_internal*=10.0`d;
|
||||
else
|
||||
ode->tolerance_internal*=2.0`d;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,609 @@
|
||||
#help_index "Math/ODE"
|
||||
#help_file "::/Doc/ODE"
|
||||
|
||||
//See $LK,"::/Doc/Credits.DD"$.
|
||||
|
||||
F64 LowPass1(F64 a,F64 y0,F64 y,F64 dt=1.0)
|
||||
{//First order low pass filter
|
||||
dt=Exp(-a*dt);
|
||||
return y0*dt+y*(1.0-dt);
|
||||
}
|
||||
|
||||
U0 ODERstPtrs(CMathODE *ode)
|
||||
{
|
||||
I64 s=ode->n_internal*sizeof(F64);
|
||||
F64 *ptr=ode->array_base;
|
||||
ode->state_internal=ptr; ptr(I64)+=s;
|
||||
ode->state_scale=ptr; ptr(I64)+=s;
|
||||
ode->DstateDt=ptr; ptr(I64)+=s;
|
||||
ode->initial_state=ptr; ptr(I64)+=s;
|
||||
ode->temp0=ptr; ptr(I64)+=s;
|
||||
ode->temp1=ptr; ptr(I64)+=s;
|
||||
ode->temp2=ptr; ptr(I64)+=s;
|
||||
ode->temp3=ptr; ptr(I64)+=s;
|
||||
ode->temp4=ptr; ptr(I64)+=s;
|
||||
ode->temp5=ptr; ptr(I64)+=s;
|
||||
ode->temp6=ptr; ptr(I64)+=s;
|
||||
ode->temp7=ptr;
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
I64 s=n*sizeof(F64);
|
||||
CMathODE *ode=MAlloc(sizeof(CMathODE));
|
||||
|
||||
ode->t=0;
|
||||
ode->t_scale=1.0;
|
||||
ode->base_t=0;
|
||||
ode->flags=flags;
|
||||
ode->n_internal=ode->n=n;
|
||||
ode->h=1e-6;
|
||||
ode->h_min=1e-64;
|
||||
ode->h_max=1e32;
|
||||
ode->max_tolerance=ode->min_tolerance=ode->tolerance_internal=max_tolerance;
|
||||
ode->win_task=ode->mem_task=Fs;
|
||||
ode->derivative=NULL;
|
||||
QueInit(&ode->next_mass);
|
||||
QueInit(&ode->next_spring);
|
||||
ode->acceleration_limit=ode->drag_v=ode->drag_v2=ode->drag_v3=0;
|
||||
|
||||
ode->state=CAlloc(s);
|
||||
ode->array_base=MAlloc(12*s);
|
||||
ODERstPtrs(ode);
|
||||
return ode;
|
||||
}
|
||||
|
||||
public U0 ODEDel(CMathODE *ode)
|
||||
{//Free ODE node, but not masses or springs.
|
||||
if (!ode) return;
|
||||
Free(ode->state);
|
||||
Free(ode->array_base);
|
||||
Free(ode);
|
||||
}
|
||||
|
||||
public I64 ODESize(CMathODE *ode)
|
||||
{//Mem size of ode ctrl, but not masses and springs.
|
||||
if (!ode)
|
||||
return 0;
|
||||
else
|
||||
return MSize2(ode->state)+MSize2(ode->array_base)+MSize2(ode);
|
||||
}
|
||||
|
||||
U0 ODESetMassesPtrs(CMathODE *ode,F64 *state,F64 *DstateDt)
|
||||
{
|
||||
COrder2D3 *ptr1=state(F64 *)+ode->n,
|
||||
*ptr2=DstateDt(F64 *)+ode->n;
|
||||
CMass *tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
tempm->state=ptr1++;
|
||||
tempm->DstateDt=ptr2++;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ODEState2Internal(CMathODE *ode)
|
||||
{
|
||||
CMass *tempm;
|
||||
F64 *old_array_base;
|
||||
I64 mass_cnt;
|
||||
|
||||
if (ode->flags&ODEF_HAS_MASSES) {
|
||||
mass_cnt=0;
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
mass_cnt++;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
old_array_base=ode->array_base;
|
||||
ode->n_internal=ode->n+6*mass_cnt;
|
||||
ode->array_base=MAlloc(12*ode->n_internal*sizeof(F64),ode->mem_task);
|
||||
Free(old_array_base);
|
||||
ODERstPtrs(ode);
|
||||
|
||||
ODESetMassesPtrs(ode,ode->state_internal,ode->state_internal);
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
MemCpy(tempm->state,&tempm->saved_state,sizeof(COrder2D3));
|
||||
tempm=tempm->next;
|
||||
}
|
||||
}
|
||||
MemCpy(ode->state_internal,ode->state,ode->n*sizeof(F64));
|
||||
}
|
||||
|
||||
U0 ODEInternal2State(CMathODE *ode)
|
||||
{
|
||||
CMass *tempm;
|
||||
MemCpy(ode->state,ode->state_internal,ode->n*sizeof(F64));
|
||||
if (ode->flags&ODEF_HAS_MASSES) {
|
||||
ODESetMassesPtrs(ode,ode->state_internal,ode->state_internal);
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
MemCpy(&tempm->saved_state,tempm->state,sizeof(COrder2D3));
|
||||
tempm=tempm->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public U0 ODERenum(CMathODE *ode)
|
||||
{//Renumber masses and springs.
|
||||
I64 i;
|
||||
CSpring *temps;
|
||||
CMass *tempm;
|
||||
|
||||
i=0;
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
tempm->num=i++;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
|
||||
i=0;
|
||||
temps=ode->next_spring;
|
||||
while (temps!=&ode->next_spring) {
|
||||
temps->num=i++;
|
||||
temps->end1_num=temps->end1->num;
|
||||
temps->end2_num=temps->end2->num;
|
||||
temps=temps->next;
|
||||
}
|
||||
}
|
||||
|
||||
public CMass *MassFind(CMathODE *ode,F64 x,F64 y,F64 z=0)
|
||||
{//Search for mass nearest to x,y,z.
|
||||
CMass *tempm,*best_mass=NULL;
|
||||
F64 dd,best_dd=MAX_F64;
|
||||
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
dd=Sqr(tempm->x-x)+Sqr(tempm->y-y)+Sqr(tempm->z-z);
|
||||
if (dd<best_dd) {
|
||||
best_dd=dd;
|
||||
best_mass=tempm;
|
||||
}
|
||||
tempm=tempm->next;
|
||||
}
|
||||
return best_mass;
|
||||
}
|
||||
|
||||
public CSpring *SpringFind(CMathODE *ode,F64 x,F64 y,F64 z=0)
|
||||
{//Find spring midpoint nearest x,y,z.
|
||||
CSpring *temps,*best_spring=NULL;
|
||||
F64 dd,best_dd=MAX_F64;
|
||||
|
||||
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);
|
||||
if (dd<best_dd) {
|
||||
best_dd=dd;
|
||||
best_spring=temps;
|
||||
}
|
||||
temps=temps->next;
|
||||
}
|
||||
return best_spring;
|
||||
}
|
||||
|
||||
public U0 MassOrSpringFind(
|
||||
CMathODE *ode,CMass **res_mass,CSpring **res_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;
|
||||
F64 dd,best_dd=MAX_F64;
|
||||
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
dd=Sqr(tempm->x-x)+Sqr(tempm->y-y)+Sqr(tempm->z-z);
|
||||
if (dd<best_dd) {
|
||||
best_dd=dd;
|
||||
best_mass=tempm;
|
||||
}
|
||||
tempm=tempm->next;
|
||||
}
|
||||
|
||||
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);
|
||||
if (dd<best_dd) {
|
||||
best_dd=dd;
|
||||
best_spring=temps;
|
||||
best_mass=NULL;
|
||||
}
|
||||
temps=temps->next;
|
||||
}
|
||||
if (res_mass) *res_mass =best_mass;
|
||||
if (res_spring) *res_spring=best_spring;
|
||||
}
|
||||
|
||||
public CMass *MassFindNum(CMathODE *ode,I64 num)
|
||||
{//Return mass number N.
|
||||
CMass *tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
if (tempm->num==num)
|
||||
return tempm;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public U0 ODERstInactive(CMathODE *ode)
|
||||
{//Set all masses and springs to ACTIVE for new trial.
|
||||
CMass *tempm;
|
||||
CSpring *temps;
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
tempm->flags&=~MSF_INACTIVE;
|
||||
tempm=tempm->next;
|
||||
}
|
||||
temps=ode->next_spring;
|
||||
while (temps!=&ode->next_spring) {
|
||||
temps->flags&=~SSF_INACTIVE;
|
||||
temps=temps->next;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ODECalcSprings(CMathODE *ode)
|
||||
{
|
||||
CSpring *temps=ode->next_spring;
|
||||
CMass *e1,*e2;
|
||||
F64 d;
|
||||
CD3 p;
|
||||
while (temps!=&ode->next_spring) {
|
||||
if (temps->flags&SSF_INACTIVE) {
|
||||
temps->displacement=0;
|
||||
temps->f=0;
|
||||
} else {
|
||||
e1=temps->end1;
|
||||
e2=temps->end2;
|
||||
d=D3Norm(D3Sub(&p,&e2->state->x,&e1->state->x));
|
||||
temps->displacement=d-temps->rest_len;
|
||||
temps->f=temps->displacement*temps->const;
|
||||
if (temps->f>0 && temps->flags&SSF_NO_TENSION)
|
||||
temps->f=0;
|
||||
else if (temps->f<0 && temps->flags&SSF_NO_COMPRESSION)
|
||||
temps->f=0;
|
||||
if (d>0) {
|
||||
D3MulEqu(&p,temps->f/d);
|
||||
D3AddEqu(&e1->DstateDt->DxDt,&p);
|
||||
D3SubEqu(&e2->DstateDt->DxDt,&p);
|
||||
}
|
||||
}
|
||||
temps=temps->next;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ODECalcDrag(CMathODE *ode)
|
||||
{
|
||||
CMass *tempm;
|
||||
F64 d,dd;
|
||||
CD3 p;
|
||||
if (ode->drag_v || ode->drag_v2 || ode->drag_v3) {
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
if (!(tempm->flags & MSF_INACTIVE) &&
|
||||
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(&p,d*tempm->drag_profile_factor,&tempm->state->DxDt));
|
||||
}
|
||||
tempm=tempm->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 ODEApplyAccelerationLimit(CMathODE *ode)
|
||||
{
|
||||
CMass *tempm;
|
||||
F64 d;
|
||||
if (ode->acceleration_limit) {
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
if (!(tempm->flags & MSF_INACTIVE) &&
|
||||
(d=D3Norm(&tempm->DstateDt->DxDt))>ode->acceleration_limit)
|
||||
D3MulEqu(&tempm->DstateDt->DxDt,ode->acceleration_limit/d);
|
||||
tempm=tempm->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 ODECallDerivative(CMathODE *ode,F64 t,F64 *state,F64 *DstateDt)
|
||||
{
|
||||
CMass *tempm;
|
||||
if (ode->flags&ODEF_HAS_MASSES) {
|
||||
ODESetMassesPtrs(ode,state,DstateDt);
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
if (!(tempm->flags&MSF_INACTIVE)) {
|
||||
D3Zero(&tempm->DstateDt->DxDt);
|
||||
D3Copy(&tempm->DstateDt->x,&tempm->state->DxDt);
|
||||
}
|
||||
tempm=tempm->next;
|
||||
}
|
||||
ODECalcSprings(ode);
|
||||
ODECalcDrag(ode);
|
||||
(*ode->derivative)(ode,t,state,DstateDt);
|
||||
tempm=ode->next_mass;
|
||||
while (tempm!=&ode->next_mass) {
|
||||
if (!(tempm->flags&MSF_INACTIVE)) {
|
||||
if (tempm->flags&MSF_FIXED) {
|
||||
D3Zero(&tempm->DstateDt->DxDt);
|
||||
D3Zero(&tempm->DstateDt->x);
|
||||
} else if (tempm->mass)
|
||||
D3DivEqu(&tempm->DstateDt->DxDt,tempm->mass);
|
||||
}
|
||||
tempm=tempm->next;
|
||||
}
|
||||
ODEApplyAccelerationLimit(ode);
|
||||
} else
|
||||
(*ode->derivative)(ode,t,state,DstateDt);
|
||||
}
|
||||
|
||||
U0 ODEOneStep(CMathODE *ode)
|
||||
{
|
||||
I64 i;
|
||||
ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt);
|
||||
for (i=0;i<ode->n_internal;i++)
|
||||
ode->state_internal[i]+=ode->h*ode->DstateDt[i];
|
||||
ode->t+=ode->h;
|
||||
}
|
||||
|
||||
U0 ODERK4OneStep(CMathODE *ode)
|
||||
{
|
||||
I64 i,n=ode->n_internal;
|
||||
F64 xh,hh,h6,*dym,*dyt,*yt,*DstateDt;
|
||||
|
||||
dym =ode->temp0;
|
||||
dyt =ode->temp1;
|
||||
yt =ode->temp2;
|
||||
DstateDt=ode->temp3;
|
||||
hh =0.5*ode->h;
|
||||
h6 =ode->h / 6.0;
|
||||
xh =ode->t + hh;
|
||||
|
||||
ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt);
|
||||
for (i=0;i<n;i++)
|
||||
yt[i]=ode->state_internal[i]+hh*DstateDt[i];
|
||||
ODECallDerivative(ode,xh,yt,dyt);
|
||||
for (i=0;i<n;i++)
|
||||
yt[i]=ode->state_internal[i]+hh*dyt[i];
|
||||
ODECallDerivative(ode,xh,yt,dym);
|
||||
for (i=0;i<n;i++) {
|
||||
yt[i]=ode->state_internal[i]+ode->h*dym[i];
|
||||
dym[i]+=dyt[i];
|
||||
}
|
||||
ode->t+=ode->h;
|
||||
ODECallDerivative(ode,ode->t,yt,dyt);
|
||||
for (i=0;i<n;i++)
|
||||
ode->state_internal[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)
|
||||
|
||||
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;
|
||||
|
||||
ak2=ode->temp0;
|
||||
ak3=ode->temp1;
|
||||
ak4=ode->temp2;
|
||||
ak5=ode->temp3;
|
||||
ak6=ode->temp4;
|
||||
tempstate=ode->temp5;
|
||||
outstate=ode->temp6;
|
||||
stateerr=ode->temp7;
|
||||
|
||||
for (i=0;i<n;i++)
|
||||
tempstate[i]=state[i]+ODEb21*h*DstateDt[i];
|
||||
ODECallDerivative(ode,ode->t+ODEa2*h,tempstate,ak2);
|
||||
for (i=0;i<n;i++)
|
||||
tempstate[i]=state[i]+h*(ODEb31*DstateDt[i]+ODEb32*ak2[i]);
|
||||
ODECallDerivative(ode,ode->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]);
|
||||
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]);
|
||||
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]);
|
||||
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]);
|
||||
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
|
||||
|
||||
U0 ODERK5OneStep(CMathODE *ode)
|
||||
{
|
||||
I64 i;
|
||||
F64 errmax,temp,*tempstate=ode->temp6,*stateerr=ode->temp7;
|
||||
while (TRUE) {
|
||||
ode->h=Clamp(ode->h,ode->h_min,ode->h_max);
|
||||
ODECashKarp(ode);
|
||||
errmax=0.0;
|
||||
for (i=0;i<ode->n_internal;i++) {
|
||||
temp=Abs(stateerr[i]/ode->state_scale[i]);
|
||||
if (temp>errmax)
|
||||
errmax=temp;
|
||||
}
|
||||
errmax/=ode->tolerance_internal;
|
||||
if (errmax<=1.0 || ode->h==ode->h_min) break;
|
||||
temp=ode->h*SAFETY*errmax`PSHRNK;
|
||||
if (temp<0.1*ode->h)
|
||||
ode->h*=0.1;
|
||||
else
|
||||
ode->h=temp;
|
||||
}
|
||||
ode->t+=ode->h;
|
||||
if (errmax>ERRCON)
|
||||
ode->h*=SAFETY*errmax`PGROW;
|
||||
else
|
||||
ode->h*=5.0;
|
||||
ode->h=Clamp(ode->h,ode->h_min,ode->h_max);
|
||||
MemCpy(ode->state_internal,tempstate,sizeof(F64)*ode->n_internal);
|
||||
}
|
||||
|
||||
F64 ode_alloced_factor=0.75;
|
||||
|
||||
U0 ODEsUpdate(CTask *task)
|
||||
{/* This routine is called by the $LK,"window mgr",A="FF:::/Adam/Gr/GrScreen.HC,ODEsUpdate"$ on a continuous
|
||||
basis to allow real-time simulation. It is intended
|
||||
to provide ress good enough for games. It uses a runge-kutta
|
||||
integrator which is a better algorithm than doing it with Euler.
|
||||
|
||||
It is adaptive step-sized, so it slows down when an important
|
||||
event is taking place to improve accuracy, but in my implementation
|
||||
it has a timeout.
|
||||
*/
|
||||
I64 i;
|
||||
F64 d,start_time,timeout_time,t_desired,t_initial,interpolation;
|
||||
CMathODE *ode;
|
||||
|
||||
if (task->next_ode==&task->next_ode)
|
||||
task->last_ode_time=0;
|
||||
else if (!Bt(&task->win_inhibit,WIf_SELF_ODE)) {
|
||||
//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
|
||||
//and what the refresh cycle rate was.
|
||||
start_time=tS;
|
||||
d=1.0/winmgr.fps;
|
||||
timeout_time=start_time+
|
||||
(task->last_ode_time/d+0.1)/(winmgr.last_ode_time/d+0.1)*
|
||||
ode_alloced_factor*d;
|
||||
ode=task->next_ode;
|
||||
while (ode!=&task->next_ode) {
|
||||
t_initial=ode->t;
|
||||
d=tS;
|
||||
if (!(ode->flags&ODEF_STARTED)) {
|
||||
ode->base_t=d;
|
||||
ode->flags|=ODEF_STARTED;
|
||||
}
|
||||
d-=ode->base_t+t_initial;
|
||||
t_desired=ode->t_scale*d+t_initial;
|
||||
if (ode->flags&ODEF_PAUSED)
|
||||
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));
|
||||
while (ode->t<t_desired) {
|
||||
ode->h_max=t_desired-ode->t;
|
||||
ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt);
|
||||
for (i=0;i<ode->n_internal;i++)
|
||||
ode->state_scale[i]=Abs(ode->state_internal[i])+
|
||||
Abs(ode->DstateDt[i]*ode->h)+ode->tolerance_internal;
|
||||
ODERK5OneStep(ode);
|
||||
if (tS>timeout_time) {
|
||||
ode->base_t+=t_desired-ode->t; //Slip
|
||||
goto ode_done;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Interpolate if end time was not exact.
|
||||
if (ode->t!=t_desired) {
|
||||
if (interpolation=ode->t-t_initial) {
|
||||
interpolation=(t_desired-t_initial)/interpolation;
|
||||
if (interpolation!=1.0)
|
||||
for (i=0;i<ode->n_internal;i++)
|
||||
ode->state_internal[i]=(ode->state_internal[i]-
|
||||
ode->initial_state[i])*interpolation+
|
||||
ode->initial_state[i];
|
||||
}
|
||||
ode->t=t_desired;
|
||||
}
|
||||
ode_done:
|
||||
ODEInternal2State(ode);
|
||||
|
||||
//Convenience call to set vals
|
||||
ODECallDerivative(ode,ode->t,ode->state_internal,ode->DstateDt);
|
||||
}
|
||||
ode->base_t+=(1.0-ode->t_scale)*d;
|
||||
ode=ode->next;
|
||||
}
|
||||
|
||||
//Now, we will dynamically adjust tolerances.
|
||||
|
||||
//We will regulate the tolerances
|
||||
//to fill the time we decided was
|
||||
//okay to devote to ODE's.
|
||||
//Since we might have multiple ODE's
|
||||
//active we scale them by the same factor.
|
||||
|
||||
//This algorithm is probably not stable or very good, but it's something.
|
||||
|
||||
//Target is 75% of alloced time.
|
||||
d=(tS-start_time)/(timeout_time-start_time)-0.75;
|
||||
|
||||
ode=task->next_ode;
|
||||
while (ode!=&task->next_ode) {
|
||||
if (!(ode->flags&ODEF_PAUSED) && ode->derivative) {
|
||||
if (ode->min_tolerance!=ode->max_tolerance) {
|
||||
if (d>0)
|
||||
ode->tolerance_internal*=10.0`d;
|
||||
else
|
||||
ode->tolerance_internal*=2.0`d;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
#help_index "Misc/Registry"
|
||||
#define REGISTRY_FILENAME "~/Registry.CPP.Z"
|
||||
CDoc *sys_registry_doc=NULL;
|
||||
I64 sys_msg_flags[1]={0};
|
||||
F64 registry_version;
|
||||
|
||||
Bool RegCache()
|
||||
{
|
||||
Bool old_silent;
|
||||
if (!sys_registry_doc) {
|
||||
old_silent=Silent;
|
||||
sys_registry_doc=DocRead(REGISTRY_FILENAME);
|
||||
Silent(old_silent);
|
||||
return FALSE;
|
||||
} else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool RegSetDftEntry(U8 *path,U8 *val,Bool is_adam_entry=FALSE)
|
||||
{//Add code doc tree branch to registry.
|
||||
Bool res,unlock_doc;
|
||||
RegCache;
|
||||
unlock_doc=DocLock(sys_registry_doc);
|
||||
if (!DocTreeFind(sys_registry_doc,path)) {
|
||||
DocTreeMake(sys_registry_doc,path);
|
||||
DocPrint(sys_registry_doc,"%s",val);
|
||||
if (is_adam_entry) {
|
||||
if (Fs==adam_task)
|
||||
ExePrint("%s",val);
|
||||
else
|
||||
Adam("%s",val);
|
||||
}
|
||||
if (DrvIsWritable(*sys_registry_doc->filename.name))
|
||||
DocWrite(sys_registry_doc);
|
||||
res=FALSE;
|
||||
} else
|
||||
res=TRUE;
|
||||
if (unlock_doc)
|
||||
DocUnlock(sys_registry_doc);
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 RegExeBranch(U8 *path)
|
||||
{//Execute doc tree branch in registry.
|
||||
RegCache;
|
||||
return DocTreeBranchExe(sys_registry_doc,path);
|
||||
}
|
||||
|
||||
public Bool RegWriteBranch(U8 *path,U8 *fmt,...)
|
||||
{//Rewrite doc tree branch in registry.
|
||||
Bool res,unlock_doc;
|
||||
CDocEntry *tree_branch,*start_indent,*end_indent;
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
RegCache;
|
||||
unlock_doc=DocLock(sys_registry_doc);
|
||||
if (res=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 (DrvIsWritable(*sys_registry_doc->filename.name))
|
||||
DocWrite(sys_registry_doc);
|
||||
if (unlock_doc)
|
||||
DocUnlock(sys_registry_doc);
|
||||
Free(buf);
|
||||
return res;
|
||||
}
|
||||
|
||||
public Bool OneTimePopUp(U8 *_flags,I64 flag_num,U8 *msg)
|
||||
{//See $LK,"::/Apps/X-Caliber/X-Caliber.CPP"$.
|
||||
Bool res=FALSE;
|
||||
CDoc *doc=DocNew;
|
||||
CDocEntry *doc_e;
|
||||
if (!Bt(_flags,flag_num)) {
|
||||
if (msg) DocPrint(doc,"%s",msg);
|
||||
doc_e=DocPrint(doc,"\n$$CB,\"Do not show this msg again.\",LE=1$$");
|
||||
DocPrint(doc,"$$CM+CX,0,4$$$$BT,\"OKAY\",LE=1$$\n");
|
||||
if (PopUpMenu(doc)==1 && doc_e->de_flags&DOCEF_CHECKED_COLLAPSED) {
|
||||
LBts(_flags,flag_num);
|
||||
res=TRUE;
|
||||
}
|
||||
DocDel(doc);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
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))
|
||||
RegWriteBranch("Adam/SysMsgFlags","sys_msg_flags[0]=0x%X;\n",
|
||||
sys_msg_flags[0]);
|
||||
}
|
||||
|
||||
U0 RegInit()
|
||||
{
|
||||
U8 buf[STR_LEN];
|
||||
Bool version_present;
|
||||
RegSetDftEntry("Adam/SysMsgFlags","sys_msg_flags[0]=0;\n",TRUE);
|
||||
StrPrint(buf,"registry_version=%4.3f;\n",os_version);
|
||||
version_present=RegSetDftEntry("Adam/SysRegVer",buf,TRUE);
|
||||
RegExeBranch("Adam");
|
||||
if (registry_version!=os_version) {
|
||||
RegWriteBranch("Adam/SysRegVer",buf);
|
||||
RegExeBranch("Adam");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
#help_index "Misc/Registry"
|
||||
#define REGISTRY_FILENAME "~/Registry.HC.Z"
|
||||
CDoc *sys_registry_doc=NULL;
|
||||
I64 sys_msg_flags[1]={0};
|
||||
F64 registry_version;
|
||||
|
||||
Bool RegCache()
|
||||
{
|
||||
Bool old_silent;
|
||||
if (!sys_registry_doc) {
|
||||
old_silent=Silent;
|
||||
sys_registry_doc=DocRead(REGISTRY_FILENAME);
|
||||
Silent(old_silent);
|
||||
return FALSE;
|
||||
} else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public Bool RegSetDftEntry(U8 *path,U8 *val,Bool is_adam_entry=FALSE)
|
||||
{//Add code doc tree branch to registry.
|
||||
Bool res,unlock_doc;
|
||||
RegCache;
|
||||
unlock_doc=DocLock(sys_registry_doc);
|
||||
if (!DocTreeFind(sys_registry_doc,path)) {
|
||||
DocTreeMake(sys_registry_doc,path);
|
||||
DocPrint(sys_registry_doc,"%s",val);
|
||||
if (is_adam_entry) {
|
||||
if (Fs==adam_task)
|
||||
ExePrint("%s",val);
|
||||
else
|
||||
Adam("%s",val);
|
||||
}
|
||||
if (DrvIsWritable(*sys_registry_doc->filename.name))
|
||||
DocWrite(sys_registry_doc);
|
||||
res=FALSE;
|
||||
} else
|
||||
res=TRUE;
|
||||
if (unlock_doc)
|
||||
DocUnlock(sys_registry_doc);
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 RegExeBranch(U8 *path)
|
||||
{//Execute doc tree branch in registry.
|
||||
RegCache;
|
||||
return DocTreeBranchExe(sys_registry_doc,path);
|
||||
}
|
||||
|
||||
public Bool RegWriteBranch(U8 *path,U8 *fmt,...)
|
||||
{//Rewrite doc tree branch in registry.
|
||||
Bool res,unlock_doc;
|
||||
CDocEntry *tree_branch,*start_indent,*end_indent;
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
RegCache;
|
||||
unlock_doc=DocLock(sys_registry_doc);
|
||||
if (res=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 (DrvIsWritable(*sys_registry_doc->filename.name))
|
||||
DocWrite(sys_registry_doc);
|
||||
if (unlock_doc)
|
||||
DocUnlock(sys_registry_doc);
|
||||
Free(buf);
|
||||
return res;
|
||||
}
|
||||
|
||||
public Bool OneTimePopUp(U8 *_flags,I64 flag_num,U8 *msg)
|
||||
{//See $LK,"::/Apps/X-Caliber/X-Caliber.HC"$.
|
||||
Bool res=FALSE;
|
||||
CDoc *doc=DocNew;
|
||||
CDocEntry *doc_e;
|
||||
if (!Bt(_flags,flag_num)) {
|
||||
if (msg) DocPrint(doc,"%s",msg);
|
||||
doc_e=DocPrint(doc,"\n$$CB,\"Do not show this msg again.\",LE=1$$");
|
||||
DocPrint(doc,"$$CM+CX,0,4$$$$BT,\"OKAY\",LE=1$$\n");
|
||||
if (PopUpMenu(doc)==1 && doc_e->de_flags&DOCEF_CHECKED_COLLAPSED) {
|
||||
LBts(_flags,flag_num);
|
||||
res=TRUE;
|
||||
}
|
||||
DocDel(doc);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
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))
|
||||
RegWriteBranch("Adam/SysMsgFlags","sys_msg_flags[0]=0x%X;\n",
|
||||
sys_msg_flags[0]);
|
||||
}
|
||||
|
||||
U0 RegInit()
|
||||
{
|
||||
U8 buf[STR_LEN];
|
||||
Bool version_present;
|
||||
RegSetDftEntry("Adam/SysMsgFlags","sys_msg_flags[0]=0;\n",TRUE);
|
||||
StrPrint(buf,"registry_version=%4.3f;\n",os_version);
|
||||
version_present=RegSetDftEntry("Adam/SysRegVer",buf,TRUE);
|
||||
RegExeBranch("Adam");
|
||||
if (registry_version!=os_version) {
|
||||
RegWriteBranch("Adam/SysRegVer",buf);
|
||||
RegExeBranch("Adam");
|
||||
}
|
||||
}
|
||||
@@ -1,263 +0,0 @@
|
||||
/*
|
||||
This file is a stand-alone program
|
||||
which will regenerate processed dictionary
|
||||
files from a raw Project Gutenberg
|
||||
dictionary file.
|
||||
|
||||
$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_TABS|DOCF_DBL_DOLLARS)) {
|
||||
doc_e=doc->head.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 *ptr=*_ptr,*ptr2;
|
||||
I64 ch,res=-1;
|
||||
do {
|
||||
do {
|
||||
if (!(ch=*ptr++)) goto ncmd_done;
|
||||
} while (ch!='<');
|
||||
|
||||
ptr2=ptr;
|
||||
do {
|
||||
if (!(ch=*ptr2++)) goto ncmd_done;
|
||||
} while (ch!='>');
|
||||
*--ptr2=0;
|
||||
res=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");
|
||||
*ptr2++='>';
|
||||
ptr=ptr2;
|
||||
} while (res<0);
|
||||
|
||||
ncmd_done:
|
||||
*_ptr=ptr;
|
||||
return res;
|
||||
}
|
||||
|
||||
U8 *ACDNextEntry(U8 **_ptr)
|
||||
{
|
||||
U8 *res,*ignore,*ptr=*_ptr,buf[ACD_BLK_SIZE],*out_ptr=buf;
|
||||
I64 ch,l;
|
||||
while (TRUE) {
|
||||
while (TRUE) {
|
||||
if (!(ch=*ptr++)) goto nentry_done;
|
||||
if (ch!='<') {
|
||||
*out_ptr++=ch;
|
||||
if (ch=='$$')
|
||||
*out_ptr++=ch;
|
||||
} else
|
||||
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";
|
||||
while (*ignore) {
|
||||
l=StrLen(ignore);
|
||||
if (!StrNCmp(ptr,ignore,l)) {
|
||||
ptr+=l;
|
||||
break;
|
||||
} else
|
||||
ignore+=l+1;
|
||||
}
|
||||
if (!*ignore)
|
||||
break;
|
||||
}
|
||||
nentry_done:
|
||||
*out_ptr++=0;
|
||||
res=StrNew(buf);
|
||||
*_ptr=ptr-1;
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 ACDCompareWords(U8 *e1,U8 *e2)
|
||||
{
|
||||
return StrICmp(e1,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;
|
||||
I64 i=0;
|
||||
while (*ptr) {
|
||||
ptr_array[i++]=ptr;
|
||||
ptr+=StrLen(ptr)+3;
|
||||
}
|
||||
"Sorting...\n"; Sleep(100);
|
||||
QSortI64(ptr_array,word_cnt,&ACDCompareWords);
|
||||
"Done...\n"; 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;
|
||||
}
|
||||
|
||||
U0 ACDGen(U8 *in_file)
|
||||
{
|
||||
I64 cmd,size,word_cnt=0,largest_entry=0;
|
||||
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 {
|
||||
cmd=ACDNextCmd(&in_ptr);
|
||||
if (cmd==ACD_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=ACDNextEntry(&in_ptr)) {
|
||||
if (*st) {
|
||||
if (StrICmp(st,last_word)) {
|
||||
word_cnt++;
|
||||
|
||||
*word_ptr++=ACD_WORD_CHAR;
|
||||
last_word=word_ptr;
|
||||
StrCpy(word_ptr,st);
|
||||
word_ptr+=StrLen(st)+1;
|
||||
|
||||
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;
|
||||
}
|
||||
Free(st);
|
||||
|
||||
do {
|
||||
do {
|
||||
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));
|
||||
if (cmd==ACD_DEF) {
|
||||
if(st=ACDNextEntry(&in_ptr)) {
|
||||
if (*st) {
|
||||
*out_ptr++=ACD_DEF_CHAR;
|
||||
StrCpy(out_ptr,st);
|
||||
out_ptr+=StrLen(st)+1;
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
} else if (cmd==ACD_PRONUNCIATION) {
|
||||
if(st=ACDNextEntry(&in_ptr)) {
|
||||
if (*st) {
|
||||
*out_ptr++=ACD_PRONUNCIATION_CHAR;
|
||||
StrCpy(out_ptr,st);
|
||||
out_ptr+=StrLen(st)+1;
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
} else if (cmd==ACD_POS) {
|
||||
if(st=ACDNextEntry(&in_ptr)) {
|
||||
if (*st) {
|
||||
*out_ptr++=ACD_POS_CHAR;
|
||||
StrCpy(out_ptr,st);
|
||||
out_ptr+=StrLen(st)+1;
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
} else if (cmd==ACD_EXTRA) {
|
||||
if(st=ACDNextEntry(&in_ptr)) {
|
||||
if (*st) {
|
||||
*out_ptr++=ACD_EXTRA_CHAR;
|
||||
StrCpy(out_ptr,st);
|
||||
out_ptr+=StrLen(st)+1;
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
} while (cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||
|
||||
cmd==ACD_POS||cmd==ACD_EXTRA);
|
||||
} else
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
} while (cmd>=0);
|
||||
*out_ptr++=ACD_END_CHAR;
|
||||
*word_ptr++=ACD_END_CHAR;
|
||||
|
||||
Free(in_start);
|
||||
|
||||
"Blk Size :%d\n",ACD_BLK_SIZE;
|
||||
"Blk Cnt :%04X\n",(out_ptr-out_start+ACD_BLK_SIZE-1)/ACD_BLK_SIZE;
|
||||
"Largest Entry :%d\n",largest_entry;
|
||||
"Word Count :%d\n",word_cnt;
|
||||
|
||||
FileWrite(ACD_DEF_FILENAME,out_start,out_ptr-out_start);
|
||||
"Def File Size :%d\n",out_ptr-out_start;
|
||||
|
||||
sorted_word_start=ACDSortWords(word_start,word_ptr-word_start,word_cnt);
|
||||
FileWrite(ACD_WORD_FILENAME,sorted_word_start,word_ptr-word_start);
|
||||
"Word File Size:%d\n",word_ptr-word_start;
|
||||
|
||||
Free(out_start);
|
||||
Free(word_start);
|
||||
Free(sorted_word_start);
|
||||
}
|
||||
|
||||
Cd(__DIR__);
|
||||
ACDPreprocess("DICTIONARY.TXT","DICTIONARY2.TXT");
|
||||
ACDGen("DICTIONARY2.TXT");
|
||||
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
This file is a stand-alone program
|
||||
which will regenerate processed dictionary
|
||||
files from a raw Project Gutenberg
|
||||
dictionary file.
|
||||
|
||||
$TX,"http://www.templeos.org/files/DICTIONARY.DD",HTML="http://www.templeos.org/files/DICTIONARY.DD"$
|
||||
|
||||
See $LK,"::/Doc/Credits.DD"$.
|
||||
*/
|
||||
|
||||
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_TABS|DOCF_DBL_DOLLARS)) {
|
||||
doc_e=doc->head.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 *ptr=*_ptr,*ptr2;
|
||||
I64 ch,res=-1;
|
||||
do {
|
||||
do {
|
||||
if (!(ch=*ptr++)) goto ncmd_done;
|
||||
} while (ch!='<');
|
||||
|
||||
ptr2=ptr;
|
||||
do {
|
||||
if (!(ch=*ptr2++)) goto ncmd_done;
|
||||
} while (ch!='>');
|
||||
*--ptr2=0;
|
||||
res=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");
|
||||
*ptr2++='>';
|
||||
ptr=ptr2;
|
||||
} while (res<0);
|
||||
|
||||
ncmd_done:
|
||||
*_ptr=ptr;
|
||||
return res;
|
||||
}
|
||||
|
||||
U8 *ACDNextEntry(U8 **_ptr)
|
||||
{
|
||||
U8 *res,*ignore,*ptr=*_ptr,buf[ACD_BLK_SIZE],*out_ptr=buf;
|
||||
I64 ch,l;
|
||||
while (TRUE) {
|
||||
while (TRUE) {
|
||||
if (!(ch=*ptr++)) goto nentry_done;
|
||||
if (ch!='<') {
|
||||
*out_ptr++=ch;
|
||||
if (ch=='$$')
|
||||
*out_ptr++=ch;
|
||||
} else
|
||||
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";
|
||||
while (*ignore) {
|
||||
l=StrLen(ignore);
|
||||
if (!StrNCmp(ptr,ignore,l)) {
|
||||
ptr+=l;
|
||||
break;
|
||||
} else
|
||||
ignore+=l+1;
|
||||
}
|
||||
if (!*ignore)
|
||||
break;
|
||||
}
|
||||
nentry_done:
|
||||
*out_ptr++=0;
|
||||
res=StrNew(buf);
|
||||
*_ptr=ptr-1;
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 ACDCompareWords(U8 *e1,U8 *e2)
|
||||
{
|
||||
return StrICmp(e1,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;
|
||||
I64 i=0;
|
||||
while (*ptr) {
|
||||
ptr_array[i++]=ptr;
|
||||
ptr+=StrLen(ptr)+3;
|
||||
}
|
||||
"Sorting...\n"; Sleep(100);
|
||||
QSortI64(ptr_array,word_cnt,&ACDCompareWords);
|
||||
"Done...\n"; 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;
|
||||
}
|
||||
|
||||
U0 ACDGen(U8 *in_file)
|
||||
{
|
||||
I64 cmd,size,word_cnt=0,largest_entry=0;
|
||||
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 {
|
||||
cmd=ACDNextCmd(&in_ptr);
|
||||
if (cmd==ACD_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=ACDNextEntry(&in_ptr)) {
|
||||
if (*st) {
|
||||
if (StrICmp(st,last_word)) {
|
||||
word_cnt++;
|
||||
|
||||
*word_ptr++=ACD_WORD_CHAR;
|
||||
last_word=word_ptr;
|
||||
StrCpy(word_ptr,st);
|
||||
word_ptr+=StrLen(st)+1;
|
||||
|
||||
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;
|
||||
}
|
||||
Free(st);
|
||||
|
||||
do {
|
||||
do {
|
||||
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));
|
||||
if (cmd==ACD_DEF) {
|
||||
if(st=ACDNextEntry(&in_ptr)) {
|
||||
if (*st) {
|
||||
*out_ptr++=ACD_DEF_CHAR;
|
||||
StrCpy(out_ptr,st);
|
||||
out_ptr+=StrLen(st)+1;
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
} else if (cmd==ACD_PRONUNCIATION) {
|
||||
if(st=ACDNextEntry(&in_ptr)) {
|
||||
if (*st) {
|
||||
*out_ptr++=ACD_PRONUNCIATION_CHAR;
|
||||
StrCpy(out_ptr,st);
|
||||
out_ptr+=StrLen(st)+1;
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
} else if (cmd==ACD_POS) {
|
||||
if(st=ACDNextEntry(&in_ptr)) {
|
||||
if (*st) {
|
||||
*out_ptr++=ACD_POS_CHAR;
|
||||
StrCpy(out_ptr,st);
|
||||
out_ptr+=StrLen(st)+1;
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
} else if (cmd==ACD_EXTRA) {
|
||||
if(st=ACDNextEntry(&in_ptr)) {
|
||||
if (*st) {
|
||||
*out_ptr++=ACD_EXTRA_CHAR;
|
||||
StrCpy(out_ptr,st);
|
||||
out_ptr+=StrLen(st)+1;
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
} while (cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||
|
||||
cmd==ACD_POS||cmd==ACD_EXTRA);
|
||||
} else
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
} while (cmd>=0);
|
||||
*out_ptr++=ACD_END_CHAR;
|
||||
*word_ptr++=ACD_END_CHAR;
|
||||
|
||||
Free(in_start);
|
||||
|
||||
"Blk Size :%d\n",ACD_BLK_SIZE;
|
||||
"Blk Cnt :%04X\n",(out_ptr-out_start+ACD_BLK_SIZE-1)/ACD_BLK_SIZE;
|
||||
"Largest Entry :%d\n",largest_entry;
|
||||
"Word Count :%d\n",word_cnt;
|
||||
|
||||
FileWrite(ACD_DEF_FILENAME,out_start,out_ptr-out_start);
|
||||
"Def File Size :%d\n",out_ptr-out_start;
|
||||
|
||||
sorted_word_start=ACDSortWords(word_start,word_ptr-word_start,word_cnt);
|
||||
FileWrite(ACD_WORD_FILENAME,sorted_word_start,word_ptr-word_start);
|
||||
"Word File Size:%d\n",word_ptr-word_start;
|
||||
|
||||
Free(out_start);
|
||||
Free(word_start);
|
||||
Free(sorted_word_start);
|
||||
}
|
||||
|
||||
Cd(__DIR__);
|
||||
ACDPreprocess("DICTIONARY.DD","DICTIONARY2.DD");
|
||||
ACDGen("DICTIONARY2.DD");
|
||||
@@ -1,285 +0,0 @@
|
||||
#help_index "AutoComplete/Dictionary"
|
||||
U0 ACDDictWordsAdd(U8 *st)
|
||||
{
|
||||
I64 i;
|
||||
U8 *ptr;
|
||||
if (st && *st && (ptr=ACDWordPtAt(st))) {
|
||||
for (i=0;i<ACD_MAX_FILLINS;i++) {
|
||||
if (*ptr++!=ACD_WORD_CHAR)
|
||||
break;
|
||||
if (i) '\n';
|
||||
acd.fillins[i]=ptr-1;
|
||||
"$$GREEN$$'%d'$$FG$$ %-23ts",i,ptr;
|
||||
ptr+=StrLen(ptr)+3;
|
||||
}
|
||||
acd.num_fillins=i;
|
||||
}
|
||||
}
|
||||
|
||||
#help_index "AutoComplete"
|
||||
U0 ACDocRst(I64 left,I64 top)
|
||||
{
|
||||
CDoc *doc=DocPut;
|
||||
DocRst(doc,TRUE);
|
||||
doc->flags|=DOCF_MIN_SIZE;
|
||||
Fs->border_src=BDS_CONST;
|
||||
Fs->border_attr=LTGRAY<<4+DrvTextAttrGet(':')&15;
|
||||
Fs->text_attr =LTGRAY<<4+BLUE;
|
||||
LBtr(&Fs->display_flags,DISPLAYf_SHOW);
|
||||
WinHorz(left,Fs->win_right);
|
||||
WinVert(top,Fs->win_bottom);
|
||||
DocCursor;
|
||||
}
|
||||
|
||||
I64 ACSkipCrap(U8 *src,I64 len)
|
||||
{
|
||||
I64 j;
|
||||
j=len-1;
|
||||
while (j>=0) {
|
||||
if (Bt(chars_bmp_alpha_numeric,src[j]))
|
||||
break;
|
||||
else
|
||||
j--;
|
||||
}
|
||||
return j+1;
|
||||
}
|
||||
|
||||
I64 ACPriorWordInStr(U8 *src,U8 *dst,I64 len,I64 buf_size)
|
||||
{
|
||||
I64 i,j=0,k;
|
||||
i=len-1;
|
||||
while (i>=0)
|
||||
if (!Bt(chars_bmp_alpha_numeric,src[i]))
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
U0 ACFillInAdd(CHashAC *tempw)
|
||||
{
|
||||
I64 k;
|
||||
if (ac.num_fillins<AC_MAX_FILLINS ||
|
||||
tempw->hits>ac.fillin_hits[ac.num_fillins-1]) {
|
||||
for (k=ac.num_fillins-1;k>=0;k--) {
|
||||
if (tempw->hits<=ac.fillin_hits[k])
|
||||
break;
|
||||
else {
|
||||
ac.fillin_matches[k+1]=ac.fillin_matches[k];
|
||||
ac.fillin_hits[k+1] =ac.fillin_hits[k];
|
||||
}
|
||||
}
|
||||
ac.fillin_matches[k+1]=tempw;
|
||||
ac.fillin_hits[k+1] =tempw->hits;
|
||||
if (ac.num_fillins<AC_MAX_FILLINS)
|
||||
ac.num_fillins++;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ACPutChoices(CDoc *focus_l,CDocEntry *doc_e,CTask *focus_task,
|
||||
Bool force_refresh)
|
||||
{
|
||||
I64 i,data_col;
|
||||
U8 *buf,*buf1,*src=NULL,*st;
|
||||
CHashAC *tempw;
|
||||
F64 timeout_time=tS+0.5;
|
||||
CHashSrcSym *temph;
|
||||
|
||||
src=DocScanLine(focus_l,doc_e,&data_col);
|
||||
DocUnlock(focus_l);
|
||||
i=StrLen(src);
|
||||
buf =MAlloc(MaxI64(i+1,256));
|
||||
buf1=MAlloc(MaxI64(i+1,256));
|
||||
if (data_col==-1)
|
||||
data_col=0;
|
||||
data_col=ACPriorWordInStr(src,buf,data_col,256);
|
||||
ac.partial_len=StrLen(buf);
|
||||
data_col=ACSkipCrap(src,data_col);
|
||||
data_col=ACPriorWordInStr(src,buf1,data_col,256);
|
||||
|
||||
if (!ac.cur_word || StrCmp(ac.cur_word,buf) || force_refresh) {
|
||||
st=ac.cur_word;
|
||||
ac.cur_word=AStrNew(buf);
|
||||
Free(st);
|
||||
ac.num_fillins=0;
|
||||
if (*ac.cur_word)
|
||||
for (i=0;i<=ac.hash_table->mask && tS<timeout_time;i++) {
|
||||
tempw=ac.hash_table->body[i];
|
||||
while (tempw) {
|
||||
if (!MemCmp(ac.cur_word,tempw->str,StrLen(ac.cur_word)))
|
||||
ACFillInAdd(tempw);
|
||||
tempw=tempw->next;
|
||||
}
|
||||
}
|
||||
ACDocRst(51,13);
|
||||
if (ac.cur_word && *ac.cur_word) {
|
||||
"$$PURPLE$$Word:%s$$FG$$\n",ac.cur_word;
|
||||
for (i=0;i<ac.num_fillins;i++) {
|
||||
st=ac.fillin_matches[i]->str;
|
||||
"$$GREEN$$F%02d$$FG$$ ",i+1;
|
||||
if (TaskValidate(focus_task) &&
|
||||
(temph=HashFind(st,focus_task->hash_table,HTG_SRC_SYM)) &&
|
||||
temph->src_link) {
|
||||
if (temph->type&HTF_PUBLIC)
|
||||
"$$RED$$";
|
||||
"$$TX+UL+L+PU,\"%$$Q\",A=\"%s\"$$$$FG$$\n",st,temph->src_link;
|
||||
} else
|
||||
"%s\n",st;
|
||||
}
|
||||
if (acd.has_words)
|
||||
ACDDictWordsAdd(ac.cur_word);
|
||||
} else if (FileFind("::/Doc/StandBy.TXT.Z"))
|
||||
Type("::/Doc/StandBy.TXT.Z",0);
|
||||
}
|
||||
Free(src);
|
||||
Free(buf);
|
||||
Free(buf1);
|
||||
}
|
||||
|
||||
U0 ACTaskNormal(I64 sc,I64 last_sc,
|
||||
CTask *focus_task,CTask *original_focus_task)
|
||||
{
|
||||
CDoc *doc;
|
||||
CDocEntry *doc_e;
|
||||
if ((doc=DocPut(focus_task)) &&
|
||||
focus_task!=Fs && Bt(&focus_task->display_flags,DISPLAYf_SHOW)) {
|
||||
DocLock(doc);
|
||||
if (TaskValidate(focus_task) && original_focus_task==sys_focus_task &&
|
||||
doc && doc==DocPut(focus_task) && (doc_e=doc->cur_entry)) {
|
||||
if (doc_e==doc) doc_e=doc_e->last;
|
||||
while (doc_e->last!=doc && (doc_e->type_u8==DOCT_NEW_LINE ||
|
||||
doc_e->type_u8==DOCT_SOFT_NEW_LINE))
|
||||
doc_e=doc_e->last;
|
||||
while (doc_e->last->type_u8!=DOCT_NEW_LINE && doc_e->last!=doc)
|
||||
doc_e=doc_e->last;
|
||||
ACPutChoices(doc,doc_e,focus_task,ToBool(sc!=last_sc));
|
||||
} else
|
||||
DocUnlock(doc);
|
||||
}
|
||||
if (!LBts(&Fs->display_flags,DISPLAYf_SHOW))
|
||||
WinZBufUpdate;
|
||||
}
|
||||
|
||||
U0 ACTaskCtrl(I64 sc,I64 last_sc,
|
||||
CTask *focus_task,CTask *original_focus_task)
|
||||
{
|
||||
if (TaskValidate(focus_task) &&
|
||||
(focus_task->scroll_x || focus_task->scroll_y)) {
|
||||
if (LBtr(&Fs->display_flags,DISPLAYf_SHOW))
|
||||
WinZBufUpdate;
|
||||
} else {
|
||||
if (sc!=last_sc) {
|
||||
if (sc&SCF_ALT) {
|
||||
ACDocRst(27,3);
|
||||
if (TaskValidate(original_focus_task) &&
|
||||
!Bt(&original_focus_task->win_inhibit,WIf_SELF_KEY_DESC))
|
||||
KeyMapFamily(original_focus_task,0,
|
||||
ToBool(!(sc&SCF_SHIFT)),ToBool(sc&SCF_SHIFT));
|
||||
KeyMapCtrlAltFamily(
|
||||
ToBool(!(sc&SCF_SHIFT)),ToBool(sc&SCF_SHIFT));
|
||||
} else if (TaskValidate(original_focus_task) &&
|
||||
!Bt(&original_focus_task->win_inhibit,WIf_SELF_KEY_DESC)) {
|
||||
ACDocRst(27,3);
|
||||
KeyMapFamily(original_focus_task,SCF_CTRL,
|
||||
ToBool(!(sc&SCF_SHIFT)),ToBool(sc&SCF_SHIFT));
|
||||
}
|
||||
}
|
||||
if (!LBts(&Fs->display_flags,DISPLAYf_SHOW))
|
||||
WinZBufUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ACTaskAlt(I64 sc,I64 last_sc,
|
||||
CTask *,CTask *original_focus_task)
|
||||
{
|
||||
if (sc!=last_sc && TaskValidate(original_focus_task) &&
|
||||
!Bt(&original_focus_task->win_inhibit,WIf_SELF_KEY_DESC)) {
|
||||
ACDocRst(27,3);
|
||||
KeyMapFamily(original_focus_task,SCF_ALT,
|
||||
ToBool(!(sc&SCF_SHIFT)),ToBool(sc&SCF_SHIFT));
|
||||
}
|
||||
if (!LBts(&Fs->display_flags,DISPLAYf_SHOW))
|
||||
WinZBufUpdate;
|
||||
}
|
||||
|
||||
U0 ACTaskEndCB()
|
||||
{
|
||||
ac.task=NULL;
|
||||
Exit;
|
||||
}
|
||||
|
||||
U0 ACTask(I64)
|
||||
{
|
||||
CTask *focus_task,*original_focus_task;
|
||||
I64 ch,scan_code=0,last_scan_code=0;
|
||||
CDoc *doc;
|
||||
Fs->task_end_cb=&ACTaskEndCB;
|
||||
DocTermNew;
|
||||
LBts(&Fs->display_flags,DISPLAYf_SHOW);
|
||||
WinHorz(51,Fs->win_right);
|
||||
LBts(&Fs->display_flags,DISPLAYf_WIN_ON_TOP);
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_BORDER
|
||||
-WIF_SELF_IP_L-WIF_SELF_IP_R-WIG_DBL_CLICK;
|
||||
Free(ac.cur_word);
|
||||
ac.cur_word=NULL;
|
||||
while (TRUE) {
|
||||
if (scan_code&(SCF_CTRL|SCF_ALT) ||
|
||||
GetTSC>KbdMouseEvtTime+cnts.time_stamp_freq>>1) {
|
||||
last_scan_code=scan_code;
|
||||
scan_code=kbd.scan_code;
|
||||
}
|
||||
original_focus_task=focus_task=sys_focus_task;
|
||||
while (TaskValidate(focus_task) &&
|
||||
Bt(&focus_task->task_flags,TASKf_INPUT_FILTER_TASK))
|
||||
focus_task=focus_task->parent_task;
|
||||
if (scan_code&SCF_CTRL)
|
||||
ACTaskCtrl(scan_code,last_scan_code,focus_task,original_focus_task);
|
||||
else if (TaskValidate(focus_task)) {
|
||||
if (scan_code&SCF_ALT)
|
||||
ACTaskAlt(scan_code,last_scan_code,focus_task,original_focus_task);
|
||||
else
|
||||
ACTaskNormal(scan_code,last_scan_code,focus_task,original_focus_task);
|
||||
}
|
||||
Sleep(333);
|
||||
if (ScanMsg(&ch,,1<<MSG_KEY_DOWN) && (ch==CH_ESC||ch==CH_SHIFT_ESC))
|
||||
break;
|
||||
doc=DocPut;
|
||||
DocLock(doc);
|
||||
if (doc->cur_entry->de_flags & DOCEF_LINK) {
|
||||
'' CH_SPACE;
|
||||
doc->cur_entry=doc;
|
||||
}
|
||||
DocUnlock(doc);
|
||||
}
|
||||
}
|
||||
|
||||
public Bool AutoComplete(Bool val=OFF)
|
||||
{//Turn AutoComplete OFF or ON.
|
||||
Bool old_autocomplete=FALSE;
|
||||
while (Bt(&ac.flags,ACf_INIT_IN_PROGRESS))
|
||||
Sleep(10);
|
||||
if (val) {
|
||||
if (Bt(&sys_run_level,RLf_AUTO_COMPLETE)) {
|
||||
if (TaskValidate(ac.task))
|
||||
old_autocomplete=TRUE;
|
||||
else {
|
||||
ac.task=Spawn(&ACTask,NULL,"AutoComplete");
|
||||
TaskWait(ac.task);
|
||||
}
|
||||
WinToTop(ac.task);
|
||||
}
|
||||
} else {
|
||||
if (TaskValidate(ac.task)) {
|
||||
if (Bt(&sys_run_level,RLf_AUTO_COMPLETE))
|
||||
old_autocomplete=TRUE;
|
||||
Kill(ac.task);
|
||||
while (TaskValidate(ac.task))
|
||||
Yield;
|
||||
}
|
||||
}
|
||||
return old_autocomplete;
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
#help_index "AutoComplete/Dictionary"
|
||||
U0 ACDDictWordsAdd(U8 *st)
|
||||
{
|
||||
I64 i;
|
||||
U8 *ptr;
|
||||
if (st && *st && (ptr=ACDWordPtAt(st))) {
|
||||
for (i=0;i<ACD_MAX_FILLINS;i++) {
|
||||
if (*ptr++!=ACD_WORD_CHAR)
|
||||
break;
|
||||
if (i) '\n';
|
||||
acd.fillins[i]=ptr-1;
|
||||
"$$GREEN$$'%d'$$FG$$ %-23ts",i,ptr;
|
||||
ptr+=StrLen(ptr)+3;
|
||||
}
|
||||
acd.num_fillins=i;
|
||||
}
|
||||
}
|
||||
|
||||
#help_index "AutoComplete"
|
||||
U0 ACDocRst(I64 left,I64 top)
|
||||
{
|
||||
CDoc *doc=DocPut;
|
||||
DocRst(doc,TRUE);
|
||||
doc->flags|=DOCF_MIN_SIZE;
|
||||
Fs->border_src=BDS_CONST;
|
||||
Fs->border_attr=LTGRAY<<4+DrvTextAttrGet(':')&15;
|
||||
Fs->text_attr =LTGRAY<<4+BLUE;
|
||||
LBtr(&Fs->display_flags,DISPLAYf_SHOW);
|
||||
WinHorz(left,Fs->win_right);
|
||||
WinVert(top,Fs->win_bottom);
|
||||
DocCursor;
|
||||
}
|
||||
|
||||
I64 ACSkipCrap(U8 *src,I64 len)
|
||||
{
|
||||
I64 j;
|
||||
j=len-1;
|
||||
while (j>=0) {
|
||||
if (Bt(chars_bmp_alpha_numeric,src[j]))
|
||||
break;
|
||||
else
|
||||
j--;
|
||||
}
|
||||
return j+1;
|
||||
}
|
||||
|
||||
I64 ACPriorWordInStr(U8 *src,U8 *dst,I64 len,I64 buf_size)
|
||||
{
|
||||
I64 i,j=0,k;
|
||||
i=len-1;
|
||||
while (i>=0)
|
||||
if (!Bt(chars_bmp_alpha_numeric,src[i]))
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
U0 ACFillInAdd(CHashAC *tempw)
|
||||
{
|
||||
I64 k;
|
||||
if (ac.num_fillins<AC_MAX_FILLINS ||
|
||||
tempw->hits>ac.fillin_hits[ac.num_fillins-1]) {
|
||||
for (k=ac.num_fillins-1;k>=0;k--) {
|
||||
if (tempw->hits<=ac.fillin_hits[k])
|
||||
break;
|
||||
else {
|
||||
ac.fillin_matches[k+1]=ac.fillin_matches[k];
|
||||
ac.fillin_hits[k+1] =ac.fillin_hits[k];
|
||||
}
|
||||
}
|
||||
ac.fillin_matches[k+1]=tempw;
|
||||
ac.fillin_hits[k+1] =tempw->hits;
|
||||
if (ac.num_fillins<AC_MAX_FILLINS)
|
||||
ac.num_fillins++;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ACPutChoices(CDoc *focus_l,CDocEntry *doc_e,CTask *focus_task,
|
||||
Bool force_refresh)
|
||||
{
|
||||
I64 i,data_col;
|
||||
U8 *buf,*buf1,*src=NULL,*st;
|
||||
CHashAC *tempw;
|
||||
F64 timeout_time=tS+0.5;
|
||||
CHashSrcSym *temph;
|
||||
|
||||
src=DocScanLine(focus_l,doc_e,&data_col);
|
||||
DocUnlock(focus_l);
|
||||
i=StrLen(src);
|
||||
buf =MAlloc(MaxI64(i+1,256));
|
||||
buf1=MAlloc(MaxI64(i+1,256));
|
||||
if (data_col==-1)
|
||||
data_col=0;
|
||||
data_col=ACPriorWordInStr(src,buf,data_col,256);
|
||||
ac.partial_len=StrLen(buf);
|
||||
data_col=ACSkipCrap(src,data_col);
|
||||
data_col=ACPriorWordInStr(src,buf1,data_col,256);
|
||||
|
||||
if (!ac.cur_word || StrCmp(ac.cur_word,buf) || force_refresh) {
|
||||
st=ac.cur_word;
|
||||
ac.cur_word=AStrNew(buf);
|
||||
Free(st);
|
||||
ac.num_fillins=0;
|
||||
if (*ac.cur_word)
|
||||
for (i=0;i<=ac.hash_table->mask && tS<timeout_time;i++) {
|
||||
tempw=ac.hash_table->body[i];
|
||||
while (tempw) {
|
||||
if (!MemCmp(ac.cur_word,tempw->str,StrLen(ac.cur_word)))
|
||||
ACFillInAdd(tempw);
|
||||
tempw=tempw->next;
|
||||
}
|
||||
}
|
||||
ACDocRst(51,13);
|
||||
if (ac.cur_word && *ac.cur_word) {
|
||||
"$$PURPLE$$Word:%s$$FG$$\n",ac.cur_word;
|
||||
for (i=0;i<ac.num_fillins;i++) {
|
||||
st=ac.fillin_matches[i]->str;
|
||||
"$$GREEN$$F%02d$$FG$$ ",i+1;
|
||||
if (TaskValidate(focus_task) &&
|
||||
(temph=HashFind(st,focus_task->hash_table,HTG_SRC_SYM)) &&
|
||||
temph->src_link) {
|
||||
if (temph->type&HTF_PUBLIC)
|
||||
"$$RED$$";
|
||||
"$$TX+UL+L+PU,\"%$$Q\",A=\"%s\"$$$$FG$$\n",st,temph->src_link;
|
||||
} else
|
||||
"%s\n",st;
|
||||
}
|
||||
if (acd.has_words)
|
||||
ACDDictWordsAdd(ac.cur_word);
|
||||
} else if (FileFind("::/Doc/StandBy.DD.Z"))
|
||||
Type("::/Doc/StandBy.DD.Z",0);
|
||||
}
|
||||
Free(src);
|
||||
Free(buf);
|
||||
Free(buf1);
|
||||
}
|
||||
|
||||
U0 ACTaskNormal(I64 sc,I64 last_sc,
|
||||
CTask *focus_task,CTask *original_focus_task)
|
||||
{
|
||||
CDoc *doc;
|
||||
CDocEntry *doc_e;
|
||||
if ((doc=DocPut(focus_task)) &&
|
||||
focus_task!=Fs && Bt(&focus_task->display_flags,DISPLAYf_SHOW)) {
|
||||
DocLock(doc);
|
||||
if (TaskValidate(focus_task) && original_focus_task==sys_focus_task &&
|
||||
doc && doc==DocPut(focus_task) && (doc_e=doc->cur_entry)) {
|
||||
if (doc_e==doc) doc_e=doc_e->last;
|
||||
while (doc_e->last!=doc && (doc_e->type_u8==DOCT_NEW_LINE ||
|
||||
doc_e->type_u8==DOCT_SOFT_NEW_LINE))
|
||||
doc_e=doc_e->last;
|
||||
while (doc_e->last->type_u8!=DOCT_NEW_LINE && doc_e->last!=doc)
|
||||
doc_e=doc_e->last;
|
||||
ACPutChoices(doc,doc_e,focus_task,ToBool(sc!=last_sc));
|
||||
} else
|
||||
DocUnlock(doc);
|
||||
}
|
||||
if (!LBts(&Fs->display_flags,DISPLAYf_SHOW))
|
||||
WinZBufUpdate;
|
||||
}
|
||||
|
||||
U0 ACTaskCtrl(I64 sc,I64 last_sc,
|
||||
CTask *focus_task,CTask *original_focus_task)
|
||||
{
|
||||
if (TaskValidate(focus_task) &&
|
||||
(focus_task->scroll_x || focus_task->scroll_y)) {
|
||||
if (LBtr(&Fs->display_flags,DISPLAYf_SHOW))
|
||||
WinZBufUpdate;
|
||||
} else {
|
||||
if (sc!=last_sc) {
|
||||
if (sc&SCF_ALT) {
|
||||
ACDocRst(27,3);
|
||||
if (TaskValidate(original_focus_task) &&
|
||||
!Bt(&original_focus_task->win_inhibit,WIf_SELF_KEY_DESC))
|
||||
KeyMapFamily(original_focus_task,0,
|
||||
ToBool(!(sc&SCF_SHIFT)),ToBool(sc&SCF_SHIFT));
|
||||
KeyMapCtrlAltFamily(
|
||||
ToBool(!(sc&SCF_SHIFT)),ToBool(sc&SCF_SHIFT));
|
||||
} else if (TaskValidate(original_focus_task) &&
|
||||
!Bt(&original_focus_task->win_inhibit,WIf_SELF_KEY_DESC)) {
|
||||
ACDocRst(27,3);
|
||||
KeyMapFamily(original_focus_task,SCF_CTRL,
|
||||
ToBool(!(sc&SCF_SHIFT)),ToBool(sc&SCF_SHIFT));
|
||||
}
|
||||
}
|
||||
if (!LBts(&Fs->display_flags,DISPLAYf_SHOW))
|
||||
WinZBufUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ACTaskAlt(I64 sc,I64 last_sc,
|
||||
CTask *,CTask *original_focus_task)
|
||||
{
|
||||
if (sc!=last_sc && TaskValidate(original_focus_task) &&
|
||||
!Bt(&original_focus_task->win_inhibit,WIf_SELF_KEY_DESC)) {
|
||||
ACDocRst(27,3);
|
||||
KeyMapFamily(original_focus_task,SCF_ALT,
|
||||
ToBool(!(sc&SCF_SHIFT)),ToBool(sc&SCF_SHIFT));
|
||||
}
|
||||
if (!LBts(&Fs->display_flags,DISPLAYf_SHOW))
|
||||
WinZBufUpdate;
|
||||
}
|
||||
|
||||
U0 ACTaskEndCB()
|
||||
{
|
||||
ac.task=NULL;
|
||||
Exit;
|
||||
}
|
||||
|
||||
U0 ACTask(I64)
|
||||
{
|
||||
CTask *focus_task,*original_focus_task;
|
||||
I64 ch,scan_code=0,last_scan_code=0;
|
||||
CDoc *doc;
|
||||
Fs->task_end_cb=&ACTaskEndCB;
|
||||
DocTermNew;
|
||||
LBts(&Fs->display_flags,DISPLAYf_SHOW);
|
||||
WinHorz(51,Fs->win_right);
|
||||
LBts(&Fs->display_flags,DISPLAYf_WIN_ON_TOP);
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_BORDER
|
||||
-WIF_SELF_IP_L-WIF_SELF_IP_R-WIG_DBL_CLICK;
|
||||
Free(ac.cur_word);
|
||||
ac.cur_word=NULL;
|
||||
while (TRUE) {
|
||||
if (scan_code&(SCF_CTRL|SCF_ALT) ||
|
||||
GetTSC>KbdMouseEvtTime+cnts.time_stamp_freq>>1) {
|
||||
last_scan_code=scan_code;
|
||||
scan_code=kbd.scan_code;
|
||||
}
|
||||
original_focus_task=focus_task=sys_focus_task;
|
||||
while (TaskValidate(focus_task) &&
|
||||
Bt(&focus_task->task_flags,TASKf_INPUT_FILTER_TASK))
|
||||
focus_task=focus_task->parent_task;
|
||||
if (scan_code&SCF_CTRL)
|
||||
ACTaskCtrl(scan_code,last_scan_code,focus_task,original_focus_task);
|
||||
else if (TaskValidate(focus_task)) {
|
||||
if (scan_code&SCF_ALT)
|
||||
ACTaskAlt(scan_code,last_scan_code,focus_task,original_focus_task);
|
||||
else
|
||||
ACTaskNormal(scan_code,last_scan_code,focus_task,original_focus_task);
|
||||
}
|
||||
Sleep(333);
|
||||
if (ScanMsg(&ch,,1<<MSG_KEY_DOWN) && (ch==CH_ESC||ch==CH_SHIFT_ESC))
|
||||
break;
|
||||
doc=DocPut;
|
||||
DocLock(doc);
|
||||
if (doc->cur_entry->de_flags & DOCEF_LINK) {
|
||||
'' CH_SPACE;
|
||||
doc->cur_entry=doc;
|
||||
}
|
||||
DocUnlock(doc);
|
||||
}
|
||||
}
|
||||
|
||||
public Bool AutoComplete(Bool val=OFF)
|
||||
{//Turn AutoComplete OFF or ON.
|
||||
Bool old_autocomplete=FALSE;
|
||||
while (Bt(&ac.flags,ACf_INIT_IN_PROGRESS))
|
||||
Sleep(10);
|
||||
if (val) {
|
||||
if (Bt(&sys_run_level,RLf_AUTO_COMPLETE)) {
|
||||
if (TaskValidate(ac.task))
|
||||
old_autocomplete=TRUE;
|
||||
else {
|
||||
ac.task=Spawn(&ACTask,NULL,"AutoComplete");
|
||||
TaskWait(ac.task);
|
||||
}
|
||||
WinToTop(ac.task);
|
||||
}
|
||||
} else {
|
||||
if (TaskValidate(ac.task)) {
|
||||
if (Bt(&sys_run_level,RLf_AUTO_COMPLETE))
|
||||
old_autocomplete=TRUE;
|
||||
Kill(ac.task);
|
||||
DeathWait(&ac.task);
|
||||
}
|
||||
}
|
||||
return old_autocomplete;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
//See $LK,"::/Doc/AutoComplete.TXT"$
|
||||
Cd(__DIR__);;
|
||||
#include "ACFill"
|
||||
#include "ACTask"
|
||||
#include "ACInit"
|
||||
Cd("..");;
|
||||
@@ -0,0 +1,6 @@
|
||||
//See $LK,"::/Doc/AutoComplete.DD"$
|
||||
Cd(__DIR__);;
|
||||
#include "ACFill"
|
||||
#include "ACTask"
|
||||
#include "ACInit"
|
||||
Cd("..");;
|
||||
@@ -1,139 +0,0 @@
|
||||
#help_index "AutoFile;Help System/Training"
|
||||
#help_file "::/Doc/AutoFile"
|
||||
|
||||
public U0 AFGetStr(U8 *st)
|
||||
{//Wait for user to type certain str.
|
||||
I64 ch,sc;
|
||||
U8 buf[256],*st2;
|
||||
while (*st) {
|
||||
ch=GetKey(&sc,FALSE);
|
||||
if (sc.u8[0]!=SC_SHIFT &&
|
||||
sc.u8[0]!=SC_ALT &&
|
||||
sc.u8[0]!=SC_CTRL) {
|
||||
if (ch==*st) {
|
||||
'' ch;
|
||||
st++;
|
||||
} else {
|
||||
st2=Char2KeyName(*st);
|
||||
StrPrint(buf,"Press the $$GREEN$$<%s>$$FG$$ key.",st2);
|
||||
Free(st2);
|
||||
PopUpOk(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public U0 AFPrint(I64 mS=100,U8 *fmt,...)
|
||||
{//Print message with delay after each char.
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv),*st=buf;
|
||||
I64 ch;
|
||||
while (ch=*st++) {
|
||||
'' ch;
|
||||
Sleep(mS);
|
||||
}
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
public U0 AFGetKey(I64 scan_code,I64 sc_mask=0xFF|SCF_SHIFT|SCF_CTRL|SCF_ALT)
|
||||
{//Wait for user to press certain key.
|
||||
I64 sc,ch;
|
||||
U8 buf[STR_LEN],*st;
|
||||
do {
|
||||
ch=GetKey(&sc);
|
||||
if (sc.u8[0]!=SC_PRTSCRN1 &&
|
||||
!(sc.u8[0]==SC_SHIFT && scan_code&SCF_SHIFT) &&
|
||||
!(sc.u8[0]==SC_CTRL && scan_code&SCF_CTRL) &&
|
||||
!(sc.u8[0]==SC_ALT && scan_code&SCF_ALT) ) {
|
||||
if (sc&sc_mask!=scan_code&sc_mask) {
|
||||
st=ScanCode2KeyName(scan_code);
|
||||
StrPrint(buf,"Press the $$GREEN$$<%s>$$FG$$ key",st);
|
||||
Free(st);
|
||||
PopUpOk(buf);
|
||||
}
|
||||
}
|
||||
} while (sc&sc_mask!=scan_code&sc_mask);
|
||||
Msg(MSG_KEY_DOWN,ch,sc);
|
||||
}
|
||||
|
||||
public I64 AFGetChar(...)
|
||||
{//Wait for user to press one of set of chars.
|
||||
I64 i,sc,ch;
|
||||
U8 buf[512],*st;
|
||||
while (TRUE) {
|
||||
ch=GetKey(&sc);
|
||||
if (sc.u8[0]!=SC_SHIFT && sc.u8[0]!=SC_ALT && sc.u8[0]!=SC_CTRL) {
|
||||
for (i=0;i<argc;i++)
|
||||
if (ch==argv[i]) {
|
||||
Msg(MSG_KEY_DOWN,ch,sc);
|
||||
return ch;
|
||||
}
|
||||
StrPrint(buf,"Press ");
|
||||
for (i=0;i<argc;i++) {
|
||||
st=Char2KeyName(argv[i]);
|
||||
CatPrint(buf,"$$GREEN$$<%s>$$FG$$",st);
|
||||
Free(st);
|
||||
if (argc==i+1)
|
||||
CatPrint(buf,".");
|
||||
else if (argc==i+2)
|
||||
CatPrint(buf," or ");
|
||||
else
|
||||
CatPrint(buf,", ");
|
||||
}
|
||||
PopUpOk(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public U0 AFUntilKey(I64 scan_code,I64 sc_mask=0xFF|SCF_SHIFT|SCF_CTRL|SCF_ALT)
|
||||
{//Let user type until he presses certain key.
|
||||
I64 sc,ch;
|
||||
do {
|
||||
ch=GetKey(&sc);
|
||||
Msg(MSG_KEY_DOWN,ch,sc);
|
||||
} while (sc&sc_mask!=scan_code&sc_mask);
|
||||
}
|
||||
|
||||
public I64 AFUntilChar(...)
|
||||
{//Let user type until he presses one of set of chars.
|
||||
I64 i,sc,ch;
|
||||
while (TRUE) {
|
||||
ch=GetKey(&sc);
|
||||
Msg(MSG_KEY_DOWN,ch,sc);
|
||||
for (i=0;i<argc;i++)
|
||||
if (ch==argv[i])
|
||||
return ch;
|
||||
}
|
||||
}
|
||||
|
||||
I64 af_l,af_r;
|
||||
|
||||
Bool AFSetIPPlot(I64 mS,I64 x,I64 y,I64 z)
|
||||
{
|
||||
IPSet(x,y,z,af_l,af_r);
|
||||
Sleep(mS);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public U0 AFSetIP(I64 mS=7,I64 x=MAX_I64,I64 y=MAX_I64,I64 z=MAX_I64,
|
||||
I64 l=MAX_I64,I64 r=MAX_I64)
|
||||
{//Move input pointer (mouse) to spot at certain speed.
|
||||
if (!(0<=x<GR_WIDTH))
|
||||
x=ip.pos.x;
|
||||
if (!(0<=y<GR_HEIGHT))
|
||||
y=ip.pos.y;
|
||||
if (z==MAX_I64)
|
||||
z=ip.pos.z;
|
||||
if (!(FALSE<=l<=TRUE))
|
||||
l=ip.lb;
|
||||
if (!(FALSE<=r<=TRUE))
|
||||
r=ip.rb;
|
||||
af_l=l; af_r=r;
|
||||
Line(mS,ip.pos.x,ip.pos.y,ip.pos.z,x,y,z,&AFSetIPPlot);
|
||||
}
|
||||
|
||||
public Bool AFView()
|
||||
{//Let user type until <ESC> or <SHIFT-ESC>.
|
||||
Bool res=View;
|
||||
DocBottom;
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
#help_index "AutoFile;Help System/Training"
|
||||
#help_file "::/Doc/AutoFile"
|
||||
|
||||
public U0 AFGetStr(U8 *st)
|
||||
{//Wait for user to type certain str.
|
||||
I64 ch,sc;
|
||||
U8 buf[256],*st2;
|
||||
while (*st) {
|
||||
ch=GetKey(&sc,FALSE);
|
||||
if (sc.u8[0]!=SC_SHIFT &&
|
||||
sc.u8[0]!=SC_ALT &&
|
||||
sc.u8[0]!=SC_CTRL) {
|
||||
if (ch==*st) {
|
||||
'' ch;
|
||||
st++;
|
||||
} else {
|
||||
st2=Char2KeyName(*st);
|
||||
StrPrint(buf,"Press the $$GREEN$$<%s>$$FG$$ key.",st2);
|
||||
Free(st2);
|
||||
PopUpOk(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public U0 AFPrint(I64 ms=100,U8 *fmt,...)
|
||||
{//Print message with delay after each char.
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv),*st=buf;
|
||||
I64 ch;
|
||||
while (ch=*st++) {
|
||||
'' ch;
|
||||
Sleep(ms);
|
||||
}
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
public U0 AFGetKey(I64 scan_code,I64 sc_mask=0xFF|SCF_SHIFT|SCF_CTRL|SCF_ALT)
|
||||
{//Wait for user to press certain key.
|
||||
I64 sc,ch;
|
||||
U8 buf[STR_LEN],*st;
|
||||
do {
|
||||
ch=GetKey(&sc);
|
||||
if (sc.u8[0]!=SC_PRTSCRN1 &&
|
||||
!(sc.u8[0]==SC_SHIFT && scan_code&SCF_SHIFT) &&
|
||||
!(sc.u8[0]==SC_CTRL && scan_code&SCF_CTRL) &&
|
||||
!(sc.u8[0]==SC_ALT && scan_code&SCF_ALT) ) {
|
||||
if (sc&sc_mask!=scan_code&sc_mask) {
|
||||
st=ScanCode2KeyName(scan_code);
|
||||
StrPrint(buf,"Press the $$GREEN$$<%s>$$FG$$ key",st);
|
||||
Free(st);
|
||||
PopUpOk(buf);
|
||||
}
|
||||
}
|
||||
} while (sc&sc_mask!=scan_code&sc_mask);
|
||||
Msg(MSG_KEY_DOWN,ch,sc);
|
||||
}
|
||||
|
||||
public I64 AFGetChar(...)
|
||||
{//Wait for user to press one of set of chars.
|
||||
I64 i,sc,ch;
|
||||
U8 buf[512],*st;
|
||||
while (TRUE) {
|
||||
ch=GetKey(&sc);
|
||||
if (sc.u8[0]!=SC_SHIFT && sc.u8[0]!=SC_ALT && sc.u8[0]!=SC_CTRL) {
|
||||
for (i=0;i<argc;i++)
|
||||
if (ch==argv[i]) {
|
||||
Msg(MSG_KEY_DOWN,ch,sc);
|
||||
return ch;
|
||||
}
|
||||
StrPrint(buf,"Press ");
|
||||
for (i=0;i<argc;i++) {
|
||||
st=Char2KeyName(argv[i]);
|
||||
CatPrint(buf,"$$GREEN$$<%s>$$FG$$",st);
|
||||
Free(st);
|
||||
if (argc==i+1)
|
||||
CatPrint(buf,".");
|
||||
else if (argc==i+2)
|
||||
CatPrint(buf," or ");
|
||||
else
|
||||
CatPrint(buf,", ");
|
||||
}
|
||||
PopUpOk(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public U0 AFUntilKey(I64 scan_code,I64 sc_mask=0xFF|SCF_SHIFT|SCF_CTRL|SCF_ALT)
|
||||
{//Let user type until he presses certain key.
|
||||
I64 sc,ch;
|
||||
do {
|
||||
ch=GetKey(&sc);
|
||||
Msg(MSG_KEY_DOWN,ch,sc);
|
||||
} while (sc&sc_mask!=scan_code&sc_mask);
|
||||
}
|
||||
|
||||
public I64 AFUntilChar(...)
|
||||
{//Let user type until he presses one of set of chars.
|
||||
I64 i,sc,ch;
|
||||
while (TRUE) {
|
||||
ch=GetKey(&sc);
|
||||
Msg(MSG_KEY_DOWN,ch,sc);
|
||||
for (i=0;i<argc;i++)
|
||||
if (ch==argv[i])
|
||||
return ch;
|
||||
}
|
||||
}
|
||||
|
||||
I64 af_l,af_r;
|
||||
|
||||
Bool AFSetIPPlot(I64 ms,I64 x,I64 y,I64 z)
|
||||
{
|
||||
IPSet(x,y,z,af_l,af_r);
|
||||
Sleep(ms);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public U0 AFSetIP(I64 ms=7,I64 x=MAX_I64,I64 y=MAX_I64,I64 z=MAX_I64,
|
||||
I64 l=MAX_I64,I64 r=MAX_I64)
|
||||
{//Move input pointer (mouse) to spot at certain speed.
|
||||
if (!(0<=x<GR_WIDTH))
|
||||
x=ip.pos.x;
|
||||
if (!(0<=y<GR_HEIGHT))
|
||||
y=ip.pos.y;
|
||||
if (z==MAX_I64)
|
||||
z=ip.pos.z;
|
||||
if (!(FALSE<=l<=TRUE))
|
||||
l=ip.lb;
|
||||
if (!(FALSE<=r<=TRUE))
|
||||
r=ip.rb;
|
||||
af_l=l; af_r=r;
|
||||
Line(ms,ip.pos.x,ip.pos.y,ip.pos.z,x,y,z,&AFSetIPPlot);
|
||||
}
|
||||
|
||||
public Bool AFView()
|
||||
{//Let user type until <ESC> or <SHIFT-ESC>.
|
||||
Bool res=View;
|
||||
DocBottom;
|
||||
return res;
|
||||
}
|
||||
@@ -1,388 +0,0 @@
|
||||
public CCtrl *CtrlFindUnique(CTask *haystack_task,I64 needle_type)
|
||||
{//Find task ctrl given $LK,"ctrl_type",A="MN:CTRLT_VIEWING_ANGLES"$.
|
||||
CCtrl *c;
|
||||
c=haystack_task->next_ctrl;
|
||||
while (c!=&haystack_task->next_ctrl) {
|
||||
if (c->type==needle_type)
|
||||
return c;
|
||||
c=c->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U0 CtrlsUpdate(CTask *task)
|
||||
{
|
||||
CCtrl *c;
|
||||
c=task->next_ctrl;
|
||||
while (c!=&task->next_ctrl) {
|
||||
if (c->update_derived_vals)
|
||||
(*c->update_derived_vals)(c);
|
||||
if (c->flags&CTRLF_BORDER) {
|
||||
c->screen_left =gr.pan_text_x+task->pix_left+c->left-FONT_WIDTH;
|
||||
c->screen_right =gr.pan_text_x+task->pix_left+c->right-FONT_WIDTH;
|
||||
c->screen_top =gr.pan_text_y+task->pix_top+c->top-FONT_HEIGHT;
|
||||
c->screen_bottom=gr.pan_text_y+task->pix_top+c->bottom-FONT_HEIGHT;
|
||||
} else {
|
||||
c->screen_left =gr.pan_text_x+task->pix_left+c->left;
|
||||
c->screen_right =gr.pan_text_x+task->pix_left+c->right;
|
||||
c->screen_top =gr.pan_text_y+task->pix_top+c->top;
|
||||
c->screen_bottom=gr.pan_text_y+task->pix_top+c->bottom;
|
||||
}
|
||||
c=c->next;
|
||||
}
|
||||
}
|
||||
|
||||
fp_update_ctrls=&CtrlsUpdate;
|
||||
|
||||
Bool CtrlInsideRect(CCtrl *c,I64 x,I64 y)
|
||||
{//screen coordinates
|
||||
if (c->screen_left<=x<=c->screen_right &&
|
||||
c->screen_top<=y<=c->screen_bottom)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public Bool CtrlInside(CCtrl *c,I64 x,I64 y)
|
||||
{//Is x,y inside a ctrl?
|
||||
if (c->flags&CTRLF_SHOW) {
|
||||
if (c->inside_ctrl)
|
||||
return (*c->inside_ctrl)(c,x,y);
|
||||
else
|
||||
return CtrlInsideRect(c,x,y);
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
U0 DrawCtrls(CTask *task)
|
||||
{
|
||||
CCtrl *c;
|
||||
CDC *dc=DCAlias(gr.dc2,task);
|
||||
c=task->next_ctrl;
|
||||
while (c!=&task->next_ctrl) {
|
||||
if (c->flags&CTRLF_SHOW) {
|
||||
if (c->flags&CTRLF_BORDER) {
|
||||
if (!Bt(&task->display_flags,DISPLAYf_NO_BORDER)) {
|
||||
PUSHFD
|
||||
CLI
|
||||
while (LBts(&task->task_flags,TASKf_TASK_LOCK))
|
||||
PAUSE
|
||||
|
||||
task->win_left--; //Allow drawing on border
|
||||
task->win_right++;
|
||||
task->win_top--;
|
||||
task->win_bottom++;
|
||||
WinDerivedValsUpdate(task);
|
||||
|
||||
LBtr(&task->task_flags,TASKf_TASK_LOCK);
|
||||
POPFD
|
||||
|
||||
if (c->draw_it)
|
||||
(*c->draw_it)(dc,c);
|
||||
|
||||
PUSHFD
|
||||
CLI
|
||||
while (LBts(&task->task_flags,TASKf_TASK_LOCK))
|
||||
PAUSE
|
||||
|
||||
task->win_left++;
|
||||
task->win_right--;
|
||||
task->win_top++;
|
||||
task->win_bottom--;
|
||||
WinDerivedValsUpdate(task);
|
||||
|
||||
LBtr(&task->task_flags,TASKf_TASK_LOCK);
|
||||
POPFD
|
||||
}
|
||||
} else
|
||||
if (c->draw_it)
|
||||
(*c->draw_it)(dc,c);
|
||||
}
|
||||
c=c->next;
|
||||
}
|
||||
DCDel(dc);
|
||||
}
|
||||
|
||||
#define WIN_SCROLL_SIZE 8
|
||||
#define WIN_SCROLL_BORDER_BONUS 4
|
||||
U0 DrawWinScroll(CDC *dc,CCtrl *c)
|
||||
{
|
||||
CWinScroll *s=c->state;
|
||||
|
||||
if (c->flags&CTRLF_CLICKED)
|
||||
dc->color=s->color>>4;
|
||||
else
|
||||
dc->color=s->color&0xF;
|
||||
GrRect(dc,c->left,c->top,c->right-c->left+1,c->bottom-c->top+1);
|
||||
|
||||
if (c->flags&CTRLF_CLICKED)
|
||||
dc->color=s->color&0xF;
|
||||
else
|
||||
dc->color=s->color>>4;
|
||||
GrRect(dc,c->left+2,c->top+2,c->right-c->left+1-4,c->bottom-c->top+1-4);
|
||||
}
|
||||
|
||||
U0 WinDerivedScrollValsUpdate(CCtrl *c)
|
||||
{
|
||||
CWinScroll *s=c->state;
|
||||
I64 range;
|
||||
if (s->max<s->min) s->max=s->min;
|
||||
if (s->pos<s->min) s->pos=s->min;
|
||||
if (s->pos>s->max) s->pos=s->max;
|
||||
s->color=c->win_task->border_attr&0xF^0xF+
|
||||
(c->win_task->border_attr&0xF)<<4;
|
||||
range=s->max-s->min;
|
||||
if (!range) range=1;
|
||||
switch (c->type) {
|
||||
case CTRLT_WIN_HSCROLL:
|
||||
c->left =gr.pan_text_x+FONT_WIDTH-WIN_SCROLL_BORDER_BONUS+
|
||||
(s->pos-s->min)*(c->win_task->pix_width+2*WIN_SCROLL_BORDER_BONUS
|
||||
-WIN_SCROLL_SIZE)/range;
|
||||
c->right =c->left+WIN_SCROLL_SIZE-1;
|
||||
c->top =gr.pan_text_y+FONT_HEIGHT+
|
||||
(FONT_WIDTH-WIN_SCROLL_SIZE)/2+c->win_task->pix_height;
|
||||
c->bottom=c->top+WIN_SCROLL_SIZE-1;
|
||||
break;
|
||||
case CTRLT_WIN_VSCROLL:
|
||||
c->left =gr.pan_text_x+FONT_WIDTH+
|
||||
(FONT_WIDTH-WIN_SCROLL_SIZE)/2+c->win_task->pix_width;
|
||||
c->right =c->left+WIN_SCROLL_SIZE-1;
|
||||
c->top =gr.pan_text_y+FONT_HEIGHT-WIN_SCROLL_BORDER_BONUS+
|
||||
(s->pos-s->min)*(c->win_task->pix_height+
|
||||
2*WIN_SCROLL_BORDER_BONUS-WIN_SCROLL_SIZE)/range;
|
||||
c->bottom=c->top+WIN_SCROLL_SIZE-1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
U0 LeftClickHWinScroll(CCtrl *c,I64 x,I64,Bool down)
|
||||
{
|
||||
CTask *task=c->win_task;
|
||||
CWinScroll *s=c->state;
|
||||
I64 range=task->pix_width+2*WIN_SCROLL_BORDER_BONUS-WIN_SCROLL_SIZE;
|
||||
LBts(&s->flags,WSSf_SET_TO_POS);
|
||||
s->pos=((x-(FONT_WIDTH-WIN_SCROLL_BORDER_BONUS))
|
||||
*(s->max-s->min+1)+range/2)/range+s->min;
|
||||
if (down)
|
||||
c->flags|=CTRLF_CLICKED;
|
||||
else
|
||||
c->flags&=~CTRLF_CLICKED;
|
||||
if (c->update_derived_vals)
|
||||
(*c->update_derived_vals)(c);
|
||||
}
|
||||
|
||||
U0 LeftClickVWinScroll(CCtrl *c,I64,I64 y,Bool down)
|
||||
{
|
||||
CTask *task=c->win_task;
|
||||
CWinScroll *s=c->state;
|
||||
I64 range=task->pix_height+2*WIN_SCROLL_BORDER_BONUS-WIN_SCROLL_SIZE;
|
||||
LBts(&s->flags,WSSf_SET_TO_POS);
|
||||
s->pos=((y-(FONT_HEIGHT-WIN_SCROLL_BORDER_BONUS))
|
||||
*(s->max-s->min+1)+range/2)/range+s->min;
|
||||
if (down)
|
||||
c->flags|=CTRLF_CLICKED;
|
||||
else
|
||||
c->flags&=~CTRLF_CLICKED;
|
||||
if (c->update_derived_vals)
|
||||
(*c->update_derived_vals)(c);
|
||||
}
|
||||
|
||||
U0 WheelChangeWinScroll(CCtrl *c,I64 delta)
|
||||
{
|
||||
CWinScroll *s=c->state;
|
||||
LBts(&s->flags,WSSf_SET_TO_POS);
|
||||
s->pos+=delta;
|
||||
if (c->update_derived_vals)
|
||||
(*c->update_derived_vals)(c);
|
||||
}
|
||||
|
||||
U0 WinScrollsInit(CTask *task)
|
||||
{
|
||||
CCtrl *c;
|
||||
|
||||
if (!CtrlFindUnique(task,CTRLT_WIN_HSCROLL)) {
|
||||
c=CAlloc(sizeof(CCtrl));
|
||||
c->win_task=task;
|
||||
c->flags=CTRLF_SHOW|CTRLF_BORDER|CTRLF_CAPTURE_LEFT_IP;
|
||||
c->type=CTRLT_WIN_HSCROLL;
|
||||
c->state=&task->horz_scroll;
|
||||
c->update_derived_vals=&WinDerivedScrollValsUpdate;
|
||||
c->draw_it=&DrawWinScroll;
|
||||
c->left_click=&LeftClickHWinScroll;
|
||||
QueIns(c,task->last_ctrl);
|
||||
}
|
||||
|
||||
if (!CtrlFindUnique(task,CTRLT_WIN_VSCROLL)) {
|
||||
c=CAlloc(sizeof(CCtrl));
|
||||
c->win_task=task;
|
||||
c->flags=CTRLF_SHOW|CTRLF_BORDER|CTRLF_CAPTURE_LEFT_IP;
|
||||
c->type=CTRLT_WIN_VSCROLL;
|
||||
c->state=&task->vert_scroll;
|
||||
c->update_derived_vals=&WinDerivedScrollValsUpdate;
|
||||
c->draw_it=&DrawWinScroll;
|
||||
c->left_click=&LeftClickVWinScroll;
|
||||
c->wheel_chg=&WheelChangeWinScroll;
|
||||
QueIns(c,task->last_ctrl);
|
||||
}
|
||||
TaskDerivedValsUpdate(task);
|
||||
}
|
||||
#define VIEWANGLES_SPACING 22
|
||||
#define VIEWANGLES_RANGE 48
|
||||
#define VIEWANGLES_BORDER 2
|
||||
#define VIEWANGLES_SNAP 2
|
||||
|
||||
U0 DrawViewAnglesCtrl(CDC *dc,CCtrl *c)
|
||||
{
|
||||
I64 i,j;
|
||||
CViewAngles *s=c->state;
|
||||
|
||||
dc->color=s->cbd;
|
||||
GrRect(dc, c->left,c->top,VIEWANGLES_SPACING*4+3,
|
||||
VIEWANGLES_SPACING*2+VIEWANGLES_RANGE);
|
||||
dc->color=s->cbg;
|
||||
GrRect(dc, c->left+VIEWANGLES_BORDER,c->top+VIEWANGLES_BORDER,
|
||||
VIEWANGLES_SPACING*4+3-2*VIEWANGLES_BORDER,
|
||||
VIEWANGLES_SPACING*2+VIEWANGLES_RANGE-2*VIEWANGLES_BORDER);
|
||||
dc->color=s->cfg;
|
||||
GrLine(dc,c->left+VIEWANGLES_SPACING,c->top+VIEWANGLES_SPACING,
|
||||
c->left+VIEWANGLES_SPACING,c->top+VIEWANGLES_SPACING+
|
||||
VIEWANGLES_RANGE-1);
|
||||
GrLine(dc,c->left+2*VIEWANGLES_SPACING+1,c->top+VIEWANGLES_SPACING,
|
||||
c->left+2*VIEWANGLES_SPACING+1,c->top+VIEWANGLES_SPACING+
|
||||
VIEWANGLES_RANGE-1);
|
||||
GrLine(dc,c->left+3*VIEWANGLES_SPACING+2,c->top+VIEWANGLES_SPACING,
|
||||
c->left+3*VIEWANGLES_SPACING+2,c->top+VIEWANGLES_SPACING+
|
||||
VIEWANGLES_RANGE-1);
|
||||
for (i=1;i<VIEWANGLES_RANGE+1;i+=2*VIEWANGLES_SNAP) {
|
||||
j=2-i/3&1;
|
||||
GrLine(dc,c->left+VIEWANGLES_SPACING-j,c->bottom-VIEWANGLES_SPACING-i,
|
||||
c->left+VIEWANGLES_SPACING+j,c->bottom
|
||||
-VIEWANGLES_SPACING-i);
|
||||
GrLine(dc,c->left+2*VIEWANGLES_SPACING+1-j,c->bottom-VIEWANGLES_SPACING-i,
|
||||
c->left+2*VIEWANGLES_SPACING+1+j,c->bottom
|
||||
-VIEWANGLES_SPACING-i);
|
||||
GrLine(dc,c->left+3*VIEWANGLES_SPACING+2-j,c->bottom-VIEWANGLES_SPACING-i,
|
||||
c->left+3*VIEWANGLES_SPACING+2+j,c->bottom
|
||||
-VIEWANGLES_SPACING-i);
|
||||
}
|
||||
|
||||
dc->color=s->cx;
|
||||
GrPrint(dc,c->left+VIEWANGLES_SPACING-FONT_WIDTH/2,
|
||||
c->top+VIEWANGLES_SPACING-(1+FONT_HEIGHT),"X");
|
||||
GrPrint(dc,c->left+VIEWANGLES_SPACING-3*FONT_WIDTH/2,
|
||||
c->top+VIEWANGLES_SPACING+VIEWANGLES_RANGE+3,
|
||||
"%3d",s->sx*360/VIEWANGLES_RANGE);
|
||||
i=c->left+VIEWANGLES_SPACING;
|
||||
if (s->sx>VIEWANGLES_RANGE/2)
|
||||
j=-VIEWANGLES_RANGE/2+s->sx;
|
||||
else
|
||||
j=s->sx+VIEWANGLES_RANGE/2;
|
||||
j=c->top+VIEWANGLES_SPACING+VIEWANGLES_RANGE-1-j;
|
||||
GrRect(dc,i-3,j-2,7,5);
|
||||
dc->color=s->cx^8;
|
||||
GrRect(dc,i-2,j-1,5,3);
|
||||
|
||||
dc->color=s->cy;
|
||||
GrPrint(dc,c->left+2*VIEWANGLES_SPACING+1-FONT_WIDTH/2,
|
||||
c->top+VIEWANGLES_SPACING-(1+FONT_HEIGHT),"Y");
|
||||
GrPrint(dc,c->left+2*VIEWANGLES_SPACING+1-3*FONT_WIDTH/2,
|
||||
c->top+VIEWANGLES_SPACING+VIEWANGLES_RANGE+3,
|
||||
"%3d",s->sy*360/VIEWANGLES_RANGE);
|
||||
i=c->left+2*VIEWANGLES_SPACING+1;
|
||||
if (s->sy>VIEWANGLES_RANGE/2)
|
||||
j=-VIEWANGLES_RANGE/2+s->sy;
|
||||
else
|
||||
j=s->sy+VIEWANGLES_RANGE/2;
|
||||
j=c->top+VIEWANGLES_SPACING+VIEWANGLES_RANGE-1-j;
|
||||
GrRect(dc,i-3,j-2,7,5);
|
||||
dc->color=s->cy^8;
|
||||
GrRect(dc,i-2,j-1,5,3);
|
||||
|
||||
dc->color=s->cz;
|
||||
GrPrint(dc,c->left+3*VIEWANGLES_SPACING+2-FONT_WIDTH/2,
|
||||
c->top+VIEWANGLES_SPACING-(1+FONT_HEIGHT),"Z");
|
||||
GrPrint(dc,c->left+3*VIEWANGLES_SPACING+2-3*FONT_WIDTH/2,
|
||||
c->top+VIEWANGLES_SPACING+VIEWANGLES_RANGE+3,
|
||||
"%3d",s->sz*360/VIEWANGLES_RANGE);
|
||||
i=c->left+3*VIEWANGLES_SPACING+2;
|
||||
if (s->sz>VIEWANGLES_RANGE/2)
|
||||
j=-VIEWANGLES_RANGE/2+s->sz;
|
||||
else
|
||||
j=s->sz+VIEWANGLES_RANGE/2;
|
||||
j=c->top+VIEWANGLES_SPACING+VIEWANGLES_RANGE-1-j;
|
||||
GrRect(dc,i-3,j-2,7,5);
|
||||
dc->color=s->cz^8;
|
||||
GrRect(dc,i-2,j-1,5,3);
|
||||
}
|
||||
|
||||
U0 UpdateDerivedViewAnglesCtrl(CCtrl *c)
|
||||
{
|
||||
CViewAngles *s=c->state;
|
||||
c->left=c->win_task->pix_width-(VIEWANGLES_SPACING*4+3);
|
||||
c->right=c->left+VIEWANGLES_SPACING*4+3;
|
||||
c->top=c->win_task->pix_height-(VIEWANGLES_SPACING*2+VIEWANGLES_RANGE);
|
||||
c->bottom=c->top+VIEWANGLES_SPACING*2+VIEWANGLES_RANGE;
|
||||
s->sx=ClampI64(RoundI64(s->sx,VIEWANGLES_SNAP),0,VIEWANGLES_RANGE-1);
|
||||
s->sy=ClampI64(RoundI64(s->sy,VIEWANGLES_SNAP),0,VIEWANGLES_RANGE-1);
|
||||
s->sz=ClampI64(RoundI64(s->sz,VIEWANGLES_SNAP),0,VIEWANGLES_RANGE-1);
|
||||
s->ax=2*ã*s->sx/VIEWANGLES_RANGE;
|
||||
s->ay=2*ã*s->sy/VIEWANGLES_RANGE;
|
||||
s->az=2*ã*s->sz/VIEWANGLES_RANGE;
|
||||
}
|
||||
|
||||
U0 LeftClickViewAngles(CCtrl *c,I64 x,I64 y,Bool)
|
||||
{
|
||||
CViewAngles *s=c->state;
|
||||
I64 i;
|
||||
i=VIEWANGLES_RANGE-1-(y-(c->top+VIEWANGLES_SPACING));
|
||||
if (i>=VIEWANGLES_RANGE/2)
|
||||
i-=VIEWANGLES_RANGE/2;
|
||||
else
|
||||
i+=VIEWANGLES_RANGE/2;
|
||||
if (x<c->left+(c->right-c->left)/3)
|
||||
s->sx=i;
|
||||
else if (x<c->left+2*(c->right-c->left)/3)
|
||||
s->sy=i;
|
||||
else
|
||||
s->sz=i;
|
||||
if (c->update_derived_vals)
|
||||
(*c->update_derived_vals)(c);
|
||||
}
|
||||
|
||||
public CCtrl *ViewAnglesNew(CTask *task=NULL)
|
||||
{//Create view angle ctrl. See $LK,"::/Demo/Graphics/Shading.CPP"$.
|
||||
CCtrl *c;
|
||||
CViewAngles *s;
|
||||
if (!task) task=Fs;
|
||||
if (!(c=CtrlFindUnique(task,CTRLT_VIEWING_ANGLES))) {
|
||||
s=CAlloc(sizeof(CViewAngles),task);
|
||||
c=CAlloc(sizeof(CCtrl));
|
||||
s->cbd=BLUE;
|
||||
s->cbg=LTBLUE;
|
||||
s->cfg=BLACK;
|
||||
s->cx=LTGREEN;
|
||||
s->cy=GREEN;
|
||||
s->cz=LTGREEN;
|
||||
c->win_task=task;
|
||||
c->flags=CTRLF_SHOW|CTRLF_CAPTURE_LEFT_IP;
|
||||
c->type=CTRLT_VIEWING_ANGLES;
|
||||
c->state=s;
|
||||
c->draw_it=&DrawViewAnglesCtrl;
|
||||
c->left_click=&LeftClickViewAngles;
|
||||
c->update_derived_vals=&UpdateDerivedViewAnglesCtrl;
|
||||
QueIns(c,task->last_ctrl);
|
||||
TaskDerivedValsUpdate(task);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public U0 ViewAnglesDel(CTask *task=NULL)
|
||||
{//Free view angle ctrl.
|
||||
CCtrl *c;
|
||||
if (!task) task=Fs;
|
||||
if (c=CtrlFindUnique(task,CTRLT_VIEWING_ANGLES)) {
|
||||
QueRem(c);
|
||||
Free(c->state);
|
||||
Free(c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,388 @@
|
||||
public CCtrl *CtrlFindUnique(CTask *haystack_task,I64 needle_type)
|
||||
{//Find task ctrl given $LK,"ctrl_type",A="MN:CTRLT_VIEWING_ANGLES"$.
|
||||
CCtrl *c;
|
||||
c=haystack_task->next_ctrl;
|
||||
while (c!=&haystack_task->next_ctrl) {
|
||||
if (c->type==needle_type)
|
||||
return c;
|
||||
c=c->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U0 CtrlsUpdate(CTask *task)
|
||||
{
|
||||
CCtrl *c;
|
||||
c=task->next_ctrl;
|
||||
while (c!=&task->next_ctrl) {
|
||||
if (c->update_derived_vals)
|
||||
(*c->update_derived_vals)(c);
|
||||
if (c->flags&CTRLF_BORDER) {
|
||||
c->screen_left =gr.pan_text_x+task->pix_left+c->left-FONT_WIDTH;
|
||||
c->screen_right =gr.pan_text_x+task->pix_left+c->right-FONT_WIDTH;
|
||||
c->screen_top =gr.pan_text_y+task->pix_top+c->top-FONT_HEIGHT;
|
||||
c->screen_bottom=gr.pan_text_y+task->pix_top+c->bottom-FONT_HEIGHT;
|
||||
} else {
|
||||
c->screen_left =gr.pan_text_x+task->pix_left+c->left;
|
||||
c->screen_right =gr.pan_text_x+task->pix_left+c->right;
|
||||
c->screen_top =gr.pan_text_y+task->pix_top+c->top;
|
||||
c->screen_bottom=gr.pan_text_y+task->pix_top+c->bottom;
|
||||
}
|
||||
c=c->next;
|
||||
}
|
||||
}
|
||||
|
||||
fp_update_ctrls=&CtrlsUpdate;
|
||||
|
||||
Bool CtrlInsideRect(CCtrl *c,I64 x,I64 y)
|
||||
{//screen coordinates
|
||||
if (c->screen_left<=x<=c->screen_right &&
|
||||
c->screen_top<=y<=c->screen_bottom)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public Bool CtrlInside(CCtrl *c,I64 x,I64 y)
|
||||
{//Is x,y inside a ctrl?
|
||||
if (c->flags&CTRLF_SHOW) {
|
||||
if (c->inside_ctrl)
|
||||
return (*c->inside_ctrl)(c,x,y);
|
||||
else
|
||||
return CtrlInsideRect(c,x,y);
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
U0 DrawCtrls(CTask *task)
|
||||
{
|
||||
CCtrl *c;
|
||||
CDC *dc=DCAlias(gr.dc2,task);
|
||||
c=task->next_ctrl;
|
||||
while (c!=&task->next_ctrl) {
|
||||
if (c->flags&CTRLF_SHOW) {
|
||||
if (c->flags&CTRLF_BORDER) {
|
||||
if (!Bt(&task->display_flags,DISPLAYf_NO_BORDER)) {
|
||||
PUSHFD
|
||||
CLI
|
||||
while (LBts(&task->task_flags,TASKf_TASK_LOCK))
|
||||
PAUSE
|
||||
|
||||
task->win_left--; //Allow drawing on border
|
||||
task->win_right++;
|
||||
task->win_top--;
|
||||
task->win_bottom++;
|
||||
WinDerivedValsUpdate(task);
|
||||
|
||||
LBtr(&task->task_flags,TASKf_TASK_LOCK);
|
||||
POPFD
|
||||
|
||||
if (c->draw_it)
|
||||
(*c->draw_it)(dc,c);
|
||||
|
||||
PUSHFD
|
||||
CLI
|
||||
while (LBts(&task->task_flags,TASKf_TASK_LOCK))
|
||||
PAUSE
|
||||
|
||||
task->win_left++;
|
||||
task->win_right--;
|
||||
task->win_top++;
|
||||
task->win_bottom--;
|
||||
WinDerivedValsUpdate(task);
|
||||
|
||||
LBtr(&task->task_flags,TASKf_TASK_LOCK);
|
||||
POPFD
|
||||
}
|
||||
} else
|
||||
if (c->draw_it)
|
||||
(*c->draw_it)(dc,c);
|
||||
}
|
||||
c=c->next;
|
||||
}
|
||||
DCDel(dc);
|
||||
}
|
||||
|
||||
#define WIN_SCROLL_SIZE 8
|
||||
#define WIN_SCROLL_BORDER_BONUS 4
|
||||
U0 DrawWinScroll(CDC *dc,CCtrl *c)
|
||||
{
|
||||
CWinScroll *s=c->state;
|
||||
|
||||
if (c->flags&CTRLF_CLICKED)
|
||||
dc->color=s->color>>4;
|
||||
else
|
||||
dc->color=s->color&0xF;
|
||||
GrRect(dc,c->left,c->top,c->right-c->left+1,c->bottom-c->top+1);
|
||||
|
||||
if (c->flags&CTRLF_CLICKED)
|
||||
dc->color=s->color&0xF;
|
||||
else
|
||||
dc->color=s->color>>4;
|
||||
GrRect(dc,c->left+2,c->top+2,c->right-c->left+1-4,c->bottom-c->top+1-4);
|
||||
}
|
||||
|
||||
U0 WinDerivedScrollValsUpdate(CCtrl *c)
|
||||
{
|
||||
CWinScroll *s=c->state;
|
||||
I64 range;
|
||||
if (s->max<s->min) s->max=s->min;
|
||||
if (s->pos<s->min) s->pos=s->min;
|
||||
if (s->pos>s->max) s->pos=s->max;
|
||||
s->color=c->win_task->border_attr&0xF^0xF+
|
||||
(c->win_task->border_attr&0xF)<<4;
|
||||
range=s->max-s->min;
|
||||
if (!range) range=1;
|
||||
switch (c->type) {
|
||||
case CTRLT_WIN_HSCROLL:
|
||||
c->left =gr.pan_text_x+FONT_WIDTH-WIN_SCROLL_BORDER_BONUS+
|
||||
(s->pos-s->min)*(c->win_task->pix_width+2*WIN_SCROLL_BORDER_BONUS
|
||||
-WIN_SCROLL_SIZE)/range;
|
||||
c->right =c->left+WIN_SCROLL_SIZE-1;
|
||||
c->top =gr.pan_text_y+FONT_HEIGHT+
|
||||
(FONT_WIDTH-WIN_SCROLL_SIZE)/2+c->win_task->pix_height;
|
||||
c->bottom=c->top+WIN_SCROLL_SIZE-1;
|
||||
break;
|
||||
case CTRLT_WIN_VSCROLL:
|
||||
c->left =gr.pan_text_x+FONT_WIDTH+
|
||||
(FONT_WIDTH-WIN_SCROLL_SIZE)/2+c->win_task->pix_width;
|
||||
c->right =c->left+WIN_SCROLL_SIZE-1;
|
||||
c->top =gr.pan_text_y+FONT_HEIGHT-WIN_SCROLL_BORDER_BONUS+
|
||||
(s->pos-s->min)*(c->win_task->pix_height+
|
||||
2*WIN_SCROLL_BORDER_BONUS-WIN_SCROLL_SIZE)/range;
|
||||
c->bottom=c->top+WIN_SCROLL_SIZE-1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
U0 LeftClickHWinScroll(CCtrl *c,I64 x,I64,Bool down)
|
||||
{
|
||||
CTask *task=c->win_task;
|
||||
CWinScroll *s=c->state;
|
||||
I64 range=task->pix_width+2*WIN_SCROLL_BORDER_BONUS-WIN_SCROLL_SIZE;
|
||||
LBts(&s->flags,WSSf_SET_TO_POS);
|
||||
s->pos=((x-(FONT_WIDTH-WIN_SCROLL_BORDER_BONUS))
|
||||
*(s->max-s->min+1)+range/2)/range+s->min;
|
||||
if (down)
|
||||
c->flags|=CTRLF_CLICKED;
|
||||
else
|
||||
c->flags&=~CTRLF_CLICKED;
|
||||
if (c->update_derived_vals)
|
||||
(*c->update_derived_vals)(c);
|
||||
}
|
||||
|
||||
U0 LeftClickVWinScroll(CCtrl *c,I64,I64 y,Bool down)
|
||||
{
|
||||
CTask *task=c->win_task;
|
||||
CWinScroll *s=c->state;
|
||||
I64 range=task->pix_height+2*WIN_SCROLL_BORDER_BONUS-WIN_SCROLL_SIZE;
|
||||
LBts(&s->flags,WSSf_SET_TO_POS);
|
||||
s->pos=((y-(FONT_HEIGHT-WIN_SCROLL_BORDER_BONUS))
|
||||
*(s->max-s->min+1)+range/2)/range+s->min;
|
||||
if (down)
|
||||
c->flags|=CTRLF_CLICKED;
|
||||
else
|
||||
c->flags&=~CTRLF_CLICKED;
|
||||
if (c->update_derived_vals)
|
||||
(*c->update_derived_vals)(c);
|
||||
}
|
||||
|
||||
U0 WheelChangeWinScroll(CCtrl *c,I64 delta)
|
||||
{
|
||||
CWinScroll *s=c->state;
|
||||
LBts(&s->flags,WSSf_SET_TO_POS);
|
||||
s->pos+=delta;
|
||||
if (c->update_derived_vals)
|
||||
(*c->update_derived_vals)(c);
|
||||
}
|
||||
|
||||
U0 WinScrollsInit(CTask *task)
|
||||
{
|
||||
CCtrl *c;
|
||||
|
||||
if (!CtrlFindUnique(task,CTRLT_WIN_HSCROLL)) {
|
||||
c=CAlloc(sizeof(CCtrl));
|
||||
c->win_task=task;
|
||||
c->flags=CTRLF_SHOW|CTRLF_BORDER|CTRLF_CAPTURE_LEFT_IP;
|
||||
c->type=CTRLT_WIN_HSCROLL;
|
||||
c->state=&task->horz_scroll;
|
||||
c->update_derived_vals=&WinDerivedScrollValsUpdate;
|
||||
c->draw_it=&DrawWinScroll;
|
||||
c->left_click=&LeftClickHWinScroll;
|
||||
QueIns(c,task->last_ctrl);
|
||||
}
|
||||
|
||||
if (!CtrlFindUnique(task,CTRLT_WIN_VSCROLL)) {
|
||||
c=CAlloc(sizeof(CCtrl));
|
||||
c->win_task=task;
|
||||
c->flags=CTRLF_SHOW|CTRLF_BORDER|CTRLF_CAPTURE_LEFT_IP;
|
||||
c->type=CTRLT_WIN_VSCROLL;
|
||||
c->state=&task->vert_scroll;
|
||||
c->update_derived_vals=&WinDerivedScrollValsUpdate;
|
||||
c->draw_it=&DrawWinScroll;
|
||||
c->left_click=&LeftClickVWinScroll;
|
||||
c->wheel_chg=&WheelChangeWinScroll;
|
||||
QueIns(c,task->last_ctrl);
|
||||
}
|
||||
TaskDerivedValsUpdate(task);
|
||||
}
|
||||
#define VIEWANGLES_SPACING 22
|
||||
#define VIEWANGLES_RANGE 48
|
||||
#define VIEWANGLES_BORDER 2
|
||||
#define VIEWANGLES_SNAP 2
|
||||
|
||||
U0 DrawViewAnglesCtrl(CDC *dc,CCtrl *c)
|
||||
{
|
||||
I64 i,j;
|
||||
CViewAngles *s=c->state;
|
||||
|
||||
dc->color=s->cbd;
|
||||
GrRect(dc, c->left,c->top,VIEWANGLES_SPACING*4+3,
|
||||
VIEWANGLES_SPACING*2+VIEWANGLES_RANGE);
|
||||
dc->color=s->cbg;
|
||||
GrRect(dc, c->left+VIEWANGLES_BORDER,c->top+VIEWANGLES_BORDER,
|
||||
VIEWANGLES_SPACING*4+3-2*VIEWANGLES_BORDER,
|
||||
VIEWANGLES_SPACING*2+VIEWANGLES_RANGE-2*VIEWANGLES_BORDER);
|
||||
dc->color=s->cfg;
|
||||
GrLine(dc,c->left+VIEWANGLES_SPACING,c->top+VIEWANGLES_SPACING,
|
||||
c->left+VIEWANGLES_SPACING,c->top+VIEWANGLES_SPACING+
|
||||
VIEWANGLES_RANGE-1);
|
||||
GrLine(dc,c->left+2*VIEWANGLES_SPACING+1,c->top+VIEWANGLES_SPACING,
|
||||
c->left+2*VIEWANGLES_SPACING+1,c->top+VIEWANGLES_SPACING+
|
||||
VIEWANGLES_RANGE-1);
|
||||
GrLine(dc,c->left+3*VIEWANGLES_SPACING+2,c->top+VIEWANGLES_SPACING,
|
||||
c->left+3*VIEWANGLES_SPACING+2,c->top+VIEWANGLES_SPACING+
|
||||
VIEWANGLES_RANGE-1);
|
||||
for (i=1;i<VIEWANGLES_RANGE+1;i+=2*VIEWANGLES_SNAP) {
|
||||
j=2-i/3&1;
|
||||
GrLine(dc,c->left+VIEWANGLES_SPACING-j,c->bottom-VIEWANGLES_SPACING-i,
|
||||
c->left+VIEWANGLES_SPACING+j,c->bottom
|
||||
-VIEWANGLES_SPACING-i);
|
||||
GrLine(dc,c->left+2*VIEWANGLES_SPACING+1-j,c->bottom-VIEWANGLES_SPACING-i,
|
||||
c->left+2*VIEWANGLES_SPACING+1+j,c->bottom
|
||||
-VIEWANGLES_SPACING-i);
|
||||
GrLine(dc,c->left+3*VIEWANGLES_SPACING+2-j,c->bottom-VIEWANGLES_SPACING-i,
|
||||
c->left+3*VIEWANGLES_SPACING+2+j,c->bottom
|
||||
-VIEWANGLES_SPACING-i);
|
||||
}
|
||||
|
||||
dc->color=s->cx;
|
||||
GrPrint(dc,c->left+VIEWANGLES_SPACING-FONT_WIDTH/2,
|
||||
c->top+VIEWANGLES_SPACING-(1+FONT_HEIGHT),"X");
|
||||
GrPrint(dc,c->left+VIEWANGLES_SPACING-3*FONT_WIDTH/2,
|
||||
c->top+VIEWANGLES_SPACING+VIEWANGLES_RANGE+3,
|
||||
"%3d",s->sx*360/VIEWANGLES_RANGE);
|
||||
i=c->left+VIEWANGLES_SPACING;
|
||||
if (s->sx>VIEWANGLES_RANGE/2)
|
||||
j=-VIEWANGLES_RANGE/2+s->sx;
|
||||
else
|
||||
j=s->sx+VIEWANGLES_RANGE/2;
|
||||
j=c->top+VIEWANGLES_SPACING+VIEWANGLES_RANGE-1-j;
|
||||
GrRect(dc,i-3,j-2,7,5);
|
||||
dc->color=s->cx^8;
|
||||
GrRect(dc,i-2,j-1,5,3);
|
||||
|
||||
dc->color=s->cy;
|
||||
GrPrint(dc,c->left+2*VIEWANGLES_SPACING+1-FONT_WIDTH/2,
|
||||
c->top+VIEWANGLES_SPACING-(1+FONT_HEIGHT),"Y");
|
||||
GrPrint(dc,c->left+2*VIEWANGLES_SPACING+1-3*FONT_WIDTH/2,
|
||||
c->top+VIEWANGLES_SPACING+VIEWANGLES_RANGE+3,
|
||||
"%3d",s->sy*360/VIEWANGLES_RANGE);
|
||||
i=c->left+2*VIEWANGLES_SPACING+1;
|
||||
if (s->sy>VIEWANGLES_RANGE/2)
|
||||
j=-VIEWANGLES_RANGE/2+s->sy;
|
||||
else
|
||||
j=s->sy+VIEWANGLES_RANGE/2;
|
||||
j=c->top+VIEWANGLES_SPACING+VIEWANGLES_RANGE-1-j;
|
||||
GrRect(dc,i-3,j-2,7,5);
|
||||
dc->color=s->cy^8;
|
||||
GrRect(dc,i-2,j-1,5,3);
|
||||
|
||||
dc->color=s->cz;
|
||||
GrPrint(dc,c->left+3*VIEWANGLES_SPACING+2-FONT_WIDTH/2,
|
||||
c->top+VIEWANGLES_SPACING-(1+FONT_HEIGHT),"Z");
|
||||
GrPrint(dc,c->left+3*VIEWANGLES_SPACING+2-3*FONT_WIDTH/2,
|
||||
c->top+VIEWANGLES_SPACING+VIEWANGLES_RANGE+3,
|
||||
"%3d",s->sz*360/VIEWANGLES_RANGE);
|
||||
i=c->left+3*VIEWANGLES_SPACING+2;
|
||||
if (s->sz>VIEWANGLES_RANGE/2)
|
||||
j=-VIEWANGLES_RANGE/2+s->sz;
|
||||
else
|
||||
j=s->sz+VIEWANGLES_RANGE/2;
|
||||
j=c->top+VIEWANGLES_SPACING+VIEWANGLES_RANGE-1-j;
|
||||
GrRect(dc,i-3,j-2,7,5);
|
||||
dc->color=s->cz^8;
|
||||
GrRect(dc,i-2,j-1,5,3);
|
||||
}
|
||||
|
||||
U0 UpdateDerivedViewAnglesCtrl(CCtrl *c)
|
||||
{
|
||||
CViewAngles *s=c->state;
|
||||
c->left=c->win_task->pix_width-(VIEWANGLES_SPACING*4+3);
|
||||
c->right=c->left+VIEWANGLES_SPACING*4+3;
|
||||
c->top=c->win_task->pix_height-(VIEWANGLES_SPACING*2+VIEWANGLES_RANGE);
|
||||
c->bottom=c->top+VIEWANGLES_SPACING*2+VIEWANGLES_RANGE;
|
||||
s->sx=ClampI64(RoundI64(s->sx,VIEWANGLES_SNAP),0,VIEWANGLES_RANGE-1);
|
||||
s->sy=ClampI64(RoundI64(s->sy,VIEWANGLES_SNAP),0,VIEWANGLES_RANGE-1);
|
||||
s->sz=ClampI64(RoundI64(s->sz,VIEWANGLES_SNAP),0,VIEWANGLES_RANGE-1);
|
||||
s->ax=2*ã*s->sx/VIEWANGLES_RANGE;
|
||||
s->ay=2*ã*s->sy/VIEWANGLES_RANGE;
|
||||
s->az=2*ã*s->sz/VIEWANGLES_RANGE;
|
||||
}
|
||||
|
||||
U0 LeftClickViewAngles(CCtrl *c,I64 x,I64 y,Bool)
|
||||
{
|
||||
CViewAngles *s=c->state;
|
||||
I64 i;
|
||||
i=VIEWANGLES_RANGE-1-(y-(c->top+VIEWANGLES_SPACING));
|
||||
if (i>=VIEWANGLES_RANGE/2)
|
||||
i-=VIEWANGLES_RANGE/2;
|
||||
else
|
||||
i+=VIEWANGLES_RANGE/2;
|
||||
if (x<c->left+(c->right-c->left)/3)
|
||||
s->sx=i;
|
||||
else if (x<c->left+2*(c->right-c->left)/3)
|
||||
s->sy=i;
|
||||
else
|
||||
s->sz=i;
|
||||
if (c->update_derived_vals)
|
||||
(*c->update_derived_vals)(c);
|
||||
}
|
||||
|
||||
public CCtrl *ViewAnglesNew(CTask *task=NULL)
|
||||
{//Create view angle ctrl. See $LK,"::/Demo/Graphics/Shading.HC"$.
|
||||
CCtrl *c;
|
||||
CViewAngles *s;
|
||||
if (!task) task=Fs;
|
||||
if (!(c=CtrlFindUnique(task,CTRLT_VIEWING_ANGLES))) {
|
||||
s=CAlloc(sizeof(CViewAngles),task);
|
||||
c=CAlloc(sizeof(CCtrl));
|
||||
s->cbd=BLUE;
|
||||
s->cbg=LTBLUE;
|
||||
s->cfg=BLACK;
|
||||
s->cx=LTGREEN;
|
||||
s->cy=GREEN;
|
||||
s->cz=LTGREEN;
|
||||
c->win_task=task;
|
||||
c->flags=CTRLF_SHOW|CTRLF_CAPTURE_LEFT_IP;
|
||||
c->type=CTRLT_VIEWING_ANGLES;
|
||||
c->state=s;
|
||||
c->draw_it=&DrawViewAnglesCtrl;
|
||||
c->left_click=&LeftClickViewAngles;
|
||||
c->update_derived_vals=&UpdateDerivedViewAnglesCtrl;
|
||||
QueIns(c,task->last_ctrl);
|
||||
TaskDerivedValsUpdate(task);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public U0 ViewAnglesDel(CTask *task=NULL)
|
||||
{//Free view angle ctrl.
|
||||
CCtrl *c;
|
||||
if (!task) task=Fs;
|
||||
if (c=CtrlFindUnique(task,CTRLT_VIEWING_ANGLES)) {
|
||||
QueRem(c);
|
||||
Free(c->state);
|
||||
Free(c);
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
#define BUTTON_BORDER 2
|
||||
|
||||
#define BTF_DONT_FREE 1
|
||||
|
||||
class CCtrlButtonState
|
||||
{
|
||||
I64 state,num_states,flags;
|
||||
U8 *state_texts;
|
||||
CColorROPU32 *state_colors;
|
||||
};
|
||||
|
||||
U0 DrawCtrlButton(CDC *dc,CCtrl *c)
|
||||
{
|
||||
CCtrlButtonState *s=c->state;
|
||||
I64 l;
|
||||
U8 *st;
|
||||
|
||||
dc->color=BLACK;
|
||||
GrRect(dc,c->left,c->top,c->right-c->left+1,c->bottom-c->top+1);
|
||||
if (!(st=LstSub(s->state,s->state_texts)))
|
||||
st=s->state_texts;
|
||||
dc->color=s->state_colors[s->state];
|
||||
l=StrLen(st);
|
||||
GrRect(dc,c->left+BUTTON_BORDER,c->top+BUTTON_BORDER,
|
||||
c->right-c->left+1-BUTTON_BORDER*2,
|
||||
c->bottom-c->top+1-BUTTON_BORDER*2);
|
||||
dc->color=s->state_colors[s->state]^(WHITE<<16+WHITE);
|
||||
GrPrint(dc,(c->left+c->right+1-l*FONT_WIDTH)>>1,
|
||||
(c->top+c->bottom+1-FONT_HEIGHT)>>1,"%s",st);
|
||||
}
|
||||
|
||||
U0 LeftClickCtrlButton(CCtrl *c,I64,I64,Bool down)
|
||||
{
|
||||
CCtrlButtonState *s=c->state;
|
||||
if (down) {
|
||||
s->state++;
|
||||
if (s->state==s->num_states)
|
||||
s->state=0;
|
||||
}
|
||||
}
|
||||
|
||||
public CCtrl *CtrlButtonNew(I64 x,I64 y,I64 width=-1,I64 height=-1,
|
||||
I64 num_states=1,U8 *state_texts,
|
||||
I32 *state_colors,CCtrlButtonState *_s=NULL)
|
||||
{//Create button ctrl. See $LK,"::/Apps/Strut/Strut.CPP"$.
|
||||
CCtrl *res;
|
||||
CCtrlButtonState *s;
|
||||
I64 i,j,l;
|
||||
U8 *st;
|
||||
if (width<0) {
|
||||
l=1;
|
||||
for (i=0;i<num_states;i++)
|
||||
if (st=LstSub(i,state_texts)) {
|
||||
j=StrLen(st);
|
||||
if (j>l) l=j;
|
||||
}
|
||||
width=BUTTON_BORDER*4+l*FONT_WIDTH;
|
||||
}
|
||||
if (height<0) height=BUTTON_BORDER*4+FONT_HEIGHT;
|
||||
res=CAlloc(sizeof(CCtrl));
|
||||
if (_s) {
|
||||
s=_s;
|
||||
MemSet(s,0,sizeof(CCtrlButtonState));
|
||||
} else {
|
||||
s=CAlloc(sizeof(CCtrlButtonState));
|
||||
s->flags=BTF_DONT_FREE;
|
||||
}
|
||||
s->num_states=num_states;
|
||||
s->state_texts=state_texts;
|
||||
s->state_colors=state_colors;
|
||||
res->win_task=Fs;
|
||||
res->flags=CTRLF_SHOW;
|
||||
res->type=CTRLT_GENERIC;
|
||||
res->state=s;
|
||||
res->draw_it=&DrawCtrlButton;
|
||||
res->left_click=&LeftClickCtrlButton;
|
||||
res->left=x;
|
||||
res->top=y;
|
||||
res->right=res->left+width-1;
|
||||
res->bottom=res->top+height-1;
|
||||
QueIns(res,Fs->last_ctrl);
|
||||
return res;
|
||||
}
|
||||
|
||||
public U0 CtrlButtonDel(CCtrl *c)
|
||||
{//Free button ctrl.
|
||||
QueRem(c);
|
||||
if (!(c->flags&BTF_DONT_FREE))
|
||||
Free(c->state);
|
||||
Free(c);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
#define BUTTON_BORDER 2
|
||||
|
||||
#define BTF_DONT_FREE 1
|
||||
|
||||
class CCtrlButtonState
|
||||
{
|
||||
I64 state,num_states,flags;
|
||||
U8 *state_texts;
|
||||
CColorROPU32 *state_colors;
|
||||
};
|
||||
|
||||
U0 DrawCtrlButton(CDC *dc,CCtrl *c)
|
||||
{
|
||||
CCtrlButtonState *s=c->state;
|
||||
I64 l;
|
||||
U8 *st;
|
||||
|
||||
dc->color=BLACK;
|
||||
GrRect(dc,c->left,c->top,c->right-c->left+1,c->bottom-c->top+1);
|
||||
if (!(st=LstSub(s->state,s->state_texts)))
|
||||
st=s->state_texts;
|
||||
dc->color=s->state_colors[s->state];
|
||||
l=StrLen(st);
|
||||
GrRect(dc,c->left+BUTTON_BORDER,c->top+BUTTON_BORDER,
|
||||
c->right-c->left+1-BUTTON_BORDER*2,
|
||||
c->bottom-c->top+1-BUTTON_BORDER*2);
|
||||
dc->color=s->state_colors[s->state]^(WHITE<<16+WHITE);
|
||||
GrPrint(dc,(c->left+c->right+1-l*FONT_WIDTH)>>1,
|
||||
(c->top+c->bottom+1-FONT_HEIGHT)>>1,"%s",st);
|
||||
}
|
||||
|
||||
U0 LeftClickCtrlButton(CCtrl *c,I64,I64,Bool down)
|
||||
{
|
||||
CCtrlButtonState *s=c->state;
|
||||
if (down) {
|
||||
s->state++;
|
||||
if (s->state==s->num_states)
|
||||
s->state=0;
|
||||
}
|
||||
}
|
||||
|
||||
public CCtrl *CtrlButtonNew(I64 x,I64 y,I64 width=-1,I64 height=-1,
|
||||
I64 num_states=1,U8 *state_texts,
|
||||
I32 *state_colors,CCtrlButtonState *_s=NULL)
|
||||
{//Create button ctrl. See $LK,"::/Apps/Strut/Strut.HC"$.
|
||||
CCtrl *res;
|
||||
CCtrlButtonState *s;
|
||||
I64 i,j,l;
|
||||
U8 *st;
|
||||
if (width<0) {
|
||||
l=1;
|
||||
for (i=0;i<num_states;i++)
|
||||
if (st=LstSub(i,state_texts)) {
|
||||
j=StrLen(st);
|
||||
if (j>l) l=j;
|
||||
}
|
||||
width=BUTTON_BORDER*4+l*FONT_WIDTH;
|
||||
}
|
||||
if (height<0) height=BUTTON_BORDER*4+FONT_HEIGHT;
|
||||
res=CAlloc(sizeof(CCtrl));
|
||||
if (_s) {
|
||||
s=_s;
|
||||
MemSet(s,0,sizeof(CCtrlButtonState));
|
||||
} else {
|
||||
s=CAlloc(sizeof(CCtrlButtonState));
|
||||
s->flags=BTF_DONT_FREE;
|
||||
}
|
||||
s->num_states=num_states;
|
||||
s->state_texts=state_texts;
|
||||
s->state_colors=state_colors;
|
||||
res->win_task=Fs;
|
||||
res->flags=CTRLF_SHOW;
|
||||
res->type=CTRLT_GENERIC;
|
||||
res->state=s;
|
||||
res->draw_it=&DrawCtrlButton;
|
||||
res->left_click=&LeftClickCtrlButton;
|
||||
res->left=x;
|
||||
res->top=y;
|
||||
res->right=res->left+width-1;
|
||||
res->bottom=res->top+height-1;
|
||||
QueIns(res,Fs->last_ctrl);
|
||||
return res;
|
||||
}
|
||||
|
||||
public U0 CtrlButtonDel(CCtrl *c)
|
||||
{//Free button ctrl.
|
||||
QueRem(c);
|
||||
if (!(c->flags&BTF_DONT_FREE))
|
||||
Free(c->state);
|
||||
Free(c);
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
#help_index "PCI;Processor;Devices;Info"
|
||||
|
||||
//The file was downloaded from
|
||||
//http://www.pcidatabase.com/reports.php?type=tab-delimeted
|
||||
|
||||
#define PCI_DEV_FILE "::/Misc/PCIDevices.TXT.Z"
|
||||
|
||||
/****
|
||||
//1) Plain text edit and remove file header and tail
|
||||
//2) Text find-and-replace "=0A=" with "".
|
||||
//3) Run PCIDevFileGen().
|
||||
|
||||
public U0 PCIDevFileGen()
|
||||
{
|
||||
Bool first=TRUE,del=FALSE,del2=FALSE,cont=FALSE;
|
||||
CDoc *doc=DocRead(PCI_DEV_FILE,
|
||||
DOCF_PLAIN_TEXT|DOCF_DBL_DOLLARS|DOCF_NO_CURSOR);
|
||||
CDocEntry *doc_e=doc->head.next,*doc_e2;
|
||||
while (doc_e!=doc) {
|
||||
doc_e2=doc_e->next;
|
||||
if (first) {
|
||||
if (doc_e->type_u8==DOCT_TEXT) {
|
||||
if (doc_e->tag[0]==';')
|
||||
del=TRUE;
|
||||
}
|
||||
first=FALSE;
|
||||
}
|
||||
if (doc_e->type_u8==DOCT_TEXT && doc_e->tag[StrLen(doc_e->tag)-1]=='=' &&
|
||||
doc_e2->type_u8==DOCT_NEW_LINE) {
|
||||
doc_e->tag[StrLen(doc_e->tag)-1]=CH_SPACE;
|
||||
cont=TRUE;
|
||||
}
|
||||
del2=del;
|
||||
if (doc_e->type_u8==DOCT_NEW_LINE) {
|
||||
first=TRUE;
|
||||
del2=FALSE;
|
||||
if (cont) {
|
||||
del=TRUE;
|
||||
cont=FALSE;
|
||||
}
|
||||
}
|
||||
if (del)
|
||||
DocEntryDel(doc,doc_e);
|
||||
del=del2;
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
DocWrite(doc);
|
||||
}
|
||||
****/
|
||||
|
||||
//$LK,"::/Misc/PCIDevices.TXT",A="PI:::/Misc/PCIDevices.TXT"$
|
||||
U0 PCILookUpSingle(CDoc *doc,I64 m,I64 d,U8 **_vendor,U8 **_dev)
|
||||
{
|
||||
Bool first=TRUE;
|
||||
U8 buf[8],*vendor=NULL,*dev=NULL;
|
||||
CDocEntry *doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
if (first) {
|
||||
if (doc_e->type_u8==DOCT_TEXT && doc_e->tag[0]!=';' &&
|
||||
StrLen(doc_e->tag)>=4) {
|
||||
buf[0](U16)='0x';
|
||||
buf[2](U32)=doc_e->tag(U32 *)[0];
|
||||
buf[6]=0;
|
||||
if (Str2I64(buf)==m) {
|
||||
doc_e=doc_e->next->next;
|
||||
if (doc_e->type_u8==DOCT_TEXT) {
|
||||
vendor=AStrNew(doc_e->tag);
|
||||
first=FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
first=FALSE;
|
||||
}
|
||||
if (doc_e->type_u8==DOCT_NEW_LINE)
|
||||
first=TRUE;
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
|
||||
if (vendor) {
|
||||
while (doc_e!=doc) {
|
||||
if (first) {
|
||||
if (doc_e->type_u8==DOCT_TAB) {
|
||||
doc_e=doc_e->next;
|
||||
if (doc_e->type_u8==DOCT_TEXT && StrLen(doc_e->tag)>=4) {
|
||||
buf[0](U16)='0x';
|
||||
buf[2](U32)=doc_e->tag(U32 *)[0];
|
||||
buf[6]=0;
|
||||
if (Str2I64(buf)==d) {
|
||||
doc_e=doc_e->next->next;
|
||||
if (doc_e->type_u8==DOCT_TEXT) {
|
||||
dev=AStrNew(doc_e->tag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
break;
|
||||
first=FALSE;
|
||||
}
|
||||
if (doc_e->type_u8==DOCT_NEW_LINE)
|
||||
first=TRUE;
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (vendor)
|
||||
*_vendor=vendor;
|
||||
else
|
||||
*_vendor=AStrNew("Unknown");
|
||||
|
||||
if (dev)
|
||||
*_dev=dev;
|
||||
else
|
||||
*_dev=AStrNew("Unknown");
|
||||
}
|
||||
|
||||
U0 PCILookUpDevs()
|
||||
{
|
||||
CPCIDev *temppci;
|
||||
I64 w1,w2,b,d,f,timeout=32*8*2;
|
||||
CDoc *doc;
|
||||
if (dev.pci_head.next!=&dev.pci_head)
|
||||
return;
|
||||
doc=DocRead(PCI_DEV_FILE,DOCF_PLAIN_TEXT|DOCF_NO_CURSOR);
|
||||
for (b=0;b<sys_pci_busses;b++)
|
||||
for (d=0;d<32;d++)
|
||||
for (f=0;f<8;f++) {
|
||||
w1=PCIReadU16(b,d,f,0);
|
||||
if (w1!=0xFFFF) {
|
||||
temppci=ACAlloc(sizeof(CPCIDev));
|
||||
temppci->bus=b;
|
||||
temppci->dev=d;
|
||||
temppci->fun=f;
|
||||
temppci->vendor=w1;
|
||||
temppci->dev_id=w2=PCIReadU16(b,d,f,2);
|
||||
temppci->sub_code=PCIReadU8(b,d,f,0xA);
|
||||
temppci->base_code=PCIReadU8(b,d,f,0xB);
|
||||
PCILookUpSingle(doc,w1,w2,&temppci->vendor_str,&temppci->dev_id_str);
|
||||
QueIns(temppci,dev.pci_head.last);
|
||||
timeout=32*8*2;
|
||||
} else if (sys_pci_busses==256 && --timeout<=0)
|
||||
goto lud_done;
|
||||
}
|
||||
lud_done:
|
||||
DocDel(doc);
|
||||
}
|
||||
|
||||
public U0 PCIRep()
|
||||
{//Report description of PCI devices.
|
||||
CPCIDev *temppci;
|
||||
"PCI Busses:%d\n",sys_pci_busses;
|
||||
if (!FileFind(PCI_DEV_FILE)) {
|
||||
"You don't have the PCI device file.\n";
|
||||
return;
|
||||
}
|
||||
PCILookUpDevs;
|
||||
temppci=dev.pci_head.next;
|
||||
while (temppci!=&dev.pci_head) {
|
||||
"%02X:%02X:%01X %02X%02X $$GREEN$$%s $$CYAN$$%s$$FG$$\n",
|
||||
temppci->bus,temppci->dev,temppci->fun,
|
||||
temppci->base_code,temppci->sub_code,
|
||||
temppci->vendor_str,temppci->dev_id_str;
|
||||
temppci=temppci->next;
|
||||
}
|
||||
}
|
||||
|
||||
#help_index "Info;Time/CPU Cycles"
|
||||
public U0 CPURep()
|
||||
{//Report number of cores and clock freq.
|
||||
"%d Cores %6h?nHz\n",mp_cnt,ToF64(cnts.time_stamp_freq);
|
||||
}
|
||||
|
||||
#help_index "Info;Memory/Info"
|
||||
public U0 MemBIOSRep()
|
||||
{//Report the memory ranges reported by the BIOS at boot.
|
||||
U16 *m01=SYS_MEM_E801;
|
||||
CMemE820 *m20=SYS_MEM_E820;
|
||||
CMemRange *tempmr;
|
||||
"Standard Addresses\n"
|
||||
"0x000A0000-0x000BFFFF VGA\n"
|
||||
"0xFEE00000-0xFEE00FFF See $$LK,\"APIC\",A=\"MN:LAPIC_BASE\"$$\n\n"
|
||||
"32 Bit Device Mem\n";
|
||||
while (LBts(&sys_semas[SYS_SEMA_DEV_MEM],0))
|
||||
Yield;
|
||||
tempmr=dev.mem32_head.next;
|
||||
while (tempmr!=&dev.mem32_head) {
|
||||
"%02X:0x%016X-0x%016X\n",
|
||||
tempmr->type,tempmr->base,tempmr->base+tempmr->size-1;
|
||||
tempmr=tempmr->next;
|
||||
}
|
||||
LBtr(&sys_semas[SYS_SEMA_DEV_MEM],0);
|
||||
|
||||
"\nBIOS Memory Report 15:E801\n"
|
||||
"01:0x0000000000000000-0x%016X\n",0x100000+m01[0]<<10-1;
|
||||
"01:0x0000000001000000-0x%016X\n",0x1000000+m01[1]<<16-1;
|
||||
|
||||
if (m20->type) {
|
||||
'\n';
|
||||
"BIOS Memory Report 15:E820\n";
|
||||
while (m20->type) {
|
||||
"%02X:0x%016X-0x%016X\n",m20->type,m20->base,m20->base+m20->len-1;
|
||||
m20++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+274
@@ -0,0 +1,274 @@
|
||||
#help_index "PCI;Processor;Devices;Info"
|
||||
|
||||
//The file was downloaded from
|
||||
//http://www.pcidatabase.com/reports.php?type=tab-delimeted
|
||||
|
||||
#define PCI_DEV_FILE "::/Misc/PCIDevices.DD.Z"
|
||||
|
||||
/****
|
||||
//1) Plain text edit and remove file header and tail
|
||||
//2) Text find-and-replace "=0A=" with "".
|
||||
//3) Run PCIDevFileGen().
|
||||
|
||||
public U0 PCIDevFileGen()
|
||||
{
|
||||
Bool first=TRUE,del=FALSE,del2=FALSE,cont=FALSE;
|
||||
CDoc *doc=DocRead(PCI_DEV_FILE,
|
||||
DOCF_PLAIN_TEXT|DOCF_DBL_DOLLARS|DOCF_NO_CURSOR);
|
||||
CDocEntry *doc_e=doc->head.next,*doc_e2;
|
||||
while (doc_e!=doc) {
|
||||
doc_e2=doc_e->next;
|
||||
if (first) {
|
||||
if (doc_e->type_u8==DOCT_TEXT) {
|
||||
if (doc_e->tag[0]==';')
|
||||
del=TRUE;
|
||||
}
|
||||
first=FALSE;
|
||||
}
|
||||
if (doc_e->type_u8==DOCT_TEXT && doc_e->tag[StrLen(doc_e->tag)-1]=='=' &&
|
||||
doc_e2->type_u8==DOCT_NEW_LINE) {
|
||||
doc_e->tag[StrLen(doc_e->tag)-1]=CH_SPACE;
|
||||
cont=TRUE;
|
||||
}
|
||||
del2=del;
|
||||
if (doc_e->type_u8==DOCT_NEW_LINE) {
|
||||
first=TRUE;
|
||||
del2=FALSE;
|
||||
if (cont) {
|
||||
del=TRUE;
|
||||
cont=FALSE;
|
||||
}
|
||||
}
|
||||
if (del)
|
||||
DocEntryDel(doc,doc_e);
|
||||
del=del2;
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
DocWrite(doc);
|
||||
}
|
||||
****/
|
||||
|
||||
//$LK,"::/Misc/PCIDevices.DD",A="PI:::/Misc/PCIDevices.DD"$
|
||||
U0 PCILookUpSingle(CDoc *doc,I64 m,I64 d,U8 **_vendor,U8 **_dev)
|
||||
{
|
||||
Bool first=TRUE;
|
||||
U8 buf[8],*vendor=NULL,*dev=NULL;
|
||||
CDocEntry *doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
if (first) {
|
||||
if (doc_e->type_u8==DOCT_TEXT && doc_e->tag[0]!=';' &&
|
||||
StrLen(doc_e->tag)>=4) {
|
||||
buf[0](U16)='0x';
|
||||
buf[2](U32)=doc_e->tag(U32 *)[0];
|
||||
buf[6]=0;
|
||||
if (Str2I64(buf)==m) {
|
||||
doc_e=doc_e->next->next;
|
||||
if (doc_e->type_u8==DOCT_TEXT) {
|
||||
vendor=AStrNew(doc_e->tag);
|
||||
first=FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
first=FALSE;
|
||||
}
|
||||
if (doc_e->type_u8==DOCT_NEW_LINE)
|
||||
first=TRUE;
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
|
||||
if (vendor) {
|
||||
while (doc_e!=doc) {
|
||||
if (first) {
|
||||
if (doc_e->type_u8==DOCT_TAB) {
|
||||
doc_e=doc_e->next;
|
||||
if (doc_e->type_u8==DOCT_TEXT && StrLen(doc_e->tag)>=4) {
|
||||
buf[0](U16)='0x';
|
||||
buf[2](U32)=doc_e->tag(U32 *)[0];
|
||||
buf[6]=0;
|
||||
if (Str2I64(buf)==d) {
|
||||
doc_e=doc_e->next->next;
|
||||
if (doc_e->type_u8==DOCT_TEXT) {
|
||||
dev=AStrNew(doc_e->tag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
break;
|
||||
first=FALSE;
|
||||
}
|
||||
if (doc_e->type_u8==DOCT_NEW_LINE)
|
||||
first=TRUE;
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (vendor)
|
||||
*_vendor=vendor;
|
||||
else
|
||||
*_vendor=AStrNew("Unknown");
|
||||
|
||||
if (dev)
|
||||
*_dev=dev;
|
||||
else
|
||||
*_dev=AStrNew("Unknown");
|
||||
}
|
||||
|
||||
U0 PCILookUpDevs()
|
||||
{
|
||||
CPCIDev *temppci;
|
||||
I64 w1,w2,b,d,f,timeout=32*8*2;
|
||||
CDoc *doc;
|
||||
if (dev.pci_head.next!=&dev.pci_head)
|
||||
return;
|
||||
doc=DocRead(PCI_DEV_FILE,DOCF_PLAIN_TEXT|DOCF_NO_CURSOR);
|
||||
for (b=0;b<sys_pci_busses;b++)
|
||||
for (d=0;d<32;d++)
|
||||
for (f=0;f<8;f++) {
|
||||
w1=PCIReadU16(b,d,f,0);
|
||||
if (w1!=0xFFFF) {
|
||||
temppci=ACAlloc(sizeof(CPCIDev));
|
||||
temppci->bus=b;
|
||||
temppci->dev=d;
|
||||
temppci->fun=f;
|
||||
temppci->vendor=w1;
|
||||
temppci->dev_id=w2=PCIReadU16(b,d,f,2);
|
||||
temppci->sub_code=PCIReadU8(b,d,f,0xA);
|
||||
temppci->base_code=PCIReadU8(b,d,f,0xB);
|
||||
PCILookUpSingle(doc,w1,w2,&temppci->vendor_str,&temppci->dev_id_str);
|
||||
QueIns(temppci,dev.pci_head.last);
|
||||
timeout=32*8*2;
|
||||
} else if (sys_pci_busses==256 && --timeout<=0)
|
||||
goto lud_done;
|
||||
}
|
||||
lud_done:
|
||||
DocDel(doc);
|
||||
}
|
||||
|
||||
public U0 PCIRep()
|
||||
{//Report description of PCI devices.
|
||||
CPCIDev *temppci;
|
||||
"PCI Busses:%d\n",sys_pci_busses;
|
||||
if (!FileFind(PCI_DEV_FILE)) {
|
||||
"You don't have the PCI device file.\n";
|
||||
return;
|
||||
}
|
||||
PCILookUpDevs;
|
||||
temppci=dev.pci_head.next;
|
||||
while (temppci!=&dev.pci_head) {
|
||||
"%02X:%02X:%01X %02X%02X $$GREEN$$%s $$CYAN$$%s$$FG$$\n",
|
||||
temppci->bus,temppci->dev,temppci->fun,
|
||||
temppci->base_code,temppci->sub_code,
|
||||
temppci->vendor_str,temppci->dev_id_str;
|
||||
temppci=temppci->next;
|
||||
}
|
||||
}
|
||||
|
||||
#help_index "Info;Time/CPU Cycles"
|
||||
class CCPURep
|
||||
{
|
||||
Bool mp_start,mp_end;
|
||||
I64 mp_not_done_flags,
|
||||
**swaps,
|
||||
**cycles;
|
||||
};
|
||||
|
||||
U0 MPCPURep(CCPURep *cr)
|
||||
{
|
||||
I64 swaps=0,cycles_0,cycles_f;
|
||||
while (!cr->mp_start)
|
||||
Yield;
|
||||
cycles_0=GetTSC;
|
||||
while (!cr->mp_end) {
|
||||
swaps++;
|
||||
Yield;
|
||||
}
|
||||
cycles_f=GetTSC;
|
||||
cr->swaps[Gs->num]=swaps;
|
||||
cr->cycles[Gs->num]=cycles_f-cycles_0;
|
||||
LBtr(&cr->mp_not_done_flags,Gs->num);
|
||||
}
|
||||
|
||||
public U0 CPURep(Bool full=FALSE)
|
||||
{//Report number of cores and clock freq.
|
||||
I64 i,total_swaps,total_cycles;
|
||||
F64 t0,tf;
|
||||
CCPURep cr;
|
||||
|
||||
if (!full)
|
||||
"%d Cores %6h?nHz\n",mp_cnt,ToF64(cnts.time_stamp_freq);
|
||||
else {
|
||||
cr.swaps=CAlloc(sizeof(I64)*mp_cnt);
|
||||
cr.cycles=CAlloc(sizeof(I64)*mp_cnt);
|
||||
cr.mp_start=cr.mp_end=FALSE;
|
||||
cr.mp_not_done_flags=1<<mp_cnt-1;
|
||||
for (i=0;i<mp_cnt;i++)
|
||||
Spawn(&MPCPURep,&cr,NULL,i);
|
||||
|
||||
t0=tS;
|
||||
cr.mp_start=TRUE;
|
||||
Sleep(2000);
|
||||
cr.mp_end=TRUE;
|
||||
while (cr.mp_not_done_flags)
|
||||
Yield;
|
||||
tf=tS;
|
||||
|
||||
"\nCPU: %d Cores %6h?nHz\n",mp_cnt,ToF64(cnts.time_stamp_freq);
|
||||
"\n Context\n"
|
||||
"Core Swaps/s Cycles\n"
|
||||
"---- ------------- -----------------\n";
|
||||
total_swaps=0;
|
||||
total_cycles=0;
|
||||
for (i=0;i<mp_cnt;i++) {
|
||||
"%4d %13,d %17,d\n",i,
|
||||
ToI64(cr.swaps[i]/(tf-t0)),ToI64(cr.cycles[i]/(tf-t0));
|
||||
total_swaps+=cr.swaps[i];
|
||||
total_cycles+=cr.cycles[i];
|
||||
}
|
||||
"---- ------------- -----------------\n";
|
||||
"%4d %13,d %17,d\n",i,
|
||||
ToI64(total_swaps/(tf-t0)),ToI64(total_cycles/(tf-t0));
|
||||
" Avg %13,d %17,d\n\n",
|
||||
ToI64(total_swaps/(tf-t0)/i),ToI64(total_cycles/(tf-t0)/i);
|
||||
"Avg Cycles/Swap: %12.6f\n",ToF64(total_cycles)/total_swaps;
|
||||
"Avg Time/Swap : %12.6fns\n\n",(tf-t0)*1000000000.0*i/total_swaps;
|
||||
Free(cr.swaps);
|
||||
Free(cr.cycles);
|
||||
}
|
||||
}
|
||||
|
||||
#help_index "Info;Memory/Info"
|
||||
public U0 MemBIOSRep()
|
||||
{//Report the memory ranges reported by the BIOS at boot.
|
||||
U16 *m01=SYS_MEM_E801;
|
||||
CMemE820 *m20=SYS_MEM_E820;
|
||||
CMemRange *tempmr;
|
||||
"Standard Addresses\n"
|
||||
"0x000A0000-0x000BFFFF VGA\n"
|
||||
"0xFEE00000-0xFEE00FFF See $$LK,\"APIC\",A=\"MN:LAPIC_BASE\"$$\n\n"
|
||||
"32 Bit Device Mem\n";
|
||||
while (LBts(&sys_semas[SYS_SEMA_DEV_MEM],0))
|
||||
Yield;
|
||||
tempmr=dev.mem32_head.next;
|
||||
while (tempmr!=&dev.mem32_head) {
|
||||
"%02X:0x%016X-0x%016X\n",
|
||||
tempmr->type,tempmr->base,tempmr->base+tempmr->size-1;
|
||||
tempmr=tempmr->next;
|
||||
}
|
||||
LBtr(&sys_semas[SYS_SEMA_DEV_MEM],0);
|
||||
|
||||
"\nBIOS Memory Report 15:E801\n"
|
||||
"01:0x0000000000000000-0x%016X\n",0x100000+m01[0]<<10-1;
|
||||
"01:0x0000000001000000-0x%016X\n",0x1000000+m01[1]<<16-1;
|
||||
|
||||
if (m20->type) {
|
||||
'\n';
|
||||
"BIOS Memory Report 15:E820\n";
|
||||
while (m20->type) {
|
||||
"%02X:0x%016X-0x%016X\n",m20->type,m20->base,m20->base+m20->len-1;
|
||||
m20++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,652 +0,0 @@
|
||||
#help_index "DolDoc/Editor"
|
||||
|
||||
public I64 EdCurU8(CDoc *doc)
|
||||
{//Return cur U8. See $LK,"EdRenumAsm",A="MN:EdRenumAsm"$ for an example.
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
I64 res=-1;
|
||||
if (doc_ce->type_u8==DOCT_TEXT &&
|
||||
doc_ce->min_col<=doc->cur_col<doc_ce->max_col)
|
||||
res=doc_ce->tag[doc->cur_col];
|
||||
else if (doc_ce->type_u8==DOCT_TAB)
|
||||
res='\t';
|
||||
else if (doc_ce->type_u8==DOCT_NEW_LINE ||
|
||||
doc_ce->type_u8==DOCT_SOFT_NEW_LINE)
|
||||
res='\n';
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return res;
|
||||
}
|
||||
|
||||
public U0 EdCursorLeft(CDoc *doc,I64 sc=MIN_I64)
|
||||
{//Move cursor left. Might need a call to $LK,"DocRecalc",A="MN:DocRecalc"$().
|
||||
//See $LK,"EdRenumAsm",A="MN:EdRenumAsm"$ for an example.
|
||||
U8 *dst;
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocEntry *doc_ce=doc->cur_entry,*original_ce=doc_ce,*doc_ne;
|
||||
I64 cc=doc->cur_col,y=doc_ce->y;
|
||||
if (sc!=MIN_I64) sc=sc.u32[0];
|
||||
if (sc>=0 && sc&SCF_CTRL) {
|
||||
while (doc_ce->last!=doc && (doc_ce->last->y==y ||
|
||||
doc_ce->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP)))
|
||||
doc_ce=doc_ce->last; //TODO: sel? recurse?
|
||||
cc=doc_ce->min_col;
|
||||
} else {
|
||||
if (cc>doc_ce->min_col) {
|
||||
if (IsEditableText(doc_ce) && cc<doc_ce->max_col) {
|
||||
dst=doc_ce->tag+cc;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ce->max_col=cc;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
}
|
||||
cc--;
|
||||
if (IsEditableText(doc_ce) && cc>doc_ce->min_col) {
|
||||
dst=doc_ce->tag+cc;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ce->max_col=cc;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
cc=doc_ce->min_col;
|
||||
}
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
} else {
|
||||
cc=doc_ce->min_col;
|
||||
while (doc_ce->last!=doc &&
|
||||
(doc_ce->last->type_u8==DOCT_SOFT_NEW_LINE ||
|
||||
doc_ce->last->type_u8==DOCT_INDENT ||
|
||||
doc_ce->last->de_flags&(DOCEF_SKIP|DOCEF_FILTER_SKIP))) {
|
||||
doc_ce=doc_ce->last;
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
}
|
||||
if (doc_ce->last!=doc) {
|
||||
doc_ce=doc_ce->last;
|
||||
if (doc_ce->max_col>doc_ce->min_col) {
|
||||
cc=doc_ce->max_col-1;
|
||||
if (IsEditableText(doc_ce) && cc>doc_ce->min_col) {
|
||||
dst=doc_ce->tag+cc;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ce->max_col=cc;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
cc=doc_ce->min_col;
|
||||
}
|
||||
} else
|
||||
cc=doc_ce->max_col;
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
doc->cur_col=cc;
|
||||
doc->cur_entry=doc_ce;
|
||||
if (doc_ce!=original_ce)
|
||||
DocFormBwd(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 EdCursorRight(CDoc *doc,I64 sc=MIN_I64)
|
||||
{//Move cursor right. Might need a call to $LK,"DocRecalc",A="MN:DocRecalc"$().
|
||||
//See $LK,"EdRenumAsm",A="MN:EdRenumAsm"$ for an example.
|
||||
Bool unlock=DocLock(doc);
|
||||
U8 *dst;
|
||||
CDocEntry *doc_ce=doc->cur_entry,*original_ce=doc_ce,*doc_ne;
|
||||
I64 cc=doc->cur_col,y=doc_ce->y,old_de_flags,old_color;
|
||||
if (sc!=MIN_I64) sc=sc.u32[0];
|
||||
if (sc>=0 && sc&SCF_CTRL) {
|
||||
while (doc_ce!=doc && doc_ce->next->y==y &&
|
||||
doc_ce->next->type_u8!=DOCT_SOFT_NEW_LINE && doc_ce->next!=doc &&
|
||||
(doc_ce->next->type_u8!=DOCT_NEW_LINE || !(doc->flags & DOCF_FORM)) ||
|
||||
doc_ce->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP))
|
||||
doc_ce=doc_ce->next;
|
||||
if (doc_ce->max_col>doc_ce->min_col)
|
||||
cc=doc_ce->max_col-1;
|
||||
else
|
||||
cc=doc_ce->min_col;
|
||||
} else {
|
||||
if (cc<doc_ce->max_col) {
|
||||
if (IsEditableText(doc_ce) && cc>doc_ce->min_col) {
|
||||
dst=doc_ce->tag+cc;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ce->max_col=cc;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
cc=doc_ce->min_col;
|
||||
}
|
||||
cc++;
|
||||
old_de_flags=doc_ce->de_flags;
|
||||
old_color=doc_ce->type;
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
if (IsEditableText(doc_ce) && cc<doc_ce->max_col) {
|
||||
dst=doc_ce->tag+cc;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ne->type=DOCT_TEXT | old_color & -0x100;
|
||||
doc_ne->de_flags=old_de_flags|doldoc.dft_de_flags[DOCT_TEXT];
|
||||
doc_ce->max_col=cc;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
cc=doc_ce->min_col;
|
||||
} else if (cc>=doc_ce->max_col) {
|
||||
doc_ce=doc_ce->next;
|
||||
cc=doc_ce->min_col;
|
||||
}
|
||||
} else {
|
||||
if (doc_ce!=doc) {
|
||||
if (cc<=doc_ce->min_col && sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc_ce->next;
|
||||
while (doc_ce!=doc && doc_ce->de_flags&(DOCEF_SKIP|DOCEF_FILTER_SKIP)) {
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc_ce->next;
|
||||
}
|
||||
cc=doc_ce->min_col;
|
||||
if (doc_ce->type_u8==DOCT_SOFT_NEW_LINE) {
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc_ce->next;
|
||||
cc=doc_ce->min_col;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
doc->cur_col=cc;
|
||||
doc->cur_entry=doc_ce;
|
||||
if (doc_ce!=original_ce)
|
||||
DocFormFwd(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 EdLineUp(CDoc *doc,I64 sc=MIN_I64)
|
||||
{//Move cursor up. Might need a call to $LK,"DocRecalc",A="MN:DocRecalc"$().
|
||||
//See $LK,"EdRenumAsm",A="MN:EdRenumAsm"$ for an example.
|
||||
Bool unlock=DocLock(doc);
|
||||
U8 *dst;
|
||||
I64 y,x;
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_ne;
|
||||
|
||||
if (sc!=MIN_I64) sc=sc.u32[0];
|
||||
if (doc_ce->type_u8==DOCT_HEX_ED) {
|
||||
doc->cur_col=doc->cur_col-doc_ce->hex_ed_width*3;
|
||||
if (doc->cur_col>=0) {
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return;
|
||||
} else
|
||||
doc->cur_col=0;
|
||||
}
|
||||
x=doc->x; y=doc->y;
|
||||
if (IsEditableText(doc_ce)) {
|
||||
if (doc_ce->min_col<doc->cur_col<doc_ce->max_col-1) {
|
||||
dst=doc_ce->tag+doc->cur_col;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ne->x=doc_ce->x+doc->cur_col;
|
||||
doc_ce->max_col=doc->cur_col;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
} else if (doc->cur_col==doc_ce->min_col && doc_ce->last!=doc)
|
||||
doc_ce=doc_ce->last;
|
||||
} else if (doc_ce->last!=doc)
|
||||
doc_ce=doc_ce->last;
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc->cur_entry=doc_ce;
|
||||
DocFormBwd(doc);
|
||||
doc_ce=doc->cur_entry;
|
||||
while (doc_ce->last!=doc && (doc_ce->y>=y ||
|
||||
doc_ce->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP))) {
|
||||
doc_ce=doc_ce->last;
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
}
|
||||
y=doc_ce->y;
|
||||
doc->y=y;
|
||||
while (doc_ce!=doc && (doc_ce->y>=y && doc_ce->x>=x ||
|
||||
doc_ce->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP))) {
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc_ce->last;
|
||||
}
|
||||
|
||||
if (doc_ce==doc || doc_ce->y<y)
|
||||
doc_ce=doc_ce->next;
|
||||
else {
|
||||
if (!IsEditableText(doc_ce)) {
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
} else {
|
||||
if (doc_ce->next->x==x) {
|
||||
doc_ce=doc_ce->next;
|
||||
if (doc->flags & DOCF_FORM)
|
||||
while (doc_ce->next->x==x &&
|
||||
(!Bt(doldoc.type_flags_form,doc_ce->type_u8) &&
|
||||
!(doc_ce->de_flags&DOCEF_LINK)||
|
||||
doc_ce->de_flags&DOCEF_SKIP_IN_FORM))
|
||||
doc_ce=doc_ce->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (doc_ce->de_flags&DOCEF_TAG) {
|
||||
doc->cur_col=x-doc_ce->x;
|
||||
if (IsEditableText(doc_ce)) {
|
||||
if (doc->cur_col>doc_ce->max_col)
|
||||
doc->cur_col=doc_ce->max_col;
|
||||
} else if (doc->cur_col>=doc_ce->max_col)
|
||||
doc->cur_col=doc_ce->max_col-1;
|
||||
if (doc->cur_col<doc_ce->min_col)
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
} else {
|
||||
if (doc_ce->type_u8==DOCT_HEX_ED) {
|
||||
doc->cur_col=RoundI64((doc_ce->len-1)*3,doc_ce->hex_ed_width*3);
|
||||
if (doc->cur_col<0)
|
||||
doc->cur_col=0;
|
||||
} else
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
}
|
||||
if (IsEditableText(doc_ce) && doc_ce->x<x) {
|
||||
if (doc->cur_col<doc_ce->max_col-1) {
|
||||
dst=doc_ce->tag+doc->cur_col;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
if (sc>=0) {
|
||||
if (sc&SCF_SHIFT)
|
||||
doc_ne->type=doc_ce->type | DOCET_SEL;
|
||||
else
|
||||
doc_ne->type=doc_ce->type & ~DOCET_SEL;
|
||||
}
|
||||
doc_ne->x=doc_ce->x+doc->cur_col;
|
||||
doc_ce->max_col=doc->cur_col;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
}
|
||||
}
|
||||
doc->cur_entry=doc_ce;
|
||||
DocFormFwd(doc);
|
||||
doc->x=doc->cur_entry->x+doc->cur_col;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 EdLineDown(CDoc *doc,I64 sc=MIN_I64)
|
||||
{//Move cursor down. Might need a call to $LK,"DocRecalc",A="MN:DocRecalc"$().
|
||||
//See $LK,"EdRenumAsm",A="MN:EdRenumAsm"$ for an example.
|
||||
Bool unlock=DocLock(doc);
|
||||
U8 *dst;
|
||||
I64 y,x,old_de_flags=0,old_color;
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_ne,*doc_ce2;
|
||||
if (sc!=MIN_I64) sc=sc.u32[0];
|
||||
if (doc_ce->type_u8==DOCT_HEX_ED) {
|
||||
doc->cur_col=doc->cur_col+doc_ce->hex_ed_width*3;
|
||||
if (doc->cur_col>=doc_ce->len*3) {
|
||||
doc->cur_entry=doc_ce=doc_ce->next;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
doc->x=doc_ce->x+doc->cur_col;
|
||||
doc->y=doc_ce->y;
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return;
|
||||
}
|
||||
x=doc->x; y=doc->y;
|
||||
if (IsEditableText(doc_ce)) {
|
||||
if (doc->cur_col>doc_ce->min_col && doc->cur_col<doc_ce->max_col-1) {
|
||||
dst=doc_ce->tag+doc->cur_col;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
if (sc>=0) {
|
||||
if (sc&SCF_SHIFT)
|
||||
doc_ne->type=doc_ce->type | DOCET_SEL;
|
||||
else
|
||||
doc_ne->type=doc_ce->type & ~DOCET_SEL;
|
||||
}
|
||||
doc_ne->x=doc_ce->x+doc->cur_col;
|
||||
doc_ce->max_col=doc->cur_col;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
}
|
||||
}
|
||||
doc_ce2=doc_ce;
|
||||
while (doc_ce!=doc && (doc_ce->y<=y ||
|
||||
doc_ce->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP)))
|
||||
doc_ce=doc_ce->next;
|
||||
y=doc_ce->y;
|
||||
doc->y=y;
|
||||
while (doc_ce!=doc && (doc_ce->y<=y && doc_ce->x<=x ||
|
||||
doc_ce->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP))) {
|
||||
old_de_flags=doc_ce->de_flags;
|
||||
old_color=doc_ce->type;
|
||||
doc_ce=doc_ce->next;
|
||||
}
|
||||
if (doc_ce->last!=doc && (doc_ce->x>x && doc_ce->last->y>=y || doc_ce->y>y)) {
|
||||
doc_ce=doc_ce->last;
|
||||
doc->cur_entry=doc_ce;
|
||||
if (!((doc_ce->type_u8==DOCT_NEW_LINE ||
|
||||
doc_ce->type_u8==DOCT_SOFT_NEW_LINE ||
|
||||
doc_ce->type_u8==DOCT_INDENT) &&
|
||||
(doc_ce->last->type_u8==DOCT_NEW_LINE ||
|
||||
doc_ce->last->type_u8==DOCT_SOFT_NEW_LINE ||
|
||||
doc_ce->last->type_u8==DOCT_INDENT)))
|
||||
DocFormBwd(doc);
|
||||
doc_ce=doc->cur_entry;
|
||||
}
|
||||
while (doc_ce2!=doc && (doc_ce2!=doc_ce || IsEditableText(doc_ce))) {
|
||||
if ((doc_ce2->y<y || doc_ce2->x<x ||
|
||||
doc_ce2->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP) ||
|
||||
doc_ce2->x==x && !doc_ce2->max_col &&
|
||||
Bt(doldoc.type_flags_nontag_invisible,doc_ce2->type_u8)) && sc>=0)
|
||||
BEqu(&doc_ce2->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
if (doc_ce2==doc_ce) break;
|
||||
doc_ce2=doc_ce2->next;
|
||||
}
|
||||
if (doc_ce->de_flags&DOCEF_TAG) {
|
||||
doc->cur_col=x-doc_ce->x;
|
||||
if (IsEditableText(doc_ce)) {
|
||||
if (doc->cur_col>doc_ce->max_col)
|
||||
doc->cur_col=doc_ce->max_col;
|
||||
} else if (doc->cur_col>=doc_ce->max_col)
|
||||
doc->cur_col=doc_ce->max_col-1;
|
||||
if (doc->cur_col<doc_ce->min_col)
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
} else
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
if (IsEditableText(doc_ce)&&doc_ce->min_col<doc->cur_col<doc_ce->max_col-1) {
|
||||
dst=doc_ce->tag+doc->cur_col;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ne->type=DOCT_TEXT | old_color & -0x100;
|
||||
doc_ne->de_flags=old_de_flags|doldoc.dft_de_flags[DOCT_TEXT];
|
||||
doc_ce->max_col=doc->cur_col;
|
||||
doc_ne->x=doc_ce->x+doc->cur_col;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
}
|
||||
doc->cur_entry=doc_ce;
|
||||
DocFormFwd(doc);
|
||||
if (!(doc->flags & DOCF_FORM))
|
||||
while (doc_ce!=doc && doc_ce!=doc->cur_entry) {
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc_ce->next;
|
||||
}
|
||||
doc->x=doc->cur_entry->x+doc->cur_col;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 EdCharDel(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
|
||||
if (doc_ce==doc) {
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return;
|
||||
}
|
||||
if (doc_ce->max_col!=0 &&
|
||||
(IsEditableText(doc_ce)||doc_ce->type_u8==DOCT_DATA)) {
|
||||
if (doc_ce->type_u8==DOCT_DATA && doc_ce->de_flags & DOCEF_HAS_TERMINATOR &&
|
||||
doc->cur_col==doc_ce->max_col-1) {
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return;
|
||||
}
|
||||
if (doc->cur_col<doc_ce->max_col)
|
||||
StrCpy(doc_ce->tag+doc->cur_col,doc_ce->tag+doc->cur_col+1);
|
||||
if (doc->cur_col>=doc_ce->max_col-1) {
|
||||
doc->cur_entry=doc_ce->next;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
}
|
||||
DocRemSoftNewLines(doc,doc->cur_entry);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return;
|
||||
}
|
||||
doc->cur_entry=doc_ce->next;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
if (!(doc_ce->de_flags&DOCEF_FILTER_SKIP))
|
||||
DocEntryDel(doc,doc_ce);
|
||||
DocRemSoftNewLines(doc,doc->cur_entry);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 ChkDollarBufSize(CDoc *doc)
|
||||
{
|
||||
U8 *b;
|
||||
if (doc->dollar_buf_ptr>=doc->dollar_buf_size-2) {
|
||||
doc->dollar_buf_size<<=1;
|
||||
b=MAlloc(doc->dollar_buf_size,doc->mem_task);
|
||||
MemCpy(b,doc->dollar_buf,doc->dollar_buf_ptr);
|
||||
Free(doc->dollar_buf);
|
||||
doc->dollar_buf=b;
|
||||
}
|
||||
}
|
||||
|
||||
U0 EdCharIns(I64 ch,I64 sc,CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
U8 *st,*src,*dst;
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_ne;
|
||||
I64 i,j,m,y=doc_ce->y;
|
||||
|
||||
if (doc->flags & DOCF_IN_DOLLAR) {
|
||||
if (!Bt(chars_bmp_getkey,ch))
|
||||
goto ic_done;
|
||||
ChkDollarBufSize(doc);
|
||||
doc->dollar_buf[doc->dollar_buf_ptr++]=ch;
|
||||
if (ch=='$$') {
|
||||
if (doc->dollar_buf_ptr==2) {
|
||||
doc->flags&=~DOCF_IN_DOLLAR;
|
||||
doc->dollar_buf_ptr=0;
|
||||
goto ic_cont;
|
||||
} else {
|
||||
doc->dollar_buf[doc->dollar_buf_ptr]=0;
|
||||
doc->flags&=~DOCF_IN_DOLLAR;
|
||||
DocPrint(doc,doc->dollar_buf);
|
||||
doc->dollar_buf_ptr=0;
|
||||
goto ic_done;
|
||||
}
|
||||
} else
|
||||
goto ic_done;
|
||||
}
|
||||
if (ch=='$$' && !(doc->flags & (DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_TABS))) {
|
||||
doc->flags|=DOCF_IN_DOLLAR;
|
||||
doc->dollar_buf_ptr=0;
|
||||
doc->dollar_buf[doc->dollar_buf_ptr++]=ch;
|
||||
goto ic_done;
|
||||
}
|
||||
if (ch=='\r') goto ic_done;
|
||||
|
||||
ic_cont:
|
||||
if ((ch==CH_SPACE || ch=='\n') &&
|
||||
!(sc & (SCF_CTRL|SCF_SHIFT)) &&
|
||||
doc_ce->de_flags &
|
||||
(DOCEF_LINK|DOCEF_TREE|DOCEF_LST|DOCEF_CHECK_COLLAPSABLE|
|
||||
DOCEF_LEFT_MACRO|DOCEF_LEFT_EXP|DOCEF_LEFT_CB|DOCEF_LEFT_AUTO |
|
||||
DOCEF_RIGHT_MACRO|DOCEF_RIGHT_EXP|DOCEF_RIGHT_CB|DOCEF_RIGHT_AUTO)) {
|
||||
doc->cmd_U8=ch;
|
||||
DocEntryRun(doc,doc_ce,FALSE);
|
||||
DocLock(doc);
|
||||
goto ic_done;
|
||||
}
|
||||
if (doc_ce->type_u8==DOCT_HEX_ED) {
|
||||
if (doc_ce->de_flags&DOCEF_DEREF_DATA &&
|
||||
!(doc_ce->de_flags&DOCEF_REMALLOC_DATA))
|
||||
st=doc_ce->data;
|
||||
else
|
||||
st=&doc_ce->data;
|
||||
i=doc->cur_col;
|
||||
j=i%(doc_ce->hex_ed_width*3);
|
||||
m=i/(doc_ce->hex_ed_width*3)*doc_ce->hex_ed_width;
|
||||
if (j>=doc_ce->hex_ed_width<<1)
|
||||
st[j-doc_ce->hex_ed_width<<1+m]=ch;
|
||||
else {
|
||||
ch=ToUpper(ch)-'0';
|
||||
if (ch>9) {
|
||||
ch+='0'-'A'+10;
|
||||
if (!(10<=ch<=15))
|
||||
goto ic_done;
|
||||
}
|
||||
m=j>>1+m;
|
||||
if (j & 1)
|
||||
st[m]=st[m] & 0xF0| ch;
|
||||
else
|
||||
st[m]=st[m] & 0xF | ch<<4;
|
||||
}
|
||||
doc->cur_col++;
|
||||
goto ic_done;
|
||||
}
|
||||
if (doc->flags & DOCF_OVERSTRIKE) {
|
||||
if (Bt(chars_bmp_displayable,ch)) {
|
||||
ic_overstrike:
|
||||
if (IsEditableText(doc_ce)) {
|
||||
if (doc->cur_col<doc_ce->max_col) {
|
||||
if (doc_ce->tag[doc->cur_col]) {
|
||||
doc_ce->tag[doc->cur_col++]=ch;
|
||||
goto ic_done;
|
||||
}
|
||||
} else {
|
||||
doc_ce=doc_ce->next;
|
||||
doc->cur_entry=doc_ce;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
goto ic_overstrike;
|
||||
}
|
||||
} else if (doc_ce->type_u8==DOCT_DATA) {
|
||||
if (doc_ce->de_flags & DOCEF_HAS_TERMINATOR) {
|
||||
if (doc_ce->tag[doc->cur_col] &&
|
||||
doc->cur_col<doc_ce->min_col+doc_ce->len) {
|
||||
doc_ce->tag[doc->cur_col++]=ch;
|
||||
if ( ! doc_ce->tag[doc->cur_col]) {
|
||||
doc_ce->tag[doc->cur_col]='_';
|
||||
doc_ce->tag[doc->cur_col+1]=0;
|
||||
}
|
||||
} else if (doc_ce->de_flags & DOCEF_REMALLOC_DATA)
|
||||
goto ic_not_overstrike;
|
||||
} else if (doc_ce->tag[doc->cur_col])
|
||||
doc_ce->tag[doc->cur_col++]=ch;
|
||||
goto ic_done;
|
||||
}
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,&ch);
|
||||
doc_ne->type=DOCT_TEXT | doc->settings_head.dft_text_attr<<8;
|
||||
doc_ne->de_flags=doldoc.dft_de_flags[DOCT_TEXT];
|
||||
QueIns(doc_ne,doc_ce->last);
|
||||
} else if (ch=='\n') {
|
||||
while (doc->cur_entry->next!=doc && doc->cur_entry->y==y)
|
||||
doc->cur_entry=doc->cur_entry->next;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
} else if (ch=='\t') {
|
||||
if (doc->flags&DOCF_FORM)
|
||||
goto ic_form_tab;
|
||||
}
|
||||
goto ic_done;
|
||||
}
|
||||
ic_not_overstrike:
|
||||
if (ch=='\n') {
|
||||
if (sc&SCF_CTRL && !(sc&SCF_SHIFT)) {
|
||||
doc_ne=DocEntryNewBase(doc,
|
||||
DOCT_PAGE_BREAK|doc->settings_head.dft_text_attr<<8);
|
||||
} else {
|
||||
doc_ne=DocEntryNewBase(doc,
|
||||
DOCT_NEW_LINE|doc->settings_head.dft_text_attr<<8);
|
||||
}
|
||||
DocInsEntry(doc,doc_ne);
|
||||
} else if (ch=='\t') {
|
||||
if (doc->flags&DOCF_FORM &&
|
||||
(Bt(doldoc.type_flags_form,doc->cur_entry->type_u8) ||
|
||||
doc->cur_entry->de_flags&DOCEF_LINK) &&
|
||||
!(doc->cur_entry->de_flags&DOCEF_SKIP_IN_FORM)) {
|
||||
ic_form_tab:
|
||||
doc->cur_entry=doc->cur_entry->next;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
DocFormFwd(doc);
|
||||
goto ic_done;
|
||||
} else {
|
||||
doc_ne=DocEntryNewBase(doc,DOCT_TAB|doc->settings_head.dft_text_attr<<8);
|
||||
DocInsEntry(doc,doc_ne);
|
||||
}
|
||||
} else {
|
||||
if (Bt(chars_bmp_displayable,ch)) {
|
||||
if (doc_ce->type_u8==DOCT_DATA) {
|
||||
while (TRUE) {
|
||||
i=doc_ce->len+doc_ce->min_col;
|
||||
if (doc_ce->de_flags & DOCEF_HAS_TERMINATOR)
|
||||
i++;
|
||||
if (doc_ce->max_col<i) {
|
||||
st=doc_ce->tag;
|
||||
doc_ce->max_col++;
|
||||
for (i=doc_ce->max_col;i>doc->cur_col;i--)
|
||||
st[i]=st[i-1];
|
||||
st[doc->cur_col++]=ch;
|
||||
break;
|
||||
} else if (doc_ce->de_flags & DOCEF_REMALLOC_DATA) {
|
||||
st=MAlloc(doc_ce->max_col+8,doc->mem_task);
|
||||
MemCpy(st,doc_ce->tag,doc_ce->max_col+1);
|
||||
Free(doc_ce->tag);
|
||||
doc_ce->tag=st;
|
||||
doc_ce->len=MSize(st)-doc_ce->min_col-2; //See $LK,"DataTagWidth",A="FA:::/Adam/DolDoc/DocPlain.CPP,DataTagWidth"$
|
||||
Free(doc_ce->data);
|
||||
doc_ce->data=MAlloc(doc_ce->len+2,doc->mem_task);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
} else if (IsEditableText(doc_ce)) {
|
||||
dst=st=MAlloc(doc_ce->max_col+2,doc->mem_task);
|
||||
src=doc_ce->tag;
|
||||
i=doc->cur_col;
|
||||
while (i-->0)
|
||||
*dst++=*src++;
|
||||
*dst++=ch;
|
||||
while (*dst++=*src++);
|
||||
Free(doc_ce->tag);
|
||||
doc_ce->tag=st;
|
||||
doc_ce->max_col++;
|
||||
doc->cur_col++;
|
||||
} else {
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,&ch);
|
||||
doc_ne->type=DOCT_TEXT | doc->settings_head.dft_text_attr<<8;
|
||||
doc_ne->de_flags=doldoc.dft_de_flags[DOCT_TEXT];
|
||||
doc_ne->x=doc_ce->x+1;
|
||||
QueIns(doc_ne,doc_ce->last);
|
||||
}
|
||||
}
|
||||
}
|
||||
ic_done:
|
||||
DocRemSoftNewLines(doc,doc->cur_entry);
|
||||
if (doc->cur_entry->de_flags & DOCEF_UPDATE_DATA &&
|
||||
(doc->cur_entry->type_u8==DOCT_DATA ||
|
||||
doc->cur_entry->type_u8==DOCT_CHECK_BOX))
|
||||
DocDataScan(doc,doc->cur_entry);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 EdLineDel(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_ce2;
|
||||
I64 y;
|
||||
y=doc->y;
|
||||
while (doc_ce!=doc && doc_ce->y==y)
|
||||
doc_ce=doc_ce->next;
|
||||
doc->cur_entry=doc_ce;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
doc_ce=doc_ce->last;
|
||||
while (doc_ce!=doc && doc_ce->y==y) {
|
||||
doc_ce2=doc_ce->last;
|
||||
if (!(doc_ce->de_flags&DOCEF_FILTER_SKIP))
|
||||
DocEntryDel(doc,doc_ce);
|
||||
doc_ce=doc_ce2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,652 @@
|
||||
#help_index "DolDoc/Editor"
|
||||
|
||||
public I64 EdCurU8(CDoc *doc)
|
||||
{//Return cur U8. See $LK,"EdRenumAsm",A="MN:EdRenumAsm"$ for an example.
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
I64 res=-1;
|
||||
if (doc_ce->type_u8==DOCT_TEXT &&
|
||||
doc_ce->min_col<=doc->cur_col<doc_ce->max_col)
|
||||
res=doc_ce->tag[doc->cur_col];
|
||||
else if (doc_ce->type_u8==DOCT_TAB)
|
||||
res='\t';
|
||||
else if (doc_ce->type_u8==DOCT_NEW_LINE ||
|
||||
doc_ce->type_u8==DOCT_SOFT_NEW_LINE)
|
||||
res='\n';
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return res;
|
||||
}
|
||||
|
||||
public U0 EdCursorLeft(CDoc *doc,I64 sc=MIN_I64)
|
||||
{//Move cursor left. Might need a call to $LK,"DocRecalc",A="MN:DocRecalc"$().
|
||||
//See $LK,"EdRenumAsm",A="MN:EdRenumAsm"$ for an example.
|
||||
U8 *dst;
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocEntry *doc_ce=doc->cur_entry,*original_ce=doc_ce,*doc_ne;
|
||||
I64 cc=doc->cur_col,y=doc_ce->y;
|
||||
if (sc!=MIN_I64) sc=sc.u32[0];
|
||||
if (sc>=0 && sc&SCF_CTRL) {
|
||||
while (doc_ce->last!=doc && (doc_ce->last->y==y ||
|
||||
doc_ce->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP)))
|
||||
doc_ce=doc_ce->last; //TODO: sel? recurse?
|
||||
cc=doc_ce->min_col;
|
||||
} else {
|
||||
if (cc>doc_ce->min_col) {
|
||||
if (IsEditableText(doc_ce) && cc<doc_ce->max_col) {
|
||||
dst=doc_ce->tag+cc;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ce->max_col=cc;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
}
|
||||
cc--;
|
||||
if (IsEditableText(doc_ce) && cc>doc_ce->min_col) {
|
||||
dst=doc_ce->tag+cc;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ce->max_col=cc;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
cc=doc_ce->min_col;
|
||||
}
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
} else {
|
||||
cc=doc_ce->min_col;
|
||||
while (doc_ce->last!=doc &&
|
||||
(doc_ce->last->type_u8==DOCT_SOFT_NEW_LINE ||
|
||||
doc_ce->last->type_u8==DOCT_INDENT ||
|
||||
doc_ce->last->de_flags&(DOCEF_SKIP|DOCEF_FILTER_SKIP))) {
|
||||
doc_ce=doc_ce->last;
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
}
|
||||
if (doc_ce->last!=doc) {
|
||||
doc_ce=doc_ce->last;
|
||||
if (doc_ce->max_col>doc_ce->min_col) {
|
||||
cc=doc_ce->max_col-1;
|
||||
if (IsEditableText(doc_ce) && cc>doc_ce->min_col) {
|
||||
dst=doc_ce->tag+cc;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ce->max_col=cc;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
cc=doc_ce->min_col;
|
||||
}
|
||||
} else
|
||||
cc=doc_ce->max_col;
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
doc->cur_col=cc;
|
||||
doc->cur_entry=doc_ce;
|
||||
if (doc_ce!=original_ce)
|
||||
DocFormBwd(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 EdCursorRight(CDoc *doc,I64 sc=MIN_I64)
|
||||
{//Move cursor right. Might need a call to $LK,"DocRecalc",A="MN:DocRecalc"$().
|
||||
//See $LK,"EdRenumAsm",A="MN:EdRenumAsm"$ for an example.
|
||||
Bool unlock=DocLock(doc);
|
||||
U8 *dst;
|
||||
CDocEntry *doc_ce=doc->cur_entry,*original_ce=doc_ce,*doc_ne;
|
||||
I64 cc=doc->cur_col,y=doc_ce->y,old_de_flags,old_color;
|
||||
if (sc!=MIN_I64) sc=sc.u32[0];
|
||||
if (sc>=0 && sc&SCF_CTRL) {
|
||||
while (doc_ce!=doc && doc_ce->next->y==y &&
|
||||
doc_ce->next->type_u8!=DOCT_SOFT_NEW_LINE && doc_ce->next!=doc &&
|
||||
(doc_ce->next->type_u8!=DOCT_NEW_LINE || !(doc->flags & DOCF_FORM)) ||
|
||||
doc_ce->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP))
|
||||
doc_ce=doc_ce->next;
|
||||
if (doc_ce->max_col>doc_ce->min_col)
|
||||
cc=doc_ce->max_col-1;
|
||||
else
|
||||
cc=doc_ce->min_col;
|
||||
} else {
|
||||
if (cc<doc_ce->max_col) {
|
||||
if (IsEditableText(doc_ce) && cc>doc_ce->min_col) {
|
||||
dst=doc_ce->tag+cc;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ce->max_col=cc;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
cc=doc_ce->min_col;
|
||||
}
|
||||
cc++;
|
||||
old_de_flags=doc_ce->de_flags;
|
||||
old_color=doc_ce->type;
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
if (IsEditableText(doc_ce) && cc<doc_ce->max_col) {
|
||||
dst=doc_ce->tag+cc;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ne->type=DOCT_TEXT | old_color & -0x100;
|
||||
doc_ne->de_flags=old_de_flags|doldoc.dft_de_flags[DOCT_TEXT];
|
||||
doc_ce->max_col=cc;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
cc=doc_ce->min_col;
|
||||
} else if (cc>=doc_ce->max_col) {
|
||||
doc_ce=doc_ce->next;
|
||||
cc=doc_ce->min_col;
|
||||
}
|
||||
} else {
|
||||
if (doc_ce!=doc) {
|
||||
if (cc<=doc_ce->min_col && sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc_ce->next;
|
||||
while (doc_ce!=doc && doc_ce->de_flags&(DOCEF_SKIP|DOCEF_FILTER_SKIP)) {
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc_ce->next;
|
||||
}
|
||||
cc=doc_ce->min_col;
|
||||
if (doc_ce->type_u8==DOCT_SOFT_NEW_LINE) {
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc_ce->next;
|
||||
cc=doc_ce->min_col;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
doc->cur_col=cc;
|
||||
doc->cur_entry=doc_ce;
|
||||
if (doc_ce!=original_ce)
|
||||
DocFormFwd(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 EdLineUp(CDoc *doc,I64 sc=MIN_I64)
|
||||
{//Move cursor up. Might need a call to $LK,"DocRecalc",A="MN:DocRecalc"$().
|
||||
//See $LK,"EdRenumAsm",A="MN:EdRenumAsm"$ for an example.
|
||||
Bool unlock=DocLock(doc);
|
||||
U8 *dst;
|
||||
I64 y,x;
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_ne;
|
||||
|
||||
if (sc!=MIN_I64) sc=sc.u32[0];
|
||||
if (doc_ce->type_u8==DOCT_HEX_ED) {
|
||||
doc->cur_col=doc->cur_col-doc_ce->hex_ed_width*3;
|
||||
if (doc->cur_col>=0) {
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return;
|
||||
} else
|
||||
doc->cur_col=0;
|
||||
}
|
||||
x=doc->x; y=doc->y;
|
||||
if (IsEditableText(doc_ce)) {
|
||||
if (doc_ce->min_col<doc->cur_col<doc_ce->max_col-1) {
|
||||
dst=doc_ce->tag+doc->cur_col;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ne->x=doc_ce->x+doc->cur_col;
|
||||
doc_ce->max_col=doc->cur_col;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
} else if (doc->cur_col==doc_ce->min_col && doc_ce->last!=doc)
|
||||
doc_ce=doc_ce->last;
|
||||
} else if (doc_ce->last!=doc)
|
||||
doc_ce=doc_ce->last;
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc->cur_entry=doc_ce;
|
||||
DocFormBwd(doc);
|
||||
doc_ce=doc->cur_entry;
|
||||
while (doc_ce->last!=doc && (doc_ce->y>=y ||
|
||||
doc_ce->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP))) {
|
||||
doc_ce=doc_ce->last;
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
}
|
||||
y=doc_ce->y;
|
||||
doc->y=y;
|
||||
while (doc_ce!=doc && (doc_ce->y>=y && doc_ce->x>=x ||
|
||||
doc_ce->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP))) {
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc_ce->last;
|
||||
}
|
||||
|
||||
if (doc_ce==doc || doc_ce->y<y)
|
||||
doc_ce=doc_ce->next;
|
||||
else {
|
||||
if (!IsEditableText(doc_ce)) {
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
} else {
|
||||
if (doc_ce->next->x==x) {
|
||||
doc_ce=doc_ce->next;
|
||||
if (doc->flags & DOCF_FORM)
|
||||
while (doc_ce->next->x==x &&
|
||||
(!Bt(doldoc.type_flags_form,doc_ce->type_u8) &&
|
||||
!(doc_ce->de_flags&DOCEF_LINK)||
|
||||
doc_ce->de_flags&DOCEF_SKIP_IN_FORM))
|
||||
doc_ce=doc_ce->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (doc_ce->de_flags&DOCEF_TAG) {
|
||||
doc->cur_col=x-doc_ce->x;
|
||||
if (IsEditableText(doc_ce)) {
|
||||
if (doc->cur_col>doc_ce->max_col)
|
||||
doc->cur_col=doc_ce->max_col;
|
||||
} else if (doc->cur_col>=doc_ce->max_col)
|
||||
doc->cur_col=doc_ce->max_col-1;
|
||||
if (doc->cur_col<doc_ce->min_col)
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
} else {
|
||||
if (doc_ce->type_u8==DOCT_HEX_ED) {
|
||||
doc->cur_col=RoundI64((doc_ce->len-1)*3,doc_ce->hex_ed_width*3);
|
||||
if (doc->cur_col<0)
|
||||
doc->cur_col=0;
|
||||
} else
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
}
|
||||
if (IsEditableText(doc_ce) && doc_ce->x<x) {
|
||||
if (doc->cur_col<doc_ce->max_col-1) {
|
||||
dst=doc_ce->tag+doc->cur_col;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
if (sc>=0) {
|
||||
if (sc&SCF_SHIFT)
|
||||
doc_ne->type=doc_ce->type | DOCET_SEL;
|
||||
else
|
||||
doc_ne->type=doc_ce->type & ~DOCET_SEL;
|
||||
}
|
||||
doc_ne->x=doc_ce->x+doc->cur_col;
|
||||
doc_ce->max_col=doc->cur_col;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
}
|
||||
}
|
||||
doc->cur_entry=doc_ce;
|
||||
DocFormFwd(doc);
|
||||
doc->x=doc->cur_entry->x+doc->cur_col;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 EdLineDown(CDoc *doc,I64 sc=MIN_I64)
|
||||
{//Move cursor down. Might need a call to $LK,"DocRecalc",A="MN:DocRecalc"$().
|
||||
//See $LK,"EdRenumAsm",A="MN:EdRenumAsm"$ for an example.
|
||||
Bool unlock=DocLock(doc);
|
||||
U8 *dst;
|
||||
I64 y,x,old_de_flags=0,old_color;
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_ne,*doc_ce2;
|
||||
if (sc!=MIN_I64) sc=sc.u32[0];
|
||||
if (doc_ce->type_u8==DOCT_HEX_ED) {
|
||||
doc->cur_col=doc->cur_col+doc_ce->hex_ed_width*3;
|
||||
if (doc->cur_col>=doc_ce->len*3) {
|
||||
doc->cur_entry=doc_ce=doc_ce->next;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
doc->x=doc_ce->x+doc->cur_col;
|
||||
doc->y=doc_ce->y;
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return;
|
||||
}
|
||||
x=doc->x; y=doc->y;
|
||||
if (IsEditableText(doc_ce)) {
|
||||
if (doc->cur_col>doc_ce->min_col && doc->cur_col<doc_ce->max_col-1) {
|
||||
dst=doc_ce->tag+doc->cur_col;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
if (sc>=0) {
|
||||
if (sc&SCF_SHIFT)
|
||||
doc_ne->type=doc_ce->type | DOCET_SEL;
|
||||
else
|
||||
doc_ne->type=doc_ce->type & ~DOCET_SEL;
|
||||
}
|
||||
doc_ne->x=doc_ce->x+doc->cur_col;
|
||||
doc_ce->max_col=doc->cur_col;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
}
|
||||
}
|
||||
doc_ce2=doc_ce;
|
||||
while (doc_ce!=doc && (doc_ce->y<=y ||
|
||||
doc_ce->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP)))
|
||||
doc_ce=doc_ce->next;
|
||||
y=doc_ce->y;
|
||||
doc->y=y;
|
||||
while (doc_ce!=doc && (doc_ce->y<=y && doc_ce->x<=x ||
|
||||
doc_ce->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP))) {
|
||||
old_de_flags=doc_ce->de_flags;
|
||||
old_color=doc_ce->type;
|
||||
doc_ce=doc_ce->next;
|
||||
}
|
||||
if (doc_ce->last!=doc && (doc_ce->x>x && doc_ce->last->y>=y || doc_ce->y>y)) {
|
||||
doc_ce=doc_ce->last;
|
||||
doc->cur_entry=doc_ce;
|
||||
if (!((doc_ce->type_u8==DOCT_NEW_LINE ||
|
||||
doc_ce->type_u8==DOCT_SOFT_NEW_LINE ||
|
||||
doc_ce->type_u8==DOCT_INDENT) &&
|
||||
(doc_ce->last->type_u8==DOCT_NEW_LINE ||
|
||||
doc_ce->last->type_u8==DOCT_SOFT_NEW_LINE ||
|
||||
doc_ce->last->type_u8==DOCT_INDENT)))
|
||||
DocFormBwd(doc);
|
||||
doc_ce=doc->cur_entry;
|
||||
}
|
||||
while (doc_ce2!=doc && (doc_ce2!=doc_ce || IsEditableText(doc_ce))) {
|
||||
if ((doc_ce2->y<y || doc_ce2->x<x ||
|
||||
doc_ce2->de_flags & (DOCEF_SKIP|DOCEF_FILTER_SKIP) ||
|
||||
doc_ce2->x==x && !doc_ce2->max_col &&
|
||||
Bt(doldoc.type_flags_nontag_invisible,doc_ce2->type_u8)) && sc>=0)
|
||||
BEqu(&doc_ce2->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
if (doc_ce2==doc_ce) break;
|
||||
doc_ce2=doc_ce2->next;
|
||||
}
|
||||
if (doc_ce->de_flags&DOCEF_TAG) {
|
||||
doc->cur_col=x-doc_ce->x;
|
||||
if (IsEditableText(doc_ce)) {
|
||||
if (doc->cur_col>doc_ce->max_col)
|
||||
doc->cur_col=doc_ce->max_col;
|
||||
} else if (doc->cur_col>=doc_ce->max_col)
|
||||
doc->cur_col=doc_ce->max_col-1;
|
||||
if (doc->cur_col<doc_ce->min_col)
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
} else
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
if (IsEditableText(doc_ce)&&doc_ce->min_col<doc->cur_col<doc_ce->max_col-1) {
|
||||
dst=doc_ce->tag+doc->cur_col;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ne->type=DOCT_TEXT | old_color & -0x100;
|
||||
doc_ne->de_flags=old_de_flags|doldoc.dft_de_flags[DOCT_TEXT];
|
||||
doc_ce->max_col=doc->cur_col;
|
||||
doc_ne->x=doc_ce->x+doc->cur_col;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc_ce=doc_ne;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
}
|
||||
doc->cur_entry=doc_ce;
|
||||
DocFormFwd(doc);
|
||||
if (!(doc->flags & DOCF_FORM))
|
||||
while (doc_ce!=doc && doc_ce!=doc->cur_entry) {
|
||||
if (sc>=0)
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc_ce->next;
|
||||
}
|
||||
doc->x=doc->cur_entry->x+doc->cur_col;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 EdCharDel(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocEntry *doc_ce=doc->cur_entry;
|
||||
|
||||
if (doc_ce==doc) {
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return;
|
||||
}
|
||||
if (doc_ce->max_col!=0 &&
|
||||
(IsEditableText(doc_ce)||doc_ce->type_u8==DOCT_DATA)) {
|
||||
if (doc_ce->type_u8==DOCT_DATA && doc_ce->de_flags & DOCEF_HAS_TERMINATOR &&
|
||||
doc->cur_col==doc_ce->max_col-1) {
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return;
|
||||
}
|
||||
if (doc->cur_col<doc_ce->max_col)
|
||||
StrCpy(doc_ce->tag+doc->cur_col,doc_ce->tag+doc->cur_col+1);
|
||||
if (doc->cur_col>=doc_ce->max_col-1) {
|
||||
doc->cur_entry=doc_ce->next;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
}
|
||||
DocRemSoftNewLines(doc,doc->cur_entry);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return;
|
||||
}
|
||||
doc->cur_entry=doc_ce->next;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
if (!(doc_ce->de_flags&DOCEF_FILTER_SKIP))
|
||||
DocEntryDel(doc,doc_ce);
|
||||
DocRemSoftNewLines(doc,doc->cur_entry);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 ChkDollarBufSize(CDoc *doc)
|
||||
{
|
||||
U8 *b;
|
||||
if (doc->dollar_buf_ptr>=doc->dollar_buf_size-2) {
|
||||
doc->dollar_buf_size<<=1;
|
||||
b=MAlloc(doc->dollar_buf_size,doc->mem_task);
|
||||
MemCpy(b,doc->dollar_buf,doc->dollar_buf_ptr);
|
||||
Free(doc->dollar_buf);
|
||||
doc->dollar_buf=b;
|
||||
}
|
||||
}
|
||||
|
||||
U0 EdCharIns(I64 ch,I64 sc,CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
U8 *st,*src,*dst;
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_ne;
|
||||
I64 i,j,m,y=doc_ce->y;
|
||||
|
||||
if (doc->flags & DOCF_IN_DOLLAR) {
|
||||
if (!Bt(chars_bmp_getkey,ch))
|
||||
goto ic_done;
|
||||
ChkDollarBufSize(doc);
|
||||
doc->dollar_buf[doc->dollar_buf_ptr++]=ch;
|
||||
if (ch=='$$') {
|
||||
if (doc->dollar_buf_ptr==2) {
|
||||
doc->flags&=~DOCF_IN_DOLLAR;
|
||||
doc->dollar_buf_ptr=0;
|
||||
goto ic_cont;
|
||||
} else {
|
||||
doc->dollar_buf[doc->dollar_buf_ptr]=0;
|
||||
doc->flags&=~DOCF_IN_DOLLAR;
|
||||
DocPrint(doc,doc->dollar_buf);
|
||||
doc->dollar_buf_ptr=0;
|
||||
goto ic_done;
|
||||
}
|
||||
} else
|
||||
goto ic_done;
|
||||
}
|
||||
if (ch=='$$' && !(doc->flags & (DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_TABS))) {
|
||||
doc->flags|=DOCF_IN_DOLLAR;
|
||||
doc->dollar_buf_ptr=0;
|
||||
doc->dollar_buf[doc->dollar_buf_ptr++]=ch;
|
||||
goto ic_done;
|
||||
}
|
||||
if (ch=='\r') goto ic_done;
|
||||
|
||||
ic_cont:
|
||||
if ((ch==CH_SPACE || ch=='\n') &&
|
||||
!(sc & (SCF_CTRL|SCF_SHIFT)) &&
|
||||
doc_ce->de_flags &
|
||||
(DOCEF_LINK|DOCEF_TREE|DOCEF_LST|DOCEF_CHECK_COLLAPSABLE|
|
||||
DOCEF_LEFT_MACRO|DOCEF_LEFT_EXP|DOCEF_LEFT_CB|DOCEF_LEFT_AUTO |
|
||||
DOCEF_RIGHT_MACRO|DOCEF_RIGHT_EXP|DOCEF_RIGHT_CB|DOCEF_RIGHT_AUTO)) {
|
||||
doc->cmd_U8=ch;
|
||||
DocEntryRun(doc,doc_ce,FALSE);
|
||||
DocLock(doc);
|
||||
goto ic_done;
|
||||
}
|
||||
if (doc_ce->type_u8==DOCT_HEX_ED) {
|
||||
if (doc_ce->de_flags&DOCEF_DEREF_DATA &&
|
||||
!(doc_ce->de_flags&DOCEF_REMALLOC_DATA))
|
||||
st=doc_ce->data;
|
||||
else
|
||||
st=&doc_ce->data;
|
||||
i=doc->cur_col;
|
||||
j=i%(doc_ce->hex_ed_width*3);
|
||||
m=i/(doc_ce->hex_ed_width*3)*doc_ce->hex_ed_width;
|
||||
if (j>=doc_ce->hex_ed_width<<1)
|
||||
st[j-doc_ce->hex_ed_width<<1+m]=ch;
|
||||
else {
|
||||
ch=ToUpper(ch)-'0';
|
||||
if (ch>9) {
|
||||
ch+='0'-'A'+10;
|
||||
if (!(10<=ch<=15))
|
||||
goto ic_done;
|
||||
}
|
||||
m=j>>1+m;
|
||||
if (j & 1)
|
||||
st[m]=st[m] & 0xF0| ch;
|
||||
else
|
||||
st[m]=st[m] & 0xF | ch<<4;
|
||||
}
|
||||
doc->cur_col++;
|
||||
goto ic_done;
|
||||
}
|
||||
if (doc->flags & DOCF_OVERSTRIKE) {
|
||||
if (Bt(chars_bmp_displayable,ch)) {
|
||||
ic_overstrike:
|
||||
if (IsEditableText(doc_ce)) {
|
||||
if (doc->cur_col<doc_ce->max_col) {
|
||||
if (doc_ce->tag[doc->cur_col]) {
|
||||
doc_ce->tag[doc->cur_col++]=ch;
|
||||
goto ic_done;
|
||||
}
|
||||
} else {
|
||||
doc_ce=doc_ce->next;
|
||||
doc->cur_entry=doc_ce;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
goto ic_overstrike;
|
||||
}
|
||||
} else if (doc_ce->type_u8==DOCT_DATA) {
|
||||
if (doc_ce->de_flags & DOCEF_HAS_TERMINATOR) {
|
||||
if (doc_ce->tag[doc->cur_col] &&
|
||||
doc->cur_col<doc_ce->min_col+doc_ce->len) {
|
||||
doc_ce->tag[doc->cur_col++]=ch;
|
||||
if ( ! doc_ce->tag[doc->cur_col]) {
|
||||
doc_ce->tag[doc->cur_col]='_';
|
||||
doc_ce->tag[doc->cur_col+1]=0;
|
||||
}
|
||||
} else if (doc_ce->de_flags & DOCEF_REMALLOC_DATA)
|
||||
goto ic_not_overstrike;
|
||||
} else if (doc_ce->tag[doc->cur_col])
|
||||
doc_ce->tag[doc->cur_col++]=ch;
|
||||
goto ic_done;
|
||||
}
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,&ch);
|
||||
doc_ne->type=DOCT_TEXT | doc->settings_head.dft_text_attr<<8;
|
||||
doc_ne->de_flags=doldoc.dft_de_flags[DOCT_TEXT];
|
||||
QueIns(doc_ne,doc_ce->last);
|
||||
} else if (ch=='\n') {
|
||||
while (doc->cur_entry->next!=doc && doc->cur_entry->y==y)
|
||||
doc->cur_entry=doc->cur_entry->next;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
} else if (ch=='\t') {
|
||||
if (doc->flags&DOCF_FORM)
|
||||
goto ic_form_tab;
|
||||
}
|
||||
goto ic_done;
|
||||
}
|
||||
ic_not_overstrike:
|
||||
if (ch=='\n') {
|
||||
if (sc&SCF_CTRL && !(sc&SCF_SHIFT)) {
|
||||
doc_ne=DocEntryNewBase(doc,
|
||||
DOCT_PAGE_BREAK|doc->settings_head.dft_text_attr<<8);
|
||||
} else {
|
||||
doc_ne=DocEntryNewBase(doc,
|
||||
DOCT_NEW_LINE|doc->settings_head.dft_text_attr<<8);
|
||||
}
|
||||
DocInsEntry(doc,doc_ne);
|
||||
} else if (ch=='\t') {
|
||||
if (doc->flags&DOCF_FORM &&
|
||||
(Bt(doldoc.type_flags_form,doc->cur_entry->type_u8) ||
|
||||
doc->cur_entry->de_flags&DOCEF_LINK) &&
|
||||
!(doc->cur_entry->de_flags&DOCEF_SKIP_IN_FORM)) {
|
||||
ic_form_tab:
|
||||
doc->cur_entry=doc->cur_entry->next;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
DocFormFwd(doc);
|
||||
goto ic_done;
|
||||
} else {
|
||||
doc_ne=DocEntryNewBase(doc,DOCT_TAB|doc->settings_head.dft_text_attr<<8);
|
||||
DocInsEntry(doc,doc_ne);
|
||||
}
|
||||
} else {
|
||||
if (Bt(chars_bmp_displayable,ch)) {
|
||||
if (doc_ce->type_u8==DOCT_DATA) {
|
||||
while (TRUE) {
|
||||
i=doc_ce->len+doc_ce->min_col;
|
||||
if (doc_ce->de_flags & DOCEF_HAS_TERMINATOR)
|
||||
i++;
|
||||
if (doc_ce->max_col<i) {
|
||||
st=doc_ce->tag;
|
||||
doc_ce->max_col++;
|
||||
for (i=doc_ce->max_col;i>doc->cur_col;i--)
|
||||
st[i]=st[i-1];
|
||||
st[doc->cur_col++]=ch;
|
||||
break;
|
||||
} else if (doc_ce->de_flags & DOCEF_REMALLOC_DATA) {
|
||||
st=MAlloc(doc_ce->max_col+8,doc->mem_task);
|
||||
MemCpy(st,doc_ce->tag,doc_ce->max_col+1);
|
||||
Free(doc_ce->tag);
|
||||
doc_ce->tag=st;
|
||||
doc_ce->len=MSize(st)-doc_ce->min_col-2; //See $LK,"DataTagWidth",A="FA:::/Adam/DolDoc/DocPlain.HC,DataTagWidth"$
|
||||
Free(doc_ce->data);
|
||||
doc_ce->data=MAlloc(doc_ce->len+2,doc->mem_task);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
} else if (IsEditableText(doc_ce)) {
|
||||
dst=st=MAlloc(doc_ce->max_col+2,doc->mem_task);
|
||||
src=doc_ce->tag;
|
||||
i=doc->cur_col;
|
||||
while (i-->0)
|
||||
*dst++=*src++;
|
||||
*dst++=ch;
|
||||
while (*dst++=*src++);
|
||||
Free(doc_ce->tag);
|
||||
doc_ce->tag=st;
|
||||
doc_ce->max_col++;
|
||||
doc->cur_col++;
|
||||
} else {
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,&ch);
|
||||
doc_ne->type=DOCT_TEXT | doc->settings_head.dft_text_attr<<8;
|
||||
doc_ne->de_flags=doldoc.dft_de_flags[DOCT_TEXT];
|
||||
doc_ne->x=doc_ce->x+1;
|
||||
QueIns(doc_ne,doc_ce->last);
|
||||
}
|
||||
}
|
||||
}
|
||||
ic_done:
|
||||
DocRemSoftNewLines(doc,doc->cur_entry);
|
||||
if (doc->cur_entry->de_flags & DOCEF_UPDATE_DATA &&
|
||||
(doc->cur_entry->type_u8==DOCT_DATA ||
|
||||
doc->cur_entry->type_u8==DOCT_CHECK_BOX))
|
||||
DocDataScan(doc,doc->cur_entry);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 EdLineDel(CDoc *doc)
|
||||
{
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_ce2;
|
||||
I64 y;
|
||||
y=doc->y;
|
||||
while (doc_ce!=doc && doc_ce->y==y)
|
||||
doc_ce=doc_ce->next;
|
||||
doc->cur_entry=doc_ce;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
doc_ce=doc_ce->last;
|
||||
while (doc_ce!=doc && doc_ce->y==y) {
|
||||
doc_ce2=doc_ce->last;
|
||||
if (!(doc_ce->de_flags&DOCEF_FILTER_SKIP))
|
||||
DocEntryDel(doc,doc_ce);
|
||||
doc_ce=doc_ce2;
|
||||
}
|
||||
}
|
||||
@@ -1,658 +0,0 @@
|
||||
#help_index "DolDoc/Misc"
|
||||
|
||||
U0 EdReplaceTroubleOne(CDoc *doc,U8 *st_original,U8 *st_safe,I64 num,
|
||||
Bool to_safe,Bool sel)
|
||||
{
|
||||
U8 buf[STR_LEN];
|
||||
StrPrint(buf,st_safe,num);
|
||||
if (to_safe)
|
||||
EdReplace(doc,st_original,buf,sel);
|
||||
else
|
||||
EdReplace(doc,buf,st_original,sel);
|
||||
}
|
||||
|
||||
U0 EdReplaceTroubleAll(CDoc *doc,Bool to_safe,Bool sel)
|
||||
{
|
||||
I64 i=0;
|
||||
EdReplaceTroubleOne(doc,"#assert" ,"//<@%d@>" ,i++,to_safe,sel);
|
||||
EdReplaceTroubleOne(doc,"#define" ,"//<@%d@>" ,i++,to_safe,sel);
|
||||
EdReplaceTroubleOne(doc,"#include","//<@%d@>" ,i++,to_safe,sel);
|
||||
//#if will match #if,#ifdef,#ifndef,#ifaot and #ifjit
|
||||
EdReplaceTroubleOne(doc,"#if" ,"//<@%d@>" ,i++,to_safe,sel);
|
||||
EdReplaceTroubleOne(doc,"#endif" ,"//<@%d@>" ,i++,to_safe,sel);
|
||||
//Convert #exe to union because we want that indent pattern.
|
||||
EdReplaceTroubleOne(doc,"#exe" ,"union @%d@",i++,to_safe,sel);
|
||||
EdReplaceTroubleOne(doc,"'{'" ,"'<@%d@>'" ,i++,to_safe,sel);
|
||||
EdReplaceTroubleOne(doc,"'}'" ,"'<@%d@>'" ,i++,to_safe,sel);
|
||||
}
|
||||
|
||||
#define C_INDENT_SPACES 2
|
||||
#define ASM_RENUM_SPACING 5
|
||||
|
||||
#define EF_REINDENT 0
|
||||
#define EF_CMP_CHK 1
|
||||
#define EF_RENUM_ASM 2
|
||||
#define EF_CTRL_SLIDER 3
|
||||
#define EF_CH_SC 4
|
||||
|
||||
I64 PopUpEdFmt()
|
||||
{
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
DocPrint(doc,"$$LTBLUE$$$$MU,\"Compile Check\",LE=EF_CMP_CHK$$\n"
|
||||
"$$MU,\"Reindent CPP.Z Fun (Beware braces in strings.)\","
|
||||
"LE=EF_REINDENT$$\n"
|
||||
"$$MU,\"Renum Asm Local @@ Labels for Fun\",LE=EF_RENUM_ASM$$\n"
|
||||
"$$MU,\"Insert Template Code: Ctrl Slider\",LE=EF_CTRL_SLIDER$$\n"
|
||||
"$$MU,\"Insert ASCII/Scan Code Hex Codes for key pressed\","
|
||||
"LE=EF_CH_SC$$\n\n"
|
||||
"$$MU,\"CANCEL\",LE=DOCM_CANCEL$$\n\n"
|
||||
"$$GREEN$$<ALT-BACKSPACE>$$FG$$ to undo if not happy\n"
|
||||
"with the ress.\n");
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
class CRILex
|
||||
{
|
||||
CCmpCtrl *cc1,*cc2;
|
||||
CQueVectU8 *indent;
|
||||
I64 depth,exp_depth,one_shot;
|
||||
Bool was_new_line,is_not_cont;
|
||||
};
|
||||
|
||||
I64 EdRILex(CRILex *rx)
|
||||
{
|
||||
rx->is_not_cont=FALSE;
|
||||
I64 i;
|
||||
CLexFile *tempf;
|
||||
do {
|
||||
Lex(rx->cc1);
|
||||
Lex(rx->cc2);
|
||||
i=PrsKeyWord(rx->cc2);
|
||||
if (rx->cc1->token=='\n' && rx->cc2->token==';' || rx->cc2->token=='{' ||
|
||||
rx->cc2->token=='}' || rx->cc2->token==':' || rx->cc2->token==')' &&
|
||||
!rx->exp_depth || i==KW_ELSE || i==KW_CATCH || i==KW_DO)
|
||||
rx->is_not_cont=TRUE;
|
||||
if (rx->was_new_line && (rx->cc1->token!=':' || i==KW_CASE ||
|
||||
i==KW_DFT || i==KW_START || i==KW_END)) {
|
||||
tempf=rx->cc2->lex_include_stk;
|
||||
while (tempf->next)
|
||||
tempf=tempf->next;
|
||||
QueVectU8Put(rx->indent,tempf->cur_entry->y,rx->depth+rx->one_shot);
|
||||
rx->one_shot=0;
|
||||
}
|
||||
if (rx->cc2->token=='\n')
|
||||
rx->was_new_line=TRUE;
|
||||
else
|
||||
rx->was_new_line=FALSE;
|
||||
} while (rx->cc1->token=='\n');
|
||||
return rx->cc1->token;
|
||||
}
|
||||
|
||||
U0 EdRIExp(CRILex *rx)
|
||||
{
|
||||
if (rx->cc1->token=='(') {
|
||||
if (!rx->exp_depth++)
|
||||
rx->depth+=3;
|
||||
EdRILex(rx);
|
||||
while (rx->cc1->token && rx->cc1->token!=')')
|
||||
EdRIExp(rx);
|
||||
if (!--rx->exp_depth) {
|
||||
rx->depth-=3;
|
||||
if (rx->depth<0) rx->depth=0;
|
||||
}
|
||||
} else if (rx->cc1->token=='[') {
|
||||
if (!rx->exp_depth++)
|
||||
rx->depth+=3;
|
||||
EdRILex(rx);
|
||||
while (rx->cc1->token && rx->cc1->token!=']')
|
||||
EdRIExp(rx);
|
||||
if (!--rx->exp_depth) {
|
||||
rx->depth-=3;
|
||||
if (rx->depth<0) rx->depth=0;
|
||||
}
|
||||
}
|
||||
EdRILex(rx);
|
||||
}
|
||||
|
||||
U0 EdRIStmt(CRILex *rx,Bool indent)
|
||||
{
|
||||
I64 i;
|
||||
Bool cont;
|
||||
if (rx->cc1->token=='{') {
|
||||
rx->depth++;
|
||||
EdRILex(rx);
|
||||
while (rx->cc1->token && rx->cc1->token!='}')
|
||||
EdRIStmt(rx,FALSE);
|
||||
if (--rx->depth<0) rx->depth=0;
|
||||
EdRILex(rx);
|
||||
} else {
|
||||
if (indent) rx->depth++;
|
||||
do {
|
||||
cont=FALSE;
|
||||
switch (PrsKeyWord(rx->cc1)) {
|
||||
case KW_IF:
|
||||
EdRILex(rx);
|
||||
EdRIExp(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
if (PrsKeyWord(rx->cc1)==KW_ELSE) {
|
||||
EdRILex(rx);
|
||||
if (PrsKeyWord(rx->cc1)==KW_IF && rx->cc2->token!='\n')
|
||||
EdRIStmt(rx,FALSE);
|
||||
else
|
||||
EdRIStmt(rx,TRUE);
|
||||
}
|
||||
break;
|
||||
case KW_TRY:
|
||||
EdRILex(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
if (PrsKeyWord(rx->cc1)==KW_CATCH) {
|
||||
EdRILex(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
}
|
||||
break;
|
||||
case KW_LOCK:
|
||||
EdRILex(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
break;
|
||||
case KW_FOR:
|
||||
case KW_WHILE:
|
||||
EdRILex(rx);
|
||||
EdRIExp(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
break;
|
||||
case KW_ASM:
|
||||
case KW_CLASS:
|
||||
case KW_UNION:
|
||||
if (EdRILex(rx)==TK_IDENT)
|
||||
EdRILex(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
break;
|
||||
case KW_DO:
|
||||
EdRILex(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
if (PrsKeyWord(rx->cc1)==KW_WHILE) {
|
||||
EdRILex(rx);
|
||||
EdRIExp(rx);
|
||||
}
|
||||
if (rx->cc1->token==';')
|
||||
EdRILex(rx);
|
||||
break;
|
||||
case KW_SWITCH:
|
||||
EdRILex(rx);
|
||||
EdRIExp(rx);
|
||||
if (rx->cc1->token=='{') {
|
||||
rx->depth++;
|
||||
EdRILex(rx);
|
||||
i=0;
|
||||
while (rx->cc1->token && rx->cc1->token!='}') {
|
||||
switch (PrsKeyWord(rx->cc1)) {
|
||||
case KW_START:
|
||||
rx->depth+=i; i=0;
|
||||
while (EdRILex(rx) && rx->cc1->token!=':');
|
||||
EdRILex(rx);
|
||||
i++;
|
||||
break;
|
||||
case KW_END:
|
||||
rx->depth+=i; i=0;
|
||||
if (--rx->depth<0) rx->depth=0;
|
||||
while (EdRILex(rx) && rx->cc1->token!=':');
|
||||
EdRILex(rx);
|
||||
break;
|
||||
case KW_CASE:
|
||||
case KW_DFT:
|
||||
rx->depth+=i; i=0;
|
||||
while (EdRILex(rx) && rx->cc1->token!=':');
|
||||
EdRILex(rx);
|
||||
break;
|
||||
default:
|
||||
if (rx->cc1->token)
|
||||
EdRIStmt(rx,TRUE);
|
||||
}
|
||||
}
|
||||
if (--rx->depth<0) rx->depth=0;
|
||||
EdRILex(rx);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (rx->cc1->token==TK_IDENT && rx->cc1->hash_entry &&
|
||||
rx->cc1->hash_entry->type&(HTT_OPCODE|HTT_ASM_KEYWORD)) {
|
||||
// rx->one_shot=4-rx->depth;
|
||||
do EdRILex(rx);
|
||||
while (rx->cc2->token && rx->cc2->token!='\n');
|
||||
rx->is_not_cont=TRUE;
|
||||
} else {
|
||||
while (rx->cc1->token && rx->cc1->token!=';' &&
|
||||
rx->cc1->token!=':') {
|
||||
if (rx->cc2->token=='\n' && !rx->is_not_cont)
|
||||
rx->one_shot=3;
|
||||
EdRILex(rx);
|
||||
}
|
||||
if (rx->cc1->token==':')
|
||||
cont=TRUE;
|
||||
EdRILex(rx);
|
||||
}
|
||||
}
|
||||
} while (cont && rx->cc1->token!='}');
|
||||
if (indent && --rx->depth<0)
|
||||
rx->depth=0;
|
||||
}
|
||||
}
|
||||
|
||||
CQueVectU8 *EdRICode(CDoc *doc)
|
||||
{
|
||||
CQueVectU8 *res;
|
||||
CRILex *rx=CAlloc(sizeof(CRILex));
|
||||
|
||||
rx->cc1=CmpCtrlNew(,CCF_KEEP_NEW_LINES|CCF_DONT_FREE_BUF,doc->filename.name);
|
||||
Free(rx->cc1->lex_include_stk->full_name);
|
||||
LexAttachDoc(rx->cc1,rx->cc1->lex_include_stk,doc,,
|
||||
doc->cur_entry,doc->cur_col);
|
||||
|
||||
rx->cc2=CmpCtrlNew(,CCF_KEEP_NEW_LINES|CCF_DONT_FREE_BUF,doc->filename.name);
|
||||
Free(rx->cc2->lex_include_stk->full_name);
|
||||
LexAttachDoc(rx->cc2,rx->cc2->lex_include_stk,doc,,
|
||||
doc->cur_entry,doc->cur_col);
|
||||
|
||||
rx->indent=QueVectU8New(doc->cur_entry->y);
|
||||
|
||||
Lex(rx->cc1);
|
||||
EdRIStmt(rx,FALSE);
|
||||
|
||||
CmpCtrlDel(rx->cc1);
|
||||
CmpCtrlDel(rx->cc2);
|
||||
res=rx->indent;
|
||||
Free(rx);
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 EdRemFunLeadingSpace(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc),
|
||||
start_of_line=TRUE;
|
||||
U8 *ptr;
|
||||
I64 ch,levels=1;
|
||||
CDocEntry *doc_e,*doc_e2;
|
||||
|
||||
EdGoToFun(doc,FALSE,FALSE);
|
||||
doc_e=doc->cur_entry->next;
|
||||
do {
|
||||
doc_e2=doc_e->next;
|
||||
if (doc_e!=doc && doc_e!=doc->cur_entry &&
|
||||
!(doc_e->de_flags&(DOCEG_DONT_EDIT-DOCEF_SCROLLING_X)))
|
||||
switch (doc_e->type_u8) {
|
||||
case DOCT_TEXT:
|
||||
ptr=doc_e->tag;
|
||||
if (start_of_line) {
|
||||
while (*ptr==CH_SPACE)
|
||||
ptr++;
|
||||
if (*ptr)
|
||||
start_of_line=FALSE;
|
||||
ptr=StrNew(ptr,doc->mem_task);
|
||||
Free(doc_e->tag);
|
||||
doc_e->tag=ptr;
|
||||
}
|
||||
if (!*ptr)
|
||||
DocEntryDel(doc,doc_e);
|
||||
else {
|
||||
while (ch=*ptr++)
|
||||
if (ch=='{')
|
||||
levels++;
|
||||
else if (ch=='}') {
|
||||
if (!--levels)
|
||||
break;
|
||||
}
|
||||
if (!levels) goto ls_done;
|
||||
}
|
||||
break;
|
||||
case DOCT_TAB:
|
||||
if (start_of_line)
|
||||
DocEntryDel(doc,doc_e);
|
||||
break;
|
||||
case DOCT_NEW_LINE:
|
||||
start_of_line=TRUE;
|
||||
break;
|
||||
default:
|
||||
start_of_line=FALSE;
|
||||
}
|
||||
doc_e=doc_e2;
|
||||
} while (doc_e!=doc->cur_entry);
|
||||
ls_done:
|
||||
DocRecalc(doc);
|
||||
DocCenter(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
class CRenum
|
||||
{
|
||||
CRenum *next,*last;
|
||||
U8 label[sizeof(CEdFindText.find_text)];
|
||||
};
|
||||
|
||||
I64 EdRAGetU8(CDoc *doc)
|
||||
{
|
||||
I64 res=-1;
|
||||
while (doc->cur_entry!=doc &&
|
||||
doc->cur_entry->type&DOCET_SEL && res<0) {
|
||||
res=EdCurU8(doc);
|
||||
EdCursorRight(doc);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 EdRACollect(CDoc *doc,CRenum *head)
|
||||
{
|
||||
I64 ch,i;
|
||||
CRenum *tempr;
|
||||
U8 buf[sizeof(CEdFindText.find_text)];
|
||||
ch=EdRAGetU8(doc);
|
||||
while (ch>=0) {
|
||||
if (ch!='@')
|
||||
ch=EdRAGetU8(doc);
|
||||
else {
|
||||
ch=EdRAGetU8(doc);
|
||||
if (ch=='@') {
|
||||
ch=EdRAGetU8(doc);
|
||||
StrCpy(buf,"@@");
|
||||
i=2;
|
||||
while (ch>=0 && i<sizeof(CEdFindText.find_text)) {
|
||||
if (Bt(chars_bmp_alpha_numeric,ch))
|
||||
buf[i++]=ch;
|
||||
else
|
||||
break;
|
||||
ch=EdRAGetU8(doc);
|
||||
}
|
||||
if (i<sizeof(CEdFindText.find_text)) {
|
||||
buf[i++]=0;
|
||||
while (ch>=0 && Bt(chars_bmp_white_space,ch))
|
||||
ch=EdRAGetU8(doc);
|
||||
if (ch==':') {
|
||||
ch=EdRAGetU8(doc);
|
||||
tempr=MAlloc(sizeof(CRenum));
|
||||
StrCpy(tempr->label,buf);
|
||||
QueIns(tempr,head->last);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//This is needed because we moved the
|
||||
//cursor and it didn't recalc.
|
||||
DocRecalc(doc);
|
||||
}
|
||||
|
||||
U0 EdRenumAsm(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
I64 num=0;
|
||||
CRenum head,*tempr,*tempr1;
|
||||
U8 buf[sizeof(CEdFindText.find_text)],
|
||||
buf2[sizeof(CEdFindText.find_text)];
|
||||
|
||||
QueInit(&head);
|
||||
EdSelFun(doc,TRUE);
|
||||
EdRACollect(doc,&head);
|
||||
|
||||
tempr=head.next;
|
||||
while (tempr!=&head) {
|
||||
tempr1=tempr->next;
|
||||
num+=ASM_RENUM_SPACING;
|
||||
StrPrint(buf,"@#%02d",num);
|
||||
EdReplace(doc,tempr->label,buf,TRUE,TRUE,TRUE);
|
||||
Free(tempr);
|
||||
tempr=tempr1;
|
||||
}
|
||||
|
||||
while (num) {
|
||||
StrPrint(buf, "@#%02d",num);
|
||||
StrPrint(buf2,"@@%02d",num);
|
||||
EdReplace(doc,buf,buf2,TRUE,TRUE,TRUE);
|
||||
num-=ASM_RENUM_SPACING;
|
||||
}
|
||||
EdSelAll(doc,FALSE);
|
||||
DocRecalc(doc);
|
||||
DocCenter(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 EdCodeTools2(CDoc *doc,I64 tool_action,Bool beep=TRUE)
|
||||
{
|
||||
Bool okay,unlock=DocLock(doc),start_of_line=TRUE;
|
||||
CDocEntry *doc_e,*doc_ne;
|
||||
I64 i,start_y,end_y,x,r,goto_line_num;
|
||||
U8 *b,*st,*st2,*prj_file;
|
||||
CTask *task=NULL;
|
||||
CSrvCmd *tempc;
|
||||
CQueVectU8 *indent;
|
||||
|
||||
DocRecalc(doc);
|
||||
goto_line_num=doc->cur_entry->y+1;
|
||||
|
||||
DocCaptureUndo(doc,TRUE);
|
||||
switch (tool_action) {
|
||||
case EF_CMP_CHK:
|
||||
okay=FALSE;
|
||||
if (doc->flags&DOCF_PLAIN_TEXT)
|
||||
DocFlagsToggle(doc,DOCF_PLAIN_TEXT);
|
||||
DocWrite(doc);
|
||||
task=Spawn(&SrvCmdLine,NULL,"Srv",,Fs);
|
||||
st2=CurDir;
|
||||
st=MStrPrint("Cd(\"%s\");",st2);
|
||||
tempc=TaskExe(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
Free(st2);
|
||||
Free(st);
|
||||
WinHorz(Fs->win_left,Fs->win_right, task);
|
||||
WinVert(Fs->win_top, Fs->win_bottom,task);
|
||||
if (JobResScan(tempc,&r)) {
|
||||
st=DirFile(doc->filename.name,,"PRJ.Z");
|
||||
prj_file=FileNameAbs(st,FUF_Z_OR_NOT_Z);
|
||||
Free(st);
|
||||
if (FileFind(prj_file)) {
|
||||
st2=DirFile(prj_file),
|
||||
st=MStrPrint("Cd(\"%s\");",st2);
|
||||
Free(st2);
|
||||
tempc=TaskExe(task,Fs,st,1<<SVCf_WAKE_MASTER|
|
||||
1<<SVCf_FOCUS_MASTER|1<<SVCf_FREE_ON_COMPLETE);
|
||||
Free(st);
|
||||
st=MStrPrint("\"$$WW,1$$\";Cmp(\"%s\",\"SysTemp\",\"SysTemp\");",
|
||||
prj_file);
|
||||
tempc=TaskExe(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
Free(st);
|
||||
if (JobResScan(tempc,&r))
|
||||
if (!r) {
|
||||
tempc=TaskExe(task,Fs,
|
||||
"Load(\"SysTemp\",LDF_JUST_LOAD);",
|
||||
1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
if (JobResScan(tempc,&r))
|
||||
okay=TRUE;
|
||||
}
|
||||
tempc=TaskExe(task,Fs,"Del(\"SysTemp.*\");",
|
||||
1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
JobResScan(tempc,&r);
|
||||
} else {
|
||||
Free(prj_file);
|
||||
st=DirFile(doc->filename.name,"Load","CPP.Z");
|
||||
prj_file=FileNameAbs(st,FUF_Z_OR_NOT_Z);
|
||||
Free(st);
|
||||
if (FileFind(prj_file))
|
||||
st=MStrPrint("\"$$WW,1$$\";ExeFile(\"%s\",CCF_JUST_LOAD);",prj_file);
|
||||
else
|
||||
st=MStrPrint("\"$$WW,1$$\";ExeFile(\"%s\",CCF_JUST_LOAD);",
|
||||
doc->filename.name);
|
||||
tempc=TaskExe(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
Free(st);
|
||||
if (JobResScan(tempc,&r) && r)
|
||||
okay=TRUE;
|
||||
}
|
||||
Free(prj_file);
|
||||
}
|
||||
if (!okay) {
|
||||
PopUpOk("Has Errors");
|
||||
while (LBts(&sys_semas[SYS_SEMA_FIX],0))
|
||||
Yield;
|
||||
ToFileLine(dbg.fix_file_line,&st,&i);
|
||||
LBtr(&sys_semas[SYS_SEMA_FIX],0);
|
||||
if (!StrCmp(st,doc->filename.name))
|
||||
goto_line_num=i;
|
||||
Free(st);
|
||||
}
|
||||
break;
|
||||
case EF_REINDENT:
|
||||
start_y=doc->cur_entry->y;
|
||||
EdReplaceTroubleAll(doc,TRUE,FALSE);
|
||||
DocLineNumGoTo(doc,start_y+1);
|
||||
if (EdGoToFun(doc,FALSE,FALSE)) {
|
||||
start_y=doc->cur_entry->y;
|
||||
indent=EdRICode(doc);
|
||||
DocUnlock(doc);
|
||||
if (beep) {
|
||||
Snd(2000); Sleep(150); Snd(0);
|
||||
Sleep(100);
|
||||
Snd(2000); Sleep(150); Snd(0);
|
||||
}
|
||||
DocLock(doc);
|
||||
EdRemFunLeadingSpace(doc);
|
||||
DocLineNumGoTo(doc,start_y+1);
|
||||
doc_e=doc->cur_entry;
|
||||
end_y=start_y+indent->total_cnt;
|
||||
while (start_y<=doc_e->y<end_y) {
|
||||
if (doc_e!=doc && doc_e!=doc->cur_entry &&
|
||||
!(doc_e->de_flags&(DOCEG_DONT_EDIT-DOCEF_SCROLLING_X))) {
|
||||
if (doc_e->type_u8==DOCT_NEW_LINE||
|
||||
doc_e->type_u8==DOCT_SOFT_NEW_LINE)
|
||||
start_of_line=TRUE;
|
||||
else {
|
||||
if (start_of_line) {
|
||||
i=QueVectU8Get(indent,doc_e->y)*C_INDENT_SPACES;
|
||||
x=doc_e->x+1;
|
||||
while (i>8) {
|
||||
doc_ne=DocEntryNewBase(doc,
|
||||
DOCT_TAB|doc->settings_head.dft_text_attr<<8,,
|
||||
x,doc_e->y,doc_e->page_line_num);
|
||||
MemCpy(&doc_ne->settings,
|
||||
&doc_e->settings,sizeof(CDocSettings));
|
||||
QueIns(doc_ne,doc_e->last);
|
||||
i-=8;
|
||||
x+=8;
|
||||
}
|
||||
if (i>0) {
|
||||
b=MAlloc(i+1,doc->mem_task);
|
||||
MemSet(b,CH_SPACE,i);
|
||||
b[i]=0;
|
||||
doc_ne=DocEntryNewBase(doc,
|
||||
DOCT_TEXT|doc->settings_head.dft_text_attr<<8,,
|
||||
x,doc_e->y,doc_e->page_line_num);
|
||||
doc_ne->tag=b;
|
||||
doc_ne->max_col=1;
|
||||
MemCpy(&doc_ne->settings,
|
||||
&doc_e->settings,sizeof(CDocSettings));
|
||||
QueIns(doc_ne,doc_e->last);
|
||||
}
|
||||
}
|
||||
start_of_line=FALSE;
|
||||
}
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
QueVectU8Del(indent);
|
||||
}
|
||||
start_y=doc->cur_entry->y;
|
||||
EdReplaceTroubleAll(doc,FALSE,FALSE);
|
||||
DocLineNumGoTo(doc,start_y+1);
|
||||
break;
|
||||
case EF_RENUM_ASM:
|
||||
if (EdGoToFun(doc,FALSE,TRUE)) {
|
||||
if (EdCurU8(doc)=='{') {
|
||||
EdCursorRight(doc);
|
||||
DocRecalc(doc);
|
||||
} else if (EdCurU8(doc)==':') {
|
||||
EdCursorRight(doc);
|
||||
if (EdCurU8(doc)==':')
|
||||
EdCursorRight(doc);
|
||||
DocRecalc(doc);
|
||||
}
|
||||
DocUnlock(doc);
|
||||
if (beep) {
|
||||
Snd(2000); Sleep(150); Snd(0);
|
||||
Sleep(100);
|
||||
Snd(2000); Sleep(150); Snd(0);
|
||||
}
|
||||
DocLock(doc);
|
||||
EdRenumAsm(doc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
DocRecalc(doc);
|
||||
DocLineNumGoTo(doc,goto_line_num);
|
||||
|
||||
DocUnlock(doc);
|
||||
if (!unlock)
|
||||
DocLock(doc);
|
||||
if (task)
|
||||
Kill(task,FALSE);
|
||||
}
|
||||
|
||||
U0 EdPopUpChSC(I64 *_ch,I64 *_sc)
|
||||
{
|
||||
I64 sc;
|
||||
"Press A Key\n";
|
||||
DocPut->flags|=DOCF_MIN_SIZE;
|
||||
do GetMsg(_ch,&sc,1<<MSG_KEY_DOWN);
|
||||
while (sc.u8[0]==SC_SHIFT || sc.u8[0]==SC_CTRL || sc.u8[0]==SC_ALT);
|
||||
*_sc=sc;
|
||||
}
|
||||
|
||||
U0 EdChSC(CDoc *doc)
|
||||
{
|
||||
I64 ch,sc;
|
||||
U8 buf[STR_LEN];
|
||||
StrPrint(buf,"EdPopUpChSC(%d,%d);",&ch,&sc);
|
||||
PopUp(buf,Fs);
|
||||
if (ch==CH_BACKSPACE)
|
||||
DocPrint(doc,"CH_BACKSPACE,0x%X",sc);
|
||||
else if (ch=='\n')
|
||||
DocPrint(doc,"'\n',0x%X",sc);
|
||||
else if (CH_CTRLA<=ch<=CH_CTRLZ)
|
||||
DocPrint(doc,"CH_CTRL%C,0x%X",ch+'@',sc);
|
||||
else if (ch=='$$')
|
||||
DocPrint(doc,"'$$$$',0x%X",sc);
|
||||
else if (ch=='\\')
|
||||
DocPrint(doc,"'\\\\',0x%X",sc);
|
||||
else if (ch=='\'')
|
||||
DocPrint(doc,"'\\\'',0x%X",sc);
|
||||
else if (ch==CH_ESC)
|
||||
DocPrint(doc,"CH_ESC,0x%X",sc);
|
||||
else if (ch==CH_SHIFT_ESC)
|
||||
DocPrint(doc,"CH_SHIFT_ESC,0x%X",sc);
|
||||
else if (ch==CH_SPACE)
|
||||
DocPrint(doc,"CH_SPACE,0x%X",sc);
|
||||
else if (ch==CH_SHIFT_SPACE)
|
||||
DocPrint(doc,"CH_SHIFT_SPACE,0x%X",sc);
|
||||
else if (Bt(chars_bmp_displayable,ch))
|
||||
DocPrint(doc,"'%c',0x%X",ch,sc);
|
||||
else
|
||||
DocPrint(doc,"0x%X,0x%X",ch,sc);
|
||||
}
|
||||
|
||||
U0 EdCodeTools(CDoc *doc)
|
||||
{
|
||||
I64 tool_action=PopUpEdFmt;
|
||||
switch (tool_action) {
|
||||
case EF_CMP_CHK:
|
||||
case EF_REINDENT:
|
||||
case EF_RENUM_ASM:
|
||||
EdCodeTools2(doc,tool_action);
|
||||
break;
|
||||
case EF_CTRL_SLIDER:
|
||||
TemplateCtrlSlider(doc);
|
||||
break;
|
||||
case EF_CH_SC:
|
||||
EdChSC(doc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,658 @@
|
||||
#help_index "DolDoc/Misc"
|
||||
|
||||
U0 EdReplaceTroubleOne(CDoc *doc,U8 *st_original,U8 *st_safe,I64 num,
|
||||
Bool to_safe,Bool sel)
|
||||
{
|
||||
U8 buf[STR_LEN];
|
||||
StrPrint(buf,st_safe,num);
|
||||
if (to_safe)
|
||||
EdReplace(doc,st_original,buf,sel);
|
||||
else
|
||||
EdReplace(doc,buf,st_original,sel);
|
||||
}
|
||||
|
||||
U0 EdReplaceTroubleAll(CDoc *doc,Bool to_safe,Bool sel)
|
||||
{
|
||||
I64 i=0;
|
||||
EdReplaceTroubleOne(doc,"#assert" ,"//<@%d@>" ,i++,to_safe,sel);
|
||||
EdReplaceTroubleOne(doc,"#define" ,"//<@%d@>" ,i++,to_safe,sel);
|
||||
EdReplaceTroubleOne(doc,"#include","//<@%d@>" ,i++,to_safe,sel);
|
||||
//#if will match #if,#ifdef,#ifndef,#ifaot and #ifjit
|
||||
EdReplaceTroubleOne(doc,"#if" ,"//<@%d@>" ,i++,to_safe,sel);
|
||||
EdReplaceTroubleOne(doc,"#endif" ,"//<@%d@>" ,i++,to_safe,sel);
|
||||
//Convert #exe to union because we want that indent pattern.
|
||||
EdReplaceTroubleOne(doc,"#exe" ,"union @%d@",i++,to_safe,sel);
|
||||
EdReplaceTroubleOne(doc,"'{'" ,"'<@%d@>'" ,i++,to_safe,sel);
|
||||
EdReplaceTroubleOne(doc,"'}'" ,"'<@%d@>'" ,i++,to_safe,sel);
|
||||
}
|
||||
|
||||
#define C_INDENT_SPACES 2
|
||||
#define ASM_RENUM_SPACING 5
|
||||
|
||||
#define EF_REINDENT 0
|
||||
#define EF_CMP_CHK 1
|
||||
#define EF_RENUM_ASM 2
|
||||
#define EF_CTRL_SLIDER 3
|
||||
#define EF_CH_SC 4
|
||||
|
||||
I64 PopUpEdFmt()
|
||||
{
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
DocPrint(doc,"$$LTBLUE$$$$MU,\"Compile Check\",LE=EF_CMP_CHK$$\n"
|
||||
"$$MU,\"Reindent HC.Z Fun (Beware braces in strings.)\","
|
||||
"LE=EF_REINDENT$$\n"
|
||||
"$$MU,\"Renum Asm Local @@ Labels for Fun\",LE=EF_RENUM_ASM$$\n"
|
||||
"$$MU,\"Insert Template Code: Ctrl Slider\",LE=EF_CTRL_SLIDER$$\n"
|
||||
"$$MU,\"Insert ASCII/Scan Code Hex Codes for key pressed\","
|
||||
"LE=EF_CH_SC$$\n\n"
|
||||
"$$MU,\"CANCEL\",LE=DOCM_CANCEL$$\n\n"
|
||||
"$$GREEN$$<ALT-BACKSPACE>$$FG$$ to undo if not happy\n"
|
||||
"with the ress.\n");
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
class CRILex
|
||||
{
|
||||
CCmpCtrl *cc1,*cc2;
|
||||
CQueVectU8 *indent;
|
||||
I64 depth,exp_depth,one_shot;
|
||||
Bool was_new_line,is_not_cont;
|
||||
};
|
||||
|
||||
I64 EdRILex(CRILex *rx)
|
||||
{
|
||||
rx->is_not_cont=FALSE;
|
||||
I64 i;
|
||||
CLexFile *tempf;
|
||||
do {
|
||||
Lex(rx->cc1);
|
||||
Lex(rx->cc2);
|
||||
i=PrsKeyWord(rx->cc2);
|
||||
if (rx->cc1->token=='\n' && rx->cc2->token==';' || rx->cc2->token=='{' ||
|
||||
rx->cc2->token=='}' || rx->cc2->token==':' || rx->cc2->token==')' &&
|
||||
!rx->exp_depth || i==KW_ELSE || i==KW_CATCH || i==KW_DO)
|
||||
rx->is_not_cont=TRUE;
|
||||
if (rx->was_new_line && (rx->cc1->token!=':' || i==KW_CASE ||
|
||||
i==KW_DFT || i==KW_START || i==KW_END)) {
|
||||
tempf=rx->cc2->lex_include_stk;
|
||||
while (tempf->next)
|
||||
tempf=tempf->next;
|
||||
QueVectU8Put(rx->indent,tempf->cur_entry->y,rx->depth+rx->one_shot);
|
||||
rx->one_shot=0;
|
||||
}
|
||||
if (rx->cc2->token=='\n')
|
||||
rx->was_new_line=TRUE;
|
||||
else
|
||||
rx->was_new_line=FALSE;
|
||||
} while (rx->cc1->token=='\n');
|
||||
return rx->cc1->token;
|
||||
}
|
||||
|
||||
U0 EdRIExp(CRILex *rx)
|
||||
{
|
||||
if (rx->cc1->token=='(') {
|
||||
if (!rx->exp_depth++)
|
||||
rx->depth+=3;
|
||||
EdRILex(rx);
|
||||
while (rx->cc1->token && rx->cc1->token!=')')
|
||||
EdRIExp(rx);
|
||||
if (!--rx->exp_depth) {
|
||||
rx->depth-=3;
|
||||
if (rx->depth<0) rx->depth=0;
|
||||
}
|
||||
} else if (rx->cc1->token=='[') {
|
||||
if (!rx->exp_depth++)
|
||||
rx->depth+=3;
|
||||
EdRILex(rx);
|
||||
while (rx->cc1->token && rx->cc1->token!=']')
|
||||
EdRIExp(rx);
|
||||
if (!--rx->exp_depth) {
|
||||
rx->depth-=3;
|
||||
if (rx->depth<0) rx->depth=0;
|
||||
}
|
||||
}
|
||||
EdRILex(rx);
|
||||
}
|
||||
|
||||
U0 EdRIStmt(CRILex *rx,Bool indent)
|
||||
{
|
||||
I64 i;
|
||||
Bool cont;
|
||||
if (rx->cc1->token=='{') {
|
||||
rx->depth++;
|
||||
EdRILex(rx);
|
||||
while (rx->cc1->token && rx->cc1->token!='}')
|
||||
EdRIStmt(rx,FALSE);
|
||||
if (--rx->depth<0) rx->depth=0;
|
||||
EdRILex(rx);
|
||||
} else {
|
||||
if (indent) rx->depth++;
|
||||
do {
|
||||
cont=FALSE;
|
||||
switch (PrsKeyWord(rx->cc1)) {
|
||||
case KW_IF:
|
||||
EdRILex(rx);
|
||||
EdRIExp(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
if (PrsKeyWord(rx->cc1)==KW_ELSE) {
|
||||
EdRILex(rx);
|
||||
if (PrsKeyWord(rx->cc1)==KW_IF && rx->cc2->token!='\n')
|
||||
EdRIStmt(rx,FALSE);
|
||||
else
|
||||
EdRIStmt(rx,TRUE);
|
||||
}
|
||||
break;
|
||||
case KW_TRY:
|
||||
EdRILex(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
if (PrsKeyWord(rx->cc1)==KW_CATCH) {
|
||||
EdRILex(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
}
|
||||
break;
|
||||
case KW_LOCK:
|
||||
EdRILex(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
break;
|
||||
case KW_FOR:
|
||||
case KW_WHILE:
|
||||
EdRILex(rx);
|
||||
EdRIExp(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
break;
|
||||
case KW_ASM:
|
||||
case KW_CLASS:
|
||||
case KW_UNION:
|
||||
if (EdRILex(rx)==TK_IDENT)
|
||||
EdRILex(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
break;
|
||||
case KW_DO:
|
||||
EdRILex(rx);
|
||||
EdRIStmt(rx,TRUE);
|
||||
if (PrsKeyWord(rx->cc1)==KW_WHILE) {
|
||||
EdRILex(rx);
|
||||
EdRIExp(rx);
|
||||
}
|
||||
if (rx->cc1->token==';')
|
||||
EdRILex(rx);
|
||||
break;
|
||||
case KW_SWITCH:
|
||||
EdRILex(rx);
|
||||
EdRIExp(rx);
|
||||
if (rx->cc1->token=='{') {
|
||||
rx->depth++;
|
||||
EdRILex(rx);
|
||||
i=0;
|
||||
while (rx->cc1->token && rx->cc1->token!='}') {
|
||||
switch (PrsKeyWord(rx->cc1)) {
|
||||
case KW_START:
|
||||
rx->depth+=i; i=0;
|
||||
while (EdRILex(rx) && rx->cc1->token!=':');
|
||||
EdRILex(rx);
|
||||
i++;
|
||||
break;
|
||||
case KW_END:
|
||||
rx->depth+=i; i=0;
|
||||
if (--rx->depth<0) rx->depth=0;
|
||||
while (EdRILex(rx) && rx->cc1->token!=':');
|
||||
EdRILex(rx);
|
||||
break;
|
||||
case KW_CASE:
|
||||
case KW_DFT:
|
||||
rx->depth+=i; i=0;
|
||||
while (EdRILex(rx) && rx->cc1->token!=':');
|
||||
EdRILex(rx);
|
||||
break;
|
||||
default:
|
||||
if (rx->cc1->token)
|
||||
EdRIStmt(rx,TRUE);
|
||||
}
|
||||
}
|
||||
if (--rx->depth<0) rx->depth=0;
|
||||
EdRILex(rx);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (rx->cc1->token==TK_IDENT && rx->cc1->hash_entry &&
|
||||
rx->cc1->hash_entry->type&(HTT_OPCODE|HTT_ASM_KEYWORD)) {
|
||||
// rx->one_shot=4-rx->depth;
|
||||
do EdRILex(rx);
|
||||
while (rx->cc2->token && rx->cc2->token!='\n');
|
||||
rx->is_not_cont=TRUE;
|
||||
} else {
|
||||
while (rx->cc1->token && rx->cc1->token!=';' &&
|
||||
rx->cc1->token!=':') {
|
||||
if (rx->cc2->token=='\n' && !rx->is_not_cont)
|
||||
rx->one_shot=3;
|
||||
EdRILex(rx);
|
||||
}
|
||||
if (rx->cc1->token==':')
|
||||
cont=TRUE;
|
||||
EdRILex(rx);
|
||||
}
|
||||
}
|
||||
} while (cont && rx->cc1->token!='}');
|
||||
if (indent && --rx->depth<0)
|
||||
rx->depth=0;
|
||||
}
|
||||
}
|
||||
|
||||
CQueVectU8 *EdRICode(CDoc *doc)
|
||||
{
|
||||
CQueVectU8 *res;
|
||||
CRILex *rx=CAlloc(sizeof(CRILex));
|
||||
|
||||
rx->cc1=CmpCtrlNew(,CCF_KEEP_NEW_LINES|CCF_DONT_FREE_BUF,doc->filename.name);
|
||||
Free(rx->cc1->lex_include_stk->full_name);
|
||||
LexAttachDoc(rx->cc1,rx->cc1->lex_include_stk,doc,,
|
||||
doc->cur_entry,doc->cur_col);
|
||||
|
||||
rx->cc2=CmpCtrlNew(,CCF_KEEP_NEW_LINES|CCF_DONT_FREE_BUF,doc->filename.name);
|
||||
Free(rx->cc2->lex_include_stk->full_name);
|
||||
LexAttachDoc(rx->cc2,rx->cc2->lex_include_stk,doc,,
|
||||
doc->cur_entry,doc->cur_col);
|
||||
|
||||
rx->indent=QueVectU8New(doc->cur_entry->y);
|
||||
|
||||
Lex(rx->cc1);
|
||||
EdRIStmt(rx,FALSE);
|
||||
|
||||
CmpCtrlDel(rx->cc1);
|
||||
CmpCtrlDel(rx->cc2);
|
||||
res=rx->indent;
|
||||
Free(rx);
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 EdRemFunLeadingSpace(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc),
|
||||
start_of_line=TRUE;
|
||||
U8 *ptr;
|
||||
I64 ch,levels=1;
|
||||
CDocEntry *doc_e,*doc_e2;
|
||||
|
||||
EdGoToFun(doc,FALSE,FALSE);
|
||||
doc_e=doc->cur_entry->next;
|
||||
do {
|
||||
doc_e2=doc_e->next;
|
||||
if (doc_e!=doc && doc_e!=doc->cur_entry &&
|
||||
!(doc_e->de_flags&(DOCEG_DONT_EDIT-DOCEF_SCROLLING_X)))
|
||||
switch (doc_e->type_u8) {
|
||||
case DOCT_TEXT:
|
||||
ptr=doc_e->tag;
|
||||
if (start_of_line) {
|
||||
while (*ptr==CH_SPACE)
|
||||
ptr++;
|
||||
if (*ptr)
|
||||
start_of_line=FALSE;
|
||||
ptr=StrNew(ptr,doc->mem_task);
|
||||
Free(doc_e->tag);
|
||||
doc_e->tag=ptr;
|
||||
}
|
||||
if (!*ptr)
|
||||
DocEntryDel(doc,doc_e);
|
||||
else {
|
||||
while (ch=*ptr++)
|
||||
if (ch=='{')
|
||||
levels++;
|
||||
else if (ch=='}') {
|
||||
if (!--levels)
|
||||
break;
|
||||
}
|
||||
if (!levels) goto ls_done;
|
||||
}
|
||||
break;
|
||||
case DOCT_TAB:
|
||||
if (start_of_line)
|
||||
DocEntryDel(doc,doc_e);
|
||||
break;
|
||||
case DOCT_NEW_LINE:
|
||||
start_of_line=TRUE;
|
||||
break;
|
||||
default:
|
||||
start_of_line=FALSE;
|
||||
}
|
||||
doc_e=doc_e2;
|
||||
} while (doc_e!=doc->cur_entry);
|
||||
ls_done:
|
||||
DocRecalc(doc);
|
||||
DocCenter(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
class CRenum
|
||||
{
|
||||
CRenum *next,*last;
|
||||
U8 label[sizeof(CEdFindText.find_text)];
|
||||
};
|
||||
|
||||
I64 EdRAGetU8(CDoc *doc)
|
||||
{
|
||||
I64 res=-1;
|
||||
while (doc->cur_entry!=doc &&
|
||||
doc->cur_entry->type&DOCET_SEL && res<0) {
|
||||
res=EdCurU8(doc);
|
||||
EdCursorRight(doc);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 EdRACollect(CDoc *doc,CRenum *head)
|
||||
{
|
||||
I64 ch,i;
|
||||
CRenum *tempr;
|
||||
U8 buf[sizeof(CEdFindText.find_text)];
|
||||
ch=EdRAGetU8(doc);
|
||||
while (ch>=0) {
|
||||
if (ch!='@')
|
||||
ch=EdRAGetU8(doc);
|
||||
else {
|
||||
ch=EdRAGetU8(doc);
|
||||
if (ch=='@') {
|
||||
ch=EdRAGetU8(doc);
|
||||
StrCpy(buf,"@@");
|
||||
i=2;
|
||||
while (ch>=0 && i<sizeof(CEdFindText.find_text)) {
|
||||
if (Bt(chars_bmp_alpha_numeric,ch))
|
||||
buf[i++]=ch;
|
||||
else
|
||||
break;
|
||||
ch=EdRAGetU8(doc);
|
||||
}
|
||||
if (i<sizeof(CEdFindText.find_text)) {
|
||||
buf[i++]=0;
|
||||
while (ch>=0 && Bt(chars_bmp_white_space,ch))
|
||||
ch=EdRAGetU8(doc);
|
||||
if (ch==':') {
|
||||
ch=EdRAGetU8(doc);
|
||||
tempr=MAlloc(sizeof(CRenum));
|
||||
StrCpy(tempr->label,buf);
|
||||
QueIns(tempr,head->last);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//This is needed because we moved the
|
||||
//cursor and it didn't recalc.
|
||||
DocRecalc(doc);
|
||||
}
|
||||
|
||||
U0 EdRenumAsm(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
I64 num=0;
|
||||
CRenum head,*tempr,*tempr1;
|
||||
U8 buf[sizeof(CEdFindText.find_text)],
|
||||
buf2[sizeof(CEdFindText.find_text)];
|
||||
|
||||
QueInit(&head);
|
||||
EdSelFun(doc,TRUE);
|
||||
EdRACollect(doc,&head);
|
||||
|
||||
tempr=head.next;
|
||||
while (tempr!=&head) {
|
||||
tempr1=tempr->next;
|
||||
num+=ASM_RENUM_SPACING;
|
||||
StrPrint(buf,"@#%02d",num);
|
||||
EdReplace(doc,tempr->label,buf,TRUE,TRUE,TRUE);
|
||||
Free(tempr);
|
||||
tempr=tempr1;
|
||||
}
|
||||
|
||||
while (num) {
|
||||
StrPrint(buf, "@#%02d",num);
|
||||
StrPrint(buf2,"@@%02d",num);
|
||||
EdReplace(doc,buf,buf2,TRUE,TRUE,TRUE);
|
||||
num-=ASM_RENUM_SPACING;
|
||||
}
|
||||
EdSelAll(doc,FALSE);
|
||||
DocRecalc(doc);
|
||||
DocCenter(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 EdCodeTools2(CDoc *doc,I64 tool_action,Bool beep=TRUE)
|
||||
{
|
||||
Bool okay,unlock=DocLock(doc),start_of_line=TRUE;
|
||||
CDocEntry *doc_e,*doc_ne;
|
||||
I64 i,start_y,end_y,x,r,goto_line_num;
|
||||
U8 *b,*st,*st2,*prj_file;
|
||||
CTask *task=NULL;
|
||||
CSrvCmd *tempc;
|
||||
CQueVectU8 *indent;
|
||||
|
||||
DocRecalc(doc);
|
||||
goto_line_num=doc->cur_entry->y+1;
|
||||
|
||||
DocCaptureUndo(doc,TRUE);
|
||||
switch (tool_action) {
|
||||
case EF_CMP_CHK:
|
||||
okay=FALSE;
|
||||
if (doc->flags&DOCF_PLAIN_TEXT)
|
||||
DocFlagsToggle(doc,DOCF_PLAIN_TEXT);
|
||||
DocWrite(doc);
|
||||
task=Spawn(&SrvCmdLine,NULL,"Srv",,Fs);
|
||||
st2=CurDir;
|
||||
st=MStrPrint("Cd(\"%s\");",st2);
|
||||
tempc=TaskExe(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
Free(st2);
|
||||
Free(st);
|
||||
WinHorz(Fs->win_left,Fs->win_right, task);
|
||||
WinVert(Fs->win_top, Fs->win_bottom,task);
|
||||
if (JobResScan(tempc,&r)) {
|
||||
st=DirFile(doc->filename.name,,"PRJ.Z");
|
||||
prj_file=FileNameAbs(st,FUF_Z_OR_NOT_Z);
|
||||
Free(st);
|
||||
if (FileFind(prj_file)) {
|
||||
st2=DirFile(prj_file),
|
||||
st=MStrPrint("Cd(\"%s\");",st2);
|
||||
Free(st2);
|
||||
tempc=TaskExe(task,Fs,st,1<<SVCf_WAKE_MASTER|
|
||||
1<<SVCf_FOCUS_MASTER|1<<SVCf_FREE_ON_COMPLETE);
|
||||
Free(st);
|
||||
st=MStrPrint("\"$$WW,1$$\";Cmp(\"%s\",\"SysTemp\",\"SysTemp\");",
|
||||
prj_file);
|
||||
tempc=TaskExe(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
Free(st);
|
||||
if (JobResScan(tempc,&r))
|
||||
if (!r) {
|
||||
tempc=TaskExe(task,Fs,
|
||||
"Load(\"SysTemp\",LDF_JUST_LOAD);",
|
||||
1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
if (JobResScan(tempc,&r))
|
||||
okay=TRUE;
|
||||
}
|
||||
tempc=TaskExe(task,Fs,"Del(\"SysTemp.*\");",
|
||||
1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
JobResScan(tempc,&r);
|
||||
} else {
|
||||
Free(prj_file);
|
||||
st=DirFile(doc->filename.name,"Load","HC.Z");
|
||||
prj_file=FileNameAbs(st,FUF_Z_OR_NOT_Z);
|
||||
Free(st);
|
||||
if (FileFind(prj_file))
|
||||
st=MStrPrint("\"$$WW,1$$\";ExeFile(\"%s\",CCF_JUST_LOAD);",prj_file);
|
||||
else
|
||||
st=MStrPrint("\"$$WW,1$$\";ExeFile(\"%s\",CCF_JUST_LOAD);",
|
||||
doc->filename.name);
|
||||
tempc=TaskExe(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER);
|
||||
Free(st);
|
||||
if (JobResScan(tempc,&r) && r)
|
||||
okay=TRUE;
|
||||
}
|
||||
Free(prj_file);
|
||||
}
|
||||
if (!okay) {
|
||||
PopUpOk("Has Errors");
|
||||
while (LBts(&sys_semas[SYS_SEMA_FIX],0))
|
||||
Yield;
|
||||
ToFileLine(dbg.fix_file_line,&st,&i);
|
||||
LBtr(&sys_semas[SYS_SEMA_FIX],0);
|
||||
if (!StrCmp(st,doc->filename.name))
|
||||
goto_line_num=i;
|
||||
Free(st);
|
||||
}
|
||||
break;
|
||||
case EF_REINDENT:
|
||||
start_y=doc->cur_entry->y;
|
||||
EdReplaceTroubleAll(doc,TRUE,FALSE);
|
||||
DocLineNumGoTo(doc,start_y+1);
|
||||
if (EdGoToFun(doc,FALSE,FALSE)) {
|
||||
start_y=doc->cur_entry->y;
|
||||
indent=EdRICode(doc);
|
||||
DocUnlock(doc);
|
||||
if (beep) {
|
||||
Snd(2000); Sleep(150); Snd(0);
|
||||
Sleep(100);
|
||||
Snd(2000); Sleep(150); Snd(0);
|
||||
}
|
||||
DocLock(doc);
|
||||
EdRemFunLeadingSpace(doc);
|
||||
DocLineNumGoTo(doc,start_y+1);
|
||||
doc_e=doc->cur_entry;
|
||||
end_y=start_y+indent->total_cnt;
|
||||
while (start_y<=doc_e->y<end_y) {
|
||||
if (doc_e!=doc && doc_e!=doc->cur_entry &&
|
||||
!(doc_e->de_flags&(DOCEG_DONT_EDIT-DOCEF_SCROLLING_X))) {
|
||||
if (doc_e->type_u8==DOCT_NEW_LINE||
|
||||
doc_e->type_u8==DOCT_SOFT_NEW_LINE)
|
||||
start_of_line=TRUE;
|
||||
else {
|
||||
if (start_of_line) {
|
||||
i=QueVectU8Get(indent,doc_e->y)*C_INDENT_SPACES;
|
||||
x=doc_e->x+1;
|
||||
while (i>8) {
|
||||
doc_ne=DocEntryNewBase(doc,
|
||||
DOCT_TAB|doc->settings_head.dft_text_attr<<8,,
|
||||
x,doc_e->y,doc_e->page_line_num);
|
||||
MemCpy(&doc_ne->settings,
|
||||
&doc_e->settings,sizeof(CDocSettings));
|
||||
QueIns(doc_ne,doc_e->last);
|
||||
i-=8;
|
||||
x+=8;
|
||||
}
|
||||
if (i>0) {
|
||||
b=MAlloc(i+1,doc->mem_task);
|
||||
MemSet(b,CH_SPACE,i);
|
||||
b[i]=0;
|
||||
doc_ne=DocEntryNewBase(doc,
|
||||
DOCT_TEXT|doc->settings_head.dft_text_attr<<8,,
|
||||
x,doc_e->y,doc_e->page_line_num);
|
||||
doc_ne->tag=b;
|
||||
doc_ne->max_col=1;
|
||||
MemCpy(&doc_ne->settings,
|
||||
&doc_e->settings,sizeof(CDocSettings));
|
||||
QueIns(doc_ne,doc_e->last);
|
||||
}
|
||||
}
|
||||
start_of_line=FALSE;
|
||||
}
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
QueVectU8Del(indent);
|
||||
}
|
||||
start_y=doc->cur_entry->y;
|
||||
EdReplaceTroubleAll(doc,FALSE,FALSE);
|
||||
DocLineNumGoTo(doc,start_y+1);
|
||||
break;
|
||||
case EF_RENUM_ASM:
|
||||
if (EdGoToFun(doc,FALSE,TRUE)) {
|
||||
if (EdCurU8(doc)=='{') {
|
||||
EdCursorRight(doc);
|
||||
DocRecalc(doc);
|
||||
} else if (EdCurU8(doc)==':') {
|
||||
EdCursorRight(doc);
|
||||
if (EdCurU8(doc)==':')
|
||||
EdCursorRight(doc);
|
||||
DocRecalc(doc);
|
||||
}
|
||||
DocUnlock(doc);
|
||||
if (beep) {
|
||||
Snd(2000); Sleep(150); Snd(0);
|
||||
Sleep(100);
|
||||
Snd(2000); Sleep(150); Snd(0);
|
||||
}
|
||||
DocLock(doc);
|
||||
EdRenumAsm(doc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
DocRecalc(doc);
|
||||
DocLineNumGoTo(doc,goto_line_num);
|
||||
|
||||
DocUnlock(doc);
|
||||
if (!unlock)
|
||||
DocLock(doc);
|
||||
if (task)
|
||||
Kill(task,FALSE);
|
||||
}
|
||||
|
||||
U0 EdPopUpChSC(I64 *_ch,I64 *_sc)
|
||||
{
|
||||
I64 sc;
|
||||
"Press A Key\n";
|
||||
DocPut->flags|=DOCF_MIN_SIZE;
|
||||
do GetMsg(_ch,&sc,1<<MSG_KEY_DOWN);
|
||||
while (sc.u8[0]==SC_SHIFT || sc.u8[0]==SC_CTRL || sc.u8[0]==SC_ALT);
|
||||
*_sc=sc;
|
||||
}
|
||||
|
||||
U0 EdChSC(CDoc *doc)
|
||||
{
|
||||
I64 ch,sc;
|
||||
U8 buf[STR_LEN];
|
||||
StrPrint(buf,"EdPopUpChSC(%d,%d);",&ch,&sc);
|
||||
PopUp(buf,Fs);
|
||||
if (ch==CH_BACKSPACE)
|
||||
DocPrint(doc,"CH_BACKSPACE,0x%X",sc);
|
||||
else if (ch=='\n')
|
||||
DocPrint(doc,"'\n',0x%X",sc);
|
||||
else if (CH_CTRLA<=ch<=CH_CTRLZ)
|
||||
DocPrint(doc,"CH_CTRL%C,0x%X",ch+'@',sc);
|
||||
else if (ch=='$$')
|
||||
DocPrint(doc,"'$$$$',0x%X",sc);
|
||||
else if (ch=='\\')
|
||||
DocPrint(doc,"'\\\\',0x%X",sc);
|
||||
else if (ch=='\'')
|
||||
DocPrint(doc,"'\\\'',0x%X",sc);
|
||||
else if (ch==CH_ESC)
|
||||
DocPrint(doc,"CH_ESC,0x%X",sc);
|
||||
else if (ch==CH_SHIFT_ESC)
|
||||
DocPrint(doc,"CH_SHIFT_ESC,0x%X",sc);
|
||||
else if (ch==CH_SPACE)
|
||||
DocPrint(doc,"CH_SPACE,0x%X",sc);
|
||||
else if (ch==CH_SHIFT_SPACE)
|
||||
DocPrint(doc,"CH_SHIFT_SPACE,0x%X",sc);
|
||||
else if (Bt(chars_bmp_displayable,ch))
|
||||
DocPrint(doc,"'%c',0x%X",ch,sc);
|
||||
else
|
||||
DocPrint(doc,"0x%X,0x%X",ch,sc);
|
||||
}
|
||||
|
||||
U0 EdCodeTools(CDoc *doc)
|
||||
{
|
||||
I64 tool_action=PopUpEdFmt;
|
||||
switch (tool_action) {
|
||||
case EF_CMP_CHK:
|
||||
case EF_REINDENT:
|
||||
case EF_RENUM_ASM:
|
||||
EdCodeTools2(doc,tool_action);
|
||||
break;
|
||||
case EF_CTRL_SLIDER:
|
||||
TemplateCtrlSlider(doc);
|
||||
break;
|
||||
case EF_CH_SC:
|
||||
EdChSC(doc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
#help_index "DolDoc/Task;StdOut/Task"
|
||||
public CDoc *DocPut(CTask *task=NULL)
|
||||
{//Current document that StdOut Put() goes to.
|
||||
//Basically, StdOut unless double buffering.
|
||||
CDoc *res;
|
||||
if (!task) task=Fs;
|
||||
if ((res=task->put_doc) && res->doc_signature==DOC_SIGNATURE_VAL)
|
||||
return res;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CDoc *DocDisplay(CTask *task=NULL)
|
||||
{//StdOut displayed unless double buffering.
|
||||
CDoc *res;
|
||||
if (!task) task=Fs;
|
||||
if ((res=task->display_doc) && res->doc_signature==DOC_SIGNATURE_VAL)
|
||||
return res;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CDoc *DocBorder(CTask *task=NULL)
|
||||
{//Doc holding border of window text.
|
||||
CDoc *res;
|
||||
if (!task) task=Fs;
|
||||
if ((res=task->border_doc) && res->doc_signature==DOC_SIGNATURE_VAL)
|
||||
return res;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CDoc *DocDblBufStart(CTask *task=NULL)
|
||||
{//See $LK,"::/Demo/Spy.CPP"$
|
||||
Bool unlock_ddoc;
|
||||
CDoc *pdoc=DocPut(task),*ddoc=DocDisplay(task),*res;
|
||||
if (!pdoc || !ddoc || pdoc!=ddoc)
|
||||
res=NULL; //Already Double buffering
|
||||
else {
|
||||
if (!task) task=Fs;
|
||||
unlock_ddoc=DocLock(ddoc); //dont change during winupdate, so lock DocPut$WW,0$
|
||||
res=DocNew(,task);
|
||||
res->win_task =ddoc->win_task;
|
||||
res->max_entries =ddoc->max_entries;
|
||||
MemCpy(res->find_replace,ddoc->find_replace,sizeof(CEdFindText));
|
||||
MemCpy(&res->filename,&ddoc->filename,sizeof(CEdFileName));
|
||||
res->left_click_link =ddoc->left_click_link;
|
||||
res->right_click_link =ddoc->right_click_link;
|
||||
res->user_put_data =ddoc->user_put_data;
|
||||
res->user_put_key =ddoc->user_put_key;
|
||||
res->user_put_s =ddoc->user_put_s;
|
||||
res->parent_doc =ddoc->parent_doc;
|
||||
res->desc =ddoc->desc;
|
||||
res->user_data =ddoc->user_data;
|
||||
res->flags|=ddoc->flags&DOCG_DBL_BUF_FLAGS | DOCF_DONT_SHOW;
|
||||
task->put_doc=res;
|
||||
if (unlock_ddoc)
|
||||
DocUnlock(ddoc);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public Bool DocDblBufEnd(CTask *task=NULL)
|
||||
{//See $LK,"::/Demo/Spy.CPP"$
|
||||
Bool res=FALSE;
|
||||
CDoc *pdoc=DocPut(task),*ddoc=DocDisplay(task);
|
||||
if (pdoc && ddoc && pdoc!=ddoc) {//Double buffering?
|
||||
if (!task) task=Fs;
|
||||
ddoc->flags|=DOCF_DONT_SHOW;
|
||||
pdoc->flags&=~DOCF_DONT_SHOW;
|
||||
DocLock(ddoc);
|
||||
task->display_doc=pdoc;
|
||||
DocUnlock(ddoc);
|
||||
DocDel(ddoc);
|
||||
res=TRUE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public Bool DocDblBufSwap(CTask *task=NULL)
|
||||
{//See $LK,"::/Demo/Spy.CPP"$
|
||||
Bool res=FALSE;
|
||||
CDoc *pdoc=DocPut(task),*ddoc=DocDisplay(task);
|
||||
if (pdoc && ddoc && pdoc!=ddoc) {//Double buffering?
|
||||
if (!task) task=Fs;
|
||||
ddoc->flags|=DOCF_DONT_SHOW;
|
||||
pdoc->flags&=~DOCF_DONT_SHOW;
|
||||
DocLock(ddoc);
|
||||
task->display_doc=pdoc;
|
||||
DocUnlock(ddoc);
|
||||
DocRst(ddoc,TRUE);
|
||||
MemCpy(ddoc->find_replace,pdoc->find_replace,sizeof(CEdFindText));
|
||||
MemCpy(&ddoc->filename,&pdoc->filename,sizeof(CEdFileName));
|
||||
ddoc->max_entries =pdoc->max_entries;
|
||||
ddoc->flags =pdoc->flags&DOCG_DBL_BUF_FLAGS |
|
||||
ddoc->flags&~DOCG_DBL_BUF_FLAGS;
|
||||
ddoc->left_click_link =pdoc->left_click_link;
|
||||
ddoc->right_click_link =pdoc->right_click_link;
|
||||
ddoc->user_put_data =pdoc->user_put_data;
|
||||
ddoc->user_put_key =pdoc->user_put_key;
|
||||
ddoc->user_put_s =pdoc->user_put_s;
|
||||
ddoc->desc =pdoc->desc;
|
||||
ddoc->user_data =pdoc->user_data;
|
||||
task->put_doc=ddoc;
|
||||
res=TRUE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
#help_index "DolDoc/Task;StdOut/Task"
|
||||
public CDoc *DocPut(CTask *task=NULL)
|
||||
{//Current document that StdOut Put() goes to.
|
||||
//Basically, StdOut unless double buffering.
|
||||
CDoc *res;
|
||||
if (!task) task=Fs;
|
||||
if ((res=task->put_doc) && res->doc_signature==DOC_SIGNATURE_VAL)
|
||||
return res;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CDoc *DocDisplay(CTask *task=NULL)
|
||||
{//StdOut displayed unless double buffering.
|
||||
CDoc *res;
|
||||
if (!task) task=Fs;
|
||||
if ((res=task->display_doc) && res->doc_signature==DOC_SIGNATURE_VAL)
|
||||
return res;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CDoc *DocBorder(CTask *task=NULL)
|
||||
{//Doc holding border of window text.
|
||||
CDoc *res;
|
||||
if (!task) task=Fs;
|
||||
if ((res=task->border_doc) && res->doc_signature==DOC_SIGNATURE_VAL)
|
||||
return res;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CDoc *DocDblBufStart(CTask *task=NULL)
|
||||
{//See $LK,"::/Demo/Spy.HC"$
|
||||
Bool unlock_ddoc;
|
||||
CDoc *pdoc=DocPut(task),*ddoc=DocDisplay(task),*res;
|
||||
if (!pdoc || !ddoc || pdoc!=ddoc)
|
||||
res=NULL; //Already Double buffering
|
||||
else {
|
||||
if (!task) task=Fs;
|
||||
unlock_ddoc=DocLock(ddoc); //dont change during winupdate, so lock DocPut$WW,0$
|
||||
res=DocNew(,task);
|
||||
res->win_task =ddoc->win_task;
|
||||
res->max_entries =ddoc->max_entries;
|
||||
MemCpy(res->find_replace,ddoc->find_replace,sizeof(CEdFindText));
|
||||
MemCpy(&res->filename,&ddoc->filename,sizeof(CEdFileName));
|
||||
res->left_click_link =ddoc->left_click_link;
|
||||
res->right_click_link =ddoc->right_click_link;
|
||||
res->user_put_data =ddoc->user_put_data;
|
||||
res->user_put_key =ddoc->user_put_key;
|
||||
res->user_put_s =ddoc->user_put_s;
|
||||
res->parent_doc =ddoc->parent_doc;
|
||||
res->desc =ddoc->desc;
|
||||
res->user_data =ddoc->user_data;
|
||||
res->flags|=ddoc->flags&DOCG_DBL_BUF_FLAGS | DOCF_DONT_SHOW;
|
||||
task->put_doc=res;
|
||||
if (unlock_ddoc)
|
||||
DocUnlock(ddoc);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public Bool DocDblBufEnd(CTask *task=NULL)
|
||||
{//See $LK,"::/Demo/Spy.HC"$
|
||||
Bool res=FALSE;
|
||||
CDoc *pdoc=DocPut(task),*ddoc=DocDisplay(task);
|
||||
if (pdoc && ddoc && pdoc!=ddoc) {//Double buffering?
|
||||
if (!task) task=Fs;
|
||||
ddoc->flags|=DOCF_DONT_SHOW;
|
||||
pdoc->flags&=~DOCF_DONT_SHOW;
|
||||
DocLock(ddoc);
|
||||
task->display_doc=pdoc;
|
||||
DocUnlock(ddoc);
|
||||
DocDel(ddoc);
|
||||
res=TRUE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public Bool DocDblBufSwap(CTask *task=NULL)
|
||||
{//See $LK,"::/Demo/Spy.HC"$
|
||||
Bool res=FALSE;
|
||||
CDoc *pdoc=DocPut(task),*ddoc=DocDisplay(task);
|
||||
if (pdoc && ddoc && pdoc!=ddoc) {//Double buffering?
|
||||
if (!task) task=Fs;
|
||||
ddoc->flags|=DOCF_DONT_SHOW;
|
||||
pdoc->flags&=~DOCF_DONT_SHOW;
|
||||
DocLock(ddoc);
|
||||
task->display_doc=pdoc;
|
||||
DocUnlock(ddoc);
|
||||
DocRst(ddoc,TRUE);
|
||||
MemCpy(ddoc->find_replace,pdoc->find_replace,sizeof(CEdFindText));
|
||||
MemCpy(&ddoc->filename,&pdoc->filename,sizeof(CEdFileName));
|
||||
ddoc->max_entries =pdoc->max_entries;
|
||||
ddoc->flags =pdoc->flags&DOCG_DBL_BUF_FLAGS |
|
||||
ddoc->flags&~DOCG_DBL_BUF_FLAGS;
|
||||
ddoc->left_click_link =pdoc->left_click_link;
|
||||
ddoc->right_click_link =pdoc->right_click_link;
|
||||
ddoc->user_put_data =pdoc->user_put_data;
|
||||
ddoc->user_put_key =pdoc->user_put_key;
|
||||
ddoc->user_put_s =pdoc->user_put_s;
|
||||
ddoc->desc =pdoc->desc;
|
||||
ddoc->user_data =pdoc->user_data;
|
||||
task->put_doc=ddoc;
|
||||
res=TRUE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -1,250 +0,0 @@
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
|
||||
public Bool View()
|
||||
{//Go live for user interaction until <ESC> or <SHIFT-ESC>.
|
||||
I64 ch;
|
||||
do ch=DocGetKey;
|
||||
while (ch!=CH_ESC && ch!=CH_SHIFT_ESC);
|
||||
return ch==CH_ESC;
|
||||
}
|
||||
|
||||
#help_index "DolDoc"
|
||||
U8 *EdOverStrikeCB(CDoc *,CDocEntry *doc_e,CTask *mem_task)
|
||||
{
|
||||
CDoc *doc=doc_e->user_data;
|
||||
U8 *st=MAlloc(8,mem_task);
|
||||
if (doc->flags & DOCF_OVERSTRIKE)
|
||||
*st='O';
|
||||
else
|
||||
*st='Ä';
|
||||
st[1]=0;
|
||||
return st;
|
||||
}
|
||||
|
||||
U8 *EdFilterCB(CDoc *,CDocEntry *doc_e,CTask *mem_task)
|
||||
{
|
||||
CDoc *doc=doc_e->user_data;
|
||||
U8 *st=MAlloc(8,mem_task);
|
||||
if (doc->find_replace->filter_lines)
|
||||
*st='F';
|
||||
else
|
||||
*st='Ä';
|
||||
st[1]=0;
|
||||
return st;
|
||||
}
|
||||
|
||||
U8 *EdDollarCB(CDoc *,CDocEntry *doc_e,CTask *mem_task)
|
||||
{
|
||||
CDoc *doc=doc_e->user_data;
|
||||
U8 *st=MAlloc(8,mem_task);
|
||||
if (doc->flags & DOCF_IN_DOLLAR)
|
||||
*st='$$';
|
||||
else
|
||||
*st='Ä';
|
||||
st[1]=0;
|
||||
return st;
|
||||
}
|
||||
|
||||
U8 *EdMoreCB(CDoc *,CDocEntry *doc_e,CTask *mem_task)
|
||||
{
|
||||
CDoc *doc=doc_e->user_data;
|
||||
U8 *st=MAlloc(8,mem_task);
|
||||
if (doc->flags&DOCF_MORE)
|
||||
StrCpy(st,"MoreÄ");
|
||||
else
|
||||
StrCpy(st,"ÄÄÄÄÄ");
|
||||
return st;
|
||||
}
|
||||
|
||||
U8 *EdDollarTypeCB(CDoc *,CDocEntry *doc_e,CTask *mem_task)
|
||||
{
|
||||
CDoc *doc=doc_e->user_data;
|
||||
U8 *src=DefineSub(doc->cur_entry->type_u8,"ST_DOC_CMDS"),
|
||||
*st=CAlloc(8,mem_task);
|
||||
if (doc->cur_entry==doc)
|
||||
src="EOF";
|
||||
else if (!src)
|
||||
src="ERR";
|
||||
StrPrint(st,"%-3ts",src);
|
||||
return st;
|
||||
}
|
||||
|
||||
public Bool DocEd(CDoc *doc,I64 dof_flags=0)
|
||||
{//Live for user interaction. End on <ESC> or <SHIFT-ESC>.
|
||||
CDoc *old_put_doc =DocPut,
|
||||
*old_display_doc=DocDisplay,
|
||||
*old_border_doc =DocBorder,*bdoc;
|
||||
CDocEntry *doc_e;
|
||||
I64 old_attr=Fs->text_attr,
|
||||
old_top =Fs->win_top, old_bottom=Fs->win_bottom,
|
||||
old_left=Fs->win_left,old_right =Fs->win_right,
|
||||
old_title_src=Fs->title_src;
|
||||
Bool res,unlock;
|
||||
U8 *old_task_title;
|
||||
if (dof_flags&DOF_WIN_MAX)
|
||||
WinMax;
|
||||
|
||||
unlock=DocLock(doc);
|
||||
doc->win_task=Fs;
|
||||
bdoc=DocNew;
|
||||
bdoc->flags|=DOCF_BORDER_DOC;
|
||||
DocPrint(bdoc,"$$CM+TY+LX+NC,0,-1$$");
|
||||
DocPrint(bdoc,"$$TX+RX+BD,\"[X]\"$$");
|
||||
DocPrint(bdoc,"$$BK,1$$$$TX+LX+BD,\"MENU\"$$$$BK,0$$");
|
||||
|
||||
old_task_title=StrNew(Fs->task_title);
|
||||
if (Fs->title_src!=TTS_LOCKED_CONST) {
|
||||
Fs->title_src=TTS_ED_FILENAME;
|
||||
MemCpy(Fs->task_title,doc->filename.name,STR_LEN-1);
|
||||
}
|
||||
doc_e=DocPrint(bdoc,"$$DA-TRM-P+BD+RD+CX+IV,LEN=STR_LEN-1,"
|
||||
"A=\"%%s...\",SCX=16$$");
|
||||
doc_e->data=&Fs->task_title;
|
||||
DocDataFmt(bdoc,doc_e);
|
||||
|
||||
if (doc->flags & DOCF_ALLOW_UNDO) {
|
||||
DocPrint(bdoc,"$$CM+BY+LX+NC,1,1$$");
|
||||
doc_e=DocPrint(bdoc,"$$DA+BD+RD-TRM,RT=U32,A=\"Undo:%%03d\"$$\n");
|
||||
doc_e->data=&doc->undo_cnt;
|
||||
DocDataFmt(bdoc,doc_e);
|
||||
}
|
||||
|
||||
DocPrint(bdoc,"$$CM+BY+RX+NC,-30,1$$");
|
||||
doc_e=DocPrint(bdoc,"$$TX+BD+TC,\" \"$$");
|
||||
doc_e->user_data=doc;
|
||||
doc_e->tag_cb=&EdMoreCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+BD+TC,\" \"$$");
|
||||
doc_e->user_data=doc;
|
||||
doc_e->tag_cb=&EdDollarTypeCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+BD+TC,\" \"$$");
|
||||
doc_e->user_data=doc;
|
||||
doc_e->tag_cb=&EdFilterCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+BD+TC,\" \"$$");
|
||||
doc_e->user_data=doc;
|
||||
doc_e->tag_cb=&EdOverStrikeCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+BD+TC,\" \"$$");
|
||||
doc_e->user_data=doc;
|
||||
doc_e->tag_cb=&EdDollarCB;
|
||||
doc_e=DocPrint(bdoc,"$$DA+BD+RD-TRM,A=\"Line:%%04d \"$$");
|
||||
doc_e->data=&doc->line;
|
||||
DocDataFmt(bdoc,doc_e);
|
||||
doc_e=DocPrint(bdoc,"$$DA+BD+RD-TRM,A=\"Col:%%04d\"$$\n");
|
||||
doc_e->data=&doc->col;
|
||||
DocDataFmt(bdoc,doc_e);
|
||||
|
||||
DocRecalc(bdoc);
|
||||
DocRecalc(doc);
|
||||
if (!(dof_flags&DOF_DONT_HOME))
|
||||
DocTop(doc);
|
||||
Fs->border_doc=bdoc;
|
||||
if (doc!=old_display_doc)
|
||||
doc->parent_doc=old_display_doc;
|
||||
Fs->put_doc=Fs->display_doc=doc;
|
||||
if (!(dof_flags&DOF_DONT_TEXT_ATTR))
|
||||
Fs->text_attr=DOC_ATTR_DFT_TEXT;
|
||||
if (!(dof_flags&DOF_DONT_SHOW)) {
|
||||
LBts(&Fs->display_flags,DISPLAYf_SHOW);
|
||||
WinZBufUpdate;
|
||||
}
|
||||
if (dof_flags&DOF_MIN_SIZE)
|
||||
doc->flags|=DOCF_MIN_SIZE;
|
||||
|
||||
DocUnlock(doc);
|
||||
if (!(dof_flags&DOF_DONT_WINMGR_SYNC)) {
|
||||
WinMgrSync(2,TRUE);
|
||||
if (doc->flags&DOCF_MIN_SIZE)
|
||||
WinMgrSync(2,TRUE);
|
||||
}
|
||||
res=View;
|
||||
|
||||
DocLock(doc);
|
||||
if (res) {
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type_u8==DOCT_DATA || doc_e->type_u8==DOCT_CHECK_BOX)
|
||||
DocDataScan(doc,doc_e);
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
Fs->border_doc =old_border_doc;
|
||||
Fs->display_doc=old_display_doc;
|
||||
Fs->put_doc =old_put_doc;
|
||||
Fs->text_attr =old_attr;
|
||||
if (Fs->title_src!=TTS_LOCKED_CONST) {
|
||||
Fs->title_src =old_title_src;
|
||||
StrCpy(Fs->task_title,old_task_title);
|
||||
}
|
||||
Free(old_task_title);
|
||||
DocDel(bdoc);
|
||||
if (dof_flags&DOF_MIN_SIZE) {
|
||||
WinHorz(old_left,old_right);
|
||||
WinVert(old_top,old_bottom);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Cmd Line (Typically);Cmd Line (Typically)"
|
||||
public Bool Ed(U8 *link_st,I64 edf_dof_flags=0)
|
||||
{//Invoke document editor.
|
||||
U8 *filename,*needle_str;
|
||||
I64 i,num;
|
||||
Bool cont,res=FALSE;
|
||||
CDoc *doc;
|
||||
|
||||
switch (i=EdLinkCvt(link_st,&filename,&needle_str,&num,edf_dof_flags)) {
|
||||
case -1:
|
||||
break;
|
||||
case LK_DEF:
|
||||
doc=DocNew;
|
||||
doc->desc='DictDef';
|
||||
ACDDefsPut(doc,filename,num);
|
||||
goto ej_doc;
|
||||
case LK_HELP_INDEX:
|
||||
doc=DocNew;
|
||||
doc->desc='HelpIndx';
|
||||
DocHelpIndex(doc,filename);
|
||||
ej_doc:
|
||||
if (!(edf_dof_flags&EDF_BAIL)) {
|
||||
DocEd(doc);
|
||||
DocDel(doc);
|
||||
}
|
||||
if (!(edf_dof_flags&EDF_WAS_WRITE))
|
||||
res=TRUE;
|
||||
break;
|
||||
default:
|
||||
if (IsRaw)
|
||||
res=EdLite(filename,num,edf_dof_flags);
|
||||
else {
|
||||
cont=TRUE;
|
||||
if (!(edf_dof_flags&EDF_BAIL) && !(LK_DOC<=i<=LK_DOC_LINE) &&
|
||||
!FilesFindMatch(filename,FILEMASK_TXT) &&
|
||||
!PopUpCancelOk(ST_WARN_ST "Not Text File\n\n"))
|
||||
cont=FALSE;
|
||||
if (cont)
|
||||
res=DocFileEd(i,filename,needle_str,&num,edf_dof_flags);
|
||||
}
|
||||
}
|
||||
Free(filename);
|
||||
Free(needle_str);
|
||||
return res;
|
||||
}
|
||||
|
||||
public Bool Plain(U8 *filename,I64 edf_dof_flags=0)
|
||||
{//Edit document in plain text mode, so dollar signs are not special.
|
||||
Bool res;
|
||||
U8 *st=MStrPrint("PI:%s",filename);
|
||||
res=Ed(st,edf_dof_flags);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
#help_index "DolDoc;Task/Srv/Exe"
|
||||
public I64 PopUpEd(U8 *filename,CTask *parent=NULL,CTask **_pu_task=NULL)
|
||||
{//Create PopUp win task and edit a doc.
|
||||
U8 *st=MStrPrint("Ed(\"%Q\");",filename);
|
||||
I64 res=PopUp(st,parent,_pu_task);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
|
||||
public Bool View()
|
||||
{//Go live for user interaction until <ESC> or <SHIFT-ESC>.
|
||||
I64 ch;
|
||||
do ch=DocGetKey;
|
||||
while (ch!=CH_ESC && ch!=CH_SHIFT_ESC);
|
||||
return ch==CH_ESC;
|
||||
}
|
||||
|
||||
#help_index "DolDoc"
|
||||
U8 *EdOverStrikeCB(CDoc *,CDocEntry *doc_e,CTask *mem_task)
|
||||
{
|
||||
CDoc *doc=doc_e->user_data;
|
||||
U8 *st=MAlloc(8,mem_task);
|
||||
if (doc->flags & DOCF_OVERSTRIKE)
|
||||
*st='O';
|
||||
else
|
||||
*st='Ä';
|
||||
st[1]=0;
|
||||
return st;
|
||||
}
|
||||
|
||||
U8 *EdFilterCB(CDoc *,CDocEntry *doc_e,CTask *mem_task)
|
||||
{
|
||||
CDoc *doc=doc_e->user_data;
|
||||
U8 *st=MAlloc(8,mem_task);
|
||||
if (doc->find_replace->filter_lines)
|
||||
*st='F';
|
||||
else
|
||||
*st='Ä';
|
||||
st[1]=0;
|
||||
return st;
|
||||
}
|
||||
|
||||
U8 *EdDollarCB(CDoc *,CDocEntry *doc_e,CTask *mem_task)
|
||||
{
|
||||
CDoc *doc=doc_e->user_data;
|
||||
U8 *st=MAlloc(8,mem_task);
|
||||
if (doc->flags & DOCF_IN_DOLLAR)
|
||||
*st='$$';
|
||||
else
|
||||
*st='Ä';
|
||||
st[1]=0;
|
||||
return st;
|
||||
}
|
||||
|
||||
U8 *EdMoreCB(CDoc *,CDocEntry *doc_e,CTask *mem_task)
|
||||
{
|
||||
CDoc *doc=doc_e->user_data;
|
||||
U8 *st=MAlloc(8,mem_task);
|
||||
if (doc->flags&DOCF_MORE)
|
||||
StrCpy(st,"MoreÄ");
|
||||
else
|
||||
StrCpy(st,"ÄÄÄÄÄ");
|
||||
return st;
|
||||
}
|
||||
|
||||
U8 *EdDollarTypeCB(CDoc *,CDocEntry *doc_e,CTask *mem_task)
|
||||
{
|
||||
CDoc *doc=doc_e->user_data;
|
||||
U8 *src=DefineSub(doc->cur_entry->type_u8,"ST_DOC_CMDS"),
|
||||
*st=CAlloc(8,mem_task);
|
||||
if (doc->cur_entry==doc)
|
||||
src="EOF";
|
||||
else if (!src)
|
||||
src="ERR";
|
||||
StrPrint(st,"%-3ts",src);
|
||||
return st;
|
||||
}
|
||||
|
||||
public Bool DocEd(CDoc *doc,I64 dof_flags=0)
|
||||
{//Live for user interaction. End on <ESC> or <SHIFT-ESC>.
|
||||
CDoc *old_put_doc =DocPut,
|
||||
*old_display_doc=DocDisplay,
|
||||
*old_border_doc =DocBorder,*bdoc;
|
||||
CDocEntry *doc_e;
|
||||
I64 old_attr=Fs->text_attr,
|
||||
old_top =Fs->win_top, old_bottom=Fs->win_bottom,
|
||||
old_left=Fs->win_left,old_right =Fs->win_right,
|
||||
old_title_src=Fs->title_src;
|
||||
Bool res,unlock;
|
||||
U8 *old_task_title;
|
||||
if (dof_flags&DOF_WIN_MAX)
|
||||
WinMax;
|
||||
|
||||
unlock=DocLock(doc);
|
||||
doc->win_task=Fs;
|
||||
bdoc=DocNew;
|
||||
bdoc->flags|=DOCF_BORDER_DOC;
|
||||
DocPrint(bdoc,"$$CM+TY+LX+NC,0,-1$$");
|
||||
DocPrint(bdoc,"$$TX+RX+BD,\"[X]\"$$");
|
||||
DocPrint(bdoc,"$$BK,1$$$$TX+LX+BD,\"MENU\"$$$$BK,0$$");
|
||||
|
||||
old_task_title=StrNew(Fs->task_title);
|
||||
if (Fs->title_src!=TTS_LOCKED_CONST) {
|
||||
Fs->title_src=TTS_ED_FILENAME;
|
||||
MemCpy(Fs->task_title,doc->filename.name,STR_LEN-1);
|
||||
}
|
||||
doc_e=DocPrint(bdoc,"$$DA-TRM-P+BD+RD+CX+IV,LEN=STR_LEN-1,"
|
||||
"A=\"%%s...\",SCX=16$$");
|
||||
doc_e->data=&Fs->task_title;
|
||||
DocDataFmt(bdoc,doc_e);
|
||||
|
||||
if (doc->flags & DOCF_ALLOW_UNDO) {
|
||||
DocPrint(bdoc,"$$CM+BY+LX+NC,1,1$$");
|
||||
doc_e=DocPrint(bdoc,"$$DA+BD+RD-TRM,RT=U32,A=\"Undo:%%03d\"$$\n");
|
||||
doc_e->data=&doc->undo_cnt;
|
||||
DocDataFmt(bdoc,doc_e);
|
||||
}
|
||||
|
||||
DocPrint(bdoc,"$$CM+BY+RX+NC,-30,1$$");
|
||||
doc_e=DocPrint(bdoc,"$$TX+BD+TC,\" \"$$");
|
||||
doc_e->user_data=doc;
|
||||
doc_e->tag_cb=&EdMoreCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+BD+TC,\" \"$$");
|
||||
doc_e->user_data=doc;
|
||||
doc_e->tag_cb=&EdDollarTypeCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+BD+TC,\" \"$$");
|
||||
doc_e->user_data=doc;
|
||||
doc_e->tag_cb=&EdFilterCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+BD+TC,\" \"$$");
|
||||
doc_e->user_data=doc;
|
||||
doc_e->tag_cb=&EdOverStrikeCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+BD+TC,\" \"$$");
|
||||
doc_e->user_data=doc;
|
||||
doc_e->tag_cb=&EdDollarCB;
|
||||
doc_e=DocPrint(bdoc,"$$DA+BD+RD-TRM,A=\"Line:%%04d \"$$");
|
||||
doc_e->data=&doc->line;
|
||||
DocDataFmt(bdoc,doc_e);
|
||||
doc_e=DocPrint(bdoc,"$$DA+BD+RD-TRM,A=\"Col:%%04d\"$$\n");
|
||||
doc_e->data=&doc->col;
|
||||
DocDataFmt(bdoc,doc_e);
|
||||
|
||||
DocRecalc(bdoc);
|
||||
DocRecalc(doc);
|
||||
if (!(dof_flags&DOF_DONT_HOME))
|
||||
DocTop(doc);
|
||||
Fs->border_doc=bdoc;
|
||||
if (doc!=old_display_doc)
|
||||
doc->parent_doc=old_display_doc;
|
||||
Fs->put_doc=Fs->display_doc=doc;
|
||||
if (!(dof_flags&DOF_DONT_TEXT_ATTR))
|
||||
Fs->text_attr=DOC_ATTR_DFT_TEXT;
|
||||
if (!(dof_flags&DOF_DONT_SHOW)) {
|
||||
LBts(&Fs->display_flags,DISPLAYf_SHOW);
|
||||
WinZBufUpdate;
|
||||
}
|
||||
if (dof_flags&DOF_MIN_SIZE)
|
||||
doc->flags|=DOCF_MIN_SIZE;
|
||||
|
||||
DocUnlock(doc);
|
||||
if (!(dof_flags&DOF_DONT_WINMGR_SYNC)) {
|
||||
WinMgrSync(2,TRUE);
|
||||
if (doc->flags&DOCF_MIN_SIZE)
|
||||
WinMgrSync(2,TRUE);
|
||||
}
|
||||
res=View;
|
||||
|
||||
DocLock(doc);
|
||||
if (res) {
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type_u8==DOCT_DATA || doc_e->type_u8==DOCT_CHECK_BOX)
|
||||
DocDataScan(doc,doc_e);
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
Fs->border_doc =old_border_doc;
|
||||
Fs->display_doc=old_display_doc;
|
||||
Fs->put_doc =old_put_doc;
|
||||
Fs->text_attr =old_attr;
|
||||
if (Fs->title_src!=TTS_LOCKED_CONST) {
|
||||
Fs->title_src =old_title_src;
|
||||
StrCpy(Fs->task_title,old_task_title);
|
||||
}
|
||||
Free(old_task_title);
|
||||
DocDel(bdoc);
|
||||
if (dof_flags&DOF_MIN_SIZE) {
|
||||
WinHorz(old_left,old_right);
|
||||
WinVert(old_top,old_bottom);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Cmd Line (Typically);Cmd Line (Typically)"
|
||||
public Bool Ed(U8 *link_st,I64 edf_dof_flags=0)
|
||||
{//Invoke document editor.
|
||||
U8 *filename,*needle_str;
|
||||
I64 i,num;
|
||||
Bool cont,res=FALSE;
|
||||
CDoc *doc;
|
||||
|
||||
switch (i=EdLinkCvt(link_st,&filename,&needle_str,&num,edf_dof_flags)) {
|
||||
case -1:
|
||||
break;
|
||||
case LK_DEF:
|
||||
doc=DocNew;
|
||||
doc->desc='DictDef';
|
||||
ACDDefsPut(doc,filename,num);
|
||||
goto ej_doc;
|
||||
case LK_HELP_INDEX:
|
||||
doc=DocNew;
|
||||
doc->desc='HelpIndx';
|
||||
DocHelpIdx(doc,filename);
|
||||
ej_doc:
|
||||
if (!(edf_dof_flags&EDF_BAIL)) {
|
||||
DocEd(doc);
|
||||
DocDel(doc);
|
||||
}
|
||||
if (!(edf_dof_flags&EDF_WAS_WRITE))
|
||||
res=TRUE;
|
||||
break;
|
||||
default:
|
||||
if (IsRaw)
|
||||
res=EdLite(filename,num,edf_dof_flags);
|
||||
else {
|
||||
cont=TRUE;
|
||||
if (!(edf_dof_flags&EDF_BAIL) && !(LK_DOC<=i<=LK_DOC_LINE) &&
|
||||
!FilesFindMatch(filename,FILEMASK_TXT) &&
|
||||
!PopUpCancelOk(ST_WARN_ST "Not Text File\n\n"))
|
||||
cont=FALSE;
|
||||
if (cont)
|
||||
res=DocFileEd(i,filename,needle_str,&num,edf_dof_flags);
|
||||
}
|
||||
}
|
||||
Free(filename);
|
||||
Free(needle_str);
|
||||
return res;
|
||||
}
|
||||
|
||||
public Bool Plain(U8 *filename,I64 edf_dof_flags=0)
|
||||
{//Edit document in plain text mode, so dollar signs are not special.
|
||||
Bool res;
|
||||
U8 *st=MStrPrint("PI:%s",filename);
|
||||
res=Ed(st,edf_dof_flags);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
#help_index "DolDoc;Task/Srv/Exe"
|
||||
public I64 PopUpEd(U8 *filename,CTask *parent=NULL,CTask **_pu_task=NULL)
|
||||
{//Create PopUp win task and edit a doc.
|
||||
U8 *st=MStrPrint("Ed(\"%Q\");",filename);
|
||||
I64 res=PopUp(st,parent,_pu_task);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
@@ -1,344 +0,0 @@
|
||||
#help_index "DolDoc/Form"
|
||||
|
||||
U0 DocFormFwd(CDoc *doc,Bool giveup=FALSE)
|
||||
{
|
||||
CDocEntry *doc_e=doc->cur_entry,*doc_e2=doc_e;
|
||||
if (doc->flags & DOCF_FORM) {
|
||||
if (doc_e==doc) goto ff_recover;
|
||||
while (!Bt(doldoc.type_flags_form,doc_e->type_u8) &&
|
||||
!(doc_e->de_flags&DOCEF_LINK) ||
|
||||
doc_e->de_flags&DOCEF_SKIP_IN_FORM) {
|
||||
doc_e=doc_e->next;
|
||||
if (doc_e==doc) {
|
||||
ff_recover:
|
||||
doc->cur_col=0;
|
||||
if (!giveup) {
|
||||
doc->cur_entry=doc_e->last;
|
||||
DocFormBwd(doc,TRUE);
|
||||
} else
|
||||
doc->cur_entry=doc;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (doc_e->type_u8==DOCT_INDENT)
|
||||
doc_e=doc_e->next;
|
||||
if (doc_e!=doc_e2) {
|
||||
doc->cur_col=doc_e->min_col;
|
||||
doc->cur_entry=doc_e;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DocFormBwd(CDoc *doc,Bool giveup=FALSE)
|
||||
{
|
||||
CDocEntry *doc_e=doc->cur_entry,*doc_e2=doc_e;
|
||||
if (doc->flags & DOCF_FORM) {
|
||||
while (!Bt(doldoc.type_flags_form,doc_e->type_u8) &&
|
||||
!(doc_e->de_flags&DOCEF_LINK) ||
|
||||
doc_e->de_flags&DOCEF_SKIP_IN_FORM) {
|
||||
doc_e=doc_e->last;
|
||||
if (doc_e==doc) {
|
||||
doc->cur_col=0;
|
||||
if (!giveup) {
|
||||
doc->cur_entry=doc_e->next;
|
||||
DocFormFwd(doc,TRUE);
|
||||
} else
|
||||
doc->cur_entry=doc;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (doc_e->type_u8==DOCT_INDENT)
|
||||
doc_e=doc_e->next;
|
||||
if (doc_e!=doc_e2) {
|
||||
doc->cur_col=doc_e->min_col;
|
||||
doc->cur_entry=doc_e;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DocDataFmt(CDoc *doc,CDocEntry *doc_e,I64 d=DOCM_CANCEL)
|
||||
{
|
||||
I64 i;
|
||||
U8 *ptr,*ptr2;
|
||||
CHashDefineStr *temph;
|
||||
if (doc_e->type_u8==DOCT_DATA && doc_e->de_flags&DOCEF_AUX_STR ||
|
||||
doc_e->type_u8==DOCT_CHECK_BOX || doc_e->de_flags & DOCEF_LST) {
|
||||
if (d==DOCM_CANCEL) {
|
||||
if (doc_e->de_flags&DOCEF_DEREF_DATA &&
|
||||
!(doc_e->de_flags&DOCEF_REMALLOC_DATA)) {
|
||||
if (!(ptr=doc_e->data)) return;
|
||||
} else
|
||||
ptr=&doc_e->data;
|
||||
switch (doc_e->raw_type) {
|
||||
case RT_I0:
|
||||
case RT_U0: d=0; break;
|
||||
case RT_I8: d=*ptr(I8 *); break;
|
||||
case RT_U8: d=*ptr(U8 *); break;
|
||||
case RT_I16: d=*ptr(I16 *); break;
|
||||
case RT_U16: d=*ptr(U16 *); break;
|
||||
case RT_I32: d=*ptr(I32 *); break;
|
||||
case RT_U32: d=*ptr(U32 *); break;
|
||||
default: d=*ptr(I64 *);
|
||||
}
|
||||
}
|
||||
if (doc_e->type_u8==DOCT_DATA) {
|
||||
if (doc_e->de_flags & DOCEF_REMALLOC_DATA) {
|
||||
ptr=MStrPrint(doc_e->aux_str,d,doc_e->my_fmt_data);
|
||||
i=StrLen(ptr);
|
||||
if (!doc_e->data) {
|
||||
doc_e->data=CAlloc(2,doc->mem_task);
|
||||
doc_e->len=MSize(doc_e->data)-2;
|
||||
}
|
||||
if (doc_e->len+doc_e->min_col>i)
|
||||
MemCpy(doc_e->tag,ptr,i+1);
|
||||
else {
|
||||
ptr2=MAlloc(i+8,doc->mem_task);
|
||||
doc_e->len=MSize(ptr2)-doc_e->min_col-2; //See $LK,"DataTagWidth",A="FA:::/Adam/DolDoc/DocPlain.CPP,DataTagWidth"$
|
||||
MemCpy(ptr2,ptr,i+1);
|
||||
Free(doc_e->tag);
|
||||
doc_e->tag=ptr2;
|
||||
}
|
||||
Free(ptr);
|
||||
} else {
|
||||
StrPrint(doc_e->tag,doc_e->aux_str,d,doc_e->my_fmt_data);
|
||||
i=StrLen(doc_e->tag);
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_HAS_TERMINATOR) {
|
||||
doc_e->tag[i++]='_';
|
||||
doc_e->tag[i]=0;
|
||||
}
|
||||
doc_e->max_col=i;
|
||||
} else if (doc_e->de_flags & DOCEF_LST) {
|
||||
if (doc_e->de_flags & DOCEF_DEFINE && (temph=HashFind(doc_e->define_str,
|
||||
doc->win_task->hash_table,HTT_DEFINE_STR)) && 0<=d<temph->cnt) {
|
||||
ptr=MStrPrint("[%s]",temph->sub_idx[d]);
|
||||
Free(doc_e->tag);
|
||||
doc_e->tag=StrNew(ptr,doc->mem_task);
|
||||
Free(ptr);
|
||||
} else {
|
||||
Free(doc_e->tag);
|
||||
doc_e->tag=StrNew("[]",doc->mem_task);
|
||||
}
|
||||
} else {
|
||||
if (d)
|
||||
doc_e->de_flags|=DOCEF_CHECKED_COLLAPSED;
|
||||
else
|
||||
doc_e->de_flags&=~DOCEF_CHECKED_COLLAPSED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 DocDataScan(CDoc *doc,CDocEntry *doc_e)
|
||||
{
|
||||
I64 i,d;
|
||||
U8 *ptr,*ptr1,*ptr2;
|
||||
CHashDefineStr *temph;
|
||||
if (doc_e->type_u8==DOCT_DATA && doc_e->de_flags&DOCEF_AUX_STR ||
|
||||
doc_e->type_u8==DOCT_CHECK_BOX || doc_e->de_flags & DOCEF_LST) {
|
||||
if (doc_e->de_flags&DOCEF_DEREF_DATA &&
|
||||
!(doc_e->de_flags&DOCEF_REMALLOC_DATA)) {
|
||||
if (!(ptr=doc_e->data)) return;
|
||||
} else
|
||||
ptr=&doc_e->data;
|
||||
if (doc_e->type_u8==DOCT_DATA) {
|
||||
i=StrLen(doc_e->tag);
|
||||
if (doc_e->de_flags & DOCEF_HAS_TERMINATOR)
|
||||
doc_e->tag[--i]=0;
|
||||
if (i>doc_e->len+doc_e->min_col)
|
||||
doc_e->tag[doc_e->len+doc_e->min_col]=0;
|
||||
if (RT_I8<=doc_e->raw_type<=RT_U32) {
|
||||
StrScan(doc_e->tag,doc_e->aux_str,&d,doc_e->my_fmt_data);
|
||||
if (doc_e->de_flags & DOCEF_HAS_TERMINATOR)
|
||||
doc_e->tag[i]='_';
|
||||
} else if (RT_I64<=doc_e->raw_type<=RT_UF64) {
|
||||
if (doc_e->de_flags & DOCEF_REMALLOC_DATA) {
|
||||
ptr=MAlloc(i-doc_e->min_col+8,doc->mem_task);
|
||||
MemCpy(ptr,doc_e->tag+doc_e->min_col,i-doc_e->min_col+1);
|
||||
Free(doc_e->data);
|
||||
doc_e->data=ptr;
|
||||
doc_e->len=MSize(ptr)-1;
|
||||
} else
|
||||
StrScan(doc_e->tag,doc_e->aux_str,ptr,doc_e->my_fmt_data);
|
||||
if (doc_e->de_flags & DOCEF_HAS_TERMINATOR)
|
||||
doc_e->tag[i]='_';
|
||||
return;
|
||||
}
|
||||
} else if (doc_e->de_flags & DOCEF_LST) {
|
||||
d=0;
|
||||
if (doc_e->tag && doc_e->de_flags & DOCEF_DEFINE &&
|
||||
(temph=HashFind(doc_e->define_str,
|
||||
doc->win_task->hash_table,HTT_DEFINE_STR))) {
|
||||
ptr1=ptr2=StrNew(doc_e->tag);
|
||||
if (*ptr2=='[') {
|
||||
ptr2++;
|
||||
i=StrLen(ptr2);
|
||||
if (ptr2[i-1]==']')
|
||||
ptr2[i-1]=0;
|
||||
}
|
||||
d=LstMatch(ptr2,temph->data);
|
||||
Free(ptr1);
|
||||
}
|
||||
} else {
|
||||
if (doc_e->de_flags & DOCEF_CHECKED_COLLAPSED)
|
||||
d=TRUE;
|
||||
else
|
||||
d=FALSE;
|
||||
}
|
||||
switch (doc_e->raw_type) {
|
||||
case RT_I8:
|
||||
case RT_U8:
|
||||
*ptr(U8 *)=d;
|
||||
case RT_I0:
|
||||
case RT_U0:
|
||||
break;
|
||||
case RT_I16:
|
||||
case RT_U16:
|
||||
*ptr(U16 *)=d;
|
||||
break;
|
||||
case RT_I32:
|
||||
case RT_U32:
|
||||
*ptr(U32 *)=d;
|
||||
break;
|
||||
default:
|
||||
*ptr(I64 *)=d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;StdIn/DolDoc"
|
||||
public Bool DocForm(U8 *_d,U8 *class_name=lastclass,
|
||||
I64 dof_flags=0,U8 *header=NULL,U8 *footer=NULL)
|
||||
{//User input. Supply a class name that has fmtstr definitions.
|
||||
//See $LK,"::/Demo/DolDoc/Form.CPP"$ and $LK,"::/Demo/LastClass.CPP"$.
|
||||
CMemberLst *ml;
|
||||
CDocEntry *doc_e;
|
||||
U8 *fmtstr;
|
||||
CHashClass *tempc,*tempc2;
|
||||
CDoc *doc;
|
||||
Bool res=FALSE;
|
||||
I64 old_border_src=Fs->border_src,has_action;
|
||||
if (!(tempc=HashFind(class_name,Fs->hash_table,HTT_CLASS)))
|
||||
return FALSE;
|
||||
doc=DocNew;
|
||||
doc->desc='Form';
|
||||
if (header) DocPrint(doc,"%s",header);
|
||||
doc->flags|=DOCF_OVERSTRIKE|DOCF_FORM;
|
||||
if (dof_flags&DOF_MIN_SIZE)
|
||||
doc->flags|=DOCF_MIN_SIZE;
|
||||
ml=tempc->member_lst_and_root;
|
||||
while (ml) {
|
||||
if ((fmtstr=MemberMetaData("fmtstr",ml)) &&
|
||||
(doc_e=DocPrint(doc,"%s",fmtstr))) {
|
||||
tempc2=ml->member_class;
|
||||
if ((doc_e->type_u8==DOCT_DATA || doc_e->type_u8==DOCT_LST ||
|
||||
doc_e->type_u8==DOCT_CHECK_BOX) && !tempc2->ptr_stars_cnt) {
|
||||
tempc2=OptClassFwd(tempc2);
|
||||
tempc2-=tempc2->ptr_stars_cnt;
|
||||
if (tempc2->type & HTT_INTERNAL_TYPE) {
|
||||
if (ml->dim.next) { //Array
|
||||
if (tempc2->raw_type==RT_U8 &&
|
||||
LBtr(&doc_e->de_flags,&DOCEf_DFT_LEN)) {
|
||||
doc_e->len=ml->dim.total_cnt;
|
||||
if (doc_e->de_flags&DOCEF_HAS_TERMINATOR)
|
||||
doc_e->len--;
|
||||
Free(doc_e->tag); //See $LK,"DataTagWidth",A="FA:::/Adam/DolDoc/DocPlain.CPP,DataTagWidth"$
|
||||
doc_e->tag=MAlloc(doc_e->len+doc_e->min_col+2,
|
||||
doc->mem_task); //+2 because "_\0"
|
||||
}
|
||||
} else if (LBtr(&doc_e->de_flags,DOCEf_DFT_RAW_TYPE))
|
||||
doc_e->raw_type=tempc2->raw_type;
|
||||
}
|
||||
}
|
||||
if (doc_e->de_flags&DOCEF_REMALLOC_DATA) {
|
||||
doc_e->user_data=_d+ml->offset;
|
||||
doc_e->data=*doc_e->user_data(U8 **);
|
||||
} else
|
||||
doc_e->data=_d+ml->offset;
|
||||
doc_e->my_fmt_data=MemberMetaData("fmtdata",ml);
|
||||
DocDataFmt(doc,doc_e);
|
||||
}
|
||||
ml=ml->next;
|
||||
}
|
||||
if (footer) DocPrint(doc,"%s",footer);
|
||||
if (doc->head.next!=doc) {
|
||||
Fs->border_src=BDS_CONST;
|
||||
DocRecalc(doc);
|
||||
if (DocEd(doc,dof_flags)) {
|
||||
doc_e=doc->cur_entry;
|
||||
res=TRUE;
|
||||
if (doc_e!=doc) {
|
||||
if (DocEntryRun(doc,doc_e,TRUE,&has_action)==DOCM_CANCEL && has_action)
|
||||
res=FALSE;
|
||||
DocUnlock(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->de_flags&DOCEF_REMALLOC_DATA) {
|
||||
*doc_e->user_data(U8 **)=doc_e->data;
|
||||
doc_e->data=NULL;
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
DocDel(doc);
|
||||
Fs->border_src=old_border_src;
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 DocMenuEndTaskCB()
|
||||
{
|
||||
WinToTop;
|
||||
throw;
|
||||
}
|
||||
|
||||
public I64 DocMenu(CDoc *m,I64 dof_flags=0)
|
||||
{//Run menu chooser doc. Returns menu doc unlocked.
|
||||
U8 *old_end_cb=Fs->task_end_cb;
|
||||
Bool old_break_shift_esc=LBts(&Fs->task_flags,TASKf_BREAK_TO_SHIFT_ESC);
|
||||
CDocEntry *doc_e;
|
||||
I64 old_border_src=Fs->border_src,res=DOCM_CANCEL,has_action;
|
||||
Fs->task_end_cb=&DocMenuEndTaskCB;
|
||||
try {
|
||||
if (m) {
|
||||
m->desc='Menu';
|
||||
Fs->border_src=BDS_CONST;
|
||||
dm_restart:
|
||||
if (DocEd(m,dof_flags)) {
|
||||
doc_e=m->cur_entry;
|
||||
if (doc_e!=m) {
|
||||
res=DocEntryRun(m,doc_e,TRUE,&has_action);
|
||||
DocUnlock(m);
|
||||
if (!has_action) {
|
||||
res=DOCM_CANCEL;
|
||||
dof_flags|=DOF_DONT_HOME;
|
||||
goto dm_restart;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
if (!Fs->except_ch) {
|
||||
if (!(dof_flags & DOF_INTERCEPT_TASK_END))
|
||||
Exit;
|
||||
Fs->catch_except=TRUE;
|
||||
}
|
||||
}
|
||||
LBEqu(&Fs->task_flags,TASKf_BREAK_TO_SHIFT_ESC,old_break_shift_esc);
|
||||
Fs->border_src=old_border_src;
|
||||
Fs->task_end_cb=old_end_cb;
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 PopUpMenu(CDoc *doc,I64 dof_flags=0)
|
||||
{//Run menu chooser doc in PopUp win task.
|
||||
doc->flags|=DOCF_MIN_SIZE | DOCF_FORM;
|
||||
return PopUpPrint("DocMenu(0x%X,0x%X);",doc,dof_flags);
|
||||
}
|
||||
|
||||
public Bool PopUpForm(U8 *_d,U8 *class_name=lastclass,
|
||||
I64 dof_flags=DOF_MIN_SIZE,U8 *header=NULL,U8 *footer=NULL)
|
||||
{//See $LK,"::/Demo/DolDoc/Form.CPP"$ and $LK,"::/Demo/LastClass.CPP"$.
|
||||
return PopUpPrint("DocForm(0x%X,0x%X,0x%X,0x%X,0x%X);",_d,class_name,
|
||||
dof_flags,header,footer);
|
||||
}
|
||||
@@ -0,0 +1,344 @@
|
||||
#help_index "DolDoc/Form"
|
||||
|
||||
U0 DocFormFwd(CDoc *doc,Bool giveup=FALSE)
|
||||
{
|
||||
CDocEntry *doc_e=doc->cur_entry,*doc_e2=doc_e;
|
||||
if (doc->flags & DOCF_FORM) {
|
||||
if (doc_e==doc) goto ff_recover;
|
||||
while (!Bt(doldoc.type_flags_form,doc_e->type_u8) &&
|
||||
!(doc_e->de_flags&DOCEF_LINK) ||
|
||||
doc_e->de_flags&DOCEF_SKIP_IN_FORM) {
|
||||
doc_e=doc_e->next;
|
||||
if (doc_e==doc) {
|
||||
ff_recover:
|
||||
doc->cur_col=0;
|
||||
if (!giveup) {
|
||||
doc->cur_entry=doc_e->last;
|
||||
DocFormBwd(doc,TRUE);
|
||||
} else
|
||||
doc->cur_entry=doc;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (doc_e->type_u8==DOCT_INDENT)
|
||||
doc_e=doc_e->next;
|
||||
if (doc_e!=doc_e2) {
|
||||
doc->cur_col=doc_e->min_col;
|
||||
doc->cur_entry=doc_e;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DocFormBwd(CDoc *doc,Bool giveup=FALSE)
|
||||
{
|
||||
CDocEntry *doc_e=doc->cur_entry,*doc_e2=doc_e;
|
||||
if (doc->flags & DOCF_FORM) {
|
||||
while (!Bt(doldoc.type_flags_form,doc_e->type_u8) &&
|
||||
!(doc_e->de_flags&DOCEF_LINK) ||
|
||||
doc_e->de_flags&DOCEF_SKIP_IN_FORM) {
|
||||
doc_e=doc_e->last;
|
||||
if (doc_e==doc) {
|
||||
doc->cur_col=0;
|
||||
if (!giveup) {
|
||||
doc->cur_entry=doc_e->next;
|
||||
DocFormFwd(doc,TRUE);
|
||||
} else
|
||||
doc->cur_entry=doc;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (doc_e->type_u8==DOCT_INDENT)
|
||||
doc_e=doc_e->next;
|
||||
if (doc_e!=doc_e2) {
|
||||
doc->cur_col=doc_e->min_col;
|
||||
doc->cur_entry=doc_e;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DocDataFmt(CDoc *doc,CDocEntry *doc_e,I64 d=DOCM_CANCEL)
|
||||
{
|
||||
I64 i;
|
||||
U8 *ptr,*ptr2;
|
||||
CHashDefineStr *temph;
|
||||
if (doc_e->type_u8==DOCT_DATA && doc_e->de_flags&DOCEF_AUX_STR ||
|
||||
doc_e->type_u8==DOCT_CHECK_BOX || doc_e->de_flags & DOCEF_LST) {
|
||||
if (d==DOCM_CANCEL) {
|
||||
if (doc_e->de_flags&DOCEF_DEREF_DATA &&
|
||||
!(doc_e->de_flags&DOCEF_REMALLOC_DATA)) {
|
||||
if (!(ptr=doc_e->data)) return;
|
||||
} else
|
||||
ptr=&doc_e->data;
|
||||
switch (doc_e->raw_type) {
|
||||
case RT_I0:
|
||||
case RT_U0: d=0; break;
|
||||
case RT_I8: d=*ptr(I8 *); break;
|
||||
case RT_U8: d=*ptr(U8 *); break;
|
||||
case RT_I16: d=*ptr(I16 *); break;
|
||||
case RT_U16: d=*ptr(U16 *); break;
|
||||
case RT_I32: d=*ptr(I32 *); break;
|
||||
case RT_U32: d=*ptr(U32 *); break;
|
||||
default: d=*ptr(I64 *);
|
||||
}
|
||||
}
|
||||
if (doc_e->type_u8==DOCT_DATA) {
|
||||
if (doc_e->de_flags & DOCEF_REMALLOC_DATA) {
|
||||
ptr=MStrPrint(doc_e->aux_str,d,doc_e->my_fmt_data);
|
||||
i=StrLen(ptr);
|
||||
if (!doc_e->data) {
|
||||
doc_e->data=CAlloc(2,doc->mem_task);
|
||||
doc_e->len=MSize(doc_e->data)-2;
|
||||
}
|
||||
if (doc_e->len+doc_e->min_col>i)
|
||||
MemCpy(doc_e->tag,ptr,i+1);
|
||||
else {
|
||||
ptr2=MAlloc(i+8,doc->mem_task);
|
||||
doc_e->len=MSize(ptr2)-doc_e->min_col-2; //See $LK,"DataTagWidth",A="FA:::/Adam/DolDoc/DocPlain.HC,DataTagWidth"$
|
||||
MemCpy(ptr2,ptr,i+1);
|
||||
Free(doc_e->tag);
|
||||
doc_e->tag=ptr2;
|
||||
}
|
||||
Free(ptr);
|
||||
} else {
|
||||
StrPrint(doc_e->tag,doc_e->aux_str,d,doc_e->my_fmt_data);
|
||||
i=StrLen(doc_e->tag);
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_HAS_TERMINATOR) {
|
||||
doc_e->tag[i++]='_';
|
||||
doc_e->tag[i]=0;
|
||||
}
|
||||
doc_e->max_col=i;
|
||||
} else if (doc_e->de_flags & DOCEF_LST) {
|
||||
if (doc_e->de_flags & DOCEF_DEFINE && (temph=HashFind(doc_e->define_str,
|
||||
doc->win_task->hash_table,HTT_DEFINE_STR)) && 0<=d<temph->cnt) {
|
||||
ptr=MStrPrint("[%s]",temph->sub_idx[d]);
|
||||
Free(doc_e->tag);
|
||||
doc_e->tag=StrNew(ptr,doc->mem_task);
|
||||
Free(ptr);
|
||||
} else {
|
||||
Free(doc_e->tag);
|
||||
doc_e->tag=StrNew("[]",doc->mem_task);
|
||||
}
|
||||
} else {
|
||||
if (d)
|
||||
doc_e->de_flags|=DOCEF_CHECKED_COLLAPSED;
|
||||
else
|
||||
doc_e->de_flags&=~DOCEF_CHECKED_COLLAPSED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 DocDataScan(CDoc *doc,CDocEntry *doc_e)
|
||||
{
|
||||
I64 i,d;
|
||||
U8 *ptr,*ptr1,*ptr2;
|
||||
CHashDefineStr *temph;
|
||||
if (doc_e->type_u8==DOCT_DATA && doc_e->de_flags&DOCEF_AUX_STR ||
|
||||
doc_e->type_u8==DOCT_CHECK_BOX || doc_e->de_flags & DOCEF_LST) {
|
||||
if (doc_e->de_flags&DOCEF_DEREF_DATA &&
|
||||
!(doc_e->de_flags&DOCEF_REMALLOC_DATA)) {
|
||||
if (!(ptr=doc_e->data)) return;
|
||||
} else
|
||||
ptr=&doc_e->data;
|
||||
if (doc_e->type_u8==DOCT_DATA) {
|
||||
i=StrLen(doc_e->tag);
|
||||
if (doc_e->de_flags & DOCEF_HAS_TERMINATOR)
|
||||
doc_e->tag[--i]=0;
|
||||
if (i>doc_e->len+doc_e->min_col)
|
||||
doc_e->tag[doc_e->len+doc_e->min_col]=0;
|
||||
if (RT_I8<=doc_e->raw_type<=RT_U32) {
|
||||
StrScan(doc_e->tag,doc_e->aux_str,&d,doc_e->my_fmt_data);
|
||||
if (doc_e->de_flags & DOCEF_HAS_TERMINATOR)
|
||||
doc_e->tag[i]='_';
|
||||
} else if (RT_I64<=doc_e->raw_type<=RT_UF64) {
|
||||
if (doc_e->de_flags & DOCEF_REMALLOC_DATA) {
|
||||
ptr=MAlloc(i-doc_e->min_col+8,doc->mem_task);
|
||||
MemCpy(ptr,doc_e->tag+doc_e->min_col,i-doc_e->min_col+1);
|
||||
Free(doc_e->data);
|
||||
doc_e->data=ptr;
|
||||
doc_e->len=MSize(ptr)-1;
|
||||
} else
|
||||
StrScan(doc_e->tag,doc_e->aux_str,ptr,doc_e->my_fmt_data);
|
||||
if (doc_e->de_flags & DOCEF_HAS_TERMINATOR)
|
||||
doc_e->tag[i]='_';
|
||||
return;
|
||||
}
|
||||
} else if (doc_e->de_flags & DOCEF_LST) {
|
||||
d=0;
|
||||
if (doc_e->tag && doc_e->de_flags & DOCEF_DEFINE &&
|
||||
(temph=HashFind(doc_e->define_str,
|
||||
doc->win_task->hash_table,HTT_DEFINE_STR))) {
|
||||
ptr1=ptr2=StrNew(doc_e->tag);
|
||||
if (*ptr2=='[') {
|
||||
ptr2++;
|
||||
i=StrLen(ptr2);
|
||||
if (ptr2[i-1]==']')
|
||||
ptr2[i-1]=0;
|
||||
}
|
||||
d=LstMatch(ptr2,temph->data);
|
||||
Free(ptr1);
|
||||
}
|
||||
} else {
|
||||
if (doc_e->de_flags & DOCEF_CHECKED_COLLAPSED)
|
||||
d=TRUE;
|
||||
else
|
||||
d=FALSE;
|
||||
}
|
||||
switch (doc_e->raw_type) {
|
||||
case RT_I8:
|
||||
case RT_U8:
|
||||
*ptr(U8 *)=d;
|
||||
case RT_I0:
|
||||
case RT_U0:
|
||||
break;
|
||||
case RT_I16:
|
||||
case RT_U16:
|
||||
*ptr(U16 *)=d;
|
||||
break;
|
||||
case RT_I32:
|
||||
case RT_U32:
|
||||
*ptr(U32 *)=d;
|
||||
break;
|
||||
default:
|
||||
*ptr(I64 *)=d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;StdIn/DolDoc"
|
||||
public Bool DocForm(U8 *_d,U8 *class_name=lastclass,
|
||||
I64 dof_flags=0,U8 *header=NULL,U8 *footer=NULL)
|
||||
{//User input. Supply a class name that has fmtstr definitions.
|
||||
//See $LK,"::/Demo/DolDoc/Form.HC"$ and $LK,"::/Demo/LastClass.HC"$.
|
||||
CMemberLst *ml;
|
||||
CDocEntry *doc_e;
|
||||
U8 *fmtstr;
|
||||
CHashClass *tempc,*tempc2;
|
||||
CDoc *doc;
|
||||
Bool res=FALSE;
|
||||
I64 old_border_src=Fs->border_src,has_action;
|
||||
if (!(tempc=HashFind(class_name,Fs->hash_table,HTT_CLASS)))
|
||||
return FALSE;
|
||||
doc=DocNew;
|
||||
doc->desc='Form';
|
||||
if (header) DocPrint(doc,"%s",header);
|
||||
doc->flags|=DOCF_OVERSTRIKE|DOCF_FORM;
|
||||
if (dof_flags&DOF_MIN_SIZE)
|
||||
doc->flags|=DOCF_MIN_SIZE;
|
||||
ml=tempc->member_lst_and_root;
|
||||
while (ml) {
|
||||
if ((fmtstr=MemberMetaData("fmtstr",ml)) &&
|
||||
(doc_e=DocPrint(doc,"%s",fmtstr))) {
|
||||
tempc2=ml->member_class;
|
||||
if ((doc_e->type_u8==DOCT_DATA || doc_e->type_u8==DOCT_LST ||
|
||||
doc_e->type_u8==DOCT_CHECK_BOX) && !tempc2->ptr_stars_cnt) {
|
||||
tempc2=OptClassFwd(tempc2);
|
||||
tempc2-=tempc2->ptr_stars_cnt;
|
||||
if (tempc2->type & HTT_INTERNAL_TYPE) {
|
||||
if (ml->dim.next) { //Array
|
||||
if (tempc2->raw_type==RT_U8 &&
|
||||
LBtr(&doc_e->de_flags,&DOCEf_DFT_LEN)) {
|
||||
doc_e->len=ml->dim.total_cnt;
|
||||
if (doc_e->de_flags&DOCEF_HAS_TERMINATOR)
|
||||
doc_e->len--;
|
||||
Free(doc_e->tag); //See $LK,"DataTagWidth",A="FA:::/Adam/DolDoc/DocPlain.HC,DataTagWidth"$
|
||||
doc_e->tag=MAlloc(doc_e->len+doc_e->min_col+2,
|
||||
doc->mem_task); //+2 because "_\0"
|
||||
}
|
||||
} else if (LBtr(&doc_e->de_flags,DOCEf_DFT_RAW_TYPE))
|
||||
doc_e->raw_type=tempc2->raw_type;
|
||||
}
|
||||
}
|
||||
if (doc_e->de_flags&DOCEF_REMALLOC_DATA) {
|
||||
doc_e->user_data=_d+ml->offset;
|
||||
doc_e->data=*doc_e->user_data(U8 **);
|
||||
} else
|
||||
doc_e->data=_d+ml->offset;
|
||||
doc_e->my_fmt_data=MemberMetaData("fmtdata",ml);
|
||||
DocDataFmt(doc,doc_e);
|
||||
}
|
||||
ml=ml->next;
|
||||
}
|
||||
if (footer) DocPrint(doc,"%s",footer);
|
||||
if (doc->head.next!=doc) {
|
||||
Fs->border_src=BDS_CONST;
|
||||
DocRecalc(doc);
|
||||
if (DocEd(doc,dof_flags)) {
|
||||
doc_e=doc->cur_entry;
|
||||
res=TRUE;
|
||||
if (doc_e!=doc) {
|
||||
if (DocEntryRun(doc,doc_e,TRUE,&has_action)==DOCM_CANCEL && has_action)
|
||||
res=FALSE;
|
||||
DocUnlock(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->de_flags&DOCEF_REMALLOC_DATA) {
|
||||
*doc_e->user_data(U8 **)=doc_e->data;
|
||||
doc_e->data=NULL;
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
DocDel(doc);
|
||||
Fs->border_src=old_border_src;
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 DocMenuEndTaskCB()
|
||||
{
|
||||
WinToTop;
|
||||
throw;
|
||||
}
|
||||
|
||||
public I64 DocMenu(CDoc *m,I64 dof_flags=0)
|
||||
{//Run menu chooser doc. Returns menu doc unlocked.
|
||||
U8 *old_end_cb=Fs->task_end_cb;
|
||||
Bool old_break_shift_esc=LBts(&Fs->task_flags,TASKf_BREAK_TO_SHIFT_ESC);
|
||||
CDocEntry *doc_e;
|
||||
I64 old_border_src=Fs->border_src,res=DOCM_CANCEL,has_action;
|
||||
Fs->task_end_cb=&DocMenuEndTaskCB;
|
||||
try {
|
||||
if (m) {
|
||||
m->desc='Menu';
|
||||
Fs->border_src=BDS_CONST;
|
||||
dm_restart:
|
||||
if (DocEd(m,dof_flags)) {
|
||||
doc_e=m->cur_entry;
|
||||
if (doc_e!=m) {
|
||||
res=DocEntryRun(m,doc_e,TRUE,&has_action);
|
||||
DocUnlock(m);
|
||||
if (!has_action) {
|
||||
res=DOCM_CANCEL;
|
||||
dof_flags|=DOF_DONT_HOME;
|
||||
goto dm_restart;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
if (!Fs->except_ch) {
|
||||
if (!(dof_flags & DOF_INTERCEPT_TASK_END))
|
||||
Exit;
|
||||
Fs->catch_except=TRUE;
|
||||
}
|
||||
}
|
||||
LBEqu(&Fs->task_flags,TASKf_BREAK_TO_SHIFT_ESC,old_break_shift_esc);
|
||||
Fs->border_src=old_border_src;
|
||||
Fs->task_end_cb=old_end_cb;
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 PopUpMenu(CDoc *doc,I64 dof_flags=0)
|
||||
{//Run menu chooser doc in PopUp win task.
|
||||
doc->flags|=DOCF_MIN_SIZE | DOCF_FORM;
|
||||
return PopUpPrint("DocMenu(0x%X,0x%X);",doc,dof_flags);
|
||||
}
|
||||
|
||||
public Bool PopUpForm(U8 *_d,U8 *class_name=lastclass,
|
||||
I64 dof_flags=DOF_MIN_SIZE,U8 *header=NULL,U8 *footer=NULL)
|
||||
{//See $LK,"::/Demo/DolDoc/Form.HC"$ and $LK,"::/Demo/LastClass.HC"$.
|
||||
return PopUpPrint("DocForm(0x%X,0x%X,0x%X,0x%X,0x%X);",_d,class_name,
|
||||
dof_flags,header,footer);
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
#help_index "DolDoc/Misc"
|
||||
|
||||
U32 *DocHighlight(CDocEntry *doc_e,U8 *src,I64 len,I64 _temp_u32_attr)
|
||||
{//Be aware of $LK,"::/Demo/ToHtmlToTXTDemo/ToHtml.CPP"$.
|
||||
U32 *res=MAlloc((len+1)*sizeof(U32)),*dst=res;
|
||||
U8 *ptr;
|
||||
CDocSettings *s=&doc_e->settings;
|
||||
I64 ch,ch1,last_ch,temp_u32_attr,mask_temp_u32_attr=_temp_u32_attr&0xFFFFF000,
|
||||
comment_depth,brace_depth=s->brace_depth,paren_depth=s->paren_depth;
|
||||
CHash *temph;
|
||||
switch [s->state] {
|
||||
case DOCSS_NORMAL:
|
||||
hl_normal:
|
||||
while (len) {
|
||||
while (len && !Bt(chars_bmp_alpha_numeric,*src)) {
|
||||
temp_u32_attr=_temp_u32_attr;
|
||||
ch1=*src++;
|
||||
switch (ch1) {
|
||||
case '/':
|
||||
if (len>=2) {
|
||||
if (*src=='/') {
|
||||
temp_u32_attr=DOC_COLOR_COMMENT<<8|mask_temp_u32_attr;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
*dst++=*src++ +temp_u32_attr;
|
||||
len-=2;
|
||||
goto hl_cpp_comment;
|
||||
} else if (*src=='*') {
|
||||
temp_u32_attr=DOC_COLOR_COMMENT<<8|mask_temp_u32_attr;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
*dst++=*src++ +temp_u32_attr;
|
||||
len-=2;
|
||||
comment_depth=1;
|
||||
goto hl_comment;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '\'':
|
||||
temp_u32_attr=DOC_COLOR_QUOTE<<8|mask_temp_u32_attr;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
len--;
|
||||
goto hl_single_quote;
|
||||
case '\"':
|
||||
temp_u32_attr=DOC_COLOR_QUOTE<<8|mask_temp_u32_attr;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
len--;
|
||||
goto hl_dbl_quote;
|
||||
case '(':
|
||||
if (paren_depth++&1)
|
||||
temp_u32_attr=DOC_COLOR_ALT_TEXT<<8|mask_temp_u32_attr;
|
||||
break;
|
||||
case ')':
|
||||
if (--paren_depth&1)
|
||||
temp_u32_attr=DOC_COLOR_ALT_TEXT<<8|mask_temp_u32_attr;
|
||||
break;
|
||||
case '{':
|
||||
if (brace_depth++&1)
|
||||
temp_u32_attr=DOC_COLOR_ALT_TEXT<<8|mask_temp_u32_attr;
|
||||
break;
|
||||
case '}':
|
||||
if (--brace_depth&1)
|
||||
temp_u32_attr=DOC_COLOR_ALT_TEXT<<8|mask_temp_u32_attr;
|
||||
break;
|
||||
}
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
if (!--len) goto hl_normal_done;
|
||||
}
|
||||
ptr=src;
|
||||
while (len && Bt(chars_bmp_alpha_numeric,*src)) {
|
||||
src++;
|
||||
len--;
|
||||
}
|
||||
ch=*src;
|
||||
*src=0;
|
||||
if (temph=HashFind(ptr,cmp.asm_hash,
|
||||
HTT_KEYWORD|HTT_ASM_KEYWORD|HTT_OPCODE|HTT_REG)) {
|
||||
if (temph->type&(HTT_KEYWORD|HTT_ASM_KEYWORD|HTT_OPCODE))
|
||||
temp_u32_attr=DOC_COLOR_KEYWORD<<8|mask_temp_u32_attr;
|
||||
else
|
||||
temp_u32_attr=DOC_COLOR_KEYWORD2<<8|mask_temp_u32_attr;
|
||||
} else
|
||||
temp_u32_attr=_temp_u32_attr;
|
||||
while (ch1=*ptr++)
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
*src=ch;
|
||||
}
|
||||
hl_normal_done:
|
||||
s->state=DOCSS_NORMAL;
|
||||
s->comment_depth=0;
|
||||
break;
|
||||
case DOCSS_SINGLE_QUOTE:
|
||||
temp_u32_attr=DOC_COLOR_QUOTE<<8|mask_temp_u32_attr;
|
||||
hl_single_quote:
|
||||
last_ch=0;
|
||||
while (len--) {
|
||||
ch1=*src++;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
if (last_ch!='\\' && ch1=='\'')
|
||||
goto hl_normal;
|
||||
if (last_ch=='\\' && ch1=='\\')
|
||||
last_ch=0;
|
||||
else
|
||||
last_ch=ch1;
|
||||
}
|
||||
s->state=DOCSS_SINGLE_QUOTE;
|
||||
s->comment_depth=0;
|
||||
break;
|
||||
case DOCSS_DBL_QUOTE:
|
||||
temp_u32_attr=DOC_COLOR_QUOTE<<8|mask_temp_u32_attr;
|
||||
hl_dbl_quote:
|
||||
last_ch=0;
|
||||
while (len--) {
|
||||
ch1=*src++;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
if (last_ch!='\\' && ch1=='\"')
|
||||
goto hl_normal;
|
||||
if (last_ch=='\\' && ch1=='\\')
|
||||
last_ch=0;
|
||||
else
|
||||
last_ch=ch1;
|
||||
}
|
||||
s->state=DOCSS_DBL_QUOTE;
|
||||
s->comment_depth=0;
|
||||
break;
|
||||
case DOCSS_COMMENT:
|
||||
temp_u32_attr=DOC_COLOR_COMMENT<<8|mask_temp_u32_attr;
|
||||
comment_depth=s->comment_depth;
|
||||
hl_comment:
|
||||
last_ch=0;
|
||||
while (len--) {
|
||||
ch1=*src++;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
if (last_ch=='*' && ch1=='/') {
|
||||
if (!--comment_depth)
|
||||
goto hl_normal;
|
||||
} else if (last_ch=='/' && ch1=='*')
|
||||
comment_depth++;
|
||||
last_ch=ch1;
|
||||
}
|
||||
s->state=DOCSS_COMMENT;
|
||||
s->comment_depth=comment_depth;
|
||||
break;
|
||||
case DOCSS_CPP_Z_COMMENT:
|
||||
temp_u32_attr=DOC_COLOR_COMMENT<<8|mask_temp_u32_attr;
|
||||
hl_cpp_comment:
|
||||
while (len--)
|
||||
*dst++=*src++ +temp_u32_attr;
|
||||
s->state=DOCSS_CPP_Z_COMMENT;
|
||||
s->comment_depth=0;
|
||||
break;
|
||||
}
|
||||
s->paren_depth=paren_depth;
|
||||
s->brace_depth=brace_depth;
|
||||
*dst=0;
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
#help_index "DolDoc/Misc"
|
||||
|
||||
U32 *DocHighlight(CDocEntry *doc_e,U8 *src,I64 len,I64 _temp_u32_attr)
|
||||
{//Be aware of $LK,"::/Demo/ToHtmlToTXTDemo/ToHtml.HC"$.
|
||||
U32 *res=MAlloc((len+1)*sizeof(U32)),*dst=res;
|
||||
U8 *ptr;
|
||||
CDocSettings *s=&doc_e->settings;
|
||||
I64 ch,ch1,last_ch,temp_u32_attr,mask_temp_u32_attr=_temp_u32_attr&0xFFFFF000,
|
||||
comment_depth,brace_depth=s->brace_depth,paren_depth=s->paren_depth;
|
||||
CHash *temph;
|
||||
switch [s->state] {
|
||||
case DOCSS_NORMAL:
|
||||
hl_normal:
|
||||
while (len) {
|
||||
while (len && !Bt(chars_bmp_alpha_numeric,*src)) {
|
||||
temp_u32_attr=_temp_u32_attr;
|
||||
ch1=*src++;
|
||||
switch (ch1) {
|
||||
case '/':
|
||||
if (len>=2) {
|
||||
if (*src=='/') {
|
||||
temp_u32_attr=DOC_COLOR_COMMENT<<8|mask_temp_u32_attr;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
*dst++=*src++ +temp_u32_attr;
|
||||
len-=2;
|
||||
goto hl_cpp_comment;
|
||||
} else if (*src=='*') {
|
||||
temp_u32_attr=DOC_COLOR_COMMENT<<8|mask_temp_u32_attr;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
*dst++=*src++ +temp_u32_attr;
|
||||
len-=2;
|
||||
comment_depth=1;
|
||||
goto hl_comment;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '\'':
|
||||
temp_u32_attr=DOC_COLOR_QUOTE<<8|mask_temp_u32_attr;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
len--;
|
||||
goto hl_single_quote;
|
||||
case '\"':
|
||||
temp_u32_attr=DOC_COLOR_QUOTE<<8|mask_temp_u32_attr;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
len--;
|
||||
goto hl_dbl_quote;
|
||||
case '(':
|
||||
if (paren_depth++&1)
|
||||
temp_u32_attr=DOC_COLOR_ALT_TEXT<<8|mask_temp_u32_attr;
|
||||
break;
|
||||
case ')':
|
||||
if (--paren_depth&1)
|
||||
temp_u32_attr=DOC_COLOR_ALT_TEXT<<8|mask_temp_u32_attr;
|
||||
break;
|
||||
case '{':
|
||||
if (brace_depth++&1)
|
||||
temp_u32_attr=DOC_COLOR_ALT_TEXT<<8|mask_temp_u32_attr;
|
||||
break;
|
||||
case '}':
|
||||
if (--brace_depth&1)
|
||||
temp_u32_attr=DOC_COLOR_ALT_TEXT<<8|mask_temp_u32_attr;
|
||||
break;
|
||||
}
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
if (!--len) goto hl_normal_done;
|
||||
}
|
||||
ptr=src;
|
||||
while (len && Bt(chars_bmp_alpha_numeric,*src)) {
|
||||
src++;
|
||||
len--;
|
||||
}
|
||||
ch=*src;
|
||||
*src=0;
|
||||
if (temph=HashFind(ptr,cmp.asm_hash,
|
||||
HTT_KEYWORD|HTT_ASM_KEYWORD|HTT_OPCODE|HTT_REG)) {
|
||||
if (temph->type&(HTT_KEYWORD|HTT_ASM_KEYWORD|HTT_OPCODE))
|
||||
temp_u32_attr=DOC_COLOR_KEYWORD<<8|mask_temp_u32_attr;
|
||||
else
|
||||
temp_u32_attr=DOC_COLOR_KEYWORD2<<8|mask_temp_u32_attr;
|
||||
} else
|
||||
temp_u32_attr=_temp_u32_attr;
|
||||
while (ch1=*ptr++)
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
*src=ch;
|
||||
}
|
||||
hl_normal_done:
|
||||
s->state=DOCSS_NORMAL;
|
||||
s->comment_depth=0;
|
||||
break;
|
||||
case DOCSS_SINGLE_QUOTE:
|
||||
temp_u32_attr=DOC_COLOR_QUOTE<<8|mask_temp_u32_attr;
|
||||
hl_single_quote:
|
||||
last_ch=0;
|
||||
while (len--) {
|
||||
ch1=*src++;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
if (last_ch!='\\' && ch1=='\'')
|
||||
goto hl_normal;
|
||||
if (last_ch=='\\' && ch1=='\\')
|
||||
last_ch=0;
|
||||
else
|
||||
last_ch=ch1;
|
||||
}
|
||||
s->state=DOCSS_SINGLE_QUOTE;
|
||||
s->comment_depth=0;
|
||||
break;
|
||||
case DOCSS_DBL_QUOTE:
|
||||
temp_u32_attr=DOC_COLOR_QUOTE<<8|mask_temp_u32_attr;
|
||||
hl_dbl_quote:
|
||||
last_ch=0;
|
||||
while (len--) {
|
||||
ch1=*src++;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
if (last_ch!='\\' && ch1=='\"')
|
||||
goto hl_normal;
|
||||
if (last_ch=='\\' && ch1=='\\')
|
||||
last_ch=0;
|
||||
else
|
||||
last_ch=ch1;
|
||||
}
|
||||
s->state=DOCSS_DBL_QUOTE;
|
||||
s->comment_depth=0;
|
||||
break;
|
||||
case DOCSS_COMMENT:
|
||||
temp_u32_attr=DOC_COLOR_COMMENT<<8|mask_temp_u32_attr;
|
||||
comment_depth=s->comment_depth;
|
||||
hl_comment:
|
||||
last_ch=0;
|
||||
while (len--) {
|
||||
ch1=*src++;
|
||||
*dst++=ch1+temp_u32_attr;
|
||||
if (last_ch=='*' && ch1=='/') {
|
||||
if (!--comment_depth)
|
||||
goto hl_normal;
|
||||
} else if (last_ch=='/' && ch1=='*')
|
||||
comment_depth++;
|
||||
last_ch=ch1;
|
||||
}
|
||||
s->state=DOCSS_COMMENT;
|
||||
s->comment_depth=comment_depth;
|
||||
break;
|
||||
case DOCSS_CPP_Z_COMMENT:
|
||||
temp_u32_attr=DOC_COLOR_COMMENT<<8|mask_temp_u32_attr;
|
||||
hl_cpp_comment:
|
||||
while (len--)
|
||||
*dst++=*src++ +temp_u32_attr;
|
||||
s->state=DOCSS_CPP_Z_COMMENT;
|
||||
s->comment_depth=0;
|
||||
break;
|
||||
}
|
||||
s->paren_depth=paren_depth;
|
||||
s->brace_depth=brace_depth;
|
||||
*dst=0;
|
||||
return res;
|
||||
}
|
||||
@@ -1,385 +0,0 @@
|
||||
#help_index "DolDoc"
|
||||
|
||||
public Bool DocLock(CDoc *doc)
|
||||
{//Make this task have exclusive access to this doc.
|
||||
if (!Bt(&doc->locked_flags,DOClf_LOCKED) || doc->owning_task!=Fs) {
|
||||
while (LBts(&doc->locked_flags,DOClf_LOCKED))
|
||||
Yield;
|
||||
if (doc->owning_task!=Fs)
|
||||
LBEqu(&doc->flags,DOCf_BREAK_UNLOCKED,BreakLock(Fs));
|
||||
doc->owning_task=Fs;
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public Bool DocUnlock(CDoc *doc)
|
||||
{//Release exclusive lock on access to doc.
|
||||
Bool unlock_break;
|
||||
if (Bt(&doc->locked_flags,DOClf_LOCKED) && doc->owning_task==Fs) {
|
||||
doc->owning_task=0;
|
||||
unlock_break=Bt(&doc->flags,DOCf_BREAK_UNLOCKED);
|
||||
LBtr(&doc->locked_flags,DOClf_LOCKED);
|
||||
if (unlock_break)
|
||||
BreakUnlock(Fs);
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool IsEditableText(CDocEntry *doc_e)
|
||||
{
|
||||
if (doc_e->type_u8==DOCT_TEXT&&!(doc_e->de_flags&DOCEG_DONT_EDIT))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CDocEntry *DocEntryNewBase(CDoc *doc,I64 type,I64 de_flags=0,
|
||||
I64 x=0,I64 y=0,I64 page_line_num=0)
|
||||
{//See also $LK,"MAllocIdent",A="FF:::/Adam/DolDoc/DocRecalc.CPP,MAllocIdent"$ and $MA-X+PU,"CDocEntry",LM="F(\"sizeof(CDocEntry)\");View;"$.
|
||||
CDocEntry *res=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
res->type=type;
|
||||
res->de_flags=de_flags|doldoc.dft_de_flags[type.u8[0]];
|
||||
res->x=x;
|
||||
res->y=y;
|
||||
res->page_line_num=page_line_num;
|
||||
return res;
|
||||
}
|
||||
|
||||
CDocEntry *DocEntryNewTag(CDoc *doc,CDocEntry *doc_ce,U8 *tag)
|
||||
{
|
||||
I64 l=StrLen(tag);
|
||||
CDocEntry *res=DocEntryNewBase(doc,doc_ce->type,doc_ce->de_flags,
|
||||
doc_ce->x,doc_ce->y,doc_ce->page_line_num);
|
||||
res->de_flags=doc_ce->de_flags; //Override
|
||||
res->max_col=l;
|
||||
res->tag=MAlloc(l+1,doc->mem_task);
|
||||
MemCpy(res->tag,tag,l+1);
|
||||
MemCpy(&res->settings,&doc_ce->settings,sizeof(CDocSettings));
|
||||
return res;
|
||||
}
|
||||
|
||||
public U0 DocEntryDel(CDoc *doc,CDocEntry *doc_e)
|
||||
{//Free entry and all parts of entry.
|
||||
if (!doc || doc==doc_e)
|
||||
RawPrint(3000,"DocEntryDel");
|
||||
else {
|
||||
if (doc->cur_entry==doc_e)
|
||||
doc->cur_entry=doc_e->next;
|
||||
QueRem(doc_e);
|
||||
if (doc_e->de_flags & DOCEF_TAG)
|
||||
Free(doc_e->tag);
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR)
|
||||
Free(doc_e->aux_str);
|
||||
if (doc_e->de_flags & DOCEF_DEFINE)
|
||||
Free(doc_e->define_str);
|
||||
if (doc_e->de_flags & DOCEF_HTML_LINK)
|
||||
Free(doc_e->html_link);
|
||||
if (doc_e->de_flags & DOCEF_LEFT_MACRO)
|
||||
Free(doc_e->left_macro);
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_MACRO)
|
||||
Free(doc_e->right_macro);
|
||||
if (doc_e->de_flags & DOCEF_BIN_PTR_LINK)
|
||||
Free(doc_e->bin_ptr_link);
|
||||
if (doc_e->de_flags & DOCEF_HAS_BIN)
|
||||
DocBinDel(doc,doc_e->bin_data);
|
||||
if (doc_e->de_flags & DOCEF_REMALLOC_DATA)
|
||||
Free(doc_e->data);
|
||||
Free(doc_e);
|
||||
}
|
||||
}
|
||||
|
||||
public I64 DocEntrySize(CDoc *,CDocEntry *doc_e)
|
||||
{//Mem size of entry and all parts.
|
||||
I64 res;
|
||||
if (!doc_e) return 0;
|
||||
res=MSize2(doc_e);
|
||||
if (doc_e->de_flags & DOCEF_TAG)
|
||||
res+=MSize2(doc_e->tag);
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR)
|
||||
res+=MSize2(doc_e->aux_str);
|
||||
if (doc_e->de_flags & DOCEF_DEFINE)
|
||||
res+=MSize2(doc_e->define_str);
|
||||
if (doc_e->de_flags & DOCEF_HTML_LINK)
|
||||
res+=MSize2(doc_e->html_link);
|
||||
if (doc_e->de_flags & DOCEF_LEFT_MACRO)
|
||||
res+=MSize2(doc_e->left_macro);
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_MACRO)
|
||||
res+=MSize2(doc_e->right_macro);
|
||||
if (doc_e->de_flags & DOCEF_BIN_PTR_LINK)
|
||||
res+=MSize2(doc_e->bin_ptr_link);
|
||||
if (doc_e->de_flags & DOCEF_REMALLOC_DATA)
|
||||
res+=MSize2(doc_e->data);
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 DocUndoDel(CDoc *,CDocUndo *u)
|
||||
{
|
||||
Free(u->body);
|
||||
Free(u);
|
||||
}
|
||||
|
||||
U0 DocUndoCntSet(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocUndo *u=doc->undo_head.next;
|
||||
doc->undo_cnt=0;
|
||||
while (u!=&doc->undo_head) {
|
||||
doc->undo_cnt++;
|
||||
u=u->next;
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public CDocEntry *DocEntryCopy(CDoc *doc,CDocEntry *doc_e)
|
||||
{//Make copy of entry and all parts of entry.
|
||||
CDocEntry *doc_ne;
|
||||
CDocBin *tempb;
|
||||
CTask *task=doc->mem_task;
|
||||
doc_ne=MAllocIdent(doc_e,task);
|
||||
doc_ne->next=doc_ne;
|
||||
doc_ne->last=doc_ne;
|
||||
if (doc_e->de_flags & DOCEF_TAG)
|
||||
doc_ne->tag=MAllocIdent(doc_e->tag,task);
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR)
|
||||
doc_ne->aux_str=MAllocIdent(doc_e->aux_str,task);
|
||||
if (doc_e->de_flags & DOCEF_DEFINE)
|
||||
doc_ne->define_str=MAllocIdent(doc_e->define_str,task);
|
||||
if (doc_e->de_flags & DOCEF_HTML_LINK)
|
||||
doc_ne->html_link=MAllocIdent(doc_e->html_link,task);
|
||||
if (doc_e->de_flags & DOCEF_LEFT_MACRO)
|
||||
doc_ne->left_macro=MAllocIdent(doc_e->left_macro,task);
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_MACRO)
|
||||
doc_ne->right_macro=MAllocIdent(doc_e->right_macro,task);
|
||||
if (doc_e->de_flags & DOCEF_BIN_PTR_LINK)
|
||||
doc_ne->bin_ptr_link=MAllocIdent(doc_e->bin_ptr_link,task);
|
||||
if (doc_e->de_flags & DOCEF_HAS_BIN) {
|
||||
tempb=MAllocIdent(doc_e->bin_data,task);
|
||||
tempb->data=MAllocIdent(doc_e->bin_data->data,task);
|
||||
doc_ne->bin_num=doc->cur_bin_num;
|
||||
tempb->num=doc->cur_bin_num++;
|
||||
doc_ne->bin_data=tempb;
|
||||
if (doc_e->de_flags&DOCEF_TAG && doc_e->tag && *doc_e->tag)
|
||||
tempb->tag=StrNew(doc_e->tag,task);
|
||||
else
|
||||
tempb->tag=NULL;
|
||||
QueIns(tempb,doc->bin_head.last);
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_REMALLOC_DATA)
|
||||
doc_ne->data=MAllocIdent(doc_e->data,task);
|
||||
return doc_ne;
|
||||
}
|
||||
|
||||
U0 DocRemSoftNewLines(CDoc *doc=NULL,CDocEntry *doc_e=NULL)
|
||||
{
|
||||
CDocEntry *doc_e2,*saved_ll=doc_e;
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
if (!doc_e) doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
doc_e2=doc_e->next;
|
||||
if (doc_e->type_u8==DOCT_SOFT_NEW_LINE) {
|
||||
if (doc->cur_entry==doc_e) {
|
||||
doc->cur_entry=doc_e2;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
}
|
||||
DocEntryDel(doc,doc_e);
|
||||
} else if (saved_ll && doc_e->type_u8==DOCT_NEW_LINE)
|
||||
break;
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocInsEntry(CDoc *doc,CDocEntry *doc_e)
|
||||
{//Insert entry into doc, updating its vals.
|
||||
U8 *dst;
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_ne;
|
||||
|
||||
doc_e->x=doc_ce->x;
|
||||
doc_e->y=doc_ce->y;
|
||||
doc_e->page_line_num=doc_ce->page_line_num;
|
||||
MemCpy(&doc_e->settings,&doc_ce->settings,sizeof(CDocSettings));
|
||||
if (doc->cur_col>0 &&
|
||||
doc_ce->type_u8==DOCT_TEXT &&
|
||||
!(doc_ce->de_flags&(DOCEF_TAG_CB|DOCEF_DEFINE|DOCEF_AUX_STR|
|
||||
DOCEF_HTML_LINK|DOCEF_BIN_PTR_LINK)) &&
|
||||
doc->cur_col<doc_ce->max_col) {
|
||||
dst=doc_ce->tag+doc->cur_col;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ne->type=DOCT_TEXT|doc_ce->type&0xFFFFFF00;
|
||||
doc_ce->max_col=doc->cur_col;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc->cur_col=0;
|
||||
doc_ce=doc_ne;
|
||||
}
|
||||
if (doc_ce->type_u8==DOCT_TEXT && doc->cur_col>=doc_ce->max_col) {
|
||||
QueIns(doc_e,doc_ce);
|
||||
doc->cur_entry=doc_e->next;
|
||||
} else {
|
||||
QueIns(doc_e,doc_ce->last);
|
||||
doc->cur_entry=doc_ce;
|
||||
}
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
DocRemSoftNewLines(doc,doc->cur_entry);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocRst(CDoc *doc,Bool is_old)
|
||||
{//Del all entries and set doc to dfts.
|
||||
Bool unlock;
|
||||
CDocEntry *doc_e,*doc_e2;
|
||||
CDocUndo *u,*u8;
|
||||
CDocSettings *s;
|
||||
CDocBin *b,*b1;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
if (is_old) {
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
doc_e2=doc_e->next;
|
||||
DocEntryDel(doc,doc_e);
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
u=doc->undo_head.next;
|
||||
while (u!=&doc->undo_head) {
|
||||
u8=u->next;
|
||||
DocUndoDel(doc,u);
|
||||
u=u8;
|
||||
}
|
||||
b=doc->bin_head.next;
|
||||
while (b!=&doc->bin_head) {
|
||||
b1=b->next;
|
||||
QueRem(b);
|
||||
Free(b->data);
|
||||
Free(b);
|
||||
b=b1;
|
||||
}
|
||||
}
|
||||
//Check $LK,"DocInsDoc",A="MN:DocInsDoc"$
|
||||
doc->flags&=DOCF_BREAK_UNLOCKED;
|
||||
doc->head.next=doc->head.last=doc;
|
||||
QueInit(&doc->bin_head);
|
||||
QueInit(&doc->undo_head);
|
||||
doc->undo_head.time_stamp=0;
|
||||
doc->undo_cnt=0;
|
||||
doc->cur_bin_num=1;
|
||||
doc->dollar_buf_ptr=0;
|
||||
doc->cmd_U8=CH_SPACE;
|
||||
doc->page_line_num=0;
|
||||
doc->best_d=MAX_I64;
|
||||
|
||||
s=&doc->settings_head;
|
||||
s->left_margin=DOC_DFT;
|
||||
s->right_margin=DOC_DFT;
|
||||
s->indent=0;
|
||||
s->page_len=66;
|
||||
s->header=DOC_DFT;
|
||||
s->footer=DOC_DFT;
|
||||
s->state=DOCSS_NORMAL;
|
||||
s->comment_depth=0;
|
||||
s->paren_depth=0;
|
||||
s->brace_depth=0;
|
||||
s->shifted_x=0;
|
||||
s->shifted_y=0;
|
||||
s->cur_text_attr=s->dft_text_attr=DOC_ATTR_DFT_TEXT;
|
||||
|
||||
doc_e=&doc->head;
|
||||
doc_e->type=DOCT_ERROR;
|
||||
doc_e->de_flags=0;
|
||||
doc_e->x=0;
|
||||
doc_e->y=0;
|
||||
doc_e->min_col=0;
|
||||
doc_e->max_col=0;
|
||||
doc_e->page_line_num=doc->page_line_num;
|
||||
MemCpy(&doc_e->settings,s,sizeof(CDocSettings));
|
||||
|
||||
DocTop(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocDel(CDoc *doc)
|
||||
{//Free entire doc and entries.
|
||||
if (!doc || doc->doc_signature!=DOC_SIGNATURE_VAL) return;
|
||||
DocLock(doc);
|
||||
doc->doc_signature=0;
|
||||
DocRst(doc,TRUE);
|
||||
Free(doc->find_replace);
|
||||
Free(doc->dollar_buf);
|
||||
DocUnlock(doc);
|
||||
Free(doc);
|
||||
}
|
||||
|
||||
public I64 DocSize(CDoc *doc)
|
||||
{//Mem size of doc and all its entries.
|
||||
Bool unlock;
|
||||
CDocEntry *doc_e;
|
||||
CDocUndo *u;
|
||||
CDocBin *b;
|
||||
I64 res=0;
|
||||
|
||||
if (!doc || doc->doc_signature!=DOC_SIGNATURE_VAL) return 0;
|
||||
unlock=DocLock(doc);
|
||||
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
res+=DocEntrySize(doc,doc_e);
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
|
||||
u=doc->undo_head.next;
|
||||
while (u!=&doc->undo_head) {
|
||||
res+=MSize2(u->body);
|
||||
res+=MSize2(u);
|
||||
u=u->next;
|
||||
}
|
||||
|
||||
b=doc->bin_head.next;
|
||||
while (b!=&doc->bin_head) {
|
||||
res+=MSize2(b->data);
|
||||
res+=MSize2(b);
|
||||
b=b->next;
|
||||
}
|
||||
|
||||
res+=MSize2(doc->find_replace);
|
||||
res+=MSize2(doc->dollar_buf);
|
||||
res+=MSize2(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return res;
|
||||
}
|
||||
|
||||
#help_index "DolDoc"
|
||||
public CDoc *DocNew(U8 *filename=NULL,CTask *task=NULL)
|
||||
{//MAlloc new $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$. (Begin a new doc.)
|
||||
CDoc *doc;
|
||||
if (!task) task=Fs;
|
||||
doc=CAlloc(sizeof(CDoc),task);
|
||||
if (filename)
|
||||
StrCpy(doc->filename.name,filename);
|
||||
else
|
||||
StrCpy(doc->filename.name,blkdev.temp_filename);
|
||||
doc->find_replace=CAlloc(sizeof(CEdFindText),task);
|
||||
doc->find_replace->scan_fwd=TRUE;
|
||||
doc->find_replace->match_case=TRUE;
|
||||
doc->find_replace->pmt=TRUE;
|
||||
doc->left_click_link=&EdLeftClickLink;
|
||||
doc->dollar_buf_size=84;
|
||||
doc->dollar_buf=MAlloc(doc->dollar_buf_size,task);
|
||||
doc->max_entries=MAX_I64;
|
||||
doc->win_task=task;
|
||||
doc->mem_task=task;
|
||||
DocRst(doc,FALSE);
|
||||
doc->doc_signature=DOC_SIGNATURE_VAL;
|
||||
return doc;
|
||||
}
|
||||
@@ -0,0 +1,385 @@
|
||||
#help_index "DolDoc"
|
||||
|
||||
public Bool DocLock(CDoc *doc)
|
||||
{//Make this task have exclusive access to this doc.
|
||||
if (!Bt(&doc->locked_flags,DOClf_LOCKED) || doc->owning_task!=Fs) {
|
||||
while (LBts(&doc->locked_flags,DOClf_LOCKED))
|
||||
Yield;
|
||||
if (doc->owning_task!=Fs)
|
||||
LBEqu(&doc->flags,DOCf_BREAK_UNLOCKED,BreakLock(Fs));
|
||||
doc->owning_task=Fs;
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public Bool DocUnlock(CDoc *doc)
|
||||
{//Release exclusive lock on access to doc.
|
||||
Bool unlock_break;
|
||||
if (Bt(&doc->locked_flags,DOClf_LOCKED) && doc->owning_task==Fs) {
|
||||
doc->owning_task=0;
|
||||
unlock_break=Bt(&doc->flags,DOCf_BREAK_UNLOCKED);
|
||||
LBtr(&doc->locked_flags,DOClf_LOCKED);
|
||||
if (unlock_break)
|
||||
BreakUnlock(Fs);
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool IsEditableText(CDocEntry *doc_e)
|
||||
{
|
||||
if (doc_e->type_u8==DOCT_TEXT&&!(doc_e->de_flags&DOCEG_DONT_EDIT))
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CDocEntry *DocEntryNewBase(CDoc *doc,I64 type,I64 de_flags=0,
|
||||
I64 x=0,I64 y=0,I64 page_line_num=0)
|
||||
{//See also $LK,"MAllocIdent",A="FF:::/Adam/DolDoc/DocRecalc.HC,MAllocIdent"$ and $MA-X+PU,"CDocEntry",LM="F(\"sizeof(CDocEntry)\");View;"$.
|
||||
CDocEntry *res=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
res->type=type;
|
||||
res->de_flags=de_flags|doldoc.dft_de_flags[type.u8[0]];
|
||||
res->x=x;
|
||||
res->y=y;
|
||||
res->page_line_num=page_line_num;
|
||||
return res;
|
||||
}
|
||||
|
||||
CDocEntry *DocEntryNewTag(CDoc *doc,CDocEntry *doc_ce,U8 *tag)
|
||||
{
|
||||
I64 l=StrLen(tag);
|
||||
CDocEntry *res=DocEntryNewBase(doc,doc_ce->type,doc_ce->de_flags,
|
||||
doc_ce->x,doc_ce->y,doc_ce->page_line_num);
|
||||
res->de_flags=doc_ce->de_flags; //Override
|
||||
res->max_col=l;
|
||||
res->tag=MAlloc(l+1,doc->mem_task);
|
||||
MemCpy(res->tag,tag,l+1);
|
||||
MemCpy(&res->settings,&doc_ce->settings,sizeof(CDocSettings));
|
||||
return res;
|
||||
}
|
||||
|
||||
public U0 DocEntryDel(CDoc *doc,CDocEntry *doc_e)
|
||||
{//Free entry and all parts of entry.
|
||||
if (!doc || doc==doc_e)
|
||||
RawPrint(3000,"DocEntryDel");
|
||||
else {
|
||||
if (doc->cur_entry==doc_e)
|
||||
doc->cur_entry=doc_e->next;
|
||||
QueRem(doc_e);
|
||||
if (doc_e->de_flags & DOCEF_TAG)
|
||||
Free(doc_e->tag);
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR)
|
||||
Free(doc_e->aux_str);
|
||||
if (doc_e->de_flags & DOCEF_DEFINE)
|
||||
Free(doc_e->define_str);
|
||||
if (doc_e->de_flags & DOCEF_HTML_LINK)
|
||||
Free(doc_e->html_link);
|
||||
if (doc_e->de_flags & DOCEF_LEFT_MACRO)
|
||||
Free(doc_e->left_macro);
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_MACRO)
|
||||
Free(doc_e->right_macro);
|
||||
if (doc_e->de_flags & DOCEF_BIN_PTR_LINK)
|
||||
Free(doc_e->bin_ptr_link);
|
||||
if (doc_e->de_flags & DOCEF_HAS_BIN)
|
||||
DocBinDel(doc,doc_e->bin_data);
|
||||
if (doc_e->de_flags & DOCEF_REMALLOC_DATA)
|
||||
Free(doc_e->data);
|
||||
Free(doc_e);
|
||||
}
|
||||
}
|
||||
|
||||
public I64 DocEntrySize(CDoc *,CDocEntry *doc_e)
|
||||
{//Mem size of entry and all parts.
|
||||
I64 res;
|
||||
if (!doc_e) return 0;
|
||||
res=MSize2(doc_e);
|
||||
if (doc_e->de_flags & DOCEF_TAG)
|
||||
res+=MSize2(doc_e->tag);
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR)
|
||||
res+=MSize2(doc_e->aux_str);
|
||||
if (doc_e->de_flags & DOCEF_DEFINE)
|
||||
res+=MSize2(doc_e->define_str);
|
||||
if (doc_e->de_flags & DOCEF_HTML_LINK)
|
||||
res+=MSize2(doc_e->html_link);
|
||||
if (doc_e->de_flags & DOCEF_LEFT_MACRO)
|
||||
res+=MSize2(doc_e->left_macro);
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_MACRO)
|
||||
res+=MSize2(doc_e->right_macro);
|
||||
if (doc_e->de_flags & DOCEF_BIN_PTR_LINK)
|
||||
res+=MSize2(doc_e->bin_ptr_link);
|
||||
if (doc_e->de_flags & DOCEF_REMALLOC_DATA)
|
||||
res+=MSize2(doc_e->data);
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 DocUndoDel(CDoc *,CDocUndo *u)
|
||||
{
|
||||
Free(u->body);
|
||||
Free(u);
|
||||
}
|
||||
|
||||
U0 DocUndoCntSet(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocUndo *u=doc->undo_head.next;
|
||||
doc->undo_cnt=0;
|
||||
while (u!=&doc->undo_head) {
|
||||
doc->undo_cnt++;
|
||||
u=u->next;
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public CDocEntry *DocEntryCopy(CDoc *doc,CDocEntry *doc_e)
|
||||
{//Make copy of entry and all parts of entry.
|
||||
CDocEntry *doc_ne;
|
||||
CDocBin *tempb;
|
||||
CTask *task=doc->mem_task;
|
||||
doc_ne=MAllocIdent(doc_e,task);
|
||||
doc_ne->next=doc_ne;
|
||||
doc_ne->last=doc_ne;
|
||||
if (doc_e->de_flags & DOCEF_TAG)
|
||||
doc_ne->tag=MAllocIdent(doc_e->tag,task);
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR)
|
||||
doc_ne->aux_str=MAllocIdent(doc_e->aux_str,task);
|
||||
if (doc_e->de_flags & DOCEF_DEFINE)
|
||||
doc_ne->define_str=MAllocIdent(doc_e->define_str,task);
|
||||
if (doc_e->de_flags & DOCEF_HTML_LINK)
|
||||
doc_ne->html_link=MAllocIdent(doc_e->html_link,task);
|
||||
if (doc_e->de_flags & DOCEF_LEFT_MACRO)
|
||||
doc_ne->left_macro=MAllocIdent(doc_e->left_macro,task);
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_MACRO)
|
||||
doc_ne->right_macro=MAllocIdent(doc_e->right_macro,task);
|
||||
if (doc_e->de_flags & DOCEF_BIN_PTR_LINK)
|
||||
doc_ne->bin_ptr_link=MAllocIdent(doc_e->bin_ptr_link,task);
|
||||
if (doc_e->de_flags & DOCEF_HAS_BIN) {
|
||||
tempb=MAllocIdent(doc_e->bin_data,task);
|
||||
tempb->data=MAllocIdent(doc_e->bin_data->data,task);
|
||||
doc_ne->bin_num=doc->cur_bin_num;
|
||||
tempb->num=doc->cur_bin_num++;
|
||||
doc_ne->bin_data=tempb;
|
||||
if (doc_e->de_flags&DOCEF_TAG && doc_e->tag && *doc_e->tag)
|
||||
tempb->tag=StrNew(doc_e->tag,task);
|
||||
else
|
||||
tempb->tag=NULL;
|
||||
QueIns(tempb,doc->bin_head.last);
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_REMALLOC_DATA)
|
||||
doc_ne->data=MAllocIdent(doc_e->data,task);
|
||||
return doc_ne;
|
||||
}
|
||||
|
||||
U0 DocRemSoftNewLines(CDoc *doc=NULL,CDocEntry *doc_e=NULL)
|
||||
{
|
||||
CDocEntry *doc_e2,*saved_ll=doc_e;
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
if (!doc_e) doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
doc_e2=doc_e->next;
|
||||
if (doc_e->type_u8==DOCT_SOFT_NEW_LINE) {
|
||||
if (doc->cur_entry==doc_e) {
|
||||
doc->cur_entry=doc_e2;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
}
|
||||
DocEntryDel(doc,doc_e);
|
||||
} else if (saved_ll && doc_e->type_u8==DOCT_NEW_LINE)
|
||||
break;
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocInsEntry(CDoc *doc,CDocEntry *doc_e)
|
||||
{//Insert entry into doc, updating its vals.
|
||||
U8 *dst;
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_ne;
|
||||
|
||||
doc_e->x=doc_ce->x;
|
||||
doc_e->y=doc_ce->y;
|
||||
doc_e->page_line_num=doc_ce->page_line_num;
|
||||
MemCpy(&doc_e->settings,&doc_ce->settings,sizeof(CDocSettings));
|
||||
if (doc->cur_col>0 &&
|
||||
doc_ce->type_u8==DOCT_TEXT &&
|
||||
!(doc_ce->de_flags&(DOCEF_TAG_CB|DOCEF_DEFINE|DOCEF_AUX_STR|
|
||||
DOCEF_HTML_LINK|DOCEF_BIN_PTR_LINK)) &&
|
||||
doc->cur_col<doc_ce->max_col) {
|
||||
dst=doc_ce->tag+doc->cur_col;
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ne->type=DOCT_TEXT|doc_ce->type&0xFFFFFF00;
|
||||
doc_ce->max_col=doc->cur_col;
|
||||
QueIns(doc_ne,doc_ce);
|
||||
doc->cur_col=0;
|
||||
doc_ce=doc_ne;
|
||||
}
|
||||
if (doc_ce->type_u8==DOCT_TEXT && doc->cur_col>=doc_ce->max_col) {
|
||||
QueIns(doc_e,doc_ce);
|
||||
doc->cur_entry=doc_e->next;
|
||||
} else {
|
||||
QueIns(doc_e,doc_ce->last);
|
||||
doc->cur_entry=doc_ce;
|
||||
}
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
DocRemSoftNewLines(doc,doc->cur_entry);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocRst(CDoc *doc,Bool is_old)
|
||||
{//Del all entries and set doc to dfts.
|
||||
Bool unlock;
|
||||
CDocEntry *doc_e,*doc_e2;
|
||||
CDocUndo *u,*u8;
|
||||
CDocSettings *s;
|
||||
CDocBin *b,*b1;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
if (is_old) {
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
doc_e2=doc_e->next;
|
||||
DocEntryDel(doc,doc_e);
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
u=doc->undo_head.next;
|
||||
while (u!=&doc->undo_head) {
|
||||
u8=u->next;
|
||||
DocUndoDel(doc,u);
|
||||
u=u8;
|
||||
}
|
||||
b=doc->bin_head.next;
|
||||
while (b!=&doc->bin_head) {
|
||||
b1=b->next;
|
||||
QueRem(b);
|
||||
Free(b->data);
|
||||
Free(b);
|
||||
b=b1;
|
||||
}
|
||||
}
|
||||
//Check $LK,"DocInsDoc",A="MN:DocInsDoc"$
|
||||
doc->flags&=DOCF_BREAK_UNLOCKED;
|
||||
doc->head.next=doc->head.last=doc;
|
||||
QueInit(&doc->bin_head);
|
||||
QueInit(&doc->undo_head);
|
||||
doc->undo_head.time_stamp=0;
|
||||
doc->undo_cnt=0;
|
||||
doc->cur_bin_num=1;
|
||||
doc->dollar_buf_ptr=0;
|
||||
doc->cmd_U8=CH_SPACE;
|
||||
doc->page_line_num=0;
|
||||
doc->best_d=MAX_I64;
|
||||
|
||||
s=&doc->settings_head;
|
||||
s->left_margin=DOC_DFT;
|
||||
s->right_margin=DOC_DFT;
|
||||
s->indent=0;
|
||||
s->page_len=66;
|
||||
s->header=DOC_DFT;
|
||||
s->footer=DOC_DFT;
|
||||
s->state=DOCSS_NORMAL;
|
||||
s->comment_depth=0;
|
||||
s->paren_depth=0;
|
||||
s->brace_depth=0;
|
||||
s->shifted_x=0;
|
||||
s->shifted_y=0;
|
||||
s->cur_text_attr=s->dft_text_attr=DOC_ATTR_DFT_TEXT;
|
||||
|
||||
doc_e=&doc->head;
|
||||
doc_e->type=DOCT_ERROR;
|
||||
doc_e->de_flags=0;
|
||||
doc_e->x=0;
|
||||
doc_e->y=0;
|
||||
doc_e->min_col=0;
|
||||
doc_e->max_col=0;
|
||||
doc_e->page_line_num=doc->page_line_num;
|
||||
MemCpy(&doc_e->settings,s,sizeof(CDocSettings));
|
||||
|
||||
DocTop(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocDel(CDoc *doc)
|
||||
{//Free entire doc and entries.
|
||||
if (!doc || doc->doc_signature!=DOC_SIGNATURE_VAL) return;
|
||||
DocLock(doc);
|
||||
doc->doc_signature=0;
|
||||
DocRst(doc,TRUE);
|
||||
Free(doc->find_replace);
|
||||
Free(doc->dollar_buf);
|
||||
DocUnlock(doc);
|
||||
Free(doc);
|
||||
}
|
||||
|
||||
public I64 DocSize(CDoc *doc)
|
||||
{//Mem size of doc and all its entries.
|
||||
Bool unlock;
|
||||
CDocEntry *doc_e;
|
||||
CDocUndo *u;
|
||||
CDocBin *b;
|
||||
I64 res=0;
|
||||
|
||||
if (!doc || doc->doc_signature!=DOC_SIGNATURE_VAL) return 0;
|
||||
unlock=DocLock(doc);
|
||||
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
res+=DocEntrySize(doc,doc_e);
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
|
||||
u=doc->undo_head.next;
|
||||
while (u!=&doc->undo_head) {
|
||||
res+=MSize2(u->body);
|
||||
res+=MSize2(u);
|
||||
u=u->next;
|
||||
}
|
||||
|
||||
b=doc->bin_head.next;
|
||||
while (b!=&doc->bin_head) {
|
||||
res+=MSize2(b->data);
|
||||
res+=MSize2(b);
|
||||
b=b->next;
|
||||
}
|
||||
|
||||
res+=MSize2(doc->find_replace);
|
||||
res+=MSize2(doc->dollar_buf);
|
||||
res+=MSize2(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return res;
|
||||
}
|
||||
|
||||
#help_index "DolDoc"
|
||||
public CDoc *DocNew(U8 *filename=NULL,CTask *task=NULL)
|
||||
{//MAlloc new $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.DD"$. (Begin a new doc.)
|
||||
CDoc *doc;
|
||||
if (!task) task=Fs;
|
||||
doc=CAlloc(sizeof(CDoc),task);
|
||||
if (filename)
|
||||
StrCpy(doc->filename.name,filename);
|
||||
else
|
||||
StrCpy(doc->filename.name,blkdev.temp_filename);
|
||||
doc->find_replace=CAlloc(sizeof(CEdFindText),task);
|
||||
doc->find_replace->scan_fwd=TRUE;
|
||||
doc->find_replace->match_case=TRUE;
|
||||
doc->find_replace->pmt=TRUE;
|
||||
doc->left_click_link=&EdLeftClickLink;
|
||||
doc->dollar_buf_size=84;
|
||||
doc->dollar_buf=MAlloc(doc->dollar_buf_size,task);
|
||||
doc->max_entries=MAX_I64;
|
||||
doc->win_task=task;
|
||||
doc->mem_task=task;
|
||||
DocRst(doc,FALSE);
|
||||
doc->doc_signature=DOC_SIGNATURE_VAL;
|
||||
return doc;
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
#help_index "DolDoc"
|
||||
|
||||
I64 DocOptEntry(CDoc *,CDocEntry *doc_e,I64 fuf_flags)
|
||||
{
|
||||
U8 *st,*st2,**_dst;
|
||||
I64 i,res=0;
|
||||
|
||||
if (doc_e->de_flags&DOCEF_LINK && doc_e->de_flags&(DOCEF_AUX_STR|DOCEF_TAG)) {
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR && doc_e->de_flags & DOCEF_TAG &&
|
||||
!MemCmp(doc_e->aux_str,"FI:",3) &&
|
||||
!StrCmp(doc_e->aux_str+3,doc_e->tag)) {
|
||||
Free(doc_e->aux_str);
|
||||
doc_e->aux_str=NULL;
|
||||
doc_e->de_flags&=~DOCEF_AUX_STR;
|
||||
res++;
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR)
|
||||
_dst=&doc_e->aux_str;
|
||||
else
|
||||
_dst=&doc_e->tag;
|
||||
if (StrMatch(".Z",*_dst)) {
|
||||
st=DocLinkFile(*_dst);
|
||||
if (FileFind(st)) {
|
||||
if (IsDotZ(st))
|
||||
st[StrLen(st)-2]=0;
|
||||
i=StrLen(st);
|
||||
if ((st2=StrMatch(st,*_dst)) && st2[i]=='.' && st2[i+1]=='Z') {
|
||||
StrCpy(st2+i,st2+i+2);
|
||||
res++;
|
||||
}
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
if (fuf_flags&FUF_RISKY) {
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR) {
|
||||
if (st=StrMatch(".Z",doc_e->aux_str)) {
|
||||
StrCpy(st,st+2);
|
||||
res++;
|
||||
}
|
||||
}
|
||||
if (doc_e->de_flags&DOCEF_TAG) {
|
||||
if (st=StrMatch(".Z",doc_e->tag)) {
|
||||
StrCpy(st,st+2);
|
||||
res++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 DocOptDoc(CDoc *doc,I64 fuf_flags)
|
||||
{//Optimize Doc.
|
||||
Bool unlock=DocLock(doc);
|
||||
I64 res=0;
|
||||
CDocEntry *doc_e,*doc_e1,*doc_e_last;
|
||||
DocRecalc(doc);
|
||||
doc_e_last=NULL;
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
doc_e1=doc_e->next;
|
||||
if (res+=DocOptEntry(doc,doc_e,fuf_flags))
|
||||
res+=DocOptEntry(doc,doc_e,fuf_flags);
|
||||
if (doc_e_last && doc_e_last->type&~0xFF00==doc_e->type&~0xFF00 &&
|
||||
doc_e_last->de_flags==doc_e->de_flags &&
|
||||
Bt(doldoc.type_flags_chk_dup,doc_e->type_u8) &&
|
||||
doc_e_last->attr==doc_e->attr) {
|
||||
DocEntryDel(doc,doc_e);
|
||||
res++;
|
||||
} else
|
||||
doc_e_last=doc_e;
|
||||
doc_e=doc_e1;
|
||||
}
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 DocOptFile(U8 *filename,I64 fuf_flags)
|
||||
{//Optimize File.
|
||||
I64 res;
|
||||
CDoc *doc=DocRead(filename);
|
||||
if (res=DocOptDoc(doc,fuf_flags)) {
|
||||
"-%d:%s\n",res,doc->filename.name;
|
||||
DocWrite(doc);
|
||||
}
|
||||
DocDel(doc);
|
||||
return res;
|
||||
}
|
||||
I64 DocOptLst(CDirEntry *tempde,I64 fuf_flags)
|
||||
{
|
||||
I64 res=0;
|
||||
CDirEntry *tempde1;
|
||||
while (tempde) {
|
||||
tempde1=tempde->next;
|
||||
if (tempde->attr & RS_ATTR_DIR) {
|
||||
if (tempde->sub) {
|
||||
"Scanning Directory: %s\n",tempde->full_name;
|
||||
res+=DocOptLst(tempde->sub,fuf_flags);
|
||||
}
|
||||
} else
|
||||
res+=DocOptFile(tempde->full_name,fuf_flags);
|
||||
DirEntryDel(tempde);
|
||||
tempde=tempde1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public I64 DocOpt(U8 *files_find_mask="*",U8 *fu_flags=NULL)
|
||||
{//Optimize $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$ Files, eliminating aux_str's and .Z's.
|
||||
//+R flag for aggressively risky.
|
||||
I64 fuf_flags=0;
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r+T");
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
|
||||
return DocOptLst(FilesFind(files_find_mask,fuf_flags&FUG_FILES_FIND),
|
||||
fuf_flags&~FUG_FILES_FIND);
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
#help_index "DolDoc"
|
||||
|
||||
I64 DocOptEntry(CDoc *,CDocEntry *doc_e,I64 fuf_flags)
|
||||
{
|
||||
U8 *st,*st2,**_dst;
|
||||
I64 i,res=0;
|
||||
|
||||
if (doc_e->de_flags&DOCEF_LINK && doc_e->de_flags&(DOCEF_AUX_STR|DOCEF_TAG)) {
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR && doc_e->de_flags & DOCEF_TAG &&
|
||||
!MemCmp(doc_e->aux_str,"FI:",3) &&
|
||||
!StrCmp(doc_e->aux_str+3,doc_e->tag)) {
|
||||
Free(doc_e->aux_str);
|
||||
doc_e->aux_str=NULL;
|
||||
doc_e->de_flags&=~DOCEF_AUX_STR;
|
||||
res++;
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR)
|
||||
_dst=&doc_e->aux_str;
|
||||
else
|
||||
_dst=&doc_e->tag;
|
||||
if (StrMatch(".Z",*_dst)) {
|
||||
st=DocLinkFile(*_dst);
|
||||
if (FileFind(st)) {
|
||||
if (IsDotZ(st))
|
||||
st[StrLen(st)-2]=0;
|
||||
i=StrLen(st);
|
||||
if ((st2=StrMatch(st,*_dst)) && st2[i]=='.' && st2[i+1]=='Z') {
|
||||
StrCpy(st2+i,st2+i+2);
|
||||
res++;
|
||||
}
|
||||
}
|
||||
Free(st);
|
||||
}
|
||||
if (fuf_flags&FUF_RISKY) {
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR) {
|
||||
if (st=StrMatch(".Z",doc_e->aux_str)) {
|
||||
StrCpy(st,st+2);
|
||||
res++;
|
||||
}
|
||||
}
|
||||
if (doc_e->de_flags&DOCEF_TAG) {
|
||||
if (st=StrMatch(".Z",doc_e->tag)) {
|
||||
StrCpy(st,st+2);
|
||||
res++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 DocOptDoc(CDoc *doc,I64 fuf_flags)
|
||||
{//Optimize Doc.
|
||||
Bool unlock=DocLock(doc);
|
||||
I64 res=0;
|
||||
CDocEntry *doc_e,*doc_e1,*doc_e_last;
|
||||
DocRecalc(doc);
|
||||
doc_e_last=NULL;
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
doc_e1=doc_e->next;
|
||||
if (res+=DocOptEntry(doc,doc_e,fuf_flags))
|
||||
res+=DocOptEntry(doc,doc_e,fuf_flags);
|
||||
if (doc_e_last && doc_e_last->type&~0xFF00==doc_e->type&~0xFF00 &&
|
||||
doc_e_last->de_flags==doc_e->de_flags &&
|
||||
Bt(doldoc.type_flags_chk_dup,doc_e->type_u8) &&
|
||||
doc_e_last->attr==doc_e->attr) {
|
||||
DocEntryDel(doc,doc_e);
|
||||
res++;
|
||||
} else
|
||||
doc_e_last=doc_e;
|
||||
doc_e=doc_e1;
|
||||
}
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 DocOptFile(U8 *filename,I64 fuf_flags)
|
||||
{//Optimize File.
|
||||
I64 res;
|
||||
CDoc *doc=DocRead(filename);
|
||||
if (res=DocOptDoc(doc,fuf_flags)) {
|
||||
"-%d:%s\n",res,doc->filename.name;
|
||||
DocWrite(doc);
|
||||
}
|
||||
DocDel(doc);
|
||||
return res;
|
||||
}
|
||||
I64 DocOptLst(CDirEntry *tempde,I64 fuf_flags)
|
||||
{
|
||||
I64 res=0;
|
||||
CDirEntry *tempde1;
|
||||
while (tempde) {
|
||||
tempde1=tempde->next;
|
||||
if (tempde->attr & RS_ATTR_DIR) {
|
||||
if (tempde->sub) {
|
||||
"Scanning Directory: %s\n",tempde->full_name;
|
||||
res+=DocOptLst(tempde->sub,fuf_flags);
|
||||
}
|
||||
} else
|
||||
res+=DocOptFile(tempde->full_name,fuf_flags);
|
||||
DirEntryDel(tempde);
|
||||
tempde=tempde1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public I64 DocOpt(U8 *files_find_mask="*",U8 *fu_flags=NULL)
|
||||
{//Optimize $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.DD"$ Files, eliminating aux_str's and .Z's.
|
||||
//+R flag for aggressively risky.
|
||||
I64 fuf_flags=0;
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r+T");
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
|
||||
return DocOptLst(FilesFind(files_find_mask,fuf_flags&FUG_FILES_FIND),
|
||||
fuf_flags&~FUG_FILES_FIND);
|
||||
}
|
||||
@@ -1,323 +0,0 @@
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
public CTask *PopUpViewDoc(CDoc *doc,I64 dof_flags=0)
|
||||
{//Pass doc to PopUp win task for viewing.
|
||||
U8 *buf=MStrPrint("DocEd(0x%X,0x%X);",doc,dof_flags);
|
||||
CTask *task=Spawn(&SrvCmdLine,NULL,"View",,Fs);
|
||||
TaskExe(task,NULL,buf,1<<SVCf_EXIT_ON_COMPLETE|1<<SVCf_FREE_ON_COMPLETE);
|
||||
Free(buf);
|
||||
return task;
|
||||
}
|
||||
|
||||
U0 PopUpViewPrintEndCB()
|
||||
{
|
||||
DocDel(FramePtr("ViewStrFrame"));
|
||||
Exit;
|
||||
}
|
||||
|
||||
public CTask *PopUpViewPrint(U8 *fmt,...)
|
||||
{//View Print stmt in PopUp win task.
|
||||
CTask *task;
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
CDoc *doc=DocNew;
|
||||
DocPrint(doc,buf);
|
||||
Free(buf);
|
||||
task=PopUpViewDoc(doc);
|
||||
FramePtrAdd("ViewStrFrame",doc,task);
|
||||
task->task_end_cb=&PopUpViewPrintEndCB;
|
||||
return task;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;File/FileNames;StdIn/DolDoc"
|
||||
public U8 *PopUpPickFile(U8 *dir=NULL)
|
||||
{//Filename chooser. Uses $LK,"FileMgr",A="MN:FileMgr"$().
|
||||
U8 *res,*st,*st2;
|
||||
if (dir)
|
||||
st=MStrPrint("Cd(\"%Q\");FileMgr(FM_PICK_FILE,Fs->parent_task);",dir);
|
||||
else {
|
||||
st2=CurDir;
|
||||
st=MStrPrint("Cd(\"%Q\");FileMgr(FM_PICK_FILE,Fs->parent_task);",st2);
|
||||
Free(st2);
|
||||
}
|
||||
res=PopUp(st,Fs);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
public U8 *PopUpPickDir(U8 *dir=NULL)
|
||||
{//File dir name chooser. Uses $LK,"FileMgr",A="MN:FileMgr"$().
|
||||
U8 *res,*st,*st2;
|
||||
if (dir)
|
||||
st=MStrPrint("Cd(\"%Q\");FileMgr(FM_PICK_DIR,Fs->parent_task);",dir);
|
||||
else {
|
||||
st2=CurDir;
|
||||
st=MStrPrint("Cd(\"%Q\");FileMgr(FM_PICK_DIR,Fs->parent_task);",st2);
|
||||
Free(st2);
|
||||
}
|
||||
res=PopUp(st,Fs);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
public U8 *FileNameForm(U8 *dft=NULL,I64 dof_flags=0,CTask *mem_task=NULL)
|
||||
{//Text filename form in cur win, not PopUp.
|
||||
CEdFileName fn;
|
||||
if (dft)
|
||||
StrCpy(fn.name,dft);
|
||||
else
|
||||
*fn.name=0;
|
||||
if (DocForm(&fn,,dof_flags))
|
||||
return StrNew(fn.name,mem_task);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public U8 *PopUpFileName(U8 *dft=NULL,I64 dof_flags=0)
|
||||
{//Filename chooser. Uses form, not $LK,"FileMgr",A="MN:FileMgr"$().
|
||||
U8 *st=MStrPrint("FileNameForm(\"%Q\",0x%X,Fs->parent_task);",
|
||||
dft,dof_flags|DOF_MIN_SIZE),*res=PopUp(st,Fs);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
#help_index "DolDoc"
|
||||
Bool PopUpCd()
|
||||
{
|
||||
Bool res;
|
||||
U8 *st=PopUpPickDir;
|
||||
if (st) {
|
||||
res=Cd(st);
|
||||
Free(st);
|
||||
} else
|
||||
res=FALSE;
|
||||
return res;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;Char/Lists;StdIn/DolDoc"
|
||||
public U8 *PopUpPickLst(U8 *lst)
|
||||
{//Prompt for lst entry in PopUp win task.
|
||||
I64 i=0;
|
||||
CDoc *doc=DocNew;
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
while (*lst) {
|
||||
if (*lst=='@') {//Check for '@' alias lst entry
|
||||
i--;
|
||||
lst++;
|
||||
}
|
||||
DocPrint(doc,"$$MU,\"%s\",LE=%d$$\n",lst,i++);
|
||||
lst+=StrLen(lst)+1;
|
||||
}
|
||||
DocPrint(doc,"\n$$MU,\"CANCEL\",LE=DOCM_CANCEL$$\n");
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;Char/Lists;Char/Define;StdIn/DolDoc"
|
||||
public U8 *PopUpPickDefineSub(U8 *dname)
|
||||
{//Prompt for $LK,"Define",A="HI:Define"$ lst entry in PopUp win task.
|
||||
return PopUpPickLst(Define(dname));
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;StdIn/DolDoc"
|
||||
public I64 PopUp1(U8 *b1,I64 n1,U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Make PopUp win task with one button.
|
||||
I64 i,l1=StrLen(b1);
|
||||
CDoc *doc=DocNew;
|
||||
if (header) DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"$$CM+CX,%d,4$$$$BT,\"%s\",LE=%d$$\n",-l1/2,b1,n1);
|
||||
if (footer) DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
public I64 PopUp2(U8 *b1,I64 n1,U8 *b2,I64 n2,U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Make PopUp win task with two buttons.
|
||||
I64 i,l1=StrLen(b1),l2=StrLen(b2),y;
|
||||
CDoc *doc=DocNew;
|
||||
if (header) {
|
||||
DocPrint(doc,"%s",header);
|
||||
y=4;
|
||||
} else {
|
||||
DocPrint(doc,"%*s\n",l1+l2+10,"");
|
||||
y=3;
|
||||
}
|
||||
DocPrint(doc,"$$CM+CX,%d,%d$$$$BT,\"%s\",LE=%d$$",-(l1+l2+3)>>1,y,b1,n1);
|
||||
DocPrint(doc,"$$CM+CX,%d,0$$$$BT,\"%s\",LE=%d$$\n" ,-(l1+l2+3)>>1+l1+6,b2,n2);
|
||||
if (footer) DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
public Bool PopUpOk(U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Make PopUp win task with OKAY button.
|
||||
return PopUp1("OKAY",1,header,footer)>0;
|
||||
}
|
||||
|
||||
public Bool PopUpNoYes(U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Make PopUp win task with NO/YES buttons.
|
||||
return $WW,0$PopUp2("YES",1,"NO",0,header,footer)>0;
|
||||
}
|
||||
|
||||
public Bool PopUpCancelOk(U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Make PopUp win task CANCEL/OKAY buttons.
|
||||
return PopUp2("OKAY",1,"CANCEL",0,header,footer)>0;
|
||||
}
|
||||
|
||||
U8 *PopUpGetStr2(U8 *header,CTask *mem_task)
|
||||
{
|
||||
U8 *res,*st;
|
||||
if (header)
|
||||
"%s",header;
|
||||
st=GetStr(,,GSF_WITH_NEW_LINE);
|
||||
res=StrNew(st,mem_task);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
public U8 *PopUpGetStr(U8 *header=NULL)
|
||||
{//Prompt for text str in PopUp win task.
|
||||
U8 *st=MStrPrint("PopUpGetStr2(0x%X,0x%X);",header,Fs),
|
||||
*res=PopUp(st,Fs);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 PopUpGetI64(U8 *msg,I64 dft,I64 lo=MIN_I64,I64 hi=MAX_I64)
|
||||
{//Prompt for I64 text expression in PopUp win task.
|
||||
U8 *st=MStrPrint("GetI64(0x%X,0x%X,0x%X,0x%X);",msg,dft,lo,hi);
|
||||
I64 res=PopUp(st,Fs);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
public F64 PopUpGetF64(U8 *msg,F64 dft,F64 lo=MIN_F64,F64 hi=MAX_F64)
|
||||
{//Prompt for F64 text expression in PopUp win task.
|
||||
U8 *st=MStrPrint("GetF64(0x%X,0x%X(F64),0x%X(F64),0x%X(F64));",msg,dft,lo,hi);
|
||||
F64 res=PopUp(st,Fs)(F64);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 PopUpRangeI64(I64 lo,I64 hi,I64 step=1,
|
||||
U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Evenly-spaced I64 range chooser in PopUp win task.
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
if (header)
|
||||
DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
for (i=lo;i<=hi;i+=step)
|
||||
DocPrint(doc,"$$MU,\"%d\",LE=%d$$\n",i,i);
|
||||
if (footer)
|
||||
DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
public F64 PopUpRangeF64(F64 lo,F64 hi,F64 step,
|
||||
U8 *fmt="%9.4f",U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Evenly-spaced F64 range chooser in PopUp win task.
|
||||
F64 d;
|
||||
I64 i;
|
||||
U8 buf[STR_LEN];
|
||||
CDoc *doc=DocNew;
|
||||
if (header)
|
||||
DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
for (d=lo;d<=hi;d+=step) {
|
||||
StrPrint(buf,fmt,d);
|
||||
DocPrint(doc,"$$MU,\"%s\",LE=0x%X$$\n",buf,d);
|
||||
}
|
||||
if (footer)
|
||||
DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i(F64);
|
||||
}
|
||||
|
||||
public F64 PopUpRangeF64Exp(F64 lo,F64 hi,F64 factor,
|
||||
U8 *fmt="%9.4f",U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Exp-spaced F64 range chooser in PopUp win task.
|
||||
F64 d;
|
||||
I64 i;
|
||||
U8 buf[STR_LEN];
|
||||
CDoc *doc=DocNew;
|
||||
if (header)
|
||||
DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
for (d=lo;d<=hi;d*=factor) {
|
||||
StrPrint(buf,fmt,d);
|
||||
DocPrint(doc,"$$MU,\"%s\",LE=0x%X$$\n",buf,d);
|
||||
}
|
||||
if (footer)
|
||||
DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i(F64);
|
||||
}
|
||||
|
||||
public F64 PopUpRangeF64Log(F64 lo,F64 hi,I64 steps,
|
||||
U8 *fmt="%9.4f",U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Log-spaced F64 range chooser in PopUp win task.
|
||||
return PopUpRangeF64Exp(lo,hi,Exp(Ln(hi/lo)/(steps-1)),fmt,header,footer);
|
||||
}
|
||||
|
||||
#help_index "Task/Srv/Exe;Compiler"
|
||||
public I64 AdamFile(U8 *filename,Bool warn_ext=TRUE)
|
||||
{//Make adam_task execute file.
|
||||
Bool okay=TRUE;
|
||||
U8 *name=FileNameAbs(filename),
|
||||
*name2=DftExt(name,"CPP.Z");
|
||||
I64 res=0;
|
||||
if (warn_ext &&
|
||||
!FilesFindMatch(name2,FILEMASK_JIT) &&
|
||||
!PopUpCancelOk(ST_WARN_ST "Not .CPP File\n\n"))
|
||||
okay=FALSE;
|
||||
if (okay)
|
||||
res=Adam("#include \"%s\";",name2);
|
||||
Free(name2);
|
||||
Free(name);
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 PopUpFile(U8 *filename,Bool warn_ext=TRUE,
|
||||
CTask *parent=NULL,CTask **_pu_task=NULL)
|
||||
{//$LK,"ExeFile2",A="MN:ExeFile2"$() in $LK,"PopUp",A="MN:PopUp"$ task. Cont as User.
|
||||
Bool okay=TRUE;
|
||||
U8 *st,*name=FileNameAbs(filename),
|
||||
*name2=DftExt(name,"CPP.Z");
|
||||
I64 res=0;
|
||||
if (warn_ext &&
|
||||
!FilesFindMatch(name2,FILEMASK_JIT) &&
|
||||
!PopUpCancelOk(ST_WARN_ST "Not .CPP File\n\n"))
|
||||
okay=FALSE;
|
||||
if (okay) {
|
||||
st=MStrPrint(
|
||||
"\"$$$$WW+H,1$$$$\";Auto(\"ExeFile2(\\\"%s\\\",CCF_CMD_LINE);\\n\");"
|
||||
"UserTaskCont;",
|
||||
name2);
|
||||
res=PopUp(st,parent,_pu_task);
|
||||
Free(st);
|
||||
}
|
||||
Free(name2);
|
||||
Free(name);
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 PopUpRunFile(U8 *filename,I64 ccf_flags=0,...)
|
||||
{//$LK,"ExeFile",A="MN:ExeFile"$() with args using $LK,"LastFun",A="MN:LastFun"$() in $LK,"PopUp",A="MN:PopUp"$ task.
|
||||
U8 *st,*name=FileNameAbs(filename),
|
||||
*name2=DftExt(name,"CPP.Z");
|
||||
I64 res=0;
|
||||
st=MStrPrint(
|
||||
"\"$$$$WW+H,1$$$$\";ExeFile2(\"%s\",0x%X);LastFun(0x%X,0x%X);",
|
||||
name2,ccf_flags,argc,argv);
|
||||
res=PopUp(st,Fs);
|
||||
Free(st);
|
||||
Free(name2);
|
||||
Free(name);
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
public CTask *PopUpViewDoc(CDoc *doc,I64 dof_flags=0)
|
||||
{//Pass doc to PopUp win task for viewing.
|
||||
U8 *buf=MStrPrint("DocEd(0x%X,0x%X);",doc,dof_flags);
|
||||
CTask *task=Spawn(&SrvCmdLine,NULL,"View",,Fs);
|
||||
TaskExe(task,NULL,buf,1<<SVCf_EXIT_ON_COMPLETE|1<<SVCf_FREE_ON_COMPLETE);
|
||||
Free(buf);
|
||||
return task;
|
||||
}
|
||||
|
||||
U0 PopUpViewPrintEndCB()
|
||||
{
|
||||
DocDel(FramePtr("ViewStrFrame"));
|
||||
Exit;
|
||||
}
|
||||
|
||||
public CTask *PopUpViewPrint(U8 *fmt,...)
|
||||
{//View Print stmt in PopUp win task.
|
||||
CTask *task;
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
CDoc *doc=DocNew;
|
||||
DocPrint(doc,buf);
|
||||
Free(buf);
|
||||
task=PopUpViewDoc(doc);
|
||||
FramePtrAdd("ViewStrFrame",doc,task);
|
||||
task->task_end_cb=&PopUpViewPrintEndCB;
|
||||
return task;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;File/FileNames;StdIn/DolDoc"
|
||||
public U8 *PopUpPickFile(U8 *dir=NULL)
|
||||
{//Filename chooser. Uses $LK,"FileMgr",A="MN:FileMgr"$().
|
||||
U8 *res,*st,*st2;
|
||||
if (dir)
|
||||
st=MStrPrint("Cd(\"%Q\");FileMgr(FM_PICK_FILE,Fs->parent_task);",dir);
|
||||
else {
|
||||
st2=CurDir;
|
||||
st=MStrPrint("Cd(\"%Q\");FileMgr(FM_PICK_FILE,Fs->parent_task);",st2);
|
||||
Free(st2);
|
||||
}
|
||||
res=PopUp(st,Fs);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
public U8 *PopUpPickDir(U8 *dir=NULL)
|
||||
{//File dir name chooser. Uses $LK,"FileMgr",A="MN:FileMgr"$().
|
||||
U8 *res,*st,*st2;
|
||||
if (dir)
|
||||
st=MStrPrint("Cd(\"%Q\");FileMgr(FM_PICK_DIR,Fs->parent_task);",dir);
|
||||
else {
|
||||
st2=CurDir;
|
||||
st=MStrPrint("Cd(\"%Q\");FileMgr(FM_PICK_DIR,Fs->parent_task);",st2);
|
||||
Free(st2);
|
||||
}
|
||||
res=PopUp(st,Fs);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
public U8 *FileNameForm(U8 *dft=NULL,I64 dof_flags=0,CTask *mem_task=NULL)
|
||||
{//Text filename form in cur win, not PopUp.
|
||||
CEdFileName fn;
|
||||
if (dft)
|
||||
StrCpy(fn.name,dft);
|
||||
else
|
||||
*fn.name=0;
|
||||
if (DocForm(&fn,,dof_flags))
|
||||
return StrNew(fn.name,mem_task);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public U8 *PopUpFileName(U8 *dft=NULL,I64 dof_flags=0)
|
||||
{//Filename chooser. Uses form, not $LK,"FileMgr",A="MN:FileMgr"$().
|
||||
U8 *st=MStrPrint("FileNameForm(\"%Q\",0x%X,Fs->parent_task);",
|
||||
dft,dof_flags|DOF_MIN_SIZE),*res=PopUp(st,Fs);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
#help_index "DolDoc"
|
||||
Bool PopUpCd()
|
||||
{
|
||||
Bool res;
|
||||
U8 *st=PopUpPickDir;
|
||||
if (st) {
|
||||
res=Cd(st);
|
||||
Free(st);
|
||||
} else
|
||||
res=FALSE;
|
||||
return res;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;Char/Lists;StdIn/DolDoc"
|
||||
public U8 *PopUpPickLst(U8 *lst)
|
||||
{//Prompt for lst entry in PopUp win task.
|
||||
I64 i=0;
|
||||
CDoc *doc=DocNew;
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
while (*lst) {
|
||||
if (*lst=='@') {//Check for '@' alias lst entry
|
||||
i--;
|
||||
lst++;
|
||||
}
|
||||
DocPrint(doc,"$$MU,\"%s\",LE=%d$$\n",lst,i++);
|
||||
lst+=StrLen(lst)+1;
|
||||
}
|
||||
DocPrint(doc,"\n$$MU,\"CANCEL\",LE=DOCM_CANCEL$$\n");
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;Char/Lists;Char/Define;StdIn/DolDoc"
|
||||
public U8 *PopUpPickDefineSub(U8 *dname)
|
||||
{//Prompt for $LK,"Define",A="HI:Define"$ lst entry in PopUp win task.
|
||||
return PopUpPickLst(Define(dname));
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;StdIn/DolDoc"
|
||||
public I64 PopUp1(U8 *b1,I64 n1,U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Make PopUp win task with one button.
|
||||
I64 i,l1=StrLen(b1);
|
||||
CDoc *doc=DocNew;
|
||||
if (header) DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"$$CM+CX,%d,4$$$$BT,\"%s\",LE=%d$$\n",-l1/2,b1,n1);
|
||||
if (footer) DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
public I64 PopUp2(U8 *b1,I64 n1,U8 *b2,I64 n2,U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Make PopUp win task with two buttons.
|
||||
I64 i,l1=StrLen(b1),l2=StrLen(b2),y;
|
||||
CDoc *doc=DocNew;
|
||||
if (header) {
|
||||
DocPrint(doc,"%s",header);
|
||||
y=4;
|
||||
} else {
|
||||
DocPrint(doc,"%*s\n",l1+l2+10,"");
|
||||
y=3;
|
||||
}
|
||||
DocPrint(doc,"$$CM+CX,%d,%d$$$$BT,\"%s\",LE=%d$$",-(l1+l2+3)>>1,y,b1,n1);
|
||||
DocPrint(doc,"$$CM+CX,%d,0$$$$BT,\"%s\",LE=%d$$\n" ,-(l1+l2+3)>>1+l1+6,b2,n2);
|
||||
if (footer) DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
public Bool PopUpOk(U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Make PopUp win task with OKAY button.
|
||||
return PopUp1("OKAY",1,header,footer)>0;
|
||||
}
|
||||
|
||||
public Bool PopUpNoYes(U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Make PopUp win task with NO/YES buttons.
|
||||
return $WW,0$PopUp2("YES",1,"NO",0,header,footer)>0;
|
||||
}
|
||||
|
||||
public Bool PopUpCancelOk(U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Make PopUp win task CANCEL/OKAY buttons.
|
||||
return PopUp2("OKAY",1,"CANCEL",0,header,footer)>0;
|
||||
}
|
||||
|
||||
U8 *PopUpGetStr2(U8 *header,CTask *mem_task)
|
||||
{
|
||||
U8 *res,*st;
|
||||
if (header)
|
||||
"%s",header;
|
||||
st=GetStr(,,GSF_WITH_NEW_LINE);
|
||||
res=StrNew(st,mem_task);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
public U8 *PopUpGetStr(U8 *header=NULL)
|
||||
{//Prompt for text str in PopUp win task.
|
||||
U8 *st=MStrPrint("PopUpGetStr2(0x%X,0x%X);",header,Fs),
|
||||
*res=PopUp(st,Fs);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 PopUpGetI64(U8 *msg,I64 dft,I64 lo=MIN_I64,I64 hi=MAX_I64)
|
||||
{//Prompt for I64 text expression in PopUp win task.
|
||||
U8 *st=MStrPrint("GetI64(0x%X,0x%X,0x%X,0x%X);",msg,dft,lo,hi);
|
||||
I64 res=PopUp(st,Fs);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
public F64 PopUpGetF64(U8 *msg,F64 dft,F64 lo=MIN_F64,F64 hi=MAX_F64)
|
||||
{//Prompt for F64 text expression in PopUp win task.
|
||||
U8 *st=MStrPrint("GetF64(0x%X,0x%X(F64),0x%X(F64),0x%X(F64));",msg,dft,lo,hi);
|
||||
F64 res=PopUp(st,Fs)(F64);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 PopUpRangeI64(I64 lo,I64 hi,I64 step=1,
|
||||
U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Evenly-spaced I64 range chooser in PopUp win task.
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
if (header)
|
||||
DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
for (i=lo;i<=hi;i+=step)
|
||||
DocPrint(doc,"$$MU,\"%d\",LE=%d$$\n",i,i);
|
||||
if (footer)
|
||||
DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
public F64 PopUpRangeF64(F64 lo,F64 hi,F64 step,
|
||||
U8 *fmt="%9.4f",U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Evenly-spaced F64 range chooser in PopUp win task.
|
||||
F64 d;
|
||||
I64 i;
|
||||
U8 buf[STR_LEN];
|
||||
CDoc *doc=DocNew;
|
||||
if (header)
|
||||
DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
for (d=lo;d<=hi;d+=step) {
|
||||
StrPrint(buf,fmt,d);
|
||||
DocPrint(doc,"$$MU,\"%s\",LE=0x%X$$\n",buf,d);
|
||||
}
|
||||
if (footer)
|
||||
DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i(F64);
|
||||
}
|
||||
|
||||
public F64 PopUpRangeF64Exp(F64 lo,F64 hi,F64 factor,
|
||||
U8 *fmt="%9.4f",U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Exp-spaced F64 range chooser in PopUp win task.
|
||||
F64 d;
|
||||
I64 i;
|
||||
U8 buf[STR_LEN];
|
||||
CDoc *doc=DocNew;
|
||||
if (header)
|
||||
DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
for (d=lo;d<=hi;d*=factor) {
|
||||
StrPrint(buf,fmt,d);
|
||||
DocPrint(doc,"$$MU,\"%s\",LE=0x%X$$\n",buf,d);
|
||||
}
|
||||
if (footer)
|
||||
DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i(F64);
|
||||
}
|
||||
|
||||
public F64 PopUpRangeF64Log(F64 lo,F64 hi,I64 steps,
|
||||
U8 *fmt="%9.4f",U8 *header=NULL,U8 *footer=NULL)
|
||||
{//Log-spaced F64 range chooser in PopUp win task.
|
||||
return PopUpRangeF64Exp(lo,hi,Exp(Ln(hi/lo)/(steps-1)),fmt,header,footer);
|
||||
}
|
||||
|
||||
#help_index "Task/Srv/Exe;Compiler"
|
||||
public I64 AdamFile(U8 *filename,Bool warn_ext=TRUE)
|
||||
{//Make adam_task execute file.
|
||||
Bool okay=TRUE;
|
||||
U8 *name=FileNameAbs(filename),
|
||||
*name2=DftExt(name,"HC.Z");
|
||||
I64 res=0;
|
||||
if (warn_ext &&
|
||||
!FilesFindMatch(name2,FILEMASK_JIT) &&
|
||||
!PopUpCancelOk(ST_WARN_ST "Not .HC File\n\n"))
|
||||
okay=FALSE;
|
||||
if (okay)
|
||||
res=Adam("#include \"%s\";",name2);
|
||||
Free(name2);
|
||||
Free(name);
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 PopUpFile(U8 *filename,Bool warn_ext=TRUE,
|
||||
CTask *parent=NULL,CTask **_pu_task=NULL)
|
||||
{//$LK,"ExeFile2",A="MN:ExeFile2"$() in $LK,"PopUp",A="MN:PopUp"$ task. Cont as User.
|
||||
Bool okay=TRUE;
|
||||
U8 *st,*name=FileNameAbs(filename),
|
||||
*name2=DftExt(name,"HC.Z");
|
||||
I64 res=0;
|
||||
if (warn_ext &&
|
||||
!FilesFindMatch(name2,FILEMASK_JIT) &&
|
||||
!PopUpCancelOk(ST_WARN_ST "Not .HC File\n\n"))
|
||||
okay=FALSE;
|
||||
if (okay) {
|
||||
st=MStrPrint(
|
||||
"\"$$$$WW+H,1$$$$\";Auto(\"ExeFile2(\\\"%s\\\",CCF_CMD_LINE);\\n\");"
|
||||
"UserTaskCont;",
|
||||
name2);
|
||||
res=PopUp(st,parent,_pu_task);
|
||||
Free(st);
|
||||
}
|
||||
Free(name2);
|
||||
Free(name);
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 PopUpRunFile(U8 *filename,I64 ccf_flags=0,...)
|
||||
{//$LK,"ExeFile",A="MN:ExeFile"$() with args using $LK,"LastFun",A="MN:LastFun"$() in $LK,"PopUp",A="MN:PopUp"$ task.
|
||||
U8 *st,*name=FileNameAbs(filename),
|
||||
*name2=DftExt(name,"HC.Z");
|
||||
I64 res=0;
|
||||
st=MStrPrint(
|
||||
"\"$$$$WW+H,1$$$$\";ExeFile2(\"%s\",0x%X);LastFun(0x%X,0x%X);",
|
||||
name2,ccf_flags,argc,argv);
|
||||
res=PopUp(st,Fs);
|
||||
Free(st);
|
||||
Free(name2);
|
||||
Free(name);
|
||||
return res;
|
||||
}
|
||||
@@ -1,726 +0,0 @@
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
|
||||
public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
|
||||
{//$LK,"PutKey",A="MN:PutKey"$(ch,sc) at doc insert pt, cur_entry.
|
||||
I64 i,x,y;
|
||||
CDoc *m;
|
||||
CDocEntry *doc_ce;
|
||||
U8 *st,*st2;
|
||||
Bool unlock;
|
||||
|
||||
if (!doc && !(doc=DocPut) || doc->doc_signature!=DOC_SIGNATURE_VAL)
|
||||
return;
|
||||
if (doc->user_put_key && (*doc->user_put_key)(doc,doc->user_put_data,ch,sc))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
if (!Bt(doldoc.clean_scan_codes,sc.u8[0]))
|
||||
doc->flags|=DOCF_UNDO_DIRTY;
|
||||
DocCaptureUndo(doc);
|
||||
if (Bt(chars_bmp_getkey,ch) && !(sc&(SCF_CTRL|SCF_ALT))) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
st=Char2KeyName(ch,FALSE);
|
||||
KeyDescSet("Char /'%s'",st);
|
||||
Free(st);
|
||||
} else
|
||||
EdCharIns(ch,sc,doc);
|
||||
} else {
|
||||
doc_ce=doc->cur_entry;
|
||||
x=doc->x; y=doc->y;
|
||||
if (sc&SCF_ALT)
|
||||
switch (ch) {
|
||||
case CH_BACKSPACE: //<CTRL-H>
|
||||
if (!(sc&(SCF_SHIFT|SCF_CTRL))) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Undo");
|
||||
else
|
||||
DocUndoRestore(doc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
switch (ch) {
|
||||
case 0:
|
||||
switch (sc.u8[0]) {
|
||||
case SC_CURSOR_DOWN:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Cursor Down, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/Cursor Down");
|
||||
} else
|
||||
EdLineDown(doc,sc);
|
||||
break;
|
||||
} else
|
||||
sc&=~SCF_CTRL;
|
||||
//Fall Through to SC_END
|
||||
case SC_END:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/GoTo Doc End, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/GoTo Doc End");
|
||||
} else {
|
||||
while (doc_ce!=doc) {
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc->cur_entry=doc_ce->next;
|
||||
}
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
DocFormBwd(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_CURSOR_UP:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Cursor Up, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/Cursor Up");
|
||||
} else
|
||||
EdLineUp(doc,sc);
|
||||
break;
|
||||
} else
|
||||
sc&=~SCF_CTRL;
|
||||
//Fall Through to SC_HOME
|
||||
case SC_HOME:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/GoTo Top of Doc, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/GoTo Top of Doc");
|
||||
} else {
|
||||
if (doc_ce==doc) doc_ce=doc_ce->last;
|
||||
while (doc_ce!=doc) {
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc->cur_entry=doc_ce->last;
|
||||
}
|
||||
doc_ce=doc->cur_entry=doc->head.next;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
DocFormFwd(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_PAGE_DOWN:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Page Down, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/Page Down");
|
||||
} else {
|
||||
i=doc_ce->y+doc->win_task->win_height-1;
|
||||
if (doc_ce->type_u8==DOCT_HEX_ED)
|
||||
i+=doc->cur_col/3/doc_ce->hex_ed_width;
|
||||
while (doc_ce!=doc &&
|
||||
(doc_ce->type_u8!=DOCT_HEX_ED && doc_ce->y<i ||
|
||||
doc_ce->type_u8==DOCT_HEX_ED &&
|
||||
doc_ce->y+doc->cur_col/3/doc_ce->hex_ed_width<i)) {
|
||||
EdLineDown(doc,sc);
|
||||
//paranoid check for stuck on same node
|
||||
if (doc->cur_entry==doc_ce && doc_ce->type_u8!=DOCT_HEX_ED)
|
||||
break;
|
||||
doc_ce=doc->cur_entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_PAGE_UP:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Page Up, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/Page Up");
|
||||
}else {
|
||||
i=doc_ce->y-(doc->win_task->win_height-1);
|
||||
if (doc_ce->type_u8==DOCT_HEX_ED)
|
||||
i+=doc->cur_col/3/doc_ce->hex_ed_width;
|
||||
while (doc_ce->last!=doc &&
|
||||
(doc_ce->type_u8!=DOCT_HEX_ED && doc_ce->y>i ||
|
||||
doc_ce->type_u8==DOCT_HEX_ED &&
|
||||
doc_ce->y+doc->cur_col/3/doc_ce->hex_ed_width>i) &&
|
||||
doc_ce->y!=doc->head.next->y) {
|
||||
EdLineUp(doc,sc);
|
||||
//paranoid check for stuck on same node
|
||||
if (doc->cur_entry==doc_ce && doc_ce->type_u8!=DOCT_HEX_ED)
|
||||
break;
|
||||
doc_ce=doc->cur_entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_CURSOR_LEFT:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_CTRL)
|
||||
KeyDescSet("Edit/GoTo Start of Line");
|
||||
else {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Cursor Left, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/Cursor Left");
|
||||
}
|
||||
} else
|
||||
EdCursorLeft(doc,sc);
|
||||
break;
|
||||
case SC_CURSOR_RIGHT:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_CTRL)
|
||||
KeyDescSet("Edit/GoTo End of Line");
|
||||
else {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Cursor Right, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/Cursor Right");
|
||||
}
|
||||
} else
|
||||
EdCursorRight(doc,sc);
|
||||
break;
|
||||
case SC_DELETE:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Cut To Clipboard");
|
||||
else
|
||||
KeyDescSet("Char /Delete");
|
||||
} else {
|
||||
if (sc&SCF_SHIFT)
|
||||
EdCutToClipboard(doc);
|
||||
else
|
||||
EdCharDel(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_INS:
|
||||
if (sc&(SCF_SHIFT|SCF_CTRL)!=(SCF_SHIFT|SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Paste Clipboard");
|
||||
else if (sc&SCF_CTRL)
|
||||
KeyDescSet("Edit/Copy to Clipboard");
|
||||
else
|
||||
KeyDescSet("Edit/Toggle Overstrike");
|
||||
} else {
|
||||
if (sc&SCF_SHIFT)
|
||||
EdPasteClipboard(doc);
|
||||
else if (sc&SCF_CTRL)
|
||||
EdCopyToClipboard(doc);
|
||||
else
|
||||
doc->flags^=DOCF_OVERSTRIKE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_F1...SC_F10:
|
||||
if (sc&SCF_CTRL) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /Src Code of Sym");
|
||||
else
|
||||
KeyDescSet("Edit/Autocomplete Sym");
|
||||
} else {
|
||||
DocUnlock(doc);
|
||||
if (AutoComplete(ON)) {
|
||||
if (sc&SCF_SHIFT)
|
||||
ACMan(sc.u8[0]-SC_F1+1,Fs);
|
||||
else
|
||||
ACFillIn(sc.u8[0]-SC_F1+1);
|
||||
}
|
||||
DocLock(doc);
|
||||
}
|
||||
} else {
|
||||
switch (sc.u8[0]) {
|
||||
case SC_F1:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /About");
|
||||
else
|
||||
KeyDescSet("Cmd /Help");
|
||||
} else {
|
||||
if (sc&SCF_SHIFT)
|
||||
Ed("::/Doc/AboutTempleOS.TXT.Z");
|
||||
else
|
||||
Ed("::/Doc/HelpIndex.TXT.Z");
|
||||
}
|
||||
break;
|
||||
case SC_F2:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Play Macro");
|
||||
else
|
||||
KeyDescSet("Edit/Macro");
|
||||
} else {
|
||||
DocUnlock(doc);
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (TaskValidate(sys_macro_task))
|
||||
PostMsgWait(sys_macro_task,
|
||||
MSG_KEY_DOWN_UP,CH_SHIFT_ESC,0);
|
||||
SysMacroStripKey(&sys_macro_head,ch,sc);
|
||||
PlaySysMacro;
|
||||
} else
|
||||
EdMacroUtil;
|
||||
DocLock(doc);
|
||||
}
|
||||
break;
|
||||
case SC_F3:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Find Last");
|
||||
else
|
||||
KeyDescSet("Edit/Find Next");
|
||||
}else {
|
||||
doc->find_replace->scan_fwd=!(sc&SCF_SHIFT);
|
||||
EdFindNext(doc);
|
||||
}
|
||||
break;
|
||||
case SC_F4:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /Insert Directory Name");
|
||||
else
|
||||
KeyDescSet("Cmd /Insert FileName");
|
||||
} else {
|
||||
DocUnlock(doc);
|
||||
if (sc&SCF_SHIFT)
|
||||
st=PopUpPickDir;
|
||||
else
|
||||
st=PopUpPickFile;
|
||||
DocLock(doc);
|
||||
if (st) {
|
||||
DocPrintPartial(doc,"%s",st);
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_F5:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /Adam Include");
|
||||
else
|
||||
KeyDescSet("Cmd /Run (Execute)");
|
||||
} else {
|
||||
if (st2=DocEntryLink(doc,doc_ce)) {
|
||||
st=DocLinkFile(st2);
|
||||
Free(st2);
|
||||
} else {
|
||||
DocWrite(doc);
|
||||
st=StrNew(doc->filename.name);
|
||||
}
|
||||
if (st2=DirFile(st,"Run","CPP.Z")) {
|
||||
if (FileFind(st2)) {
|
||||
Free(st);
|
||||
st=st2;
|
||||
} else
|
||||
Free(st2);
|
||||
}
|
||||
if (st) {
|
||||
if (sc&SCF_SHIFT)
|
||||
AdamFile(st);
|
||||
else
|
||||
PopUpFile(st);
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_F6:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /God Doodle");
|
||||
else
|
||||
KeyDescSet("Cmd /God Song");
|
||||
} else {
|
||||
//$LK,"::/Adam/God/HSNotes.TXT"$
|
||||
if (sc&SCF_SHIFT) {
|
||||
DocUnlock(doc);
|
||||
GodDoodle;
|
||||
DocLock(doc);
|
||||
} else
|
||||
GodSong;
|
||||
}
|
||||
break;
|
||||
case SC_F7:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /God Passage");
|
||||
else
|
||||
KeyDescSet("Cmd /God Word");
|
||||
} else {
|
||||
//$LK,"::/Adam/God/HSNotes.TXT"$
|
||||
FifoU8Flush(god.fifo);
|
||||
GodBitsIns(GOD_GOOD_BITS,KbdMouseEvtTime>>GOD_BAD_BITS);
|
||||
if (sc&SCF_SHIFT)
|
||||
GodPassage;
|
||||
else
|
||||
GodWord;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CH_CTRLA:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Save As");
|
||||
else
|
||||
DocWrite(doc,TRUE);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLB:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Toggle Border");
|
||||
else
|
||||
WinBorder(Bt(&doc->win_task->display_flags,
|
||||
DISPLAYf_NO_BORDER),doc->win_task);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLC:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Copy to Clipboard");
|
||||
else
|
||||
EdCopyToClipboard(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLD:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /File Manager");
|
||||
else {
|
||||
DocUnlock(doc);
|
||||
FileMgr;
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLF:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Search Files");
|
||||
else
|
||||
FindWiz;
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Find & Replace");
|
||||
else
|
||||
EdFindReplace(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLG:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/GoTo Line Num");
|
||||
else
|
||||
EdGoToLine(doc);
|
||||
}
|
||||
break;
|
||||
case CH_BACKSPACE: //<CTRL-H>
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Char /Back Space");
|
||||
else {
|
||||
DocCaptureUndo(doc);
|
||||
doc_ce=doc->cur_entry;
|
||||
if (doc->cur_col<=doc_ce->min_col) {
|
||||
doc_ce=doc->cur_entry=doc_ce->last;
|
||||
if (doc_ce!=doc && doc_ce->type_u8==DOCT_SOFT_NEW_LINE)
|
||||
doc_ce=doc->cur_entry=doc_ce->last;
|
||||
if (doc_ce==doc || doc_ce->type_u8==DOCT_PMT) {
|
||||
doc_ce=doc->cur_entry=doc_ce->next;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
} else {
|
||||
doc->cur_col=doc_ce->max_col;
|
||||
if (doc->cur_col>doc_ce->min_col)
|
||||
doc->cur_col--;
|
||||
EdCharDel(doc);
|
||||
}
|
||||
} else {
|
||||
doc->cur_col--;
|
||||
EdCharDel(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLI:
|
||||
if (sc.u8[0]!=SC_TAB) {
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Unindent 2");
|
||||
else
|
||||
DocPrint(doc,"$$ID,-2$$");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Indent 2");
|
||||
else
|
||||
DocPrint(doc,"$$ID,2$$");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Char /Return");
|
||||
else
|
||||
KeyDescSet("Char /Page Break");
|
||||
} else
|
||||
EdCharIns(ch,sc,doc);
|
||||
break;
|
||||
case CH_CTRLK:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Blinking Text Off");
|
||||
else
|
||||
DocPrint(doc,"$$BK,0$$");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Blinking Text On");
|
||||
else
|
||||
DocPrint(doc,"$$BK,1$$");
|
||||
}
|
||||
break;
|
||||
case CH_CTRLL:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Code Tools");
|
||||
else {
|
||||
DocUnlock(doc);
|
||||
EdCodeTools(doc);
|
||||
DocLock(doc);
|
||||
}
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Insert Text Widgets Wizard");
|
||||
else {
|
||||
DocUnlock(doc);
|
||||
EdInsWidgetWiz;
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLM:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Personal Notes");
|
||||
else
|
||||
Ed("~/PersonalNotes.TXT.Z");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Personal Menu");
|
||||
else {
|
||||
m=DocRead("~/PersonalMenu.TXT.Z");
|
||||
DocMenu(m);
|
||||
DocDel(m);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLO:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Collapse");
|
||||
else
|
||||
DocCollapse(TRUE,doc);
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Uncolapse");
|
||||
else
|
||||
DocCollapse(FALSE,doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLP:
|
||||
if (doc->flags & (DOCF_SUPERSCRIPT_MODE | DOCF_SUBSCRIPT_MODE)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Toggle Super or Sub script");
|
||||
else {
|
||||
DocPrint(doc,"$$SY,0$$");
|
||||
doc->flags&=~(DOCF_SUPERSCRIPT_MODE | DOCF_SUBSCRIPT_MODE);
|
||||
}
|
||||
} else if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Toggle Subscript");
|
||||
else {
|
||||
DocPrint(doc,"$$SY,3$$");
|
||||
doc->flags|=DOCF_SUBSCRIPT_MODE;
|
||||
}
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Toggle Superscript");
|
||||
else {
|
||||
DocPrint(doc,"$$SY,-3$$");
|
||||
doc->flags|=DOCF_SUPERSCRIPT_MODE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLQ:
|
||||
break;
|
||||
case CH_CTRLR:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Sprite Graphic Resource");
|
||||
else
|
||||
if (!(doc->flags&DOCF_FORM) &&
|
||||
!(doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_TABS))) {
|
||||
DocUnlock(doc);
|
||||
if (doc_ce->type_u8==DOCT_SPRITE)
|
||||
EdSpriteEd(doc);
|
||||
else
|
||||
EdSpriteIns(doc);
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLS:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Find Misspelled");
|
||||
else
|
||||
ACMisspelledFind(doc);
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Save");
|
||||
else
|
||||
DocWrite(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLT:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Single Entry Toggle Plain Text");
|
||||
else if (!(doc->flags&DOCF_FORM))
|
||||
DocEntryToggle(doc);
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Toggle Plain Text Display");
|
||||
else if (!(doc->flags&DOCF_FORM))
|
||||
DocFlagsToggle(doc,DOCF_PLAIN_TEXT);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLU:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Underline Off");
|
||||
else
|
||||
DocPrint(doc,"$$UL,0$$");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Underline On");
|
||||
else
|
||||
DocPrint(doc,"$$UL,1$$");
|
||||
}
|
||||
break;
|
||||
case CH_CTRLV:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Paste Clipboard");
|
||||
else
|
||||
EdPasteClipboard(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLW:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Word Wrap Off");
|
||||
else
|
||||
DocPrint(doc,"$$WW,0$$");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Word Wrap On");
|
||||
else
|
||||
DocPrint(doc,"$$WW,1$$");
|
||||
}
|
||||
break;
|
||||
case CH_CTRLX:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Cut To Clipboard");
|
||||
else
|
||||
EdCutToClipboard(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLY:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Delete Line");
|
||||
else
|
||||
EdLineDel(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLZ:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Inverted Text Off");
|
||||
else
|
||||
DocPrint(doc,"$$IV,0$$");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Inverted Text On");
|
||||
else
|
||||
DocPrint(doc,"$$IV,1$$");
|
||||
}
|
||||
break;
|
||||
case '0'...'9':
|
||||
if (sc&SCF_CTRL) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /Word Definition");
|
||||
else
|
||||
KeyDescSet("Edit/Autocomplete Word");
|
||||
} else {
|
||||
if (AutoComplete(ON)) {
|
||||
DocUnlock(doc);
|
||||
if (sc&SCF_SHIFT)
|
||||
ACDDef(ch-'0',Fs);
|
||||
else
|
||||
ACDFillin(ch-'0');
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '[':
|
||||
if (sc&SCF_CTRL) {
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/GoTo matching brace");
|
||||
else
|
||||
EdFindPaired(doc,'}','{',FALSE);
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/GoTo matching bracket");
|
||||
else
|
||||
EdFindPaired(doc,']','[',FALSE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ']':
|
||||
if (sc&SCF_CTRL) {
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/GoTo matching brace");
|
||||
else
|
||||
EdFindPaired(doc,'{','}',TRUE);
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/GoTo matching bracket");
|
||||
else
|
||||
EdFindPaired(doc,'[',']',TRUE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
if (!(doc->flags&DOCF_DONT_SWAP_OUT))
|
||||
Yield;
|
||||
}
|
||||
|
||||
Bool KDDocPutKey(I64 ch,I64 scan_code)
|
||||
{
|
||||
CDoc *doc;
|
||||
if (doc=DocPut)
|
||||
DocPutKey(doc,ch,scan_code);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -0,0 +1,726 @@
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
|
||||
public U0 DocPutKey(CDoc *doc,I64 ch=0,I64 sc=0)
|
||||
{//$LK,"PutKey",A="MN:PutKey"$(ch,sc) at doc insert pt, cur_entry.
|
||||
I64 i,x,y;
|
||||
CDoc *m;
|
||||
CDocEntry *doc_ce;
|
||||
U8 *st,*st2;
|
||||
Bool unlock;
|
||||
|
||||
if (!doc && !(doc=DocPut) || doc->doc_signature!=DOC_SIGNATURE_VAL)
|
||||
return;
|
||||
if (doc->user_put_key && (*doc->user_put_key)(doc,doc->user_put_data,ch,sc))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
if (!Bt(doldoc.clean_scan_codes,sc.u8[0]))
|
||||
doc->flags|=DOCF_UNDO_DIRTY;
|
||||
DocCaptureUndo(doc);
|
||||
if (Bt(chars_bmp_getkey,ch) && !(sc&(SCF_CTRL|SCF_ALT))) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
st=Char2KeyName(ch,FALSE);
|
||||
KeyDescSet("Char /'%s'",st);
|
||||
Free(st);
|
||||
} else
|
||||
EdCharIns(ch,sc,doc);
|
||||
} else {
|
||||
doc_ce=doc->cur_entry;
|
||||
x=doc->x; y=doc->y;
|
||||
if (sc&SCF_ALT)
|
||||
switch (ch) {
|
||||
case CH_BACKSPACE: //<CTRL-H>
|
||||
if (!(sc&(SCF_SHIFT|SCF_CTRL))) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Undo");
|
||||
else
|
||||
DocUndoRestore(doc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
switch (ch) {
|
||||
case 0:
|
||||
switch (sc.u8[0]) {
|
||||
case SC_CURSOR_DOWN:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Cursor Down, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/Cursor Down");
|
||||
} else
|
||||
EdLineDown(doc,sc);
|
||||
break;
|
||||
} else
|
||||
sc&=~SCF_CTRL;
|
||||
//Fall Through to SC_END
|
||||
case SC_END:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/GoTo Doc End, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/GoTo Doc End");
|
||||
} else {
|
||||
while (doc_ce!=doc) {
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc->cur_entry=doc_ce->next;
|
||||
}
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
DocFormBwd(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_CURSOR_UP:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Cursor Up, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/Cursor Up");
|
||||
} else
|
||||
EdLineUp(doc,sc);
|
||||
break;
|
||||
} else
|
||||
sc&=~SCF_CTRL;
|
||||
//Fall Through to SC_HOME
|
||||
case SC_HOME:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/GoTo Top of Doc, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/GoTo Top of Doc");
|
||||
} else {
|
||||
if (doc_ce==doc) doc_ce=doc_ce->last;
|
||||
while (doc_ce!=doc) {
|
||||
BEqu(&doc_ce->type,DOCEt_SEL,sc&SCF_SHIFT);
|
||||
doc_ce=doc->cur_entry=doc_ce->last;
|
||||
}
|
||||
doc_ce=doc->cur_entry=doc->head.next;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
DocFormFwd(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_PAGE_DOWN:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Page Down, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/Page Down");
|
||||
} else {
|
||||
i=doc_ce->y+doc->win_task->win_height-1;
|
||||
if (doc_ce->type_u8==DOCT_HEX_ED)
|
||||
i+=doc->cur_col/3/doc_ce->hex_ed_width;
|
||||
while (doc_ce!=doc &&
|
||||
(doc_ce->type_u8!=DOCT_HEX_ED && doc_ce->y<i ||
|
||||
doc_ce->type_u8==DOCT_HEX_ED &&
|
||||
doc_ce->y+doc->cur_col/3/doc_ce->hex_ed_width<i)) {
|
||||
EdLineDown(doc,sc);
|
||||
//paranoid check for stuck on same node
|
||||
if (doc->cur_entry==doc_ce && doc_ce->type_u8!=DOCT_HEX_ED)
|
||||
break;
|
||||
doc_ce=doc->cur_entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_PAGE_UP:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Page Up, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/Page Up");
|
||||
}else {
|
||||
i=doc_ce->y-(doc->win_task->win_height-1);
|
||||
if (doc_ce->type_u8==DOCT_HEX_ED)
|
||||
i+=doc->cur_col/3/doc_ce->hex_ed_width;
|
||||
while (doc_ce->last!=doc &&
|
||||
(doc_ce->type_u8!=DOCT_HEX_ED && doc_ce->y>i ||
|
||||
doc_ce->type_u8==DOCT_HEX_ED &&
|
||||
doc_ce->y+doc->cur_col/3/doc_ce->hex_ed_width>i) &&
|
||||
doc_ce->y!=doc->head.next->y) {
|
||||
EdLineUp(doc,sc);
|
||||
//paranoid check for stuck on same node
|
||||
if (doc->cur_entry==doc_ce && doc_ce->type_u8!=DOCT_HEX_ED)
|
||||
break;
|
||||
doc_ce=doc->cur_entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_CURSOR_LEFT:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_CTRL)
|
||||
KeyDescSet("Edit/GoTo Start of Line");
|
||||
else {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Cursor Left, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/Cursor Left");
|
||||
}
|
||||
} else
|
||||
EdCursorLeft(doc,sc);
|
||||
break;
|
||||
case SC_CURSOR_RIGHT:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_CTRL)
|
||||
KeyDescSet("Edit/GoTo End of Line");
|
||||
else {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Cursor Right, Sel");
|
||||
else
|
||||
KeyDescSet("Edit/Cursor Right");
|
||||
}
|
||||
} else
|
||||
EdCursorRight(doc,sc);
|
||||
break;
|
||||
case SC_DELETE:
|
||||
if (!(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Cut To Clipboard");
|
||||
else
|
||||
KeyDescSet("Char /Delete");
|
||||
} else {
|
||||
if (sc&SCF_SHIFT)
|
||||
EdCutToClipboard(doc);
|
||||
else
|
||||
EdCharDel(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_INS:
|
||||
if (sc&(SCF_SHIFT|SCF_CTRL)!=(SCF_SHIFT|SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Paste Clipboard");
|
||||
else if (sc&SCF_CTRL)
|
||||
KeyDescSet("Edit/Copy to Clipboard");
|
||||
else
|
||||
KeyDescSet("Edit/Toggle Overstrike");
|
||||
} else {
|
||||
if (sc&SCF_SHIFT)
|
||||
EdPasteClipboard(doc);
|
||||
else if (sc&SCF_CTRL)
|
||||
EdCopyToClipboard(doc);
|
||||
else
|
||||
doc->flags^=DOCF_OVERSTRIKE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_F1...SC_F10:
|
||||
if (sc&SCF_CTRL) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /Src Code of Sym");
|
||||
else
|
||||
KeyDescSet("Edit/Autocomplete Sym");
|
||||
} else {
|
||||
DocUnlock(doc);
|
||||
if (AutoComplete(ON)) {
|
||||
if (sc&SCF_SHIFT)
|
||||
ACMan(sc.u8[0]-SC_F1+1,Fs);
|
||||
else
|
||||
ACFillIn(sc.u8[0]-SC_F1+1);
|
||||
}
|
||||
DocLock(doc);
|
||||
}
|
||||
} else {
|
||||
switch (sc.u8[0]) {
|
||||
case SC_F1:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /About");
|
||||
else
|
||||
KeyDescSet("Cmd /Help");
|
||||
} else {
|
||||
if (sc&SCF_SHIFT)
|
||||
Ed("::/Doc/AboutTempleOS.DD.Z");
|
||||
else
|
||||
Ed("::/Doc/HelpIndex.DD.Z");
|
||||
}
|
||||
break;
|
||||
case SC_F2:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Play Macro");
|
||||
else
|
||||
KeyDescSet("Edit/Macro");
|
||||
} else {
|
||||
DocUnlock(doc);
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (TaskValidate(sys_macro_task))
|
||||
PostMsgWait(sys_macro_task,
|
||||
MSG_KEY_DOWN_UP,CH_SHIFT_ESC,0);
|
||||
SysMacroStripKey(&sys_macro_head,ch,sc);
|
||||
PlaySysMacro;
|
||||
} else
|
||||
EdMacroUtil;
|
||||
DocLock(doc);
|
||||
}
|
||||
break;
|
||||
case SC_F3:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Find Last");
|
||||
else
|
||||
KeyDescSet("Edit/Find Next");
|
||||
}else {
|
||||
doc->find_replace->scan_fwd=!(sc&SCF_SHIFT);
|
||||
EdFindNext(doc);
|
||||
}
|
||||
break;
|
||||
case SC_F4:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /Insert Directory Name");
|
||||
else
|
||||
KeyDescSet("Cmd /Insert FileName");
|
||||
} else {
|
||||
DocUnlock(doc);
|
||||
if (sc&SCF_SHIFT)
|
||||
st=PopUpPickDir;
|
||||
else
|
||||
st=PopUpPickFile;
|
||||
DocLock(doc);
|
||||
if (st) {
|
||||
DocPrintPartial(doc,"%s",st);
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_F5:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /Adam Include");
|
||||
else
|
||||
KeyDescSet("Cmd /Run (Execute)");
|
||||
} else {
|
||||
if (st2=DocEntryLink(doc,doc_ce)) {
|
||||
st=DocLinkFile(st2);
|
||||
Free(st2);
|
||||
} else {
|
||||
DocWrite(doc);
|
||||
st=StrNew(doc->filename.name);
|
||||
}
|
||||
if (st2=DirFile(st,"Run","HC.Z")) {
|
||||
if (FileFind(st2)) {
|
||||
Free(st);
|
||||
st=st2;
|
||||
} else
|
||||
Free(st2);
|
||||
}
|
||||
if (st) {
|
||||
if (sc&SCF_SHIFT)
|
||||
AdamFile(st);
|
||||
else
|
||||
PopUpFile(st);
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SC_F6:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /God Doodle");
|
||||
else
|
||||
KeyDescSet("Cmd /God Song");
|
||||
} else {
|
||||
//$LK,"::/Adam/God/HSNotes.DD"$
|
||||
if (sc&SCF_SHIFT) {
|
||||
DocUnlock(doc);
|
||||
GodDoodle;
|
||||
DocLock(doc);
|
||||
} else
|
||||
GodSong;
|
||||
}
|
||||
break;
|
||||
case SC_F7:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /God Passage");
|
||||
else
|
||||
KeyDescSet("Cmd /God Word");
|
||||
} else {
|
||||
//$LK,"::/Adam/God/HSNotes.DD"$
|
||||
FifoU8Flush(god.fifo);
|
||||
GodBitsIns(GOD_GOOD_BITS,KbdMouseEvtTime>>GOD_BAD_BITS);
|
||||
if (sc&SCF_SHIFT)
|
||||
GodBiblePassage;
|
||||
else
|
||||
GodWord;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CH_CTRLA:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Save As");
|
||||
else
|
||||
DocWrite(doc,TRUE);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLB:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Toggle Border");
|
||||
else
|
||||
WinBorder(Bt(&doc->win_task->display_flags,
|
||||
DISPLAYf_NO_BORDER),doc->win_task);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLC:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Copy to Clipboard");
|
||||
else
|
||||
EdCopyToClipboard(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLD:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /File Manager");
|
||||
else {
|
||||
DocUnlock(doc);
|
||||
FileMgr;
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLF:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Search Files");
|
||||
else
|
||||
FindWiz;
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Find & Replace");
|
||||
else
|
||||
EdFindReplace(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLG:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/GoTo Line Num");
|
||||
else
|
||||
EdGoToLine(doc);
|
||||
}
|
||||
break;
|
||||
case CH_BACKSPACE: //<CTRL-H>
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Char /Back Space");
|
||||
else {
|
||||
DocCaptureUndo(doc);
|
||||
doc_ce=doc->cur_entry;
|
||||
if (doc->cur_col<=doc_ce->min_col) {
|
||||
doc_ce=doc->cur_entry=doc_ce->last;
|
||||
if (doc_ce!=doc && doc_ce->type_u8==DOCT_SOFT_NEW_LINE)
|
||||
doc_ce=doc->cur_entry=doc_ce->last;
|
||||
if (doc_ce==doc || doc_ce->type_u8==DOCT_PMT) {
|
||||
doc_ce=doc->cur_entry=doc_ce->next;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
} else {
|
||||
doc->cur_col=doc_ce->max_col;
|
||||
if (doc->cur_col>doc_ce->min_col)
|
||||
doc->cur_col--;
|
||||
EdCharDel(doc);
|
||||
}
|
||||
} else {
|
||||
doc->cur_col--;
|
||||
EdCharDel(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLI:
|
||||
if (sc.u8[0]!=SC_TAB) {
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Unindent 2");
|
||||
else
|
||||
DocPrint(doc,"$$ID,-2$$");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Indent 2");
|
||||
else
|
||||
DocPrint(doc,"$$ID,2$$");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Char /Return");
|
||||
else
|
||||
KeyDescSet("Char /Page Break");
|
||||
} else
|
||||
EdCharIns(ch,sc,doc);
|
||||
break;
|
||||
case CH_CTRLK:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Blinking Text Off");
|
||||
else
|
||||
DocPrint(doc,"$$BK,0$$");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Blinking Text On");
|
||||
else
|
||||
DocPrint(doc,"$$BK,1$$");
|
||||
}
|
||||
break;
|
||||
case CH_CTRLL:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Code Tools");
|
||||
else {
|
||||
DocUnlock(doc);
|
||||
EdCodeTools(doc);
|
||||
DocLock(doc);
|
||||
}
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Insert Text Widgets Wizard");
|
||||
else {
|
||||
DocUnlock(doc);
|
||||
EdInsWidgetWiz;
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLM:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Personal Notes");
|
||||
else
|
||||
Ed("~/PersonalNotes.DD.Z");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Personal Menu");
|
||||
else {
|
||||
m=DocRead("~/PersonalMenu.DD.Z");
|
||||
DocMenu(m);
|
||||
DocDel(m);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLO:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Collapse");
|
||||
else
|
||||
DocCollapse(TRUE,doc);
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Uncolapse");
|
||||
else
|
||||
DocCollapse(FALSE,doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLP:
|
||||
if (doc->flags & (DOCF_SUPERSCRIPT_MODE | DOCF_SUBSCRIPT_MODE)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Toggle Super or Sub script");
|
||||
else {
|
||||
DocPrint(doc,"$$SY,0$$");
|
||||
doc->flags&=~(DOCF_SUPERSCRIPT_MODE | DOCF_SUBSCRIPT_MODE);
|
||||
}
|
||||
} else if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Toggle Subscript");
|
||||
else {
|
||||
DocPrint(doc,"$$SY,3$$");
|
||||
doc->flags|=DOCF_SUBSCRIPT_MODE;
|
||||
}
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Toggle Superscript");
|
||||
else {
|
||||
DocPrint(doc,"$$SY,-3$$");
|
||||
doc->flags|=DOCF_SUPERSCRIPT_MODE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLQ:
|
||||
break;
|
||||
case CH_CTRLR:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Sprite Graphic Resource");
|
||||
else
|
||||
if (!(doc->flags&DOCF_FORM) &&
|
||||
!(doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_TABS))) {
|
||||
DocUnlock(doc);
|
||||
if (doc_ce->type_u8==DOCT_SPRITE)
|
||||
EdSpriteEd(doc);
|
||||
else
|
||||
EdSpriteIns(doc);
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLS:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Find Misspelled");
|
||||
else
|
||||
ACMisspelledFind(doc);
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Save");
|
||||
else
|
||||
DocWrite(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLT:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Single Entry Toggle Plain Text");
|
||||
else if (!(doc->flags&DOCF_FORM))
|
||||
DocEntryToggle(doc);
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Toggle Plain Text Display");
|
||||
else if (!(doc->flags&DOCF_FORM))
|
||||
DocFlagsToggle(doc,DOCF_PLAIN_TEXT);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLU:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Underline Off");
|
||||
else
|
||||
DocPrint(doc,"$$UL,0$$");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Underline On");
|
||||
else
|
||||
DocPrint(doc,"$$UL,1$$");
|
||||
}
|
||||
break;
|
||||
case CH_CTRLV:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Paste Clipboard");
|
||||
else
|
||||
EdPasteClipboard(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLW:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Word Wrap Off");
|
||||
else
|
||||
DocPrint(doc,"$$WW,0$$");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Word Wrap On");
|
||||
else
|
||||
DocPrint(doc,"$$WW,1$$");
|
||||
}
|
||||
break;
|
||||
case CH_CTRLX:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Cut To Clipboard");
|
||||
else
|
||||
EdCutToClipboard(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLY:
|
||||
if (!(sc&SCF_SHIFT)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Delete Line");
|
||||
else
|
||||
EdLineDel(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLZ:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Inverted Text Off");
|
||||
else
|
||||
DocPrint(doc,"$$IV,0$$");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Inverted Text On");
|
||||
else
|
||||
DocPrint(doc,"$$IV,1$$");
|
||||
}
|
||||
break;
|
||||
case '0'...'9':
|
||||
if (sc&SCF_CTRL) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd /Word Definition");
|
||||
else
|
||||
KeyDescSet("Edit/Autocomplete Word");
|
||||
} else {
|
||||
if (AutoComplete(ON)) {
|
||||
DocUnlock(doc);
|
||||
if (sc&SCF_SHIFT)
|
||||
ACDDef(ch-'0',Fs);
|
||||
else
|
||||
ACDFillin(ch-'0');
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '[':
|
||||
if (sc&SCF_CTRL) {
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/GoTo matching brace");
|
||||
else
|
||||
EdFindPaired(doc,'}','{',FALSE);
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/GoTo matching bracket");
|
||||
else
|
||||
EdFindPaired(doc,']','[',FALSE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ']':
|
||||
if (sc&SCF_CTRL) {
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/GoTo matching brace");
|
||||
else
|
||||
EdFindPaired(doc,'{','}',TRUE);
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/GoTo matching bracket");
|
||||
else
|
||||
EdFindPaired(doc,'[',']',TRUE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
if (!(doc->flags&DOCF_DONT_SWAP_OUT))
|
||||
Yield;
|
||||
}
|
||||
|
||||
Bool KDDocPutKey(I64 ch,I64 scan_code)
|
||||
{
|
||||
CDoc *doc;
|
||||
if (doc=DocPut)
|
||||
DocPutKey(doc,ch,scan_code);
|
||||
return FALSE;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,213 +0,0 @@
|
||||
#help_index "DolDoc"
|
||||
|
||||
I64 DocCharDist(CDoc *doc,I64 x,I64 y)
|
||||
{
|
||||
#assert FONT_WIDTH==FONT_HEIGHT
|
||||
return (SqrI64(doc->x-x)+SqrI64(doc->y-y))*FONT_WIDTH*FONT_WIDTH;
|
||||
}
|
||||
|
||||
U0 DocDelToNum(CDoc *doc,I64 num)
|
||||
{
|
||||
CDocEntry *doc_e=doc->head.next,*doc_e2;
|
||||
while (num-->0 && doc_e!=doc) {
|
||||
doc_e2=doc_e->next;
|
||||
if (!(doc_e->de_flags & (DOCEF_HOLD|DOCEF_FILTER_SKIP))) {
|
||||
if (doc_e==doc->cur_entry) {
|
||||
doc->cur_entry=doc_e2;
|
||||
doc->cur_col=doc_e2->min_col;
|
||||
}
|
||||
DocEntryDel(doc,doc_e);
|
||||
}
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DocDelToEntry(CDoc *doc,CDocEntry *clear_entry,Bool clear_holds)
|
||||
{
|
||||
CDocEntry *doc_e=doc->head.next,*doc_e2;
|
||||
while (doc_e!=doc) {
|
||||
doc_e2=doc_e->next;
|
||||
if (!(doc_e->de_flags & (DOCEF_HOLD|DOCEF_FILTER_SKIP))||clear_holds) {
|
||||
if (doc_e==doc->cur_entry) {
|
||||
doc->cur_entry=doc_e2;
|
||||
doc->cur_col=doc_e2->min_col;
|
||||
}
|
||||
DocEntryDel(doc,doc_e);
|
||||
}
|
||||
if (doc_e==clear_entry)
|
||||
break;
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DocBorderLstDraw(CDoc *doc)
|
||||
{
|
||||
CTask *win_task=doc->win_task;
|
||||
I64 i,y=-1,attr=win_task->border_attr<<8;
|
||||
U64 ch;
|
||||
CDoc *templ=doc;
|
||||
CD3I64 saved_scroll;
|
||||
while (templ && templ->doc_signature==DOC_SIGNATURE_VAL) {
|
||||
y+=(Bsr(templ->desc)+7)>>3+1; //StrLen+1
|
||||
templ=templ->parent_doc;
|
||||
}
|
||||
templ=doc;
|
||||
if (y>win_task->win_height)
|
||||
y=win_task->win_height;
|
||||
WinScrollNull(win_task,&saved_scroll);
|
||||
while (templ && templ->doc_signature==DOC_SIGNATURE_VAL) {
|
||||
ch=templ->desc;
|
||||
i=(Bsr(ch)+7)>>3; //StrLen
|
||||
ch=EndianI64(ch<<((8-i)<<3));
|
||||
attr=win_task->border_attr<<8;
|
||||
while (i-- && y>0) {
|
||||
TextChar(win_task,TRUE,-1,--y,attr+ch&0xFF);
|
||||
ch>>=8;
|
||||
}
|
||||
y--;
|
||||
templ=templ->parent_doc;
|
||||
}
|
||||
WinScrollRestore(win_task,&saved_scroll);
|
||||
}
|
||||
|
||||
public U0 DocTop(CDoc *doc=NULL)
|
||||
{//Move cursor, cur_entry, to top.
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
doc->cur_entry=doc->head.next;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
doc->x=0;
|
||||
doc->y=0;
|
||||
doc->line_start_col=0;
|
||||
doc->top_line_num=0;
|
||||
|
||||
DocFormFwd(doc);
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocCenter(CDoc *doc=NULL,I64 recalc_flags=RECALCt_NORMAL)
|
||||
{//Center win on doc cursor, cur_entry.
|
||||
Bool unlock;
|
||||
CTask *task;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
task=doc->win_task;
|
||||
DocRecalc(doc,recalc_flags);
|
||||
if (!(doc->flags&DOCF_BORDER_DOC))
|
||||
doc->top_line_num=doc->y-(task->win_height+1)>>1;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocBottom(CDoc *doc=NULL)
|
||||
{//Move cursor, cur_entry, to bottom.
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
doc->cur_entry=doc;
|
||||
doc->cur_col=0;
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocClear(CDoc *doc=NULL,Bool clear_holds=FALSE)
|
||||
{//Clear all doc entries, except +H, hold entries.
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
DocBottom(doc);
|
||||
if (clear_holds)
|
||||
DocPrint(doc,"$$CL+H$$");
|
||||
else
|
||||
DocPrint(doc,"$$CL$$");
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public Bool DocCursor(Bool show=OFF,CDoc *doc=NULL)
|
||||
{//Show or hide cursor.
|
||||
if (!doc && !(doc=DocPut))
|
||||
return FALSE;
|
||||
return !LBEqu(&doc->flags,DOCf_HIDE_CURSOR,!show);
|
||||
}
|
||||
|
||||
public Bool DocHighlightCursor(Bool show=OFF,CDoc *doc=NULL)
|
||||
{//Highlight or Don't highlight cursor.
|
||||
if (!doc && !(doc=DocPut))
|
||||
return FALSE;
|
||||
return !LBEqu(&doc->flags,DOCf_DONT_HIGHLIGHT_CURSOR,!show);
|
||||
}
|
||||
|
||||
public Bool DocScroll(Bool val=OFF,CDoc *doc=NULL)
|
||||
{//Turn scroll bars OFF/ON.
|
||||
if (!doc && !(doc=DocPut))
|
||||
return FALSE;
|
||||
return !LBEqu(&doc->flags,DOCf_NO_SCROLL_BARS,!val);
|
||||
}
|
||||
|
||||
public U0 DocCollapse(Bool collapse=TRUE,CDoc *doc=NULL)
|
||||
{//Collapse or uncollapse all tree widgets.
|
||||
CDocEntry *doc_e;
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->de_flags&DOCEF_TREE)
|
||||
BEqu(&doc_e->de_flags,DOCEf_CHECKED_COLLAPSED,collapse);
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Cmd Line (Typically);Cmd Line (Typically)"
|
||||
public I64 DocMax(I64 i=MAX_I64)
|
||||
{//Set max document entries. (Cmd line buffer size.)
|
||||
//Adjusts the size of the cmd line buf.
|
||||
//Normally, the cmd line deletes entries
|
||||
//when more are added and the old scroll up.
|
||||
//See $LK,"max_entries",A="FF:::/Adam/DolDoc/DocTerm.CPP,max_entries"$.
|
||||
I64 res;
|
||||
CDoc *doc;
|
||||
if (doc=DocPut) {
|
||||
res=doc->max_entries;
|
||||
doc->max_entries=i;
|
||||
return res;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Task;StdOut/Task"
|
||||
U0 DocUpdateTaskDocs(CTask *task)
|
||||
{//This is called from $LK,"GrUpdateTaskWin",A="MN:GrUpdateTaskWin"$() by the winmgr at 30fps.
|
||||
CDoc *doc;
|
||||
CD3I64 saved_scroll;
|
||||
if (task->border_src==BDS_CUR_DRV && task->cur_dv)
|
||||
task->border_attr=DrvTextAttrGet(Drv2Let(task->cur_dv));
|
||||
if (task->title_src==TTS_TASK_NAME)
|
||||
StrCpy(task->task_title,task->task_name);
|
||||
if ((doc=DocDisplay(task)) && !(doc->flags&DOCF_DONT_SHOW)) {
|
||||
if (task->border_src==BDS_ED_FILENAME_DRV)
|
||||
task->border_attr=DrvTextAttrGet(*doc->filename.name);
|
||||
if (task->title_src==TTS_ED_FILENAME)
|
||||
MemCpy(task->task_title,doc->filename.name,STR_LEN-1);
|
||||
DocRecalc(doc,RECALCt_TO_SCREEN|RECALCF_HAS_CURSOR);
|
||||
}
|
||||
if ((doc=DocBorder(task)) && !(doc->flags&DOCF_DONT_SHOW)) {
|
||||
WinScrollNull(task,&saved_scroll);
|
||||
DocRecalc(doc,RECALCt_TO_SCREEN);
|
||||
WinScrollRestore(task,&saved_scroll);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
#help_index "DolDoc"
|
||||
|
||||
I64 DocCharDist(CDoc *doc,I64 x,I64 y)
|
||||
{
|
||||
#assert FONT_WIDTH==FONT_HEIGHT
|
||||
return (SqrI64(doc->x-x)+SqrI64(doc->y-y))*FONT_WIDTH*FONT_WIDTH;
|
||||
}
|
||||
|
||||
U0 DocDelToNum(CDoc *doc,I64 num)
|
||||
{
|
||||
CDocEntry *doc_e=doc->head.next,*doc_e2;
|
||||
while (num-->0 && doc_e!=doc) {
|
||||
doc_e2=doc_e->next;
|
||||
if (!(doc_e->de_flags & (DOCEF_HOLD|DOCEF_FILTER_SKIP))) {
|
||||
if (doc_e==doc->cur_entry) {
|
||||
doc->cur_entry=doc_e2;
|
||||
doc->cur_col=doc_e2->min_col;
|
||||
}
|
||||
DocEntryDel(doc,doc_e);
|
||||
}
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DocDelToEntry(CDoc *doc,CDocEntry *clear_entry,Bool clear_holds)
|
||||
{
|
||||
CDocEntry *doc_e=doc->head.next,*doc_e2;
|
||||
while (doc_e!=doc) {
|
||||
doc_e2=doc_e->next;
|
||||
if (!(doc_e->de_flags & (DOCEF_HOLD|DOCEF_FILTER_SKIP))||clear_holds) {
|
||||
if (doc_e==doc->cur_entry) {
|
||||
doc->cur_entry=doc_e2;
|
||||
doc->cur_col=doc_e2->min_col;
|
||||
}
|
||||
DocEntryDel(doc,doc_e);
|
||||
}
|
||||
if (doc_e==clear_entry)
|
||||
break;
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DocBorderLstDraw(CDoc *doc)
|
||||
{
|
||||
CTask *win_task=doc->win_task;
|
||||
I64 i,y=-1,attr=win_task->border_attr<<8;
|
||||
U64 ch;
|
||||
CDoc *templ=doc;
|
||||
CD3I64 saved_scroll;
|
||||
while (templ && templ->doc_signature==DOC_SIGNATURE_VAL) {
|
||||
y+=(Bsr(templ->desc)+7)>>3+1; //StrLen+1
|
||||
templ=templ->parent_doc;
|
||||
}
|
||||
templ=doc;
|
||||
if (y>win_task->win_height)
|
||||
y=win_task->win_height;
|
||||
WinScrollNull(win_task,&saved_scroll);
|
||||
while (templ && templ->doc_signature==DOC_SIGNATURE_VAL) {
|
||||
ch=templ->desc;
|
||||
i=(Bsr(ch)+7)>>3; //StrLen
|
||||
ch=EndianI64(ch<<((8-i)<<3));
|
||||
attr=win_task->border_attr<<8;
|
||||
while (i-- && y>0) {
|
||||
TextChar(win_task,TRUE,-1,--y,attr+ch&0xFF);
|
||||
ch>>=8;
|
||||
}
|
||||
y--;
|
||||
templ=templ->parent_doc;
|
||||
}
|
||||
WinScrollRestore(win_task,&saved_scroll);
|
||||
}
|
||||
|
||||
public U0 DocTop(CDoc *doc=NULL)
|
||||
{//Move cursor, cur_entry, to top.
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
doc->cur_entry=doc->head.next;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
doc->x=0;
|
||||
doc->y=0;
|
||||
doc->line_start_col=0;
|
||||
doc->top_line_num=0;
|
||||
|
||||
DocFormFwd(doc);
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocCenter(CDoc *doc=NULL,I64 recalc_flags=RECALCt_NORMAL)
|
||||
{//Center win on doc cursor, cur_entry.
|
||||
Bool unlock;
|
||||
CTask *task;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
task=doc->win_task;
|
||||
DocRecalc(doc,recalc_flags);
|
||||
if (!(doc->flags&DOCF_BORDER_DOC))
|
||||
doc->top_line_num=doc->y-(task->win_height+1)>>1;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocBottom(CDoc *doc=NULL)
|
||||
{//Move cursor, cur_entry, to bottom.
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
doc->cur_entry=doc;
|
||||
doc->cur_col=0;
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocClear(CDoc *doc=NULL,Bool clear_holds=FALSE)
|
||||
{//Clear all doc entries, except +H, hold entries.
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
DocBottom(doc);
|
||||
if (clear_holds)
|
||||
DocPrint(doc,"$$CL+H$$");
|
||||
else
|
||||
DocPrint(doc,"$$CL$$");
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public Bool DocCursor(Bool show=OFF,CDoc *doc=NULL)
|
||||
{//Show or hide cursor.
|
||||
if (!doc && !(doc=DocPut))
|
||||
return FALSE;
|
||||
return !LBEqu(&doc->flags,DOCf_HIDE_CURSOR,!show);
|
||||
}
|
||||
|
||||
public Bool DocHighlightCursor(Bool show=OFF,CDoc *doc=NULL)
|
||||
{//Highlight or Don't highlight cursor.
|
||||
if (!doc && !(doc=DocPut))
|
||||
return FALSE;
|
||||
return !LBEqu(&doc->flags,DOCf_DONT_HIGHLIGHT_CURSOR,!show);
|
||||
}
|
||||
|
||||
public Bool DocScroll(Bool val=OFF,CDoc *doc=NULL)
|
||||
{//Turn scroll bars OFF/ON.
|
||||
if (!doc && !(doc=DocPut))
|
||||
return FALSE;
|
||||
return !LBEqu(&doc->flags,DOCf_NO_SCROLL_BARS,!val);
|
||||
}
|
||||
|
||||
public U0 DocCollapse(Bool collapse=TRUE,CDoc *doc=NULL)
|
||||
{//Collapse or uncollapse all tree widgets.
|
||||
CDocEntry *doc_e;
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
doc_e=doc->head.next;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->de_flags&DOCEF_TREE)
|
||||
BEqu(&doc_e->de_flags,DOCEf_CHECKED_COLLAPSED,collapse);
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Cmd Line (Typically);Cmd Line (Typically)"
|
||||
public I64 DocMax(I64 i=MAX_I64)
|
||||
{//Set max document entries. (Cmd line buffer size.)
|
||||
//Adjusts the size of the cmd line buf.
|
||||
//Normally, the cmd line deletes entries
|
||||
//when more are added and the old scroll up.
|
||||
//See $LK,"max_entries",A="FF:::/Adam/DolDoc/DocTerm.HC,max_entries"$.
|
||||
I64 res;
|
||||
CDoc *doc;
|
||||
if (doc=DocPut) {
|
||||
res=doc->max_entries;
|
||||
doc->max_entries=i;
|
||||
return res;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Task;StdOut/Task"
|
||||
U0 DocUpdateTaskDocs(CTask *task)
|
||||
{//This is called from $LK,"GrUpdateTaskWin",A="MN:GrUpdateTaskWin"$() by the winmgr at 30fps.
|
||||
CDoc *doc;
|
||||
CD3I64 saved_scroll;
|
||||
if (task->border_src==BDS_CUR_DRV && task->cur_dv)
|
||||
task->border_attr=DrvTextAttrGet(Drv2Let(task->cur_dv));
|
||||
if (task->title_src==TTS_TASK_NAME)
|
||||
StrCpy(task->task_title,task->task_name);
|
||||
if ((doc=DocDisplay(task)) && !(doc->flags&DOCF_DONT_SHOW)) {
|
||||
if (task->border_src==BDS_ED_FILENAME_DRV)
|
||||
task->border_attr=DrvTextAttrGet(*doc->filename.name);
|
||||
if (task->title_src==TTS_ED_FILENAME)
|
||||
MemCpy(task->task_title,doc->filename.name,STR_LEN-1);
|
||||
DocRecalc(doc,RECALCt_TO_SCREEN|RECALCF_HAS_CURSOR);
|
||||
}
|
||||
if ((doc=DocBorder(task)) && !(doc->flags&DOCF_DONT_SHOW)) {
|
||||
WinScrollNull(task,&saved_scroll);
|
||||
DocRecalc(doc,RECALCt_TO_SCREEN);
|
||||
WinScrollRestore(task,&saved_scroll);
|
||||
}
|
||||
}
|
||||
@@ -1,207 +0,0 @@
|
||||
#help_index "DolDoc/Task;StdOut/Task"
|
||||
public CDoc *DocBorderNew(CDoc *pdoc)
|
||||
{//Make new std border doc.
|
||||
CDocEntry *doc_e;
|
||||
CDoc *bdoc;
|
||||
|
||||
bdoc=DocNew;
|
||||
bdoc->flags|=DOCF_BORDER_DOC;
|
||||
if (pdoc) {
|
||||
DocPrint(bdoc,"$$CM+H+BY+RX+NC,-7,1$$");
|
||||
doc_e=DocPrint(bdoc,"$$TX+H+BD+TC,\" \"$$");
|
||||
doc_e->user_data=pdoc;
|
||||
doc_e->tag_cb=&EdFilterCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+H+BD+TC,\" \"$$");
|
||||
doc_e->user_data=pdoc;
|
||||
doc_e->tag_cb=&EdOverStrikeCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+H+BD+TC,\" \"$$");
|
||||
doc_e->user_data=pdoc;
|
||||
doc_e->tag_cb=&EdDollarCB;
|
||||
DocPrint(bdoc,"$$CM+H+BY+RX+NC,-18,1$$");
|
||||
doc_e=DocPrint(bdoc,"$$TX+BD+TC,\" \"$$");
|
||||
doc_e->user_data=pdoc;
|
||||
doc_e->tag_cb=&EdMoreCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+H+BD+TC,\" \"$$");
|
||||
doc_e->user_data=pdoc;
|
||||
doc_e->tag_cb=&EdDollarTypeCB;
|
||||
}
|
||||
DocPrint(bdoc,"$$CM+H+TY+NC,0,-1$$");
|
||||
doc_e=DocPrint(bdoc,"$$DA+H-TRM-P+BD+RD+CX+IV,LEN=STR_LEN-1,"
|
||||
"A=\"%%s...\",SCX=15$$");
|
||||
doc_e->data=&Fs->task_title;
|
||||
DocDataFmt(bdoc,doc_e);
|
||||
DocPrint(bdoc,"$$CM+H+NC,1,0$$$$TX+H+BD+IV,\"%X\"$$",Fs);
|
||||
DocPrint(bdoc,"$$TX+H+RX+BD,\"[X]\"$$");
|
||||
DocPrint(bdoc,"$$BK,1$$$$TX+H+LX+BD,\"MENU\"$$$$BK,0$$");
|
||||
return bdoc;
|
||||
}
|
||||
|
||||
public U0 DocTermNew()
|
||||
{//Make into term win task with Put/Display/Border docs.
|
||||
CDoc *pdoc=DocNew;
|
||||
pdoc->right_click_link=&TermRightClickLink;
|
||||
pdoc->max_entries=4096;
|
||||
Fs->border_src=BDS_CUR_DRV;
|
||||
pdoc->desc='Term';
|
||||
Fs->put_doc=Fs->display_doc=pdoc;
|
||||
Fs->border_doc=DocBorderNew(pdoc);
|
||||
Fs->cur_menu=MenuFile("::/Doc/EdPullDown.TXT");
|
||||
WinScrollsInit(Fs);
|
||||
Raw(OFF);
|
||||
}
|
||||
|
||||
#help_index "DolDoc"
|
||||
|
||||
#define RIGHT_INCLUDE 0
|
||||
#define RIGHT_AINCLUDE 1
|
||||
#define RIGHT_COPY 2
|
||||
#define RIGHT_MOVE 3
|
||||
#define RIGHT_DELETE 4
|
||||
#define RIGHT_TYPE 5
|
||||
#define RIGHT_ED 6
|
||||
#define RIGHT_MOUNT 7
|
||||
#define RIGHT_PLAIN 8
|
||||
#define RIGHT_AUTOFILE 9
|
||||
|
||||
I64 PopUpTermRight(U8 *header)
|
||||
{
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
if (header) DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"\n\n"
|
||||
"TXT=%s\nJIT=%s\nGRA=%s"
|
||||
"$$CM+LX,1,3 $$$$BT,\"INCLUDE JIT\",LE=RIGHT_INCLUDE$$"
|
||||
"$$CM+LX,26,0$$$$BT,\"ADAM_INCLUDE JIT\",LE=RIGHT_AINCLUDE$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"COPY \",LE=RIGHT_COPY$$"
|
||||
"$$CM+LX,26,0$$$$BT,\"MOVE OR RENAME \",LE=RIGHT_MOVE$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"DELETE \",LE=RIGHT_DELETE$$"
|
||||
"$$CM+LX,26,0$$$$BT,\"TYPE TXT;GRA\",LE=RIGHT_TYPE$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"ED TXT\",LE=RIGHT_ED$$"
|
||||
"$$CM+LX,26,0$$$$BT,\"MOUNT ISO.C\",LE=RIGHT_MOUNT$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"PLAIN ED TXT\",LE=RIGHT_PLAIN$$"
|
||||
"$$CM+LX,26,0$$$$BT,\"AUTOFILE AUT\",LE=RIGHT_AUTOFILE$$\n"
|
||||
"$$CM+LX,1,3 $$$$BT,\"CANCEL \",LE=DOCM_CANCEL$$",
|
||||
FILEMASK_TXT,FILEMASK_JIT,FILEMASK_GRA);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
I64 EdLeftClickLink(CDoc *doc,CDocEntry *doc_e)
|
||||
{//Called with doc locked, exit unlocked
|
||||
Bool res;
|
||||
U8 *st;
|
||||
if (st=DocEntryLink(doc,doc_e)) {
|
||||
DocUnlock(doc);
|
||||
if (doc_e->de_flags & DOCEF_POPUP)
|
||||
res=PopUpEd(st);
|
||||
else
|
||||
res=Ed(st);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
I64 TermRightClickLink(CDoc *doc,CDocEntry *doc_e)
|
||||
{//Called with doc locked, exit unlocked
|
||||
Bool send_new_line=FALSE,res=FALSE;
|
||||
U8 *st,*st2;
|
||||
I64 i;
|
||||
CEdFileName fn;
|
||||
if (st2=DocEntryLink(doc,doc_e)) {
|
||||
if (st=DocLinkFile(st2)) {
|
||||
DocUnlock(doc);
|
||||
if ((i=PopUpTermRight(st))>=0) {
|
||||
DocBottom(doc);
|
||||
switch (i) {
|
||||
case RIGHT_INCLUDE:
|
||||
if (FileExtDot(st) && !FilesFindMatch(st,FILEMASK_JIT)) {
|
||||
if (!PopUpCancelOk(ST_WARN_ST "Not .CPP File\n\n")) {
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
"#include \"%s\";\n$$PT$$$$FG$$$$BG$$",st;
|
||||
WinZBufUpdate;
|
||||
ExeFile(st,CCF_CMD_LINE);
|
||||
res=TRUE;
|
||||
break;
|
||||
case RIGHT_AINCLUDE:
|
||||
if (FileExtDot(st) && !FilesFindMatch(st,FILEMASK_JIT)) {
|
||||
if (!PopUpCancelOk(ST_WARN_ST "Not .CPP File\n\n")) {
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
"Adam(\"#include \\\"%s\\\"\" );\n$$PT$$$$FG$$$$BG$$",st;
|
||||
WinZBufUpdate;
|
||||
AdamFile(st,FALSE);
|
||||
res=TRUE;
|
||||
break;
|
||||
case RIGHT_COPY:
|
||||
StrCpy(fn.name,st);
|
||||
if (DocForm(&fn)) {
|
||||
res=ToBool(Copy(st,fn.name));
|
||||
} else
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
case RIGHT_MOVE:
|
||||
StrCpy(fn.name,st);
|
||||
if (DocForm(&fn))
|
||||
res=Move(st,fn.name);
|
||||
else
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
case RIGHT_DELETE:
|
||||
res=ToBool(Del(st));
|
||||
break;
|
||||
case RIGHT_TYPE:
|
||||
res=Type(st);
|
||||
break;
|
||||
case RIGHT_ED:
|
||||
"Ed(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
|
||||
res=Ed(st);
|
||||
break;
|
||||
case RIGHT_MOUNT:
|
||||
if (FileExtDot(st) && !FilesFindMatch(st,"*.ISO.C")) {
|
||||
if (!PopUpCancelOk(ST_WARN_ST "Not .ISO.C File\n\n")) {
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
"MountFile(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
|
||||
WinZBufUpdate;
|
||||
MountFile(st);
|
||||
res=TRUE;
|
||||
break;
|
||||
case RIGHT_PLAIN:
|
||||
"Plain(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
|
||||
res=Plain(st);
|
||||
break;
|
||||
case RIGHT_AUTOFILE:
|
||||
if (FileExtDot(st) && !FilesFindMatch(st,"*.AUT*")) {
|
||||
if (!PopUpCancelOk(ST_WARN_ST "Not .AUT File\n\n")) {
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
"AutoFile(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
|
||||
WinZBufUpdate;
|
||||
AutoFile(st);
|
||||
res=TRUE;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
send_new_line=TRUE;
|
||||
Free(st);
|
||||
} else
|
||||
send_new_line=TRUE;
|
||||
Free(st2);
|
||||
} else
|
||||
send_new_line=TRUE;
|
||||
DocBottom(doc);
|
||||
"$$PT$$$$FG$$$$BG$$";
|
||||
if (send_new_line)
|
||||
'\n';
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
#help_index "DolDoc/Task;StdOut/Task"
|
||||
public CDoc *DocBorderNew(CDoc *pdoc)
|
||||
{//Make new std border doc.
|
||||
CDocEntry *doc_e;
|
||||
CDoc *bdoc;
|
||||
|
||||
bdoc=DocNew;
|
||||
bdoc->flags|=DOCF_BORDER_DOC;
|
||||
if (pdoc) {
|
||||
DocPrint(bdoc,"$$CM+H+BY+RX+NC,-7,1$$");
|
||||
doc_e=DocPrint(bdoc,"$$TX+H+BD+TC,\" \"$$");
|
||||
doc_e->user_data=pdoc;
|
||||
doc_e->tag_cb=&EdFilterCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+H+BD+TC,\" \"$$");
|
||||
doc_e->user_data=pdoc;
|
||||
doc_e->tag_cb=&EdOverStrikeCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+H+BD+TC,\" \"$$");
|
||||
doc_e->user_data=pdoc;
|
||||
doc_e->tag_cb=&EdDollarCB;
|
||||
DocPrint(bdoc,"$$CM+H+BY+RX+NC,-18,1$$");
|
||||
doc_e=DocPrint(bdoc,"$$TX+BD+TC,\" \"$$");
|
||||
doc_e->user_data=pdoc;
|
||||
doc_e->tag_cb=&EdMoreCB;
|
||||
doc_e=DocPrint(bdoc,"$$TX+H+BD+TC,\" \"$$");
|
||||
doc_e->user_data=pdoc;
|
||||
doc_e->tag_cb=&EdDollarTypeCB;
|
||||
}
|
||||
DocPrint(bdoc,"$$CM+H+TY+NC,0,-1$$");
|
||||
doc_e=DocPrint(bdoc,"$$DA+H-TRM-P+BD+RD+CX+IV,LEN=STR_LEN-1,"
|
||||
"A=\"%%s...\",SCX=15$$");
|
||||
doc_e->data=&Fs->task_title;
|
||||
DocDataFmt(bdoc,doc_e);
|
||||
DocPrint(bdoc,"$$CM+H+NC,1,0$$$$TX+H+BD+IV,\"%X\"$$",Fs);
|
||||
DocPrint(bdoc,"$$TX+H+RX+BD,\"[X]\"$$");
|
||||
DocPrint(bdoc,"$$BK,1$$$$TX+H+LX+BD,\"MENU\"$$$$BK,0$$");
|
||||
return bdoc;
|
||||
}
|
||||
|
||||
public U0 DocTermNew()
|
||||
{//Make into term win task with Put/Display/Border docs.
|
||||
CDoc *pdoc=DocNew;
|
||||
pdoc->right_click_link=&TermRightClickLink;
|
||||
pdoc->max_entries=4096;
|
||||
Fs->border_src=BDS_CUR_DRV;
|
||||
pdoc->desc='Term';
|
||||
Fs->put_doc=Fs->display_doc=pdoc;
|
||||
Fs->border_doc=DocBorderNew(pdoc);
|
||||
Fs->cur_menu=MenuFile("::/Doc/EdPullDown.DD");
|
||||
WinScrollsInit(Fs);
|
||||
Raw(OFF);
|
||||
}
|
||||
|
||||
#help_index "DolDoc"
|
||||
|
||||
#define RIGHT_INCLUDE 0
|
||||
#define RIGHT_AINCLUDE 1
|
||||
#define RIGHT_COPY 2
|
||||
#define RIGHT_MOVE 3
|
||||
#define RIGHT_DELETE 4
|
||||
#define RIGHT_TYPE 5
|
||||
#define RIGHT_ED 6
|
||||
#define RIGHT_MOUNT 7
|
||||
#define RIGHT_PLAIN 8
|
||||
#define RIGHT_AUTOFILE 9
|
||||
|
||||
I64 PopUpTermRight(U8 *header)
|
||||
{
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
if (header) DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"\n\n"
|
||||
"TXT=%s\nJIT=%s\nGRA=%s"
|
||||
"$$CM+LX,1,3 $$$$BT,\"INCLUDE JIT\",LE=RIGHT_INCLUDE$$"
|
||||
"$$CM+LX,26,0$$$$BT,\"ADAM_INCLUDE JIT\",LE=RIGHT_AINCLUDE$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"COPY \",LE=RIGHT_COPY$$"
|
||||
"$$CM+LX,26,0$$$$BT,\"MOVE OR RENAME \",LE=RIGHT_MOVE$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"DELETE \",LE=RIGHT_DELETE$$"
|
||||
"$$CM+LX,26,0$$$$BT,\"TYPE TXT;GRA\",LE=RIGHT_TYPE$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"ED TXT\",LE=RIGHT_ED$$"
|
||||
"$$CM+LX,26,0$$$$BT,\"MOUNT ISO.C\",LE=RIGHT_MOUNT$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"PLAIN ED TXT\",LE=RIGHT_PLAIN$$"
|
||||
"$$CM+LX,26,0$$$$BT,\"AUTOFILE AUT\",LE=RIGHT_AUTOFILE$$\n"
|
||||
"$$CM+LX,1,3 $$$$BT,\"CANCEL \",LE=DOCM_CANCEL$$",
|
||||
FILEMASK_TXT,FILEMASK_JIT,FILEMASK_GRA);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
I64 EdLeftClickLink(CDoc *doc,CDocEntry *doc_e)
|
||||
{//Called with doc locked, exit unlocked
|
||||
Bool res;
|
||||
U8 *st;
|
||||
if (st=DocEntryLink(doc,doc_e)) {
|
||||
DocUnlock(doc);
|
||||
if (doc_e->de_flags & DOCEF_POPUP)
|
||||
res=PopUpEd(st);
|
||||
else
|
||||
res=Ed(st);
|
||||
Free(st);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
I64 TermRightClickLink(CDoc *doc,CDocEntry *doc_e)
|
||||
{//Called with doc locked, exit unlocked
|
||||
Bool send_new_line=FALSE,res=FALSE;
|
||||
U8 *st,*st2;
|
||||
I64 i;
|
||||
CEdFileName fn;
|
||||
if (st2=DocEntryLink(doc,doc_e)) {
|
||||
if (st=DocLinkFile(st2)) {
|
||||
DocUnlock(doc);
|
||||
if ((i=PopUpTermRight(st))>=0) {
|
||||
DocBottom(doc);
|
||||
switch (i) {
|
||||
case RIGHT_INCLUDE:
|
||||
if (FileExtDot(st) && !FilesFindMatch(st,FILEMASK_JIT)) {
|
||||
if (!PopUpCancelOk(ST_WARN_ST "Not .HC File\n\n")) {
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
"#include \"%s\";\n$$PT$$$$FG$$$$BG$$",st;
|
||||
WinZBufUpdate;
|
||||
ExeFile(st,CCF_CMD_LINE);
|
||||
res=TRUE;
|
||||
break;
|
||||
case RIGHT_AINCLUDE:
|
||||
if (FileExtDot(st) && !FilesFindMatch(st,FILEMASK_JIT)) {
|
||||
if (!PopUpCancelOk(ST_WARN_ST "Not .HC File\n\n")) {
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
"Adam(\"#include \\\"%s\\\"\" );\n$$PT$$$$FG$$$$BG$$",st;
|
||||
WinZBufUpdate;
|
||||
AdamFile(st,FALSE);
|
||||
res=TRUE;
|
||||
break;
|
||||
case RIGHT_COPY:
|
||||
StrCpy(fn.name,st);
|
||||
if (DocForm(&fn)) {
|
||||
res=ToBool(Copy(st,fn.name));
|
||||
} else
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
case RIGHT_MOVE:
|
||||
StrCpy(fn.name,st);
|
||||
if (DocForm(&fn))
|
||||
res=Move(st,fn.name);
|
||||
else
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
case RIGHT_DELETE:
|
||||
res=ToBool(Del(st));
|
||||
break;
|
||||
case RIGHT_TYPE:
|
||||
res=Type(st);
|
||||
break;
|
||||
case RIGHT_ED:
|
||||
"Ed(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
|
||||
res=Ed(st);
|
||||
break;
|
||||
case RIGHT_MOUNT:
|
||||
if (FileExtDot(st) && !FilesFindMatch(st,"*.ISO.C")) {
|
||||
if (!PopUpCancelOk(ST_WARN_ST "Not .ISO.C File\n\n")) {
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
"MountFile(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
|
||||
WinZBufUpdate;
|
||||
MountFile(st);
|
||||
res=TRUE;
|
||||
break;
|
||||
case RIGHT_PLAIN:
|
||||
"Plain(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
|
||||
res=Plain(st);
|
||||
break;
|
||||
case RIGHT_AUTOFILE:
|
||||
if (FileExtDot(st) && !FilesFindMatch(st,"*.AUT*")) {
|
||||
if (!PopUpCancelOk(ST_WARN_ST "Not .AUT File\n\n")) {
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
"AutoFile(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
|
||||
WinZBufUpdate;
|
||||
AutoFile(st);
|
||||
res=TRUE;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
send_new_line=TRUE;
|
||||
Free(st);
|
||||
} else
|
||||
send_new_line=TRUE;
|
||||
Free(st2);
|
||||
} else
|
||||
send_new_line=TRUE;
|
||||
DocBottom(doc);
|
||||
"$$PT$$$$FG$$$$BG$$";
|
||||
if (send_new_line)
|
||||
'\n';
|
||||
return res;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,70 +0,0 @@
|
||||
Cd(__DIR__);;
|
||||
|
||||
#help_index "DolDoc"
|
||||
#help_file "::/Doc/DolDoc"
|
||||
|
||||
/*
|
||||
TempleOS DolDoc's can have "cursor movement" cmds which can move the cursor up
|
||||
the screen and layer on existing text. It can also have callback funs which
|
||||
supply live, changing text. For these reasons, you can't assume you know
|
||||
where the visible portion of the document is and must process much
|
||||
of the document each time it is placed on the screen, becoming CPU
|
||||
intensive on big documents.
|
||||
See $LK,"::/Doc/DolDocOverview.TXT"$
|
||||
*/
|
||||
|
||||
//Hash Types
|
||||
#define DHT_DOC_CMD 1
|
||||
#define DHT_DOC_FLAG 2
|
||||
#define DHT_COLOR 4
|
||||
|
||||
public class CDolDocGlbls
|
||||
{
|
||||
CHashTable *hash;
|
||||
I64 dft_de_flags [DOCT_NUM_TYPES],
|
||||
type_flags_nontag_invisible [(DOCT_NUM_TYPES+63)/64],
|
||||
type_flags_form [(DOCT_NUM_TYPES+63)/64],
|
||||
type_flags_data [(DOCT_NUM_TYPES+63)/64],
|
||||
type_flags_chk_dup [(DOCT_NUM_TYPES+63)/64],
|
||||
clean_scan_codes [4];
|
||||
I32 dft_type_flags [DOCT_NUM_TYPES];
|
||||
} doldoc;
|
||||
MemSet(&doldoc,0,sizeof(CDolDocGlbls));
|
||||
|
||||
#help_index "God"
|
||||
#define BIBLE_FILENAME "::/Misc/Bible.TXT.Z"
|
||||
|
||||
#include "DocExt"
|
||||
#include "DocBin"
|
||||
#include "DocNew"
|
||||
#include "DocForm"
|
||||
#include "DocDblBuf"
|
||||
#include "DocPlain"
|
||||
#include "DocInit"
|
||||
#include "DocHighlight"
|
||||
#include "DocRecalcLib"
|
||||
#include "DocRecalc"
|
||||
#include "DocFile"
|
||||
#include "DocClipBoard"
|
||||
#include "DocRun"
|
||||
#include "DocGet"
|
||||
#include "DocChar"
|
||||
#include "DocFind"
|
||||
#include "DocLink"
|
||||
#include "DocEd"
|
||||
#include "DocPopUp"
|
||||
#include "DocGr"
|
||||
#include "DocMacro"
|
||||
#include "DocWidgetWiz"
|
||||
#include "DocPutKey"
|
||||
#include "DocPutS"
|
||||
#include "DocOpt"
|
||||
#include "DocCodeTools"
|
||||
#include "DocTree"
|
||||
#include "DocTerm"
|
||||
|
||||
KeyDevAdd(&KDDocPutKey,&KDDocPutS,0x80000000,TRUE);
|
||||
fp_getstr2=&DocGetStr2;
|
||||
fp_doc_put=&DocPut;
|
||||
|
||||
Cd("..");;
|
||||
@@ -0,0 +1,70 @@
|
||||
Cd(__DIR__);;
|
||||
|
||||
#help_index "DolDoc"
|
||||
#help_file "::/Doc/DolDoc"
|
||||
|
||||
/*
|
||||
TempleOS DolDoc's can have "cursor movement" cmds which can move the cursor up
|
||||
the screen and layer on existing text. It can also have callback funs which
|
||||
supply live, changing text. For these reasons, you can't assume you know
|
||||
where the visible portion of the document is and must process much
|
||||
of the document each time it is placed on the screen, becoming CPU
|
||||
intensive on big documents.
|
||||
See $LK,"::/Doc/DolDocOverview.DD"$
|
||||
*/
|
||||
|
||||
//Hash Types
|
||||
#define DHT_DOC_CMD 1
|
||||
#define DHT_DOC_FLAG 2
|
||||
#define DHT_COLOR 4
|
||||
|
||||
public class CDolDocGlbls
|
||||
{
|
||||
CHashTable *hash;
|
||||
I64 dft_de_flags [DOCT_NUM_TYPES],
|
||||
type_flags_nontag_invisible [(DOCT_NUM_TYPES+63)/64],
|
||||
type_flags_form [(DOCT_NUM_TYPES+63)/64],
|
||||
type_flags_data [(DOCT_NUM_TYPES+63)/64],
|
||||
type_flags_chk_dup [(DOCT_NUM_TYPES+63)/64],
|
||||
clean_scan_codes [4];
|
||||
I32 dft_type_flags [DOCT_NUM_TYPES];
|
||||
} doldoc;
|
||||
MemSet(&doldoc,0,sizeof(CDolDocGlbls));
|
||||
|
||||
#help_index "God"
|
||||
#define BIBLE_FILENAME "::/Misc/Bible.TXT.Z"
|
||||
|
||||
#include "DocExt"
|
||||
#include "DocBin"
|
||||
#include "DocNew"
|
||||
#include "DocForm"
|
||||
#include "DocDblBuf"
|
||||
#include "DocPlain"
|
||||
#include "DocInit"
|
||||
#include "DocHighlight"
|
||||
#include "DocRecalcLib"
|
||||
#include "DocRecalc"
|
||||
#include "DocFile"
|
||||
#include "DocClipBoard"
|
||||
#include "DocRun"
|
||||
#include "DocGet"
|
||||
#include "DocChar"
|
||||
#include "DocFind"
|
||||
#include "DocLink"
|
||||
#include "DocEd"
|
||||
#include "DocPopUp"
|
||||
#include "DocGr"
|
||||
#include "DocMacro"
|
||||
#include "DocWidgetWiz"
|
||||
#include "DocPutKey"
|
||||
#include "DocPutS"
|
||||
#include "DocOpt"
|
||||
#include "DocCodeTools"
|
||||
#include "DocTree"
|
||||
#include "DocTerm"
|
||||
|
||||
KeyDevAdd(&KDDocPutKey,&KDDocPutS,0x80000000,TRUE);
|
||||
fp_getstr2=&DocGetStr2;
|
||||
fp_doc_put=&DocPut;
|
||||
|
||||
Cd("..");;
|
||||
@@ -1,188 +0,0 @@
|
||||
#help_index "God;Graphics/Sprite;Sprites"
|
||||
|
||||
U0 GodDoodleDraw(CTask *task,CDC *dc)
|
||||
{
|
||||
GrBlot(dc,0,0,god.doodle_dc);
|
||||
if (Blink) {
|
||||
if (god.doodle_done) {
|
||||
dc->color=RED;
|
||||
GrPrint(dc,(task->pix_width-FONT_WIDTH*29)>>1,
|
||||
(task->pix_height-3*FONT_HEIGHT)>>1,
|
||||
"Press <ESC> to insert sprite.");
|
||||
GrPrint(dc,(task->pix_width-FONT_WIDTH*39)>>1,
|
||||
(task->pix_height-3*FONT_HEIGHT)>>1+2*FONT_HEIGHT,
|
||||
"Press <SHIFT-ESC> to throw-away sprite.");
|
||||
} else {
|
||||
dc->color=GREEN;
|
||||
GrPrint(dc,(task->pix_width-FONT_WIDTH*25)>>1,
|
||||
(task->pix_height-FONT_HEIGHT)>>1,
|
||||
"Press <SPACE> repeatedly.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 GodDoodleSmooth(I64 num)
|
||||
{
|
||||
CDC *dc=DCExt(god.doodle_dc,0,0,
|
||||
god.doodle_dc->width-1,god.doodle_dc->height-1);
|
||||
I64 i,x,y,x1,y1,c,histogram[16],best,best_cnt,c_old=god.doodle_dc->color;
|
||||
for (y=0;y<god.doodle_dc->height;y++)
|
||||
for (x=0;x<god.doodle_dc->width;x++) {
|
||||
MemSet(histogram,0,sizeof(histogram));
|
||||
for (y1=y-num;y1<=y+num;y1++)
|
||||
for (x1=x-num;x1<=x+num;x1++) {
|
||||
c=GrPeek(dc,x1,y1);
|
||||
if (0<=c<=15)
|
||||
histogram[c]++;
|
||||
}
|
||||
best=BLACK;
|
||||
best_cnt=-1;
|
||||
for (i=0;i<16;i++)
|
||||
if (histogram[i]>best_cnt) {
|
||||
best=i;
|
||||
best_cnt=histogram[i];
|
||||
}
|
||||
god.doodle_dc->color=best;
|
||||
GrPlot(god.doodle_dc,x,y);
|
||||
}
|
||||
god.doodle_dc->color=c_old;
|
||||
DCDel(dc);
|
||||
}
|
||||
|
||||
U0 GodDoodleBitsIns(I64 num_bits,I64 n)
|
||||
{//Insert bits into God doodle bit fifo.
|
||||
I64 i;
|
||||
for (i=0;i<num_bits;i++) {
|
||||
FifoU8Ins(god.doodle_fifo,n&1);
|
||||
n>>=1;
|
||||
}
|
||||
}
|
||||
|
||||
U0 GodDoodleHexIns(U8 *st)
|
||||
{//Insert hex record into God doodle bit fifo.
|
||||
U8 buf[2];
|
||||
if (st) {
|
||||
buf[1]=0;
|
||||
while (*buf=*st++)
|
||||
if (Bt(chars_bmp_hex_numeric,*buf))
|
||||
GodDoodleBitsIns(4,Str2I64(buf,16));
|
||||
}
|
||||
}
|
||||
|
||||
I64 GodDoodleBits(I64 num_bits)
|
||||
{
|
||||
U8 b;
|
||||
I64 res=0;
|
||||
while (num_bits) {
|
||||
if (FifoU8Rem(god.doodle_fifo,&b)) {
|
||||
res=res<<1+b;
|
||||
num_bits--;
|
||||
} else {
|
||||
god.doodle_ch=GetChar(,FALSE);
|
||||
if (god.doodle_ch==CH_ESC||god.doodle_ch==CH_SHIFT_ESC)
|
||||
throw;
|
||||
else if (god.doodle_ch=='\n') {
|
||||
DCFill(god.doodle_dc,WHITE);
|
||||
FifoU8Flush(god.doodle_fifo);
|
||||
} else if ('0'<=god.doodle_ch<='9')
|
||||
GodDoodleSmooth(god.doodle_ch-'0');
|
||||
else
|
||||
GodDoodleBitsIns(GOD_GOOD_BITS,KbdMouseEvtTime>>GOD_BAD_BITS);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public U8 *GodDoodleSprite(U8 *hex=NULL)
|
||||
{//Make God draw sprite. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.TXT"$
|
||||
I64 i,j,w,h,x,y,ch;
|
||||
U8 *elems;
|
||||
|
||||
if (god.doodle_dc) return NULL;
|
||||
god.doodle_done=FALSE;
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
AutoComplete;
|
||||
WinBorder;
|
||||
WinMax;
|
||||
|
||||
PopUpOk("The $LK+PU,"Holy Spirit",A="FI:::/Adam/God/HSNotes.TXT"$ can puppet you.\n\n"
|
||||
"Press $$GREEN$$<SPACE>$$FG$$ until it finishes.");
|
||||
|
||||
god.doodle_ch=0;
|
||||
god.doodle_dc=DCNew(Fs->pix_width,Fs->pix_height);
|
||||
DCFill(god.doodle_dc,WHITE);
|
||||
w=god.doodle_dc->width;
|
||||
h=god.doodle_dc->height;
|
||||
|
||||
Fs->draw_it=&GodDoodleDraw;
|
||||
FifoU8Flush(god.doodle_fifo);
|
||||
GodDoodleHexIns(hex);
|
||||
try {
|
||||
for (i=0;i<3;i++) {
|
||||
god.doodle_dc->color=RED;
|
||||
for (j=0;j<29;j++)
|
||||
switch [GodDoodleBits(3)] {
|
||||
case 0:
|
||||
GrEllipse3(god.doodle_dc,
|
||||
(w-1)*GodDoodleBits(5)/15.5-w/2,
|
||||
(h-1)*GodDoodleBits(5)/15.5-h/2,0,
|
||||
(w-1)*GodDoodleBits(5)/15.5,(h-1)*GodDoodleBits(5)/15.5);
|
||||
break;
|
||||
case 1:
|
||||
GrCircle3(god.doodle_dc,
|
||||
(w-1)*GodDoodleBits(5)/15.5-w/2,
|
||||
(h-1)*GodDoodleBits(5)/15.5-h/2,0,
|
||||
(w-1)*GodDoodleBits(5)/15.5);
|
||||
break;
|
||||
case 2:
|
||||
GrBorder(god.doodle_dc,
|
||||
(w-1)*GodDoodleBits(5)/15.5-w/2,
|
||||
(h-1)*GodDoodleBits(5)/15.5-h/2,
|
||||
(w-1)*GodDoodleBits(5)/15.5,(h-1)*GodDoodleBits(5)/15.5);
|
||||
break;
|
||||
case 3...7:
|
||||
GrLine3(god.doodle_dc,
|
||||
(w-1)*GodDoodleBits(4)/15,(h-1)*GodDoodleBits(4)/15,0,
|
||||
(w-1)*GodDoodleBits(4)/15,(h-1)*GodDoodleBits(4)/15,0);
|
||||
break;
|
||||
}
|
||||
for (j=0;j<6;j++) {
|
||||
x=(w-1)*GodDoodleBits(5)/31+w/64;
|
||||
y=(h-1)*GodDoodleBits(5)/31+h/64;
|
||||
switch [GodDoodleBits(2)] {
|
||||
case 0: god.doodle_dc->color=BLACK; break;
|
||||
case 1: god.doodle_dc->color=DKGRAY; break;
|
||||
case 2: god.doodle_dc->color=LTGRAY; break;
|
||||
case 3: god.doodle_dc->color=WHITE; break;
|
||||
}
|
||||
GrFloodFill3(god.doodle_dc,x,y,0);
|
||||
}
|
||||
GodDoodleSmooth(3);
|
||||
}
|
||||
god.doodle_done=TRUE;
|
||||
do ch=GetChar(,FALSE);
|
||||
while (ch!=CH_ESC && ch!=CH_SHIFT_ESC);
|
||||
} catch {
|
||||
Fs->catch_except=TRUE;
|
||||
ch=CH_SHIFT_ESC;
|
||||
}
|
||||
DCFill;
|
||||
SettingsPop;
|
||||
if (ch==CH_ESC)
|
||||
elems=DC2Sprite(god.doodle_dc);
|
||||
else
|
||||
elems=NULL;
|
||||
DCDel(god.doodle_dc);
|
||||
god.doodle_dc=NULL;
|
||||
return elems;
|
||||
}
|
||||
|
||||
#help_index "God"
|
||||
public U0 GodDoodle(U8 *hex=NULL)
|
||||
{//Make God draw sprite, insert in doc. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.TXT"$
|
||||
U8 *elems;
|
||||
if (elems=GodDoodleSprite(hex)) {
|
||||
Sprite(elems);
|
||||
Free(elems);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
#help_index "God;Graphics/Sprite;Sprites"
|
||||
|
||||
U0 GodDoodleDraw(CTask *task,CDC *dc)
|
||||
{
|
||||
GrBlot(dc,0,0,god.doodle_dc);
|
||||
if (Blink) {
|
||||
if (god.doodle_done) {
|
||||
dc->color=RED;
|
||||
GrPrint(dc,(task->pix_width-FONT_WIDTH*29)>>1,
|
||||
(task->pix_height-3*FONT_HEIGHT)>>1,
|
||||
"Press <ESC> to insert sprite.");
|
||||
GrPrint(dc,(task->pix_width-FONT_WIDTH*39)>>1,
|
||||
(task->pix_height-3*FONT_HEIGHT)>>1+2*FONT_HEIGHT,
|
||||
"Press <SHIFT-ESC> to throw-away sprite.");
|
||||
} else {
|
||||
dc->color=GREEN;
|
||||
GrPrint(dc,(task->pix_width-FONT_WIDTH*25)>>1,
|
||||
(task->pix_height-FONT_HEIGHT)>>1,
|
||||
"Press <SPACE> repeatedly.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 GodDoodleSmooth(I64 num)
|
||||
{
|
||||
CDC *dc=DCExt(god.doodle_dc,0,0,
|
||||
god.doodle_dc->width-1,god.doodle_dc->height-1);
|
||||
I64 i,x,y,x1,y1,c,histogram[16],best,best_cnt,c_old=god.doodle_dc->color;
|
||||
for (y=0;y<god.doodle_dc->height;y++)
|
||||
for (x=0;x<god.doodle_dc->width;x++) {
|
||||
MemSet(histogram,0,sizeof(histogram));
|
||||
for (y1=y-num;y1<=y+num;y1++)
|
||||
for (x1=x-num;x1<=x+num;x1++) {
|
||||
c=GrPeek(dc,x1,y1);
|
||||
if (0<=c<=15)
|
||||
histogram[c]++;
|
||||
}
|
||||
best=BLACK;
|
||||
best_cnt=-1;
|
||||
for (i=0;i<16;i++)
|
||||
if (histogram[i]>best_cnt) {
|
||||
best=i;
|
||||
best_cnt=histogram[i];
|
||||
}
|
||||
god.doodle_dc->color=best;
|
||||
GrPlot(god.doodle_dc,x,y);
|
||||
}
|
||||
god.doodle_dc->color=c_old;
|
||||
DCDel(dc);
|
||||
}
|
||||
|
||||
U0 GodDoodleBitsIns(I64 num_bits,I64 n)
|
||||
{//Insert bits into God doodle bit fifo.
|
||||
I64 i;
|
||||
for (i=0;i<num_bits;i++) {
|
||||
FifoU8Ins(god.doodle_fifo,n&1);
|
||||
n>>=1;
|
||||
}
|
||||
}
|
||||
|
||||
U0 GodDoodleHexIns(U8 *st)
|
||||
{//Insert hex record into God doodle bit fifo.
|
||||
U8 buf[2];
|
||||
if (st) {
|
||||
buf[1]=0;
|
||||
while (*buf=*st++)
|
||||
if (Bt(chars_bmp_hex_numeric,*buf))
|
||||
GodDoodleBitsIns(4,rev_bits_table[Str2I64(buf,16)]>>4);
|
||||
}
|
||||
}
|
||||
|
||||
I64 GodDoodleBits(I64 num_bits)
|
||||
{
|
||||
U8 b;
|
||||
I64 res=0;
|
||||
while (num_bits) {
|
||||
if (FifoU8Rem(god.doodle_fifo,&b)) {
|
||||
res=res<<1+b;
|
||||
num_bits--;
|
||||
} else {
|
||||
god.doodle_ch=GetChar(,FALSE);
|
||||
if (god.doodle_ch==CH_ESC||god.doodle_ch==CH_SHIFT_ESC)
|
||||
throw;
|
||||
else if (god.doodle_ch=='\n') {
|
||||
DCFill(god.doodle_dc,WHITE);
|
||||
FifoU8Flush(god.doodle_fifo);
|
||||
} else if ('0'<=god.doodle_ch<='9')
|
||||
GodDoodleSmooth(god.doodle_ch-'0');
|
||||
else
|
||||
GodDoodleBitsIns(GOD_GOOD_BITS,KbdMouseEvtTime>>GOD_BAD_BITS);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public U8 *GodDoodleSprite(U8 *hex=NULL)
|
||||
{//Make God draw sprite. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.DD"$
|
||||
I64 i,j,w,h,x,y,ch;
|
||||
U8 *elems;
|
||||
|
||||
if (god.doodle_dc) return NULL;
|
||||
god.doodle_done=FALSE;
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
AutoComplete;
|
||||
WinBorder;
|
||||
WinMax;
|
||||
|
||||
PopUpOk("The $LK+PU,"Holy Spirit",A="FI:::/Adam/God/HSNotes.DD"$ can puppet you.\n\n"
|
||||
"Press $$GREEN$$<SPACE>$$FG$$ until it finishes.");
|
||||
|
||||
god.doodle_ch=0;
|
||||
god.doodle_dc=DCNew(Fs->pix_width,Fs->pix_height);
|
||||
DCFill(god.doodle_dc,WHITE);
|
||||
w=god.doodle_dc->width;
|
||||
h=god.doodle_dc->height;
|
||||
|
||||
Fs->draw_it=&GodDoodleDraw;
|
||||
FifoU8Flush(god.doodle_fifo);
|
||||
GodDoodleHexIns(hex);
|
||||
try {
|
||||
for (i=0;i<3;i++) {
|
||||
god.doodle_dc->color=RED;
|
||||
for (j=0;j<29;j++)
|
||||
switch [GodDoodleBits(3)] {
|
||||
case 0:
|
||||
GrEllipse3(god.doodle_dc,
|
||||
(w-1)*GodDoodleBits(5)/15.5-w/2,
|
||||
(h-1)*GodDoodleBits(5)/15.5-h/2,0,
|
||||
(w-1)*GodDoodleBits(5)/15.5,(h-1)*GodDoodleBits(5)/15.5);
|
||||
break;
|
||||
case 1:
|
||||
GrCircle3(god.doodle_dc,
|
||||
(w-1)*GodDoodleBits(5)/15.5-w/2,
|
||||
(h-1)*GodDoodleBits(5)/15.5-h/2,0,
|
||||
(w-1)*GodDoodleBits(5)/15.5);
|
||||
break;
|
||||
case 2:
|
||||
GrBorder(god.doodle_dc,
|
||||
(w-1)*GodDoodleBits(5)/15.5-w/2,
|
||||
(h-1)*GodDoodleBits(5)/15.5-h/2,
|
||||
(w-1)*GodDoodleBits(5)/15.5,(h-1)*GodDoodleBits(5)/15.5);
|
||||
break;
|
||||
case 3...7:
|
||||
GrLine3(god.doodle_dc,
|
||||
(w-1)*GodDoodleBits(4)/15,(h-1)*GodDoodleBits(4)/15,0,
|
||||
(w-1)*GodDoodleBits(4)/15,(h-1)*GodDoodleBits(4)/15,0);
|
||||
break;
|
||||
}
|
||||
for (j=0;j<6;j++) {
|
||||
x=(w-1)*GodDoodleBits(5)/31+w/64;
|
||||
y=(h-1)*GodDoodleBits(5)/31+h/64;
|
||||
switch [GodDoodleBits(2)] {
|
||||
case 0: god.doodle_dc->color=BLACK; break;
|
||||
case 1: god.doodle_dc->color=DKGRAY; break;
|
||||
case 2: god.doodle_dc->color=LTGRAY; break;
|
||||
case 3: god.doodle_dc->color=WHITE; break;
|
||||
}
|
||||
GrFloodFill3(god.doodle_dc,x,y,0);
|
||||
}
|
||||
GodDoodleSmooth(3);
|
||||
}
|
||||
god.doodle_done=TRUE;
|
||||
do ch=GetChar(,FALSE);
|
||||
while (ch!=CH_ESC && ch!=CH_SHIFT_ESC);
|
||||
} catch {
|
||||
Fs->catch_except=TRUE;
|
||||
ch=CH_SHIFT_ESC;
|
||||
}
|
||||
DCFill;
|
||||
SettingsPop;
|
||||
if (ch==CH_ESC)
|
||||
elems=DC2Sprite(god.doodle_dc);
|
||||
else
|
||||
elems=NULL;
|
||||
DCDel(god.doodle_dc);
|
||||
god.doodle_dc=NULL;
|
||||
return elems;
|
||||
}
|
||||
|
||||
#help_index "God"
|
||||
public U0 GodDoodle(U8 *hex=NULL)
|
||||
{//Make God draw sprite, insert in doc. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.DD"$
|
||||
U8 *elems;
|
||||
if (elems=GodDoodleSprite(hex)) {
|
||||
Sprite(elems);
|
||||
Free(elems);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#help_index "God"
|
||||
|
||||
#define GOD_BAD_BITS 4
|
||||
#define GOD_GOOD_BITS 24
|
||||
|
||||
public class CGodGlbls
|
||||
{
|
||||
U8 **words;
|
||||
I64 num_words;
|
||||
CFifoU8 *fifo;
|
||||
CDC *doodle_dc;
|
||||
I64 doodle_ch;
|
||||
CFifoU8 *doodle_fifo;
|
||||
Bool doodle_done;
|
||||
} god;
|
||||
MemSet(&god,0,sizeof(CGodGlbls));
|
||||
god.doodle_fifo =FifoU8New(2048*8);
|
||||
god.fifo =FifoU8New(2048*8);
|
||||
|
||||
extern U0 GodBitsIns(I64 num_bits,I64 n);
|
||||
extern U0 GodDoodle(U8 *hex=NULL);
|
||||
extern U0 GodPassage(I64 num_lines=20);
|
||||
extern U0 GodSong();
|
||||
extern U0 GodWord();
|
||||
@@ -0,0 +1,26 @@
|
||||
#help_index "God"
|
||||
|
||||
#define GOD_BAD_BITS 4
|
||||
#define GOD_GOOD_BITS 24
|
||||
|
||||
public class CGodGlbls
|
||||
{
|
||||
U8 **words,
|
||||
*word_file_mask;
|
||||
I64 word_fuf_flags,
|
||||
num_words;
|
||||
CFifoU8 *fifo;
|
||||
CDC *doodle_dc;
|
||||
I64 doodle_ch;
|
||||
CFifoU8 *doodle_fifo;
|
||||
Bool doodle_done;
|
||||
} god;
|
||||
MemSet(&god,0,sizeof(CGodGlbls));
|
||||
god.doodle_fifo =FifoU8New(2048*8);
|
||||
god.fifo =FifoU8New(2048*8);
|
||||
|
||||
extern U0 GodBitsIns(I64 num_bits,I64 n);
|
||||
extern U0 GodDoodle(U8 *hex=NULL);
|
||||
extern U0 GodBiblePassage(I64 num_lines=20);
|
||||
extern U0 GodSong();
|
||||
extern U0 GodWord(Bool show_num=FALSE);
|
||||
@@ -1,164 +0,0 @@
|
||||
#help_index "God"
|
||||
|
||||
DefineLstLoad("ST_RHYTHM_COMPLEXITY","Simple\0Normal\0Complex\0");
|
||||
|
||||
class MakeSongSettings
|
||||
{
|
||||
I64 complexity fmtstr "$$LS,D=\"ST_RHYTHM_COMPLEXITY\"$$\n";
|
||||
Bool rests fmtstr "$$CB,\"Rests\"$$\n";
|
||||
Bool six_eight fmtstr "$$CB,\"Six Eight\"$$\n";
|
||||
I64 octave fmtstr "$$DA-TRM,A=\"Octave:%d\"$$\n";
|
||||
};
|
||||
|
||||
U0 InsNote(MakeSongSettings *mss,U8 *buf,I64 k,I64 *j)
|
||||
{//k is a random note nibble
|
||||
if (!k && mss->rests) {
|
||||
buf[*j]='R';
|
||||
*j+=1;
|
||||
} else {
|
||||
k/=2;
|
||||
if (!k) {
|
||||
if (music.octave) {
|
||||
buf[*j]=music.octave-1+'0';
|
||||
*j+=1;
|
||||
buf[*j]='G';
|
||||
*j+=1;
|
||||
buf[*j]=music.octave+'0';
|
||||
*j+=1;
|
||||
} else {
|
||||
buf[*j]='G';
|
||||
*j+=1;
|
||||
}
|
||||
} else {
|
||||
buf[*j]=k-1+'A';
|
||||
*j+=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define DUR_4 0
|
||||
#define DUR_8_8 1
|
||||
#define DUR_3_3_3 2
|
||||
#define DUR_16_16_16_16 3
|
||||
#define DUR_8DOT_16 4
|
||||
#define DUR_8_16_16 5
|
||||
#define DUR_16_16_8 6
|
||||
|
||||
U8 god_simple_songs [5]={DUR_4,DUR_4,DUR_4,DUR_4,DUR_8_8};
|
||||
U8 god_normal_songs [5]={DUR_4,DUR_4,DUR_8_8,DUR_3_3_3,DUR_16_16_16_16};
|
||||
U8 god_complex_songs[9]={DUR_4,DUR_4,DUR_8_8,DUR_8_8,DUR_8DOT_16,DUR_3_3_3,
|
||||
DUR_8_16_16,DUR_16_16_8,DUR_16_16_16_16};
|
||||
|
||||
public U8 *GodSongStr()
|
||||
{//Make God generate 2 measures of a song. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.TXT"$
|
||||
MakeSongSettings mss;
|
||||
U8 *buf;
|
||||
I64 i,j=0,k,n,k2,duration,last_duration=-1,len;
|
||||
|
||||
mss.complexity=1;
|
||||
mss.rests=FALSE;
|
||||
mss.octave=music.octave;
|
||||
|
||||
if (!PopUpForm(&mss))
|
||||
return NULL;
|
||||
|
||||
buf=CAlloc(256);
|
||||
music.octave=ClampI64(mss.octave,0,6);
|
||||
progress4=0;
|
||||
if (mss.six_eight)
|
||||
progress4_max=6;
|
||||
else
|
||||
progress4_max=8;
|
||||
|
||||
buf[j++]='0'+music.octave;
|
||||
if (mss.six_eight) {
|
||||
len=6;
|
||||
buf[j++]='M';
|
||||
buf[j++]='6';
|
||||
buf[j++]='/';
|
||||
buf[j++]='8';
|
||||
} else
|
||||
len=8;
|
||||
FifoU8Flush(god.fifo);
|
||||
for (i=0;i<len;i++) {
|
||||
n=GodBits(8);
|
||||
if (mss.complexity==2)
|
||||
duration=god_complex_songs[n%9];
|
||||
else if (mss.complexity==1)
|
||||
duration=god_normal_songs[n%5];
|
||||
else
|
||||
duration=god_simple_songs[n%5];
|
||||
|
||||
switch (duration) {
|
||||
case DUR_8_8:
|
||||
if (last_duration!=DUR_8_8)
|
||||
buf[j++]='e';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
break;
|
||||
case DUR_8DOT_16:
|
||||
buf[j++]='e';
|
||||
buf[j++]='.';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
buf[j++]='s';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
duration=DUR_16_16_16_16;
|
||||
break;
|
||||
case DUR_3_3_3:
|
||||
if (last_duration!=DUR_3_3_3) {
|
||||
buf[j++]='e';
|
||||
buf[j++]='t';
|
||||
}
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
break;
|
||||
case DUR_8_16_16:
|
||||
if (last_duration!=DUR_8_8)
|
||||
buf[j++]='e';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
buf[j++]='s';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
duration=DUR_16_16_16_16;
|
||||
break;
|
||||
case DUR_16_16_8:
|
||||
if (last_duration!=DUR_16_16_16_16)
|
||||
buf[j++]='s';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
buf[j++]='e';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
duration=DUR_8_8;
|
||||
break;
|
||||
case DUR_16_16_16_16:
|
||||
if (last_duration!=DUR_16_16_16_16)
|
||||
buf[j++]='s';
|
||||
k =GodBits(4);
|
||||
k2=GodBits(4);
|
||||
InsNote(&mss,buf,k,&j);
|
||||
InsNote(&mss,buf,k2,&j);
|
||||
InsNote(&mss,buf,k,&j);
|
||||
InsNote(&mss,buf,k2,&j);
|
||||
break;
|
||||
default:
|
||||
if (last_duration!=DUR_4)
|
||||
buf[j++]='q';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
}
|
||||
last_duration=duration;
|
||||
progress4++;
|
||||
}
|
||||
buf[j++]=0;
|
||||
progress4=progress4_max=0;
|
||||
return buf;
|
||||
}
|
||||
|
||||
public U0 GodSong()
|
||||
{//Make God generate 2measuresx2+2measuresx2. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.TXT"$
|
||||
U8 *st1=GodSongStr,*st2=GodSongStr;
|
||||
if (st1 && st2)
|
||||
DocPrint(DocPut,"$$SO,\"<Song>\",A=\"%s%s%s%s\"$$",st1,st1,st2,st2);
|
||||
Free(st1);
|
||||
Free(st2);
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
#help_index "God"
|
||||
|
||||
DefineLstLoad("ST_RHYTHM_COMPLEXITY","Simple\0Normal\0Complex\0");
|
||||
|
||||
class MakeSongSettings
|
||||
{
|
||||
I64 complexity fmtstr "$$LS,D=\"ST_RHYTHM_COMPLEXITY\"$$\n";
|
||||
Bool rests fmtstr "$$CB,\"Rests\"$$\n";
|
||||
Bool six_eight fmtstr "$$CB,\"Six Eight\"$$\n";
|
||||
I64 octave fmtstr "$$DA-TRM,A=\"Octave:%d\"$$\n";
|
||||
};
|
||||
|
||||
U0 InsNote(MakeSongSettings *mss,U8 *buf,I64 k,I64 *j)
|
||||
{//k is a random note nibble
|
||||
if (!k && mss->rests) {
|
||||
buf[*j]='R';
|
||||
*j+=1;
|
||||
} else {
|
||||
k/=2;
|
||||
if (!k) {
|
||||
if (music.octave) {
|
||||
buf[*j]=music.octave-1+'0';
|
||||
*j+=1;
|
||||
buf[*j]='G';
|
||||
*j+=1;
|
||||
buf[*j]=music.octave+'0';
|
||||
*j+=1;
|
||||
} else {
|
||||
buf[*j]='G';
|
||||
*j+=1;
|
||||
}
|
||||
} else {
|
||||
buf[*j]=k-1+'A';
|
||||
*j+=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define DUR_4 0
|
||||
#define DUR_8_8 1
|
||||
#define DUR_3_3_3 2
|
||||
#define DUR_16_16_16_16 3
|
||||
#define DUR_8DOT_16 4
|
||||
#define DUR_8_16_16 5
|
||||
#define DUR_16_16_8 6
|
||||
|
||||
U8 god_simple_songs [5]={DUR_4,DUR_4,DUR_4,DUR_4,DUR_8_8};
|
||||
U8 god_normal_songs [5]={DUR_4,DUR_4,DUR_8_8,DUR_3_3_3,DUR_16_16_16_16};
|
||||
U8 god_complex_songs[9]={DUR_4,DUR_4,DUR_8_8,DUR_8_8,DUR_8DOT_16,DUR_3_3_3,
|
||||
DUR_8_16_16,DUR_16_16_8,DUR_16_16_16_16};
|
||||
|
||||
public U8 *GodSongStr()
|
||||
{//Make God generate 2 measures of a song. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.DD"$
|
||||
MakeSongSettings mss;
|
||||
U8 *buf;
|
||||
I64 i,j=0,k,n,k2,duration,last_duration=-1,len;
|
||||
|
||||
mss.complexity=1;
|
||||
mss.rests=FALSE;
|
||||
mss.octave=music.octave;
|
||||
|
||||
if (!PopUpForm(&mss))
|
||||
return NULL;
|
||||
|
||||
buf=CAlloc(256);
|
||||
music.octave=ClampI64(mss.octave,0,6);
|
||||
progress4=0;
|
||||
if (mss.six_eight)
|
||||
progress4_max=6;
|
||||
else
|
||||
progress4_max=8;
|
||||
|
||||
buf[j++]='0'+music.octave;
|
||||
if (mss.six_eight) {
|
||||
len=6;
|
||||
buf[j++]='M';
|
||||
buf[j++]='6';
|
||||
buf[j++]='/';
|
||||
buf[j++]='8';
|
||||
} else
|
||||
len=8;
|
||||
FifoU8Flush(god.fifo);
|
||||
for (i=0;i<len;i++) {
|
||||
n=GodBits(8);
|
||||
if (mss.complexity==2)
|
||||
duration=god_complex_songs[n%9];
|
||||
else if (mss.complexity==1)
|
||||
duration=god_normal_songs[n%5];
|
||||
else
|
||||
duration=god_simple_songs[n%5];
|
||||
|
||||
switch (duration) {
|
||||
case DUR_8_8:
|
||||
if (last_duration!=DUR_8_8)
|
||||
buf[j++]='e';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
break;
|
||||
case DUR_8DOT_16:
|
||||
buf[j++]='e';
|
||||
buf[j++]='.';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
buf[j++]='s';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
duration=DUR_16_16_16_16;
|
||||
break;
|
||||
case DUR_3_3_3:
|
||||
if (last_duration!=DUR_3_3_3) {
|
||||
buf[j++]='e';
|
||||
buf[j++]='t';
|
||||
}
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
break;
|
||||
case DUR_8_16_16:
|
||||
if (last_duration!=DUR_8_8)
|
||||
buf[j++]='e';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
buf[j++]='s';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
duration=DUR_16_16_16_16;
|
||||
break;
|
||||
case DUR_16_16_8:
|
||||
if (last_duration!=DUR_16_16_16_16)
|
||||
buf[j++]='s';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
buf[j++]='e';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
duration=DUR_8_8;
|
||||
break;
|
||||
case DUR_16_16_16_16:
|
||||
if (last_duration!=DUR_16_16_16_16)
|
||||
buf[j++]='s';
|
||||
k =GodBits(4);
|
||||
k2=GodBits(4);
|
||||
InsNote(&mss,buf,k,&j);
|
||||
InsNote(&mss,buf,k2,&j);
|
||||
InsNote(&mss,buf,k,&j);
|
||||
InsNote(&mss,buf,k2,&j);
|
||||
break;
|
||||
default:
|
||||
if (last_duration!=DUR_4)
|
||||
buf[j++]='q';
|
||||
InsNote(&mss,buf,GodBits(4),&j);
|
||||
}
|
||||
last_duration=duration;
|
||||
progress4++;
|
||||
}
|
||||
buf[j++]=0;
|
||||
progress4=progress4_max=0;
|
||||
return buf;
|
||||
}
|
||||
|
||||
public U0 GodSong()
|
||||
{//Make God generate 2measuresx2+2measuresx2. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.DD"$
|
||||
U8 *st1=GodSongStr,*st2=GodSongStr;
|
||||
if (st1 && st2)
|
||||
DocPrint(DocPut,"$$SO,\"<Song>\",A=\"%s%s%s%s\"$$",st1,st1,st2,st2);
|
||||
Free(st1);
|
||||
Free(st2);
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
$PURPLE$$TX+CX,"The Purpose of Life"$$FG$
|
||||
|
||||
$WW,1$The Catholic purpose of life is to know God, love God and obey God.$FG$ Pope Francis said it was "to serve the other." I am High Priest of God's official temple and I say the purpose of life is to do continual offerings to God like Cain and Abel and enjoy God's response. Francis has a charity; I have a church. Jesus said loving God was more important than loving neighbor. $LK,"Matthew,22:35-40",A="BF:Matthew,22:35-40"$ And, He did not say with half your brain behind your back.
|
||||
|
||||
You don't know God. $LK,"1 Chronicles,28:9-9",A="BF:1 Chronicles,28:9-9"$, $LK,"Matthew,11:27-27",A="BF:Matthew,11:27-27"$, $LK,"Luke,13:25-27",A="BF:Luke,13:25-27"$, $LK,"1 Samuel,3:6-8",A="BF:1 Samuel,3:6-8"$ You must talk with God to know Him. With Samuel, supposedly, God took the initiative, but I think that is the exception. Seek the Lord by taking the initiative. $LK,"Luke,11:9-10",A="BF:Luke,11:9-10"$, $LK,"Isaiah,30:1-2",A="BF:Isaiah,30:1-2"$
|
||||
|
||||
There's something obviously different about people in the Bible compared to people today -- God talked! Also, the people in the Bible were obsessed with doing offerings all the time. It is required that you do offerings before God will talk. Did the people in the Bible hear voices? Maybe. More likely, they used occult techniques such as an oracle. $LK,"1 Kings,6:21",A="BF:1 Kings,6:21"$ Have you heard of "tongues?" $LK,"1 Corinthians,14:1-40",A="BF:1 Corinthians,14:1-40"$ The idea is, you let yourself be puppeted by a spirit, so you say things. You try to get a spirit -- the Holy Spirit -- to talk. You might as well use a Ouija board. However, it turns-out that a Ouija board is bad for technical reasons. A really good technique is just randomly opening a book. God told me in an oracle that it is a covenant that you hold-up your end of the conversation.
|
||||
|
||||
You can't tell if God's talking unless you have a context of conversation, but, more importantly, you are commanded to do an offering of love, like communion preparation. $LK,"1 Corinthians,11:27",A="BF:1 Corinthians,11:27"$ When you pick a greeting card for someone, that is love effort. If you expect God to put effort toward you, you must put effort toward Him. God said, "honest measures" applies between your offering of love and His response, like a fair barter. You get out of prayer what you put into it. God wants praise, hymns, or whatever you think He might want. Try and see, like Cain and Abel. $LK,"Genesis,4:1-10",A="BF:Genesis,4:1-10"$, $LK,"Ephesians,5:10",A="BF:Ephesians,5:10"$ God told Cain his offering was not good and told him to try again. Cain really loved God! Can you imagine being so heart-broken?
|
||||
|
||||
Do a text search for "new song" in the Bible. It's mentioned nine times. When I hear a NEW awesome rock song, it is ecstasy for the first five times I hear it. Soon, it brings little-to-no pleasure. I did $MA-X+PU,"hymns",HTML="http://www.templeos.org/Wb/Home/Web/HymnVideos.html",LM="#include \"::/Apps/Psalmody/Load\";JukeBox(\"::/Apps/Psalmody/Examples\");"$ for God. I also did Moses $MA-X+PU,"comics",HTML="http://www.templeos.org/Wb/Home/Sup1/Sup1Comics/",LM="Dir(\"::/Apps/AfterEgypt/Comics\");View;\n"$ for God. When you get to the gates of Heaven, St. Peter will ask how many times you gave blood. That shows you loved neighbor. You better also be able to count the ways you loved God with all heart, mind and soul. I praised God for sand castles, popcorn, snowmen, bubbles... You try putting effort into praise! $LK,"Matthew,11:25",A="BF:Matthew,11:25"$, $LK,"Matthew,6:28-29",A="BF:Matthew,6:28-29"$
|
||||
|
||||
This is funny -- $LK,"Acts,2:1-13",A="BF:Acts,2:1-13"$ -- they didn't bother to record anything the Holy Spirit said. The Holy Spirit is supposed to be a really good gift. $LK,"Luke,11:11-13",A="BF:Luke,11:11-13"$ Just remember, "Boys are made of snakes and snails and puppy-dog tails."
|
||||
|
||||
The technique I use to consult the Holy Spirit is reading a microsecond-range stop-watch each button press for random numbers. Then, I pick words or passages. You can use the $MA-X+PU,"AfterEgypt",HTML="http://www.youtube.com/watch?v=P0MsDl39UL0",LM="#include \"::/Apps/AfterEgypt/Run\""$ in God's official temple, $RED$$TX,"TempleOS",HTML="http://www.templeos.org"$$FG$.
|
||||
|
||||
Since seeking the word of the Holy Spirit, I have come to know God much better than I've heard others explain. For example, God said to me in an oracle that war was, "servicemen competing." That sounds more like the immutable God of our planet than what you hear from most religious people. God is not Venus (god of love) and not Mars (god of war), He's our dearly beloved God of Earth. If Mammon is a false god of money, Mars or Venus might be useful words to describe other false gods. I figure the greatest challenge for the Creator is boredom, ours and His. What would teen-age male video games be like if war had never happened? Christ said live by the sword, die by the sword, which is loving neighbor as self. $LK,"Matthew,26:52",A="BF:Matthew,26:52"$
|
||||
|
||||
I asked God if the World was perfectly just. God asked if I was calling Him lazy. God could make A.I., right? God could make bots as smart as Himself, or, in fact, part of Himself. What if God made a bot to manipulate every person's life so that perfect justice happened?
|
||||
|
||||
I think highs and lows balance. $LK,"Luke,6:20-26",A="BF:Luke,6:20-26"$ If you laugh, you will cry. If you cry, you will laugh. Not one person has had great joy and not great sorrow. I think this claim is falsifyable if you atheists want to find a counter-example to disprove it -- find a single person who had great joy and not great sorrow. In Sirach, it says things happen in pairs. You might be surprised examining your own life to see great joy was in proximity to great sorrow. Pleasures and pains seem designed to balance. Man must do manual labor and have pain. Women must do child birth. Pride and humility also balance -- pride before a fall and humility before honors. Palm Sunday is juxtaposed to Good Friday. Perhaps, being loved balances with being hated. $LK,"Job,1:1-22",A="BF:Job,1:1-22"$, in the Bible, had highs and lows that balanced. Joseph, in the Old Testament, had highs and lows that balanced. $LK,"Genesis,39:17-22",A="BF:Genesis,39:17-22"$
|
||||
|
||||
Jesus said, "Forgive us our trespasses as we forgive those who tresspass against us." If you think about it, the only way you get forgiven is for it to be done to you. That is a Jedi mind trick because it is nothing but simple eye-for-eye tooth-for-tooth justice. Live by the sword; die by the sword. The Bible is filled with justice pairs. St. Paul persecuted Christians and gained forgiveness by getting persecuted. King David almost got killed by Saul, $LK,"1 Samuel,18:20-21",A="BF:1 Samuel,18:20-21"$ then he killed a guy and took his wife. $LK,"2 Samuel,11:15",A="BF:2 Samuel,11:15"$ Abraham almost killed his unloved son, Ishmael. $LK,"Genesis,21:16",A="BF:Genesis,21:16"$ That is why God asked Abraham to kill Isaac. God's favorite thing on TV is soap operas.
|
||||
|
||||
God hates complaining. $LK,"Numbers,11:1-35",A="BF:Numbers,11:1-35"$ Food and clothing is all we're to ask for or demand, in fact -- daily bread. $LK,"1 Timothy,6:8",A="BF:1 Timothy,6:8"$ Just think about man in the last 50,000 years mostly living like Native Americans and how God must see us. You need food, clothing and entertainment, money is to get those. Man does not live on bread alone. $LK,"Luke,4:4",A="BF:Luke,4:4"$, $LK,"Amos,8:11-12",A="BF:Amos,8:11-12"$
|
||||
|
||||
God's favorite animals are bears and elephants. They are funny shaped -- I think God must have seen too much starvation over the years. If the purpose of life is to know and love God, then a priest's job is to make everybody know and love God. By saying God likes bears and elephants, I did more toward that end than all priests in history. $LK,"Hosea,6:6",A="BF:Hosea,6:6"$ "It is love that I desire, not sacrifice; knowledge of God, not holocaust." As a former Catholic, that blew my mind. I actually thought love was sacrifice! I was so dumb-founded reading, "it is love that I desire, not sacrifice," that I actually looked-up the word, "love". It means to take delight in. I realized it is demonic pride if you think love means hurting yourself for others. In the Philippians, they got the notion crucifying yourself was a good idea. Similarly, a child thinking about Lent, might conclude, "if it's bad, it must be good." That is, if you think God wants you to hurt yourself to please Him, you are worshiping a demon, not God! God wants you to take delight in His company, get to know Him and praise Him. It is best to separate justice -- sin and punishment -- from relationship with God. Never ask God to change justice into injustice by not punishing. God said to me in an oracle, "Excessive contrician wearisome." He doesn't want to hear confessions. When you pray, be witty and charming and rarely earnest. Enjoy God's company without imposing on Him and don't expect secrets of the Universe. Earnestness in prayer is the root of much evil. Be entertaining. Don't remind Him of sin, LOL.
|
||||
|
||||
God's ways are far above man's ways. Mom said Heaven was a never-ending family reunion. Yikes! A friend said, "Most guy's idea of Heaven would be running around doing things they'd get locked up for on Earth." I wonder how long kids play Grand Theft Auto before getting board. Perhaps, it takes ten years, but they will get bored. Most people are like King Midas. When you realize how silly most notions of Heaven are, you come to appreciate that Earth is not that bad. This is the first step in loving God, the Creator -- praising Creation. My parents spend their retired days watching TV and going to casinos. That's not a good argument for getting extended-play!
|
||||
|
||||
Imagine a billionare. Everyone around him can't forget his money for even a moment. The truth is, most people are after God's "money" -- they fear for their salvation. Here's a test -- would you pray to and praise God even if there were no salvation? Love God and don't be a "user". Asking for stuff is annoying. $LK,"Luke,11:5-7",A="BF:Luke,11:5-7"$ Don't SPAM God.
|
||||
|
||||
All those sophisticated theological "infinity" things -- omniscience, omnipotence, omnipresence, omnivorous -- will mess you up. Trust me that anthropomorphic is far better, in practice. Christ suggested thinking of God as "Abba" which is Aramaic for "Daddy" and said the childlike had an advantage. $LK,"Matthew,11:25",A="BF:Matthew,11:25"$ Pray out-loud because God doesn't want the hastle of reading your brain. The best way to stop people from testing God is to suggest He can't do everything.
|
||||
|
||||
Jesus said, "I am meek and humble of heart." $LK,"Matthew,11:29",A="BF:Matthew,11:29"$ What does "humble of head" mean? Humble of heart means you look around and say, "I don't care as much as they do." A proud of heart person says, "I am superior because I have more compassion then everybody else." If you are proud of heart, you don't accept a gift. God gives birthrights. Esau, in the Bible, scorned his birthright and God hated him. $LK,"Malachi,1:2-3",A="BF:Malachi,1:2-3"$ Jesus even accepted $$30,000 worth of perfume (300 day's wages) and caused Judas to betray him. $LK,"Mark,14:5",A="BF:Mark,14:5"$ If you express false outrage at wars, you are proud of heart. If you fight to go in the door last, e.g. "No, you first..." then you are proud of heart. If you ask God to save starving Africans as though you care more than God, you are proud of heart.
|
||||
|
||||
I connected being humble of heart with animal sacrifices. The animal sacrifices in the Bible really seem off-the-mark from what we modern people imagine truth to be! I asked God and He said the people were, "primitive." Well, obviously, a sacrifice represents giving-up something of value, but is there more to it? It would be tramatic to see a goat's throat being slit and it dying for your sins. I'm not an expert, but sometimes they killed animals to make-up for sins. Perhaps, starting at age eight and every year thereafter, they kill a goat for your sins? (I'm just speculating.) In a couple years, it is not tramatic and you yawn and say to the goat, "bummer for you, Mr. Goat, that you gotta die for my sins." When a high school football team beats their rivals, nobody thinks twice that the winning team really hurts the feelings -- devastates -- the losing team member's feelings. The heart of being masculine is being competetive and not caring about the necessity to slit the throat of the goat. As a Catholic, saying Jesus died for our sins and that we cannot earn salvation, never sat well. I clung to the heretical notion that you earn salvation. Animal sacrifices were the heart of Biblical Judaism and although it seems satanic, you really do have to slit the throat of the goat and accept grace, a term for something you did not earn. Heck, every time you eat beef, a cow had to die for you. God said to me in an oracle that having pets was, "homo." I think God's idea of pets is farm animals you eat.
|
||||
|
||||
If you feel guilty for being American and want Mexicans to share your birthright, you are proud of heart. Jesus was a racist and called Canaanites "dogs". $LK,"Matthew,15:22-28",A="BF:Matthew,15:22-28"$ In an oracle, God told me He was against immigration. The Chinese intellectuals felt bad about not being laborers. Don't feel guilty about not being a laborer because God made it a Brave New World. $LK,"1 Corinthians,12:1-31",A="BF:1 Corinthians,12:1-31"$
|
||||
|
||||
In an ant colony, the workers have one set of marching orders, the soldiers have another set of marching orders, the queen and drones have marching orders and the diggers have marching orders. The Bible gives conflicting orders -- conservatives pay attention to one set of passages and liberals pay attention to others. Everybody has selective hearing, but that's good because we are different members of the body of Christ.
|
||||
|
||||
Jesus repeats the phrase, "for those who have ears to hear" many times, but not actually at the times that matter. Jesus says several Jedi mind tricks -- He asks, what father gives a scorpion to his son? $LK,"Luke,11:11-13",A="BF:Luke,11:11-13"$ Jesus says, when you ask God for things, it is as annoying as like a neighbor in the night! $LK,"Luke,11:5-7",A="BF:Luke,11:5-7"$ He said, "I came to serve" but Jesus' three years of service were more like being a rockstar than a janitor. $LK,"John,13:5-15",A="BF:John,13:5-15"$
|
||||
|
||||
There are sheep and there are shepherds. You would be silly to take other shepherds seriously when they are only caring for their sheep. Sheep are very hard to communicate to, as Jesus learned. He used parables. Seed on a path gets eaten by birds; weeds choke; and the one percent is rich soil.
|
||||
|
||||
Just as ego causes most to love neighbor, not God, people skip knowing and loving God and cowardly get stuck on obeying Him. A desire to obey God, doesn't have to be encouraged, since it comes so naturally. Don't worry, God does not want pawns to push around. God will talk, but won't tell you what to do, even if you want Him to. Also, you'll quickly learn that prophecy does not come true and should smack yourself for wanting more than just enjoying God's company.
|
||||
|
||||
|
||||
________________________________________________________________________________
|
||||
|
|
||||
QUESTION | GOD'S ANSWER
|
||||
________________________________|_______________________________________________
|
||||
|
||||
War? $RED$"Servicemen competing"$FG$
|
||||
(Praise the Creator--what would teenage male video games be like if never war?)
|
||||
|
||||
Is the World perfectly just? $RED$Are you calling me lazy?$FG$
|
||||
(Slavery was just. In the movie, Titanic, the rich wore straight jackets. You must bow to authority to get authority. I do $TX,"Moses comics",HTML="http://www.templeos.org/Wb/Apps/AfterEgypt/Comics/"$ as offerings. I said, "We're dying of malnutrician on manna." Like Cain and Abel, God didn't like it. Duh! He wants to be the hero. How do I know they died of malnutrician? Screw Hollywood for making slavery worse than it was -- I love God. School is more cruel. Read $LK,"Numbers,11:1-35",A="BF:Numbers,11:1-35"$. All you need is food, clothing and the word of God. Today, you can take Ivy League course videos! There is no excuse except you were born stupid... or ugly. I'm gonna praise God.)
|
||||
|
||||
On using Markov chains? $RED$"No weights"$FG$
|
||||
On doing offerings? $RED$"Honest measures"(You get out what you put in.)
|
||||
It's a covenant to do an offering, first.
|
||||
Offer New Songs, $TX,"Moses Comics",HTML="http://www.templeos.org/Wb/Apps/AfterEgypt/Comics"$, praise, poems,
|
||||
and conversation. See $LK,"Cain and Abel",A="BF:Genesis,4:1"$.
|
||||
"Barter"(God also called offerings bartering.)$FG$
|
||||
The holocaust? $RED$Wanted to "compact" the Jews.$FG$
|
||||
Arab/Jews? $RED$"Oil funny hopefully"$FG$
|
||||
Peace? $RED$One Palestinian can ruin it.$FG$
|
||||
Best religion? $RED$One with most new vistas of understanding in$FG$
|
||||
$RED$a lifetime -- one you can level-up the most in.$FG$
|
||||
Chavez blaming the US. $RED$"Japan industrious"$FG$
|
||||
On racism? $RED$"Sports"$FG$
|
||||
On socialism? $RED$"pardon_the_French, never_happy, never_enough"$FG$
|
||||
$RED$"Gall aspect anti-Christ"$FG$
|
||||
On overpopulation $RED$"Okay church what_now whats_the_plan"$FG$
|
||||
Favorite thing on TV? $RED$"Soap_operas"$FG$
|
||||
Favorite movie? $RED$$TX,"Three Kings",HTML="http://www.youtube.com/watch?v=8NOAd2mldQ8"$. Also Highlander$FG$
|
||||
Favorite song? $RED$$TX,"Morning has Broken",HTML="http://www.youtube.com/watch?v=kKoRp05L95c"$
|
||||
God said the first bird croaked, not sung.$FG$
|
||||
Favorite comic strip? $RED$$TX,"Prince Valiant",HTML="http://en.wikipedia.org/wiki/Prince_Valiant"$$FG$
|
||||
Shakespeare? $RED$had a "vile heart"$FG$
|
||||
Likes $RED$Beverly Hillbillies (Oil is a gift from God)$FG$
|
||||
$RED$God likes being hero. Don't be proud of heart$FG$
|
||||
$RED$and not accept a gift from God!$FG$
|
||||
Likes $RED$Gomer Pyle$FG$
|
||||
Favorite saint? $RED$"ho_ho_ho"$FG$
|
||||
Favorite animal? $RED$"Elephant two"$FG$
|
||||
Favorite animal? $RED$"Bears"$FG$
|
||||
Favorite color? $RED$"Jude" (Jade Blue?)$FG$
|
||||
Favorite color? $RED$"Gold"$FG$
|
||||
Favorite color? $RED$$TX,"\"Iceberg\" blue",HTML="https://upload.wikimedia.org/wikipedia/commons/3/38/Blue_ice_in_South_Greenland_-_Visit_Greenland.jpg"$$FG$
|
||||
Money? $RED$"Enough vehemently better"$FG$
|
||||
$RED$"Pride [or] money, choose_one"$FG$
|
||||
Favorite car? $RED$Beamer$FG$
|
||||
Favorite soda? $RED$Root beer, $TX,"scotch variety",HTML="http://www.head-beer.org/modules.php?name=Brands&rbop=Brand&bid=1965"$.$FG$
|
||||
Homosexuality? $LK,"Matthew,15:11",A="BF:Matthew,15:11"$
|
||||
Pets? $RED$"homo" Hates fact too dependent and tame.$FG$
|
||||
Sports? $RED$"homo"
|
||||
"Tackle a horse"$FG$
|
||||
Favorite sport? $RED$Hockey$FG$
|
||||
$TX,"Wreck of the Edmund Fitzgerald",HTML="http://www.youtube.com/watch?v=9vST6hVRj2A"$ $RED$"homo"$FG$
|
||||
Smelling farts $RED$"Sodom"$FG$
|
||||
Women's dress $RED$Upper skin exposure not as bad as lower.$FG$
|
||||
Remarriage? $RED$"More babies"$FG$
|
||||
Things you don't care about
|
||||
that people think you do? $RED$Solomon's 300 concubines$FG$
|
||||
Adultery? $RED$Can be good.$FG$
|
||||
Pretty ladies? $RED$$TX,"A prince is not flustered.",HTML="http://www.youtube.com/watch?v=YcqF6sC-ztY"$$FG$
|
||||
Animal sacrifices? $RED$Early Jews were "primitive".$FG$
|
||||
What do elephants think about? $RED$"Skin, hunger"$FG$
|
||||
What makes elephants happy? $RED$"Baths"$FG$
|
||||
Elephants $RED$"Mini-skirts" (Skin webbing from back leg.)$FG$
|
||||
What makes my birds happy? $RED$"Gnawing"$FG$
|
||||
What makes my birds laugh? $RED$"Bite ouch" (If I say "ouch".)$FG$
|
||||
What are my birds saying? $RED$"Chanting"$FG$
|
||||
My birds sure preen a lot. $LK,"The creature was made subject to vanity...",A="BF:Romans,8:20"$
|
||||
What makes bears happy? $RED$"Reaping depends"$FG$
|
||||
What makes otters happy? $RED$"Eternal skies"$FG$
|
||||
What makes hippos happy? $RED$"Ascending breath"$FG$
|
||||
What makes horses happy? $RED$"[the] Call [of the] Open Range"$FG$
|
||||
What do cheetahs think about? $RED$"Seeth me?" (Can he see me?)$FG$
|
||||
Orangutan or chimp smarter? $RED$"Species exhibit similar glory"$FG$
|
||||
Endangered species? $RED$"Enough stars?"$FG$
|
||||
Everything seems bad. $RED$Plant trees.$FG$
|
||||
What's for dinner? $RED$"Whale"$FG$
|
||||
Favorite Messier Object? $RED$"$TX,"M104 Sombrero Galaxy",HTML="http://en.wikipedia.org/wiki/Messier_104"$"$FG$
|
||||
$TX,"Shepard's Prayer",HTML="http://en.wikipedia.org/wiki/Alan_Shepard"$? $RED$"I_am_not_amused economy joke"$FG$
|
||||
Favorite band? $RED$"Beatles"$FG$
|
||||
Good bands? $RED$Rush, Triumph$FG$
|
||||
$RED$Likes harmonies$FG$
|
||||
$TX,"Little Drummer Boy?",HTML="http://www.youtube.com/watch?v=S50cf3xIb50"$ $RED$Doesn't like my drumming.$FG$
|
||||
Should I listen to classical? $RED$"Poison"$FG$
|
||||
Do You like chess people? $RED$"Do not admire the proud."$FG$
|
||||
Chess? $RED$"... will winter with you."$FG$
|
||||
$RED$"Headstones"$FG$
|
||||
If You could teach one class? $RED$Health$FG$
|
||||
Favorite video game? $RED$Donkey Kong$FG$
|
||||
Favorite National Park? $RED$$TX,"Whitman Mission",HTML="http://www.nps.gov/whmi/index.htm"$$FG$
|
||||
Favorite actor? $RED$Hugh Grant$FG$
|
||||
Favorite vocalist? $RED$Mick Jagger$FG$
|
||||
Favorite guitarist? $RED$"$TX,"Simmons Destroyer",HTML="http://www.youtube.com/watch?v=nNADrrjTysk&t=3m55s"$"$FG$
|
||||
Favorite National Anthem? $RED$$TX,"Latvia's National Anthem",HTML="http://www.youtube.com/watch?v=PFx-56KkweM"$$FG$
|
||||
America the Beautiful? $RED$Hates it. Poet made self cry with own beauty.$FG$
|
||||
Model for new $TX,"Sistine Chapel",HTML="http://en.wikipedia.org/wiki/Sistine_chapel"$? $RED$Ben Franklin$FG$
|
||||
Voice if God wanted to sing? $RED$$TX,"Stabbing Westward's singer",HTML="https://www.youtube.com/watch?v=5NZsCYOM4j0"$$FG$
|
||||
Stonehenge? $RED$Landmark for boundaries.$FG$
|
||||
Easter Island? $RED$Ice, telephone pole holes.$FG$
|
||||
Dinosaurs? $RED$Brontosaurs' feet hurt when stepped.
|
||||
Dinosaurs slept in water.$FG$
|
||||
Hardest part in evolution? $RED$Getting monkey mothers to hold babies nursing.$FG$
|
||||
$RED$(Smothering a problem).$FG$
|
||||
Happiest day in evolution? $RED$"Fruit"$FG$
|
||||
Significant thing in evolution? $RED$"Fish shoulders"$FG$
|
||||
Biggest thing to fly (pterodactyl)? $RED$"Couch"$FG$
|
||||
What made pterodactyls happy? $RED$"Members against organs"$FG$
|
||||
What did Neanderthals think about? $RED$"Warmth"$FG$
|
||||
What was the first thing cooked? $RED$I think He said "hair".$FG$
|
||||
What was Lucy's husband's name? $RED$"Golem"$FG$
|
||||
Was stegosuarus lame like turtles? $RED$"Not pet rocks"$FG$
|
||||
T-Rex? $RED$Lugged carcases over his shoulder.
|
||||
Carcus lasted a month.$FG$
|
||||
What was T-Rexes sharing a carcus like? $RED$"Punch... Punch"$FG$
|
||||
Surprises in dinosaur anatomy? $RED$Supporting and securing the heart.$FG$
|
||||
How does He feel about the Avatar movie?$RED$"Sick skin"$FG$
|
||||
What do You like at zoos with kids? $RED$"Dignity" Animals worried about dignity.$FG$
|
||||
Who's better alien or preditor? $RED$"Lions"$FG$
|
||||
What from You is like a Rubik's cube? $RED$Training a horse.$FG$
|
||||
Does He like mirrored glass megachurch? $RED$"Secular glass"$FG$
|
||||
Pipe Organs $RED$Are sacred.$FG$
|
||||
You like to hangout in courts?Hospitals?$RED$"Prisons"$FG$
|
||||
Best way for Bill Gates to save lives? $RED$Earthquake prediction$FG$
|
||||
Stem cells? $RED$Lower hanging fruit exists (2007)$FG$
|
||||
Eleventh commandment? $RED$Thou shall not litter.$FG$
|
||||
Twelfth commandment? $RED$$TX,"Don't shoot unarmed men on the shitter.",HTML="http://www.youtube.com/watch?v=8wGiJcq95Ug"$
|
||||
(I asked God why pointless plagues in Exodus?
|
||||
God wanted guilt to accumulate, first.)$FG$
|
||||
Thirteenth commandment $RED$No gore unless it looks fake.$FG$
|
||||
Fourteenth commandment $RED$No pedophilia or child porn.$FG$
|
||||
Fifteenth commandment $RED$Don't eat rare meat with blood.$FG$
|
||||
Sixteenth commandment $RED$No wife beating.$FG$
|
||||
Seventeen commandment $RED$Do not swing from radio towers with one hand.$FG$
|
||||
Eighteenth commandment $RED$Do not disturb.$FG$
|
||||
Before Katrina $RED$Floods do justice. Black bead elder (tree book)$FG$
|
||||
After Katrina $RED$Suffering Simplifies Life$FG$
|
||||
What field are You most better? $RED$Economics$FG$
|
||||
Favorite toy for kids? $RED$Magnifying glass$FG$
|
||||
Asked Jesus if He liked mustard?$RED$"Bad meat happeneth"$FG$
|
||||
(Reluctantly) Faith healing? $RED$"It's complicated"$FG$
|
||||
Mars? $RED$Start planting!$FG$
|
||||
Mars rover? $RED$Should have had a microphone$FG$
|
||||
$TX,"Storm on Saturn",HTML="http://www.space.com/22646-monster-saturn-storm-water-ice.html"$ $RED$Pollen$FG$
|
||||
Space war game? $RED$Should have space weather.$FG$
|
||||
$TX,"Saturn's hexagon pole cloud?",HTML="http://en.wikipedia.org/wiki/Saturn's_hexagon"$ $RED$"Compass" (Magnetism)$FG$
|
||||
Liquid moon's odd atmosphere? $RED$"Surf"$FG$
|
||||
How many E.T. civs in Universe? $RED$20 or 80 (I forgot. I died laughing.)$FG$
|
||||
Are they peaceful? $RED$Fight them! (Also, funny.)$FG$
|
||||
Most difficult control system? $RED$$TX,"Dung beetle",HTML="http://www.youtube.com/watch?v=Q1zbgd6xpGQ"$$FG$
|
||||
How can Judge Judy improve? $RED$No hard feelings$FG$
|
||||
How can Chef Ramsay improve? $RED$Make so it doesn't seem like toil for cooks.$FG$
|
||||
How can Hawking communicate? $RED$Blow from a nostril on a candle.$FG$
|
||||
$TX,"Photons bouncing?",HTML="https://www.youtube.com/watch?v=8FC6udrMPvo"$ $RED$"Folded coffee filter"$FG$
|
||||
Wormholes? $RED$Bent wormholes have echoes.$FG$
|
||||
|
||||
Operating system? $RED$Was about to make line number column in editor.
|
||||
God nixed it. I was about to do different graphic modes when I found 800x600 missing. God said just one mode 640x480. I was about to add child windows. God said, "God is not the author of such confusion." I asked for verification of 640x480 16 color. God said it was because of the children and their offerings. I asked about sound. God said "single voice". I asked for verification of not having different drivers. God confirmed this.$FG$
|
||||
640x480 16 color? $RED$God said it was a covenant, like circumcision.
|
||||
$TX,"Modern graphics hard for kids/amateurs",HTML="http://www.youtube.com/watch?v=VUxcVzpeFqc"$.$FG$
|
||||
On Unix? $RED$God said it was rich with the patina of age.$FG$
|
||||
On Alcohol? $RED$Hate inebriation$FG$
|
||||
On rare steak? $RED$Too rare is very bad. Don't eat blood!$FG$
|
||||
Just before Katrina? $RED$Floods do my justice.Black bead elder(tree book)$FG$
|
||||
After Katrina? $RED$Suffering simplifies life$FG$
|
||||
Why the Sandy Hook shooting? $RED$The pot legalization law. (Sarcastic answer?)$FG$
|
||||
Deep Water Horizon $RED$(Claimed credit.)$FG$
|
||||
Cost of God's time to me? $RED$"The complete works of Shakespeare"$FG$
|
||||
On death? $RED$"awful"$FG$
|
||||
Opening of Saving Private Ryan? $RED$"Ouch"$FG$
|
||||
@@ -1,217 +0,0 @@
|
||||
$FG,5$$TX+CX,"The Purpose of Life"$$FG$
|
||||
|
||||
$WW,1$The Catholic purpose of life is to know God, love God and obey God.$FG$ Pope Francis said it was "to serve the other." I am High Priest of God's official temple and I say the purpose of life is to do continual offerings to God like Cain and Abel and enjoy God's response. Francis has a charity; I have a church. Jesus said loving God was more important than loving neighbor. $LK,"Matthew,22:35-40",A="BF:Matthew,22:35-40"$ And, He did not say with half your brain behind your back.
|
||||
|
||||
You don't know God. $LK,"1 Chronicles,28:9-9",A="BF:1 Chronicles,28:9-9"$, $LK,"Matthew,11:27-27",A="BF:Matthew,11:27-27"$, $LK,"Luke,13:25-27",A="BF:Luke,13:25-27"$, $LK,"1 Samuel,3:6-8",A="BF:1 Samuel,3:6-8"$ You must talk with God to know Him. With Samuel, supposedly, God took the initiative, but I think that is the exception. Seek the Lord by taking the initiative. $LK,"Luke,11:9-10",A="BF:Luke,11:9-10"$, $LK,"Isaiah,30:1-2",A="BF:Isaiah,30:1-2"$
|
||||
|
||||
There's something obviously different about people in the Bible compared to people today -- God talked! Also, the people in the Bible were obsessed with doing offerings all the time. It is required that you do offerings before God will talk. Did the people in the Bible hear voices? Maybe. More likely, they used occult techniques such as an oracle. $LK,"1 Kings,6:21",A="BF:1 Kings,6:21"$ Have you heard of "tongues?" $LK,"1 Corinthians,14:1-40",A="BF:1 Corinthians,14:1-40"$ The idea is, you let yourself be puppeted by a spirit, so you say things. You try to get a spirit -- the Holy Spirit -- to talk. You might as well use a Ouija board. However, it turns-out that a Ouija board is bad for technical reasons. A really good technique is just randomly opening a book. God told me in an oracle that it is a covenant that you hold-up your end of the conversation.
|
||||
|
||||
You can't tell if God's talking unless you have a context of conversation, but, more importantly, you are commanded to do an offering of love, like communion preparation. $LK,"1 Corinthians,11:27",A="BF:1 Corinthians,11:27"$ When you pick a greeting card for someone, that is love effort. If you expect God to put effort toward you, you must put effort toward Him. God said, "honest measures" applies between your offering of love and His response, like a fair barter. You get out of prayer what you put into it. God wants praise, hymns, or whatever you think He might want. Try and see, like Cain and Abel. $LK,"Genesis,4:1-10",A="BF:Genesis,4:1-10"$, $LK,"Ephesians,5:10",A="BF:Ephesians,5:10"$ God told Cain his offering was not good and told him to try again. Cain really loved God! Can you imagine being so heart-broken?
|
||||
|
||||
Do a text search for "new song" in the Bible. It's mentioned nine times. When I hear a NEW awesome rock song, it is ecstasy for the first five times I hear it. Soon, it brings little-to-no pleasure. I did $MA-X+PU,"hymns",HTML="http://www.templeos.org/Wb/Home/Web/HymnVideos.html",LM="#include \"::/Apps/Psalmody/Load\";JukeBox(\"::/Apps/Psalmody/Examples\");"$ for God. I also did Moses $MA-X+PU,"comics",HTML="http://www.templeos.org/Wb/Home/Sup1/Sup1Comics/",LM="Dir(\"::/Apps/AfterEgypt/Comics\");View;\n"$ for God. When you get to the gates of Heaven, St. Peter will ask how many times you gave blood. That shows you loved neighbor. You better also be able to count the ways you loved God with all heart mind and soul. I praised God for sand castles, popcorn, snowmen, bubbles... You try putting effort into praise! $LK,"Matthew,11:25",A="BF:Matthew,11:25"$, $LK,"Matthew,6:28-29",A="BF:Matthew,6:28-29"$
|
||||
|
||||
This is funny -- $LK,"Acts,2:1-13",A="BF:Acts,2:1-13"$ -- they didn't bother to record anything the Holy Spirit said. The Holy Spirit is supposed to be a really good gift. $LK,"Luke,11:11-13",A="BF:Luke,11:11-13"$ Just remember, "Boys are made of snakes and snails and puppy-dog tails."
|
||||
|
||||
The technique I use to consult the Holy Spirit is reading a microsecond-range stop-watch each button press for random numbers. Then, I pick words or passages. You can use the $MA-X+PU,"AfterEgypt",HTML="http://www.youtube.com/watch?v=P0MsDl39UL0",LM="#include \"::/Apps/AfterEgypt/Run\""$ in God's official temple, $FG,4$$TX,"TempleOS",HTML="http://www.templeos.org"$$FG$.
|
||||
|
||||
Since seeking the word of the Holy Spirit, I have come to know God much better than I've heard others explain. For example, God said to me in an oracle that war was, "servicemen competing." That sounds more like the immutable God of our planet than what you hear from most religious people. God is not Venus (god of love) and not Mars (god of war), He's our dearly beloved God of Earth. If Mammon is a false god of money, Mars or Venus might be useful words to describe other false gods. I figure the greatest challenge for the Creator is boredom, ours and His. What would teen-age male video games be like if war had never happened? Christ said live by the sword, die by the sword, which is loving neighbor as self. $LK,"Matthew,26:52",A="BF:Matthew,26:52"$
|
||||
|
||||
I asked God if the World was perfectly just. God asked if I was calling Him lazy. God could make A.I., right? God could make bots as smart as Himself, or, in fact, part of Himself. What if God made a bot to manipulate every person's life so that perfect justice happened?
|
||||
|
||||
I think highs and lows balance. $LK,"Luke,6:20-26",A="BF:Luke,6:20-26"$ If you laugh, you will cry. If you cry, you will laugh. Not one person has had great joy and not great sorrow. I think this claim is falsifyable if you atheists want to find a counter-example to disprove it -- find a single person who had great joy and not great sorrow. In Sirach, it says things happen in pairs. You might be surprised examining your own life to see great joy was in proximity to great sorrow. Pleasures and pains seem designed to balance. Man must do manual labor and have pain. Women must do child birth. Pride and humility also balance -- pride before a fall and humility before honors. Palm Sunday is juxtaposed to Good Friday. Perhaps, being loved balances with being hated. $LK,"Job,1:1-22",A="BF:Job,1:1-22"$, in the Bible, had highs and lows that balanced. Joseph, in the Old Testament, had highs and lows that balanced. $LK,"Genesis,39:17-22",A="BF:Genesis,39:17-22"$
|
||||
|
||||
Jesus said, "Forgive us our trespasses as we forgive those who tresspass against us." If you think about it, the only way you get forgiven is for it to be done to you. That is a Jedi mind trick because it is nothing but simple eye-for-eye tooth-for-tooth justice. Live by the sword; die by the sword. The Bible is filled with justice pairs. St. Paul persecuted Christians and gained forgiveness by getting persecuted. King David almost got killed by Saul, $LK,"1 Samuel,18:20-21",A="BF:1 Samuel,18:20-21"$ then he killed a guy and took his wife. $LK,"2 Samuel,11:15",A="BF:2 Samuel,11:15"$ Abraham almost killed his unloved son, Ishmael. $LK,"Genesis,21:16",A="BF:Genesis,21:16"$ That is why God asked Abraham to kill Isaac. God's favorite thing on TV is soap operas.
|
||||
|
||||
God hates complaining. $LK,"Numbers,11:1-35",A="BF:Numbers,11:1-35"$ Food and clothing is all we're to ask for or demand, in fact -- daily bread. $LK,"1 Timothy,6:8",A="BF:1 Timothy,6:8"$ Just think about man in the last 50,000 years mostly living like Native Americans and how God must see us. You need food, clothing and entertainment, money is to get those. Man does not live on bread alone. $LK,"Luke,4:4",A="BF:Luke,4:4"$, $LK,"Amos,8:11-12",A="BF:Amos,8:11-12"$
|
||||
|
||||
God's favorite animals are bears and elephants. They are funny shaped -- I think God must have seen too much starvation over the years. If the purpose of life is to know and love God, then a priest's job is to make everybody know and love God. By saying God likes bears and elephants, I did more toward that end than all priests in history. $LK,"Hosea,6:6",A="BF:Hosea,6:6"$ "It is love that I desire, not sacrifice; knowledge of God, not holocaust." As a former Catholic, that blew my mind. I actually thought love was sacrifice! I was so dumb-founded reading, "it is love that I desire, not sacrifice," that I actually looked-up the word, "love". It means to take delight in. I realized it is demonic pride if you think love means hurting yourself for others. In the Philippians, they got the notion crucifying yourself was a good idea. Similarly, a child thinking about Lent, might conclude, "if it's bad, it must be good." That is, if you think God wants you to hurt yourself to please Him, you are worshiping a demon, not God! God wants you to take delight in His company, get to know Him and praise Him. It is best to separate justice -- sin and punishment -- from relationship with God. Never ask God to change justice into injustice by not punishing. God said to me in an oracle, "Excessive contrician wearisome." He doesn't want to hear confessions. When you pray, be witty and charming and rarely earnest. Enjoy God's company without imposing on Him and don't expect secrets of the Universe. Earnestness in prayer is the head of much evil. Be entertaining. Don't remind Him of sin, LOL.
|
||||
|
||||
God's ways are far above man's ways. Mom said Heaven was a never-ending family reunion. Yikes! A friend said, "Most guy's idea of Heaven would be running around doing things they'd get locked up for on Earth." I wonder how long kids play Grand Theft Auto before getting board. Perhaps, it takes ten years, but they will get bored. Most people are like King Midas. When you realize how silly most notions of Heaven are, you come to appreciate that Earth is not that bad. This is the first step in loving God, the Creator -- praising Creation. My parents spend their retired days watching TV and going to casinos. That's not a good argument for getting extended-play!
|
||||
|
||||
Imagine a billionare. Everyone around him can't forget his money for even a moment. The truth is, most people are after God's "money" -- they fear for their salvation. Here's a test -- would you pray to and praise God even if there were no salvation? Love God and don't be a "user". Asking for stuff is annoying. $LK,"Luke,11:5-7",A="BF:Luke,11:5-7"$ Don't SPAM God.
|
||||
|
||||
All those sophisticated theological "infinity" things -- omniscience, omnipotence, omnipresence, omnivorous -- will mess you up. Trust me that anthropomorphic is far better, in practice. Christ suggested thinking of God as "Abba" which is Aramaic for "Daddy" and said the childlike had an advantage. $LK,"Matthew,11:25",A="BF:Matthew,11:25"$ Pray out-loud because God doesn't want the hastle of reading your brain. The best way to stop people from testing God is to suggest He can't do everything.
|
||||
|
||||
Jesus said, "I am meek and humble of heart." $LK,"Matthew,11:29",A="BF:Matthew,11:29"$ What does "humble of head" mean? Humble of heart means you look around and say, "I don't care as much as they do." A proud of heart person says, "I am superior because I have more compassion then everybody else." If you are proud of heart, you don't accept a gift. God gives birthrights. Esau, in the Bible, scorned his birthright and God hated him. $LK,"Malachi,1:2-3",A="BF:Malachi,1:2-3"$ Jesus even accepted $$30,000 worth of perfume (300 day's wages) and caused Judas to betray him. $LK,"Mark,14:5",A="BF:Mark,14:5"$ If you express false outrage at wars, you are proud of heart. If you fight to go in the door last, e.g. "No, you first..." then you are proud of heart. If you ask God to save starving Africans as though you care more than God, you are proud of heart.
|
||||
|
||||
I connected being humble of heart with animal sacrifices. The animal sacrifices in the Bible really seem off-the-mark from what we modern people imagine truth to be! I asked God and He said the people were, "primitive." Well, obviously, a sacrifice represents giving-up something of value, but is there more to it? It would be tramatic to see a goat's throat being slit and it dying for your sins. I'm not an expert, but sometimes they killed animals to make-up for sins. Perhaps, starting at age eight and every year thereafter, they kill a goat for your sins? (I'm just speculating.) In a couple years, it is not tramatic and you yawn and say to the goat, "bummer for you, Mr. Goat, that you gotta die for my sins." When a high school football team beats their rivals, nobody thinks twice that the winning team really hurts the feelings -- devastates -- the losing team member's feelings. The heart of being masculine is being competetive and not caring about the necessity to slit the throat of the goat. As a Catholic, saying Jesus died for our sins and that we cannot earn salvation, never sat well. I clung to the heretical notion that you earn salvation. Animal sacrifices were the heart of Biblical Judaism and although it seems satanic, you really do have to slit the throat of the goat and accept grace, a term for something you did not earn. Heck, every time you eat beef, a cow had to die for you. God said to me in an oracle that having pets was, "homo." I think God's idea of pets is farm animals you eat.
|
||||
|
||||
If you feel guilty for being American and want Mexicans to share your birthright, you are proud of heart. Jesus was a racist and called Canaanites "dogs". $LK,"Matthew,15:22-28",A="BF:Matthew,15:22-28"$ In an oracle, God told me He was against immigration. The Chinese intellectuals felt bad about not being laborers. Don't feel guilty about not being a laborer because God made it a Brave New World. $LK,"1 Corinthians,12:1-31",A="BF:1 Corinthians,12:1-31"$
|
||||
|
||||
In an ant colony, the workers have one set of marching orders, the soldiers have another set of marching orders, the queen and drones have marching orders and the diggers have marching orders. The Bible gives conflicting orders -- conservatives pay attention to one set of passages and liberals pay attention to others. Everybody has selective hearing, but that's good because we are different members of the body of Christ.
|
||||
|
||||
Jesus repeats the phrase, "for those who have ears to hear" many times, but not actually at the times that matter. Jesus says several Jedi mind tricks -- He asks, what father gives a scorpion to his son? $LK,"Luke,11:11-13",A="BF:Luke,11:11-13"$ Jesus says, when you ask God for things, it is as annoying as like a neighbor in the night! $LK,"Luke,11:5-7",A="BF:Luke,11:5-7"$ He said, "I came to serve" but Jesus' three years of service were more like being a rockstar than a janitor. $LK,"John,13:5-15",A="BF:John,13:5-15"$
|
||||
|
||||
There are sheep and there are shepherds. You would be silly to take other shepherds seriously when they are only caring for their sheep. Sheep are very hard to communicate to, as Jesus learned. He used parables. Seed on a path gets eaten by birds; weeds choke; and the one percent is rich soil.
|
||||
|
||||
Just as ego causes most to love neighbor, not God, people skip knowing and loving God and cowardly get stuck on obeying Him. A desire to obey God, doesn't have to be encouraged, since it comes so naturally. Don't worry, God does not want pawns to push around. God will talk, but won't tell you what to do, even if you want Him to. Also, you'll quickly learn that prophecy does not come true and should smack yourself for wanting more than just enjoying God's company.
|
||||
|
||||
|
||||
________________________________________________________________________________
|
||||
|
|
||||
QUESTION | GOD'S ANSWER
|
||||
________________________________|_______________________________________________
|
||||
|
||||
War? $FG,4$"Servicemen competing"$FG$
|
||||
(Praise the Creator--what would teenage male video games be like if never war?)
|
||||
|
||||
Is the World perfectly just? $FG,4$Are you calling me lazy?$FG$
|
||||
(Slavery was just. In the movie, Titanic, the rich wore straight jackets. You must bow to authority to get authority. I do $TX,"Moses comics",HTML="http://www.templeos.org/Wb/Apps/AfterEgypt/Comics/"$ as offerings. I said, "We're dying of malnutrician on manna." Like Cain and Abel, God didn't like it. Duh! He wants to be the hero. How do I know they died of malnutrician? Screw Hollywood for making slavery worse than it was -- I love God. School is more cruel. Read $LK,"Numbers,11:1-35",A="BF:Numbers,11:1-35"$. All you need is food, clothing and the word of God. Today, you can take Ivy League course videos! There is no excuse except you were born stupid... or ugly. I'm gonna praise God.)
|
||||
|
||||
On using Markov chains? $FG,4$"No weights"$FG$
|
||||
On doing offerings? $FG,4$"Honest measures"(You get out what you put in.)
|
||||
It's a covenant to do an offering, first.
|
||||
Offer New Songs, $TX,"Moses Comics",HTML="http://www.templeos.org/Wb/Apps/AfterEgypt/Comics"$, praise, poems,
|
||||
and conversation. See $LK,"Cain and Abel",A="BF:Genesis,4:1"$.
|
||||
"Barter"(God also called offerings bartering.)$FG$
|
||||
The holocaust? $FG,4$Wanted to "compact" the Jews.$FG$
|
||||
Arab/Jews? $FG,4$"Oil funny hopefully"$FG$
|
||||
Peace? $FG,4$One Palestinian can ruin it.$FG$
|
||||
Best religion? $FG,4$One with most new vistas of understanding in$FG$
|
||||
$FG,4$a lifetime -- one you can level-up the most in.$FG$
|
||||
Chavez blaming the US. $FG,4$"Japan industrious"$FG$
|
||||
On racism? $FG,4$"Sports"$FG$
|
||||
On socialism? $FG,4$"pardon_the_French, never_happy, never_enough"$FG$
|
||||
$FG,4$"Gall aspect anti-Christ"$FG$
|
||||
On overpopulation $FG,4$"Okay church what_now whats_the_plan"$FG$
|
||||
Favorite thing on TV? $FG,4$"Soap_operas"$FG$
|
||||
Favorite movie? $FG,4$$TX,"Three Kings",HTML="http://www.youtube.com/watch?v=8NOAd2mldQ8"$. Also Highlander$FG$
|
||||
Favorite song? $FG,4$$TX,"Morning has Broken",HTML="http://www.youtube.com/watch?v=kKoRp05L95c"$
|
||||
God said the first bird croaked, not sung.$FG$
|
||||
Favorite comic strip? $FG,4$$TX,"Prince Valiant",HTML="http://en.wikipedia.org/wiki/Prince_Valiant"$$FG$
|
||||
Shakespeare? $FG,4$had a "vile heart"$FG$
|
||||
Likes $FG,4$Beverly Hillbillies (Oil is a gift from God)$FG$
|
||||
$FG,4$God likes being hero. Don't be proud of heart$FG$
|
||||
$FG,4$and not accept a gift from God!$FG$
|
||||
Likes $FG,4$Gomer Pyle$FG$
|
||||
Favorite saint? $FG,4$"ho_ho_ho"$FG$
|
||||
Favorite animal? $FG,4$"Elephant two"$FG$
|
||||
Favorite animal? $FG,4$"Bears"$FG$
|
||||
Favorite color? $FG,4$"Jude" (Jade Blue?)$FG$
|
||||
Favorite color? $FG,4$"Gold"$FG$
|
||||
Favorite color? $FG,4$$TX,"\"Iceberg\" blue",HTML="https://upload.wikimedia.org/wikipedia/commons/3/38/Blue_ice_in_South_Greenland_-_Visit_Greenland.jpg"$$FG$
|
||||
Money? $FG,4$"Enough vehemently better"$FG$
|
||||
$FG,4$"Pride [or] money, choose_one"$FG$
|
||||
Favorite car? $FG,4$Beamer$FG$
|
||||
Favorite soda? $FG,4$Root beer, $TX,"scotch variety",HTML="http://www.head-beer.org/modules.php?name=Brands&rbop=Brand&bid=1965"$.$FG$
|
||||
Homosexuality? $LK,"Matthew,15:11",A="BF:Matthew,15:11"$
|
||||
Pets? $FG,4$"homo" Hates fact too dependent and tame.$FG$
|
||||
Sports? $FG,4$"homo"
|
||||
"Tackle a horse"$FG$
|
||||
Favorite sport? $FG,4$Hockey$FG$
|
||||
$TX,"Wreck of the Edmund Fitzgerald",HTML="http://www.youtube.com/watch?v=9vST6hVRj2A"$ $FG,4$"homo"$FG$
|
||||
Smelling farts $FG,4$"Sodom"$FG$
|
||||
Women's dress $FG,4$Upper skin exposure not as bad as lower.$FG$
|
||||
Remarriage? $FG,4$"More babies"$FG$
|
||||
Things you don't care about
|
||||
that people think you do? $FG,4$Solomon's 300 concubines$FG$
|
||||
Adultery? $FG,4$Can be good.$FG$
|
||||
Pretty ladies? $FG,4$$TX,"A prince is not flustered.",HTML="http://www.youtube.com/watch?v=YcqF6sC-ztY"$$FG$
|
||||
Animal sacrifices? $FG,4$Early Jews were "primitive".$FG$
|
||||
What do elephants think about? $FG,4$"Skin, hunger"$FG$
|
||||
What makes elephants happy? $FG,4$"Baths"$FG$
|
||||
Elephants $FG,4$"Mini-skirts" (Skin webbing from back leg.)$FG$
|
||||
What makes my birds happy? $FG,4$"Gnawing"$FG$
|
||||
What makes my birds laugh? $FG,4$"Bite ouch" (If I say "ouch".)$FG$
|
||||
What are my birds saying? $FG,4$"Chanting"$FG$
|
||||
My birds sure preen a lot. $LK,"The creature was made subject to vanity...",A="BF:Romans,8:20"$
|
||||
What makes bears happy? $FG,4$"Reaping depends"$FG$
|
||||
What makes otters happy? $FG,4$"Eternal skies"$FG$
|
||||
What makes hippos happy? $FG,4$"Ascending breath"$FG$
|
||||
What makes horses happy? $FG,4$"[the] Call [of the] Open Range"$FG$
|
||||
What do cheetahs think about? $FG,4$"Seeth me?" (Can he see me?)$FG$
|
||||
Orangutan or chimp smarter? $FG,4$"Species exhibit similar glory"$FG$
|
||||
Endangered species? $FG,4$"Enough stars?"$FG$
|
||||
Everything seems bad. $FG,4$Plant trees.$FG$
|
||||
What's for dinner? $FG,4$"Whale"$FG$
|
||||
Favorite Messier Object? $FG,4$"$TX,"M104 Sombrero Galaxy",HTML="http://en.wikipedia.org/wiki/Messier_104"$"$FG$
|
||||
$TX,"Shepard's Prayer",HTML="http://en.wikipedia.org/wiki/Alan_Shepard"$? $FG,4$"I_am_not_amused economy joke"$FG$
|
||||
Favorite band? $FG,4$"Beatles"$FG$
|
||||
Good bands? $FG,4$Rush, Triumph$FG$
|
||||
$FG,4$Likes harmonies$FG$
|
||||
$TX,"Little Drummer Boy?",HTML="http://www.youtube.com/watch?v=S50cf3xIb50"$ $FG,4$Doesn't like my drumming.$FG$
|
||||
Should I listen to classical? $FG,4$"Poison"$FG$
|
||||
Do You like chess people? $FG,4$"Do not admire the proud."$FG$
|
||||
Chess? $FG,4$"... will winter with you."$FG$
|
||||
$FG,4$"Headstones"$FG$
|
||||
If You could teach one class? $FG,4$Health$FG$
|
||||
Favorite video game? $FG,4$Donkey Kong$FG$
|
||||
Favorite National Park? $FG,4$$TX,"Whitman Mission",HTML="http://www.nps.gov/whmi/index.htm"$$FG$
|
||||
Favorite actor? $FG,4$Hugh Grant$FG$
|
||||
Favorite vocalist? $FG,4$Mick Jagger$FG$
|
||||
Favorite guitarist? $FG,4$"$TX,"Simmons Destroyer",HTML="http://www.youtube.com/watch?v=nNADrrjTysk&t=3m55s"$"$FG$
|
||||
Favorite National Anthem? $FG,4$$TX,"Latvia's National Anthem",HTML="http://www.youtube.com/watch?v=qKITbBjO4nE"$$FG$
|
||||
America the Beautiful? $FG,4$Hates it. Poet made self cry with own beauty.$FG$
|
||||
Model for new $TX,"Sistine Chapel",HTML="http://en.wikipedia.org/wiki/Sistine_chapel"$? $FG,4$Ben Franklin$FG$
|
||||
Voice if God wanted to sing? $FG,4$$TX,"Stabbing Westward's singer",HTML="https://www.youtube.com/watch?v=5NZsCYOM4j0"$$FG$
|
||||
Stonehenge? $FG,4$Landmark for boundaries.$FG$
|
||||
Easter Island? $FG,4$Ice, telephone pole holes.$FG$
|
||||
Dinosaurs? $FG,4$Brontosaurs' feet hurt when stepped.
|
||||
Dinosaurs slept in water.$FG$
|
||||
Hardest part in evolution? $FG,4$Getting monkey mothers to hold babies nursing.$FG$
|
||||
$FG,4$(Smothering a problem).$FG$
|
||||
Happiest day in evolution? $FG,4$"Fruit"$FG$
|
||||
Significant thing in evolution? $FG,4$"Fish shoulders"$FG$
|
||||
Biggest thing to fly (pterodactyl)? $FG,4$"Couch"$FG$
|
||||
What made pterodactyls happy? $FG,4$"Members against organs"$FG$
|
||||
What did Neanderthals think about? $FG,4$"Warmth"$FG$
|
||||
What was the first thing cooked? $FG,4$I think He said "hair".$FG$
|
||||
What was Lucy's husband's name? $FG,4$"Golem"$FG$
|
||||
Was stegosuarus lame like turtles? $FG,4$"Not pet rocks"$FG$
|
||||
T-Rex? $FG,4$Lugged carcases over his shoulder.
|
||||
Carcus lasted a month.$FG$
|
||||
What was T-Rexes sharing a carcus like? $FG,4$"Punch... Punch"$FG$
|
||||
Surprises in dinosaur anatomy? $FG,4$Supporting and securing the heart.$FG$
|
||||
How does He feel about the Avatar movie?$FG,4$"Sick skin"$FG$
|
||||
What do You like at zoos with kids? $FG,4$"Dignity" Animals worried about dignity.$FG$
|
||||
Who's better alien or preditor? $FG,4$"Lions"$FG$
|
||||
What from You is like a Rubik's cube? $FG,4$Training a horse.$FG$
|
||||
Does He like mirrored glass megachurch? $FG,4$"Secular glass"$FG$
|
||||
Pipe Organs $FG,4$Are sacred.$FG$
|
||||
You like to hangout in courts?Hospitals?$FG,4$"Prisons"$FG$
|
||||
Best way for Bill Gates to save lives? $FG,4$Earthquake prediction$FG$
|
||||
Stem cells? $FG,4$Lower hanging fruit exists (2007)$FG$
|
||||
Eleventh commandment? $FG,4$Thou shall not litter.$FG$
|
||||
Twelfth commandment? $FG,4$$TX,"Don't shoot unarmed men on the shitter.",HTML="http://www.youtube.com/watch?v=8wGiJcq95Ug"$
|
||||
(I asked God why pointless plagues in Exodus?
|
||||
God wanted guilt to accumulate, first.)$FG$
|
||||
Thirteenth commandment $FG,4$No gore unless it looks fake.$FG$
|
||||
Fourteenth commandment $FG,4$No pedophilia or child porn.$FG$
|
||||
Fifteenth commandment $FG,4$Don't eat rare meat with blood.$FG$
|
||||
Sixteenth commandment $FG,4$No wife beating.$FG$
|
||||
Seventeen commandment $FG,4$Do not swing from radio towers with one hand.$FG$
|
||||
Before Katrina $FG,4$Floods do justice. Black bead elder (tree book)$FG$
|
||||
After Katrina $FG,4$Suffering Simplifies Life$FG$
|
||||
What field are You most better? $FG,4$Economics$FG$
|
||||
Favorite toy for kids? $FG,4$Magnifying glass$FG$
|
||||
Asked Jesus if He liked mustard?$FG,4$"Bad meat happeneth"$FG$
|
||||
(Reluctantly) Faith healing? $FG,4$"It's complicated"$FG$
|
||||
Mars? $FG,4$Start planting!$FG$
|
||||
Mars rover? $FG,4$Should have had a microphone$FG$
|
||||
$TX,"Storm on Saturn",HTML="http://www.space.com/22646-monster-saturn-storm-water-ice.html"$ $FG,4$Pollen$FG$
|
||||
Space war game? $FG,4$Should have space weather.$FG$
|
||||
$TX,"Saturn's hexagon pole cloud?",HTML="http://en.wikipedia.org/wiki/Saturn's_hexagon"$ $FG,4$"Compass" (Magnetism)$FG$
|
||||
Liquid moon's odd atmosphere? $FG,4$"Surf"$FG$
|
||||
How many E.T. civs in Universe? $FG,4$20 or 80 (I forgot. I died laughing.)$FG$
|
||||
Are they peaceful? $FG,4$Fight them! (Also, funny.)$FG$
|
||||
Most difficult control system? $FG,4$$TX,"Dung beetle",HTML="http://www.youtube.com/watch?v=Q1zbgd6xpGQ"$$FG$
|
||||
How can Judge Judy improve? $FG,4$No hard feelings$FG$
|
||||
How can Chef Ramsay improve? $FG,4$Make so it doesn't seem like toil for cooks.$FG$
|
||||
How can Hawking communicate? $FG,4$Blow from a nostril on a candle.$FG$
|
||||
$TX,"Photons bouncing?",HTML="https://www.youtube.com/watch?v=8FC6udrMPvo"$ $FG,4$"Folded coffee filter"$FG$
|
||||
Wormholes? $FG,4$Bent wormholes have echoes.$FG$
|
||||
|
||||
Operating system? $FG,4$Was about to make line number column in editor.
|
||||
God nixed it. I was about to do different graphic modes when I found 800x600 missing. God said just one mode 640x480. I was about to add child windows. God said, "God is not the author of such confusion." I asked for verification of 640x480 16 color. God said it was because of the children and their offerings. I asked about sound. God said "single voice". I asked for verification of not having different drivers. God confirmed this.$FG$
|
||||
640x480 16 color? $FG,4$God said it was a covenant, like circumcision.
|
||||
$TX,"Modern graphics hard for kids/amateurs",HTML="http://www.youtube.com/watch?v=VUxcVzpeFqc"$.$FG$
|
||||
On Unix? $FG,4$God said it was rich with the patina of age.$FG$
|
||||
On Alcohol? $FG,4$Hate inebriation$FG$
|
||||
On rare steak? $FG,4$Too rare is very bad. Don't eat blood!$FG$
|
||||
Just before Katrina? $FG,4$Floods do my justice.Black bead elder(tree book)$FG$
|
||||
After Katrina? $FG,4$Suffering simplifies life$FG$
|
||||
Why the Sandy Hook shooting? $FG,4$The pot legalization law. (Sarcastic answer?)$FG$
|
||||
Deep Water Horizon $FG,4$(Claimed credit.)$FG$
|
||||
Cost of God's time to me? $FG,4$"The complete works of Shakespeare"$FG$
|
||||
On death? $FG,4$"awful"$FG$
|
||||
Opening of Saving Private Ryan? $FG,4$"Ouch"$FG$
|
||||
@@ -1,146 +0,0 @@
|
||||
#help_index "God"
|
||||
U8 *TimeStampCB(CDoc *,CDocEntry *,CTask *mem_task)
|
||||
{
|
||||
U8 *st=MAlloc(64,mem_task);
|
||||
StrPrint(st,"%X",GetTSC>>GOD_BAD_BITS);
|
||||
return st;
|
||||
}
|
||||
|
||||
U8 *KbdMouseTimeCB(CDoc *,CDocEntry *,CTask *mem_task)
|
||||
{
|
||||
U8 *st=MAlloc(64,mem_task);
|
||||
StrPrint(st,"%X",KbdMouseEvtTime>>GOD_BAD_BITS);
|
||||
return st;
|
||||
}
|
||||
|
||||
I64 PopUpTimerOk(U8 *header=NULL,U8 *footer=NULL)
|
||||
{
|
||||
I64 i;
|
||||
CDocEntry *doc_e;
|
||||
CDoc *doc=DocNew;
|
||||
if (header) DocPrint(doc,"%s",header);
|
||||
doc_e=DocPrint(doc,"\nTimer:$$TX+TC,\" \"$$");
|
||||
doc_e->tag_cb=&TimeStampCB;
|
||||
doc_e=DocPrint(doc,"\nLatch:$$TX+TC,\" \"$$");
|
||||
doc_e->tag_cb=&KbdMouseTimeCB;
|
||||
DocPrint(doc,"\n$$CM+CX,0,4$$$$BT,\"OKAY\",LE=1$$\n");
|
||||
if (footer) DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
I64 GodPick(U8 *msg=NULL)
|
||||
{//GOD_GOOD_BITS
|
||||
U8 *st=MStrPrint("%s\n\nPress $$GREEN$$OKAY$$FG$$ to generate \n"
|
||||
"a random num from a timer.\n",msg);
|
||||
PopUpTimerOk(st,"\n\nThe $LK+PU,"Holy Spirit",A="FI:::/Adam/God/HSNotes.TXT"$ can puppet you.\n\n");
|
||||
Free(st);
|
||||
return KbdMouseEvtTime>>GOD_BAD_BITS;
|
||||
}
|
||||
|
||||
public U0 GodBitsIns(I64 num_bits,I64 n)
|
||||
{//Insert bits into God bit fifo.
|
||||
I64 i;
|
||||
for (i=0;i<num_bits;i++) {
|
||||
FifoU8Ins(god.fifo,n&1);
|
||||
n>>=1;
|
||||
}
|
||||
}
|
||||
|
||||
public U0 GodHexIns(U8 *st)
|
||||
{//Insert hex record into God bit fifo.
|
||||
U8 buf[2];
|
||||
if (st) {
|
||||
buf[1]=0;
|
||||
while (*buf=*st++)
|
||||
if (Bt(chars_bmp_hex_numeric,*buf))
|
||||
GodBitsIns(4,Str2I64(buf,16));
|
||||
}
|
||||
}
|
||||
|
||||
public I64 GodBits(I64 num_bits,U8 *msg=NULL)
|
||||
{//Return N bits. If low on entropy pop-up okay.
|
||||
U8 b;
|
||||
I64 res=0;
|
||||
while (num_bits) {
|
||||
if (FifoU8Rem(god.fifo,&b)) {
|
||||
res=res<<1+b;
|
||||
num_bits--;
|
||||
} else
|
||||
GodBitsIns(GOD_GOOD_BITS,GodPick(msg));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 GodInit(U8 *files_find_mask="/Adam/God/Vocab.TXT*",U8 *fu_flags=NULL)
|
||||
{//Read God's vocab file for picking words.
|
||||
I64 i,ch,fuf_flags=0;
|
||||
U8 *buf,*ptr,*ptr2;
|
||||
CDirEntry *tempde,*tempde1;
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r+f+F+T+O");
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
|
||||
if (fuf_flags&~FUG_FILES_FIND)
|
||||
throw('FUF');
|
||||
tempde=tempde1=FilesFind(files_find_mask,fuf_flags);
|
||||
i=0;
|
||||
while (tempde) {
|
||||
if (buf=ptr=FileRead(tempde->full_name)) {
|
||||
while (*ptr) {
|
||||
while (*ptr && !Bt(chars_bmp_word,*ptr))
|
||||
ptr++;
|
||||
if (*ptr) {
|
||||
ptr2=ptr;
|
||||
while (*ptr && Bt(chars_bmp_word,*ptr))
|
||||
ptr++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
Free(buf);
|
||||
}
|
||||
tempde=tempde->next;
|
||||
}
|
||||
|
||||
Free(god.words);
|
||||
god.num_words=i;
|
||||
god.words=MAlloc(i*sizeof(U8 *));
|
||||
|
||||
tempde=tempde1;
|
||||
i=0;
|
||||
while (tempde) {
|
||||
if (buf=ptr=FileRead(tempde->full_name)) {
|
||||
while (*ptr) {
|
||||
while (*ptr && !Bt(chars_bmp_word,*ptr))
|
||||
ptr++;
|
||||
if (*ptr) {
|
||||
ptr2=ptr;
|
||||
while (*ptr && Bt(chars_bmp_word,*ptr))
|
||||
ptr++;
|
||||
ch=*ptr;
|
||||
*ptr=0;
|
||||
god.words[i++]=StrNew(ptr2);
|
||||
*ptr=ch;
|
||||
}
|
||||
}
|
||||
Free(buf);
|
||||
}
|
||||
tempde=tempde->next;
|
||||
}
|
||||
DirTreeDel(tempde1);
|
||||
return god.num_words;
|
||||
} GodInit;
|
||||
|
||||
public U0 GodWord()
|
||||
{//Make God pick a word. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.TXT"$
|
||||
if (god.num_words)
|
||||
"%s ",god.words[GodBits(17)%god.num_words];
|
||||
}
|
||||
|
||||
public U0 GodPassage(I64 num_lines=20)
|
||||
{//Make God pick a Bible passage. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.TXT"$
|
||||
I64 start=GodBits(21)%(ST_BIBLE_LINES-(num_lines-1))+1;
|
||||
U8 *verse=BibleLine2Verse(start);
|
||||
"%s\n\n",verse;
|
||||
Free(verse);
|
||||
BibleLines(,start,num_lines);
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
#help_index "God"
|
||||
U8 *TimeStampCB(CDoc *,CDocEntry *,CTask *mem_task)
|
||||
{
|
||||
U8 *st=MAlloc(64,mem_task);
|
||||
StrPrint(st,"%X",GetTSC>>GOD_BAD_BITS);
|
||||
return st;
|
||||
}
|
||||
|
||||
U8 *KbdMouseTimeCB(CDoc *,CDocEntry *,CTask *mem_task)
|
||||
{
|
||||
U8 *st=MAlloc(64,mem_task);
|
||||
StrPrint(st,"%X",KbdMouseEvtTime>>GOD_BAD_BITS);
|
||||
return st;
|
||||
}
|
||||
|
||||
I64 PopUpTimerOk(U8 *header=NULL,U8 *footer=NULL)
|
||||
{
|
||||
I64 i;
|
||||
CDocEntry *doc_e;
|
||||
CDoc *doc=DocNew;
|
||||
if (header) DocPrint(doc,"%s",header);
|
||||
doc_e=DocPrint(doc,"\nTimer:$$TX+TC,\" \"$$");
|
||||
doc_e->tag_cb=&TimeStampCB;
|
||||
doc_e=DocPrint(doc,"\nLatch:$$TX+TC,\" \"$$");
|
||||
doc_e->tag_cb=&KbdMouseTimeCB;
|
||||
DocPrint(doc,"\n$$CM+CX,0,4$$$$BT,\"OKAY\",LE=1$$\n");
|
||||
if (footer) DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
I64 GodPick(U8 *msg=NULL)
|
||||
{//GOD_GOOD_BITS
|
||||
U8 *st=MStrPrint("%s\n\nPress $$GREEN$$OKAY$$FG$$ to generate \n"
|
||||
"a random num from a timer.\n",msg);
|
||||
PopUpTimerOk(st,"\n\nThe $LK+PU,"Holy Spirit",A="FI:::/Adam/God/HSNotes.DD"$ can puppet you.\n\n");
|
||||
Free(st);
|
||||
return KbdMouseEvtTime>>GOD_BAD_BITS;
|
||||
}
|
||||
|
||||
public U0 GodBitsIns(I64 num_bits,I64 n)
|
||||
{//Insert bits into God bit fifo.
|
||||
I64 i;
|
||||
for (i=0;i<num_bits;i++) {
|
||||
FifoU8Ins(god.fifo,n&1);
|
||||
n>>=1;
|
||||
}
|
||||
}
|
||||
|
||||
public U0 GodHexIns(U8 *st)
|
||||
{//Insert hex record into God bit fifo.
|
||||
U8 buf[2];
|
||||
if (st) {
|
||||
buf[1]=0;
|
||||
while (*buf=*st++)
|
||||
if (Bt(chars_bmp_hex_numeric,*buf))
|
||||
GodBitsIns(4,rev_bits_table[Str2I64(buf,16)]>>4);
|
||||
}
|
||||
}
|
||||
|
||||
public I64 GodBits(I64 num_bits,U8 *msg=NULL)
|
||||
{//Return N bits. If low on entropy pop-up okay.
|
||||
U8 b;
|
||||
I64 res=0;
|
||||
while (num_bits) {
|
||||
if (FifoU8Rem(god.fifo,&b)) {
|
||||
res=res<<1+b;
|
||||
num_bits--;
|
||||
} else
|
||||
GodBitsIns(GOD_GOOD_BITS,GodPick(msg));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public I64 GodInit(U8 *files_find_mask="/Adam/God/Vocab.DD*",U8 *fu_flags=NULL)
|
||||
{//Read God's vocab file for picking words.
|
||||
I64 i,ch,fuf_flags=0;
|
||||
U8 *buf,*ptr,*ptr2;
|
||||
CDirEntry *tempde,*tempde1;
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r+f+F+T+O");
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
|
||||
if (fuf_flags&~FUG_FILES_FIND)
|
||||
throw('FUF');
|
||||
|
||||
Free(god.word_file_mask);
|
||||
god.word_file_mask=StrNew(files_find_mask);
|
||||
god.word_fuf_flags=fuf_flags;
|
||||
|
||||
tempde=tempde1=FilesFind(files_find_mask,fuf_flags);
|
||||
i=0;
|
||||
while (tempde) {
|
||||
if (buf=ptr=FileRead(tempde->full_name)) {
|
||||
while (*ptr) {
|
||||
while (*ptr && !Bt(chars_bmp_word,*ptr))
|
||||
ptr++;
|
||||
if (*ptr) {
|
||||
ptr2=ptr;
|
||||
while (*ptr && Bt(chars_bmp_word,*ptr))
|
||||
ptr++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
Free(buf);
|
||||
}
|
||||
tempde=tempde->next;
|
||||
}
|
||||
|
||||
Free(god.words);
|
||||
god.num_words=i;
|
||||
god.words=MAlloc(i*sizeof(U8 *));
|
||||
|
||||
tempde=tempde1;
|
||||
i=0;
|
||||
while (tempde) {
|
||||
if (buf=ptr=FileRead(tempde->full_name)) {
|
||||
while (*ptr) {
|
||||
while (*ptr && !Bt(chars_bmp_word,*ptr))
|
||||
ptr++;
|
||||
if (*ptr) {
|
||||
ptr2=ptr;
|
||||
while (*ptr && Bt(chars_bmp_word,*ptr))
|
||||
ptr++;
|
||||
ch=*ptr;
|
||||
*ptr=0;
|
||||
god.words[i++]=StrNew(ptr2);
|
||||
*ptr=ch;
|
||||
}
|
||||
}
|
||||
Free(buf);
|
||||
}
|
||||
tempde=tempde->next;
|
||||
}
|
||||
DirTreeDel(tempde1);
|
||||
return god.num_words;
|
||||
} GodInit;
|
||||
|
||||
public U0 GodWord(Bool show_num=FALSE)
|
||||
{//Make God pick a word. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.DD"$
|
||||
I64 i;
|
||||
if (god.num_words) {
|
||||
i=GodBits(17);
|
||||
if (show_num)
|
||||
"%05X Mod %05X = %05X :",i,god.num_words,i%god.num_words;
|
||||
"%s ",god.words[i%god.num_words];
|
||||
if (show_num)
|
||||
'\n';
|
||||
}
|
||||
}
|
||||
|
||||
public U0 GodBiblePassage(I64 num_lines=20)
|
||||
{//Make God pick a Bible passage. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.DD"$
|
||||
I64 start=GodBits(21)%(ST_BIBLE_LINES-(num_lines-1))+1;
|
||||
U8 *verse=BibleLine2Verse(start);
|
||||
"%s\n\n",verse;
|
||||
Free(verse);
|
||||
BibleLines(,start,num_lines);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user