TempleOSCDV3.11.ISO
This commit is contained in:
1 parent
f8c05f98f4
commit
ed64d7e3b8
549 files changed
+10427
-12639
No files matched your search
Binary file not shown.
@@ -1,106 +0,0 @@
|
||||
//This is executed by the Adam task at boot.
|
||||
//See $LK,"Adam Start-up",A="FF:::/Kernel/KEnd.CPP,\"Adam:2"$.
|
||||
|
||||
//You do not place this file in /Home. (It would be ignored.)
|
||||
//but look at the bottom of this file to see
|
||||
//files you do customize.
|
||||
|
||||
extern I8i OptEqu(I64i num,I8i val);
|
||||
OptEqu(0,0); //(0,0)=EchoOff (0,1)=EchoOn
|
||||
#include "/Kernel/KernelA.HPP"
|
||||
#include "/Compiler/CompilerA.HPP"
|
||||
#include "/Kernel/KernelB.HPP"
|
||||
#include "/Kernel/KernelC.HPP"
|
||||
#include "/Compiler/CompilerB.HPP"
|
||||
|
||||
Cd("/Adam");;
|
||||
#exe {OptOn(OPTf_WARN_PAREN);};
|
||||
#exe {OptOn(OPTf_WARN_DUP_TYPES);};
|
||||
|
||||
HashTablePurge(adam_task->hash_table);
|
||||
|
||||
#help_index "Misc"
|
||||
|
||||
//Use Dbg("Type 'G;'"); to debug before window mgr is running.
|
||||
|
||||
public F64 os_version=3.07;//Operating system version.
|
||||
|
||||
#include "AExts.HPP"
|
||||
#include "AMath"
|
||||
#include "Training"
|
||||
#include "AUtils"
|
||||
#include "AMathODE"
|
||||
Cd("::/Adam/Gr");;
|
||||
#include "Gr"
|
||||
|
||||
Cd("::/Adam/Snd");;
|
||||
#include "Snd"
|
||||
|
||||
Cd("::/Adam/Dsk");;
|
||||
#include "ADsk"
|
||||
|
||||
Cd("::/Adam");;
|
||||
#include "Menu"
|
||||
#include "WinA"
|
||||
#include "WinB"
|
||||
#include "ADbg"
|
||||
|
||||
#include "::/Adam/God/GodExt"
|
||||
|
||||
Cd("::/Adam/DolDoc");;
|
||||
#include "Doc"
|
||||
LBts(&sys_run_level,RLf_DOC);
|
||||
|
||||
Cd("::/Adam/Ctrls");;
|
||||
#include "Ctrls"
|
||||
|
||||
Cd("::/Adam");;
|
||||
#include "AutoFile"
|
||||
#include "ARegistry"
|
||||
|
||||
Cd("::/Adam/AutoComplete");;
|
||||
#include "AutoComplete"
|
||||
|
||||
Cd("::/Adam/God");;
|
||||
#include "God"
|
||||
|
||||
Cd("::/Adam");;
|
||||
#include "AHash"
|
||||
#include "TaskSettings"
|
||||
#include "DevInfo"
|
||||
#include "ADefine"
|
||||
|
||||
//Dbg("Type 'G;'");
|
||||
DocTermNew;
|
||||
WinVert(2,10);
|
||||
|
||||
sys_winmgr_task=Spawn(&WinMgrTask,NULL,"Window Mgr");
|
||||
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_BORDER
|
||||
-WIF_SELF_GRAB_SCROLL-WIF_SELF_CTRLS;
|
||||
LBts(&Fs->display_flags,DISPLAYf_CHILDREN_NOT_ON_TOP);
|
||||
LBts(&Fs->display_flags,DISPLAYf_SHOW);
|
||||
RegInit;
|
||||
LBts(&sys_run_level,RLf_REGISTRY);
|
||||
|
||||
Cd("::/Adam");;
|
||||
#include "WallPaper"
|
||||
|
||||
if (DrvIsWritable)
|
||||
MkDir("/Temp"); //Good to have a Temp
|
||||
|
||||
#exe {OptOff(OPTf_WARN_PAREN);};
|
||||
#exe {OptOff(OPTf_WARN_DUP_TYPES);};
|
||||
LBts(&sys_run_level,RLf_HOME);
|
||||
|
||||
#help_index ""
|
||||
Cd("::/Home");;
|
||||
|
||||
//If these are not present in /Home, it uses the version in the root dir.
|
||||
//You should make your own version of these files in you /Home directory.
|
||||
#include "::/Home/AdamLocalize"
|
||||
#include "::/Home/AdamPkgs"
|
||||
#include "::/Home/AdamKeyPlugIns"
|
||||
#include "::/Home/AdamWrappers"
|
||||
#include "::/Home/AdamSys"
|
||||
|
||||
//After this file, the Adam task enters $LK,"server mode",A="HI:Task/Srv"$.
|
||||
@@ -319,7 +319,7 @@ I64 RedSeaUnusedDrvSpace(U8 drv_let=0)
|
||||
l=(dv->size+dv->spc-1)/dv->spc;
|
||||
i=((l+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS;
|
||||
bitmap=MAlloc(i<<BLK_SIZE_BITS);
|
||||
RBlks(dv,bitmap,dv->map1,i);
|
||||
RBlks(dv,bitmap,dv->fat1,i);
|
||||
for (i=0;i<l;i++)
|
||||
if (!Bt(bitmap,i))
|
||||
result++;
|
||||
@@ -337,7 +337,7 @@ I64 FAT32UnusedDrvSpace(U8 drv_let=0)
|
||||
l=(dv->size+dv->spc-1)/dv->spc;
|
||||
i=(l*4+BLK_SIZE-1)>>BLK_SIZE_BITS;
|
||||
bitmap=MAlloc(i<<BLK_SIZE_BITS);
|
||||
RBlks(dv,bitmap,dv->map1,i);
|
||||
RBlks(dv,bitmap,dv->fat1,i);
|
||||
for (i=0;i<l;i++)
|
||||
if (!bitmap[i])
|
||||
result++;
|
||||
@@ -253,7 +253,7 @@ U0 RedSeaDrvView(U8 drv_let=0)
|
||||
try {
|
||||
i=((s+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS;
|
||||
bitmap=MAlloc(i<<BLK_SIZE_BITS);
|
||||
RBlks(dv,bitmap,dv->map1,i);
|
||||
RBlks(dv,bitmap,dv->fat1,i);
|
||||
i=0;
|
||||
for (y=0;y<GR_HEIGHT-3*FONT_HEIGHT;y++) {
|
||||
if (ScanKey)
|
||||
@@ -295,7 +295,7 @@ U0 FAT32DrvView(U8 drv_let=0)
|
||||
try {
|
||||
i=(s*4+BLK_SIZE-1)>>BLK_SIZE_BITS;
|
||||
bitmap=MAlloc(i<<BLK_SIZE_BITS);
|
||||
RBlks(dv,bitmap,dv->map1,i);
|
||||
RBlks(dv,bitmap,dv->fat1,i);
|
||||
i=0;
|
||||
for (y=0;y<GR_HEIGHT-3*FONT_HEIGHT;y++) {
|
||||
if (ScanKey)
|
||||
@@ -361,7 +361,7 @@ public U0 DskView(U8 drv_let=0)
|
||||
|
||||
j=1;
|
||||
for (i=0;i<NUM_DRVS;i++) {
|
||||
dv=&dsk.drvs[i];
|
||||
dv=&blkdev.drvs[i];
|
||||
if (bd==dv->bd && dv->type) {
|
||||
sect_start=-(dv->base_offset*2*ã/(bd->max_blk+1));
|
||||
sect_end =-((dv->base_offset+dv->size)*2*ã/(bd->max_blk+1));
|
||||
@@ -60,7 +60,7 @@ I64 RedSeaChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
|
||||
bpc=dv->spc<<BLK_SIZE_BITS;
|
||||
bits=CAlloc((size+7)>>3);
|
||||
bits2=CAlloc((size+7)>>3+BLK_SIZE);
|
||||
RBlks(dv,bits2,dv->map1,((size+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS);
|
||||
RBlks(dv,bits2,dv->fat1,((size+7)>>3+BLK_SIZE-1)>>BLK_SIZE_BITS);
|
||||
|
||||
//Get Root Dir size
|
||||
ptr2=MAlloc(bpc);
|
||||
@@ -164,7 +164,7 @@ I64 FAT32ChkDsk(U8 drv_let,Bool *_fix,Bool *_confirm)
|
||||
bpc=dv->spc<<BLK_SIZE_BITS;
|
||||
bits=CAlloc((size+7)>>3);
|
||||
bits2=CAlloc(size*4+BLK_SIZE);
|
||||
RBlks(dv,bits2,dv->map1,(size*4+BLK_SIZE-1)>>BLK_SIZE_BITS);
|
||||
RBlks(dv,bits2,dv->fat1,(size*4+BLK_SIZE-1)>>BLK_SIZE_BITS);
|
||||
|
||||
c=dv->root_cluster;
|
||||
while (0<c<0x0FFFFFF8) {
|
||||
@@ -223,7 +223,7 @@ public I64 ChkDsk(U8 drv_let=0,Bool fix=FALSE,Bool confirm=TRUE)
|
||||
if (errs) {
|
||||
if (fix)
|
||||
"It might be a little better. ";
|
||||
"Copy files to another partition or CD-ROM, "
|
||||
"Copy files to another partition or CD/DVD, "
|
||||
"reformat, and copy back. "
|
||||
"Or, copy from a back-up.\n";
|
||||
}
|
||||
@@ -216,7 +216,7 @@ U0 FMRebuildDoc(CDoc **_doc,CDirEntry **_root,I64 mode)
|
||||
}
|
||||
DocPrint(doc,"$$LTBLUE$$");
|
||||
for (i=0;i<NUM_DRVS;i++) {
|
||||
dv=&dsk.drvs[i];
|
||||
dv=&blkdev.drvs[i];
|
||||
if (dv->type==DVT_REDSEA||dv->type==DVT_FAT32)
|
||||
FMRebuildDocDrv(Drv2Let(dv),doc,_root,TRUE);
|
||||
else if (dv->type==DVT_ISO9660) {
|
||||
@@ -401,7 +401,7 @@ U0 FMBurnISO(CDoc *doc)
|
||||
while (tempde->parent)
|
||||
tempde=tempde->parent;
|
||||
Silent;
|
||||
CDImageWrite(*tempde->full_name);
|
||||
DVDImageWrite(*tempde->full_name);
|
||||
Silent(OFF);
|
||||
}
|
||||
}
|
||||
@@ -480,8 +480,8 @@ I64 PopUpFMRight(U8 *header=NULL,U8 *footer=NULL)
|
||||
"$$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,\"MAKE ISO (CD-ROM) FILE\",LE=FMR_MAKE_ISO$$"
|
||||
"$$CM+LX,27,0$$$$BT,\"BURN ISO (CD-ROM) FILE\",LE=FMR_BURN_ISO$$"
|
||||
"$$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);
|
||||
@@ -585,9 +585,8 @@ public U8 *FileMgr(I64 mode=FM_NORMAL,CTask *mem_task=NULL)
|
||||
case MSG_IP_L_UP:
|
||||
if (doc_ce) {
|
||||
gr.fp_final_screen_update=fp_old_final_screen_update;
|
||||
if (WinCursorPosSet(Fs,
|
||||
a1/FONT_WIDTH+Fs->win_left+Fs->scroll_x/FONT_WIDTH,
|
||||
a2/FONT_HEIGHT+Fs->win_top+Fs->scroll_y/FONT_HEIGHT,TRUE)) {
|
||||
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;
|
||||
@@ -1,4 +1,6 @@
|
||||
Cd(__DIR__);;
|
||||
#include "ADskA"
|
||||
#include "ADskB"
|
||||
#include "ChkDsk"
|
||||
#include "FileMgr"
|
||||
Cd("..");;
|
||||
+9
-15
@@ -21,7 +21,7 @@ Bool ClassRep2(CDoc *doc,U8 *_d,U8 *class_name=lastclass,
|
||||
return FALSE;
|
||||
unlock=DocLock(doc);
|
||||
DocPrint(doc,"Class:\"%s\"\n",class_name);
|
||||
ml=tempc->member_lst;
|
||||
ml=tempc->member_lst_and_root;
|
||||
while (ml) {
|
||||
tempc2=ml->member_class;
|
||||
ptr=_d(U8 *)+ml->offset;
|
||||
@@ -155,12 +155,10 @@ public U0 ClassRep(U8 *_d,U8 *class_name=lastclass,
|
||||
I64 max_depth=2,Bool fun=FALSE,I64 offset=0)
|
||||
{//Displays members of a record by using the compiler's info.
|
||||
CDoc *doc;
|
||||
Bool old_preempt;
|
||||
if (IsRaw) {
|
||||
if (IsRaw)
|
||||
doc=DocNew;
|
||||
} else {
|
||||
else {
|
||||
DocMax;
|
||||
old_preempt=Preempt;
|
||||
doc=DocPut;
|
||||
}
|
||||
if (fun)
|
||||
@@ -172,20 +170,17 @@ public U0 ClassRep(U8 *_d,U8 *class_name=lastclass,
|
||||
if (IsRaw) {
|
||||
DocDump(doc,100000);
|
||||
DocDel(doc);
|
||||
} else
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
}
|
||||
|
||||
public U0 ClassRepD(U8 *_d,U8 *class_name=lastclass,
|
||||
I64 max_depth=2,Bool fun=FALSE,I64 offset=0)
|
||||
{//Dynamic ClassRep. Uses hex_ed widgit for live changes.
|
||||
CDoc *doc;
|
||||
Bool old_preempt;
|
||||
if (IsRaw) {
|
||||
if (IsRaw)
|
||||
doc=DocNew;
|
||||
} else {
|
||||
else {
|
||||
DocMax;
|
||||
old_preempt=Preempt;
|
||||
doc=DocPut;
|
||||
}
|
||||
if (fun)
|
||||
@@ -197,15 +192,14 @@ public U0 ClassRepD(U8 *_d,U8 *class_name=lastclass,
|
||||
if (IsRaw) {
|
||||
DocDump(doc,100000);
|
||||
DocDel(doc);
|
||||
} else
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
}
|
||||
|
||||
U0 UpdateRegVarImg(CHashFun *tempf,U8 *_b,CTask *task)
|
||||
{
|
||||
CMemberLst *ml;
|
||||
CHashClass *tempc;
|
||||
ml=tempf->member_lst;
|
||||
ml=tempf->member_lst_and_root;
|
||||
while (ml) {
|
||||
if (ml->reg!=REG_NONE) {
|
||||
tempc=OptClassFwd(ml->member_class);
|
||||
@@ -236,7 +230,7 @@ public U0 FunRep(U8 *st,U8 *rbp=NULL,I64 max_depth=2,CTask *task=NULL)
|
||||
} else
|
||||
ClassRep(rbp,st,max_depth,TRUE);
|
||||
} else {
|
||||
tempm=tempf->member_lst;
|
||||
tempm=tempf->member_lst_and_root;
|
||||
while (tempm) {
|
||||
if (0<=tempm->reg<NUM_REGS)
|
||||
"%08Z %s\n",tempm->reg,"ST_U64_REGS",tempm->str;
|
||||
|
||||
+3
-3
@@ -11,15 +11,15 @@ U0 LoadDocDefines()
|
||||
//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","122,918");
|
||||
DefinePrint("DD_TEMPLEOS_LOC_OFFICIAL","80,950");
|
||||
$ID,4$DefinePrint("DD_TEMPLEOS_LOC","118,728");
|
||||
DefinePrint("DD_TEMPLEOS_LOC_OFFICIAL","80,899");
|
||||
$ID,-4$
|
||||
DefinePrint("DD_KERNEL","%08X",bfh);
|
||||
bfh(I64)+=bfh->file_size-1;
|
||||
DefinePrint("DD_KERNEL_END","%08X",bfh);
|
||||
DefinePrint("DD_PROTECTED_LOW","%08X",MEM_PROTECTED_LOW_LIMIT);
|
||||
|
||||
//$LK,"DD_BOOT_HIGH_LOC_CD",A="FF:::/Adam/Boot/BootCD.CPP,DD_BOOT_HIGH_LOC_CD"$
|
||||
//$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",
|
||||
|
||||
@@ -30,7 +30,6 @@ extern Bool DocForm(U8 *_d,U8 *class_name=lastclass,
|
||||
extern U0 DocHelpIndex(CDoc *doc,U8 *index);
|
||||
extern U0 DocInsDoc(CDoc *doc,CDoc *doc2);
|
||||
extern U0 DocInsEntry(CDoc *doc,CDocEntry *doc_e);
|
||||
extern U8 *DocLinkFile(U8 *link_st,CTask *mem_task=NULL);
|
||||
extern Bool DocLock(CDoc *doc);
|
||||
extern U0 DocMax(I64 i=MAX_I32);
|
||||
extern CDoc *DocNew(U8 *filename=NULL,CTask *task=NULL);
|
||||
@@ -46,9 +45,6 @@ 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 I64 EdCurU8(CDoc *doc);
|
||||
extern U0 EdCursorLeft(CDoc *doc,I64 sc=MIN_I64);
|
||||
extern U0 EdCursorRight(CDoc *doc,I64 sc=MIN_I64);
|
||||
extern U8 *EdSprite(I64 bin_num);
|
||||
extern I64 FindWiz();
|
||||
extern I64 GetI64(U8 *msg,I64 dft,I64 lo=MIN_I64,I64 hi=MAX_I64);
|
||||
@@ -85,8 +81,7 @@ extern Bool View();
|
||||
extern U0 ViewAnglesDel(CTask *task=NULL);
|
||||
extern CCtrl *ViewAnglesNew(CTask *task=NULL);
|
||||
extern Bool WinBorder(Bool val,CTask *task=NULL);
|
||||
extern CDoc *WinCursorPosSet(
|
||||
CTask *task,I64 ip_text_x,I64 ip_text_y,Bool set_cursor=TRUE);
|
||||
extern CDoc *WinCursorPosSet(CTask *task,I64 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);
|
||||
+3
-5
@@ -158,7 +158,7 @@ U8 *index=NULL,CDoc *doc=NULL)
|
||||
CWho *lst;
|
||||
I64 cnt,i,j,k,f=0;
|
||||
U8 buf[512],*st,*last_index=StrNew(""),*cur_index,*comment;
|
||||
Bool recurse,publics,map,old_preempt=Preempt;
|
||||
Bool recurse,publics,map;
|
||||
CTask *task;
|
||||
|
||||
ScanFlags(&f,Define("ST_FILE_UTIL_FLAGS"),"+r");
|
||||
@@ -226,7 +226,6 @@ U8 *index=NULL,CDoc *doc=NULL)
|
||||
else
|
||||
break;
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
|
||||
if (map)
|
||||
QSort(lst,cnt,sizeof(CWho),&HashEntriesCompare2);
|
||||
@@ -314,8 +313,7 @@ U8 *index=NULL,CDoc *doc=NULL)
|
||||
if (index)
|
||||
progress1=progress1_max=0;
|
||||
|
||||
wh_done:
|
||||
Preempt(old_preempt);
|
||||
wh_done:
|
||||
if (doc) {
|
||||
if (doc->root.next==doc)
|
||||
DocPrint(doc,"No Match");
|
||||
@@ -403,7 +401,7 @@ public U0 MapFileLoad(U8 *filename)
|
||||
|
||||
ptr=temph->src_link;
|
||||
if (ptr[0] && ptr[1] && ptr[2]==':' && ptr[3]==':')
|
||||
ptr[3]=dsk.boot_drv_let;
|
||||
ptr[3]=blkdev.boot_drv_let;
|
||||
|
||||
doc_e->aux_str=NULL;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -177,38 +177,3 @@ public Bool HeapWalk(CTask *task=NULL)
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#help_index "Info;Task"
|
||||
U0 TaskRepTask(CTask *task,I64 indent)
|
||||
{
|
||||
CTask *task1;
|
||||
U8 *st,*desc=MStrUtil(task->task_title,SUF_SAFE_DOLLAR);
|
||||
st=MStrPrint("$$MA,T=\"%08X\",LM=\"Kill(0x%X);\n\",$$",task,task,task);
|
||||
"%h*c%s $$TX,\"%Q...\",SCX=16$$ Mem:%08X\n",indent,CH_SPACE,
|
||||
st,desc,TaskMemAlloced(task);
|
||||
"%h*cFlags:%04X:%04X Time:%0.2fm\n",indent+2,CH_SPACE,
|
||||
task->task_flags,task->display_flags,
|
||||
task->total_time/60.0/cnts.time_stamp_freq_initial;
|
||||
Free(st);
|
||||
Free(desc);
|
||||
task1=task->next_child_task;
|
||||
while (task1!=(&task->next_child_task)(U8 *)
|
||||
-offset(CTask.next_sibling_task)) {
|
||||
TaskRepTask(task1,indent+2);
|
||||
task1=task1->next_sibling_task;
|
||||
}
|
||||
}
|
||||
|
||||
public U0 TaskRep()
|
||||
{//Report current tasks on all cores.
|
||||
I64 i;
|
||||
CCPU *c;
|
||||
PUSHFD
|
||||
CLI
|
||||
for (i=0;i<mp_cnt;i++) {
|
||||
c=&cpu_structs[i];
|
||||
"$$RED$$CPU:%d$$FG$$\n",i;
|
||||
TaskRepTask(c->seth_task,2);
|
||||
}
|
||||
POPFD
|
||||
}
|
||||
@@ -1,43 +1,4 @@
|
||||
#help_index "AutoComplete/Dictionary"
|
||||
|
||||
public U0 ACDWordsLoad()
|
||||
{//Put words from word list into hash table.
|
||||
I64 size;
|
||||
CHashGeneric *temph;
|
||||
U8 *in_ptr,*in_start,*st2;
|
||||
U16 *d;
|
||||
acd.num_words=0;
|
||||
if (in_ptr=FileRead(ACD_WORD_FILENAME,&size)) {
|
||||
in_start=in_ptr;
|
||||
Free(acd.word_lst);
|
||||
acd.word_lst=AMAlloc(size);
|
||||
MemCpy(acd.word_lst,in_start,size);
|
||||
acd.word_lst_size=size;
|
||||
|
||||
while (in_ptr<in_start+size) {
|
||||
if (*in_ptr==ACD_WORD_CHAR)
|
||||
in_ptr++;
|
||||
if (*in_ptr) {
|
||||
st2=MStrUtil(in_ptr,SUF_TO_UPPER);
|
||||
temph=ACAlloc(sizeof(CHashGeneric)+StrLen(st2)+1);
|
||||
StrCpy(temph+1,st2);
|
||||
Free(st2);
|
||||
in_ptr+=StrLen(in_ptr)+1;
|
||||
temph->str=temph+1;
|
||||
temph->use_cnt=1;
|
||||
temph->type=HTT_DICT_WORD;
|
||||
d=in_ptr;
|
||||
temph->user_data0=*d;
|
||||
in_ptr+=2;
|
||||
HashAdd(temph,ac.hash_table);
|
||||
acd.num_words++;
|
||||
} else
|
||||
in_ptr+=3;
|
||||
}
|
||||
Free(in_start);
|
||||
}
|
||||
}
|
||||
|
||||
public U8 *ACDDefGet(U8 *st,I64 def_num=1)
|
||||
{//MAlloc str holding single dict definition of word.
|
||||
CFile *f;
|
||||
@@ -174,24 +135,6 @@ public U8 *ACDWordPtAt(U8 *st)
|
||||
return acd.word_lst;
|
||||
}
|
||||
|
||||
U0 ACDDictWordsAdd(CDoc *doc,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)
|
||||
DocPrint(doc,"\n");
|
||||
acd.fillins[i]=ptr-1;
|
||||
DocPrint(doc,"$$GREEN$$'%d'$$FG$$ %-23ts",i,ptr);
|
||||
ptr+=StrLen(ptr)+3;
|
||||
}
|
||||
acd.num_fillins=i;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ACDFillin(I64 n)
|
||||
{
|
||||
U8 *s;
|
||||
@@ -295,3 +238,24 @@ fm_done:
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
#help_index "AutoComplete"
|
||||
U0 ACFillIn(I64 n)
|
||||
{
|
||||
U8 *s;
|
||||
if (0<=--n<ac.num_fillins) {
|
||||
s=ac.fillin_matches[n]->str;
|
||||
if (StrLen(s)>ac.partial_len)
|
||||
Auto(s+ac.partial_len);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ACMan(I64 n,CTask *parent_task=NULL)
|
||||
{
|
||||
CHashAC *tempw;
|
||||
CHashSrcSym *temph;
|
||||
if (0<=--n<ac.num_fillins && (tempw=ac.fillin_matches[n]) &&
|
||||
(temph=HashFind(tempw->str,Fs->hash_table,HTG_SRC_SYM)) &&
|
||||
temph->src_link)
|
||||
PopUpEd(temph->src_link,parent_task);
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
#help_index "AutoComplete/Dictionary"
|
||||
acd.has_words=FileFind(ACD_WORD_FILENAME);
|
||||
acd.has_defs =FileFind(ACD_DEF_FILENAME)||FileFind(ACD_DEF_FILENAME_Z);
|
||||
|
||||
public U0 ACDWordsLoad()
|
||||
{//Put words from word list into hash table.
|
||||
I64 size;
|
||||
CHashGeneric *temph;
|
||||
U8 *in_ptr,*in_start,*st2;
|
||||
U16 *d;
|
||||
acd.num_words=0;
|
||||
if (in_ptr=FileRead(ACD_WORD_FILENAME,&size)) {
|
||||
in_start=in_ptr;
|
||||
Free(acd.word_lst);
|
||||
acd.word_lst=AMAlloc(size);
|
||||
MemCpy(acd.word_lst,in_start,size);
|
||||
acd.word_lst_size=size;
|
||||
|
||||
while (in_ptr<in_start+size) {
|
||||
if (*in_ptr==ACD_WORD_CHAR)
|
||||
in_ptr++;
|
||||
if (*in_ptr) {
|
||||
st2=MStrUtil(in_ptr,SUF_TO_UPPER);
|
||||
temph=ACAlloc(sizeof(CHashGeneric)+StrLen(st2)+1);
|
||||
StrCpy(temph+1,st2);
|
||||
Free(st2);
|
||||
in_ptr+=StrLen(in_ptr)+1;
|
||||
temph->str=temph+1;
|
||||
temph->use_cnt=1;
|
||||
temph->type=HTT_DICT_WORD;
|
||||
d=in_ptr;
|
||||
temph->user_data0=*d;
|
||||
in_ptr+=2;
|
||||
HashAdd(temph,ac.hash_table);
|
||||
acd.num_words++;
|
||||
} else
|
||||
in_ptr+=3;
|
||||
}
|
||||
Free(in_start);
|
||||
}
|
||||
}
|
||||
|
||||
#help_index "AutoComplete"
|
||||
CHashAC *ACHashAdd(U8 *w)
|
||||
{
|
||||
CHashAC *tempw=HashFind(w,ac.hash_table,HTT_WORD);
|
||||
if (tempw) {
|
||||
tempw->hits++;
|
||||
return tempw;
|
||||
}
|
||||
tempw=ACAlloc(sizeof(CHashAC));
|
||||
tempw->str=AStrNew(w);
|
||||
tempw->type=HTT_WORD;
|
||||
tempw->use_cnt=1;
|
||||
tempw->hits=1;
|
||||
HashAdd(tempw,ac.hash_table);
|
||||
ac.num_words++;
|
||||
return tempw;
|
||||
}
|
||||
|
||||
U0 ACSingleFileAdd(U8 *buf)
|
||||
{
|
||||
I64 ch;
|
||||
U8 *ptr=buf,*ptr2,*ptr3;
|
||||
while (TRUE) {
|
||||
while (TRUE) {
|
||||
if (ch=*ptr++) {
|
||||
if (Bt(chars_bmp_alpha_numeric,ch))
|
||||
break;
|
||||
} else
|
||||
return;
|
||||
}
|
||||
ptr3=ptr;
|
||||
ptr2=ptr;
|
||||
ptr--;
|
||||
while (TRUE) {
|
||||
if (ch=*ptr2++) {
|
||||
if (Bt(chars_bmp_alpha_numeric,ch))
|
||||
*ptr3++=ch;
|
||||
else if (ch!=CH_CURSOR)
|
||||
break;
|
||||
} else {
|
||||
ptr2--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*ptr3=0;
|
||||
ACHashAdd(ptr);
|
||||
ptr=ptr2;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ACMainFileLstTraverse(U8 *files_find_mask)
|
||||
{
|
||||
U8 *buf;
|
||||
CDirEntry *tempde,*tempde1;
|
||||
try {
|
||||
tempde=tempde1=FilesFind(files_find_mask,
|
||||
FUF_RECURSE|FUF_JUST_TXT|FUF_JUST_FILES|FUF_CLUSTER_ORDER);
|
||||
while (tempde) {
|
||||
"%s\n",tempde->full_name;
|
||||
buf=FileRead(tempde->full_name);
|
||||
ACSingleFileAdd(buf);
|
||||
Free(buf);
|
||||
tempde=tempde->next;
|
||||
}
|
||||
} catch
|
||||
Fs->catch_except=TRUE;
|
||||
DirTreeDel(tempde1);
|
||||
}
|
||||
|
||||
U0 ACProgressTask(Bool *_start_flag)
|
||||
{
|
||||
I64 start=blkdev.write_cnt;
|
||||
progress1=0;
|
||||
progress1_max=(Size(ACD_DEF_FILENAME_Z,"+x+s")+BLK_SIZE-1)>>BLK_SIZE_BITS;
|
||||
StrCpy(progress1_desc,"Uncompressing Dictionary");
|
||||
start=blkdev.write_cnt;
|
||||
*_start_flag=TRUE;
|
||||
while (progress1<progress1_max) {
|
||||
progress1=blkdev.write_cnt-start;
|
||||
Sleep(10);
|
||||
}
|
||||
*progress1_desc=progress1=progress1_max=0;
|
||||
}
|
||||
|
||||
public U0 ACInit(U8 *mask=NULL)
|
||||
{//Read files and build AutoComplete statistics.
|
||||
Bool start_flag;
|
||||
CBlkDev *bd=Let2BlkDev;
|
||||
|
||||
while (LBts(&ac.flags,ACf_INIT_IN_PROGRESS))
|
||||
Yield;
|
||||
AutoComplete;
|
||||
|
||||
if (DrvIsWritable && FileFind(ACD_DEF_FILENAME_Z) &&
|
||||
!FileFind(ACD_DEF_FILENAME)) {
|
||||
if (bd->type!=BDT_RAM) {
|
||||
start_flag=FALSE;
|
||||
Spawn(&ACProgressTask,&start_flag);
|
||||
while (!start_flag)
|
||||
Yield;
|
||||
}
|
||||
Move(ACD_DEF_FILENAME_Z,ACD_DEF_FILENAME);
|
||||
}
|
||||
|
||||
HashTableDel(ac.hash_table);
|
||||
ac.hash_table=HashTableNew(2048,adam_task);
|
||||
|
||||
ac.num_words=0;
|
||||
Free(ac.cur_word);
|
||||
ac.cur_word=NULL;
|
||||
|
||||
if (mask)
|
||||
ACMainFileLstTraverse(mask);
|
||||
|
||||
ACDWordsLoad;
|
||||
LBtr(&ac.flags,ACf_INIT_IN_PROGRESS);
|
||||
AutoComplete(ON);
|
||||
}
|
||||
|
||||
I64 AutoCompleteSize()
|
||||
{
|
||||
if (ac.hash_table)
|
||||
return HashTableSize2(ac.hash_table)+MSize2(acd.word_lst);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -1,347 +0,0 @@
|
||||
#help_index "AutoComplete"
|
||||
|
||||
CHashAC *ACHashAdd(U8 *w)
|
||||
{
|
||||
CHashAC *tempw=HashFind(w,ac.hash_table,HTT_WORD);
|
||||
if (tempw) {
|
||||
tempw->hits++;
|
||||
return tempw;
|
||||
}
|
||||
tempw=ACAlloc(sizeof(CHashAC));
|
||||
tempw->str=AStrNew(w);
|
||||
tempw->type=HTT_WORD;
|
||||
tempw->use_cnt=1;
|
||||
tempw->hits=1;
|
||||
HashAdd(tempw,ac.hash_table);
|
||||
ac.num_words++;
|
||||
return tempw;
|
||||
}
|
||||
|
||||
U0 ACSingleFileAdd(U8 *buf)
|
||||
{
|
||||
I64 ch;
|
||||
U8 *ptr=buf,*ptr2,*ptr3;
|
||||
while (TRUE) {
|
||||
while (TRUE) {
|
||||
if (ch=*ptr++) {
|
||||
if (Bt(chars_bmp_alpha_numeric,ch))
|
||||
break;
|
||||
} else
|
||||
return;
|
||||
}
|
||||
ptr3=ptr;
|
||||
ptr2=ptr;
|
||||
ptr--;
|
||||
while (TRUE) {
|
||||
if (ch=*ptr2++) {
|
||||
if (Bt(chars_bmp_alpha_numeric,ch))
|
||||
*ptr3++=ch;
|
||||
else if (ch!=CH_CURSOR)
|
||||
break;
|
||||
} else {
|
||||
ptr2--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*ptr3=0;
|
||||
ACHashAdd(ptr);
|
||||
ptr=ptr2;
|
||||
}
|
||||
}
|
||||
|
||||
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 ACFillIn(I64 n)
|
||||
{
|
||||
U8 *s;
|
||||
if (0<=--n<ac.num_fillins) {
|
||||
s=ac.fillin_matches[n]->str;
|
||||
if (StrLen(s)>ac.partial_len)
|
||||
Auto(s+ac.partial_len);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ACMan(I64 n,CTask *parent_task=NULL)
|
||||
{
|
||||
CHashAC *tempw;
|
||||
CHashSrcSym *temph;
|
||||
Bool old_preempt=Preempt;
|
||||
if (0<=--n<ac.num_fillins && (tempw=ac.fillin_matches[n]) &&
|
||||
(temph=HashFind(tempw->str,Fs->hash_table,HTG_SRC_SYM)) &&
|
||||
temph->src_link) {
|
||||
Preempt(old_preempt);
|
||||
PopUpEd(temph->src_link,parent_task);
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
I64 i,data_col;
|
||||
U8 *buf,*buf1,*src=NULL,*st;
|
||||
CHashAC *tempw;
|
||||
F64 timeout_time=tS+0.5;
|
||||
CHashSrcSym *temph;
|
||||
CDoc *doc=DocPut;
|
||||
|
||||
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)) {
|
||||
st=ac.cur_word;
|
||||
ac.cur_word=AStrNew(buf);
|
||||
Free(st);
|
||||
ac.num_fillins=0;
|
||||
if (*ac.cur_word) {
|
||||
Preempt(ON);
|
||||
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;
|
||||
}
|
||||
}
|
||||
Preempt;
|
||||
}
|
||||
DocRst(doc,TRUE);
|
||||
doc->flags|=DOCF_MIN_SIZE;
|
||||
DocCursor;
|
||||
Fs->border_src=BDS_CONST;
|
||||
Fs->text_attr =Fs->border_attr=LTGRAY<<4+BLUE;
|
||||
if (ac.cur_word && *ac.cur_word) {
|
||||
DocPrint(doc,"$$PURPLE$$Word:%s$$FG$$\n",ac.cur_word);
|
||||
for (i=0;i<ac.num_fillins;i++) {
|
||||
st=ac.fillin_matches[i]->str;
|
||||
DocPrint(doc,"$$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)
|
||||
DocPrint(doc,"$$RED$$");
|
||||
DocPrint(doc,"$$TX+UL+L+PU,\"%Q\",A=\"%s\"$$$$FG$$\n",st,temph->src_link);
|
||||
} else
|
||||
DocPrint(doc,"%s\n",st);
|
||||
}
|
||||
if (acd.has_words)
|
||||
ACDDictWordsAdd(doc,ac.cur_word);
|
||||
} else if (FileFind("::/Doc/StandBy.TXT.Z"))
|
||||
DocType(doc,"::/Doc/StandBy.TXT.Z",0);
|
||||
|
||||
DocRecalc(doc);
|
||||
}
|
||||
|
||||
if (!LBts(&Fs->display_flags,DISPLAYf_SHOW))
|
||||
WinZBufUpdate;
|
||||
|
||||
Free(src);
|
||||
Free(buf);
|
||||
Free(buf1);
|
||||
}
|
||||
|
||||
U0 ACTask(I64)
|
||||
{
|
||||
CTask *focus_task,*original_focus_task;
|
||||
CDoc *doc;
|
||||
CDocEntry *doc_e;
|
||||
I64 ch;
|
||||
DocTermNew;
|
||||
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) {
|
||||
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 (TaskValidate(focus_task) && (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);
|
||||
} else
|
||||
DocUnlock(doc);
|
||||
}
|
||||
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);
|
||||
}
|
||||
ac.task=NULL;
|
||||
}
|
||||
|
||||
U0 ACMainFileLstTraverse(U8 *files_find_mask)
|
||||
{
|
||||
U8 *buf;
|
||||
CDirEntry *tempde,*tempde1;
|
||||
try {
|
||||
tempde=tempde1=FilesFind(files_find_mask,
|
||||
FUF_RECURSE|FUF_JUST_TXT|FUF_JUST_FILES|FUF_CLUSTER_ORDER);
|
||||
while (tempde) {
|
||||
"%s\n",tempde->full_name;
|
||||
buf=FileRead(tempde->full_name);
|
||||
ACSingleFileAdd(buf);
|
||||
Free(buf);
|
||||
tempde=tempde->next;
|
||||
}
|
||||
} catch
|
||||
Fs->catch_except=TRUE;
|
||||
DirTreeDel(tempde1);
|
||||
}
|
||||
|
||||
public Bool AutoComplete(Bool val=OFF)
|
||||
{//Turn AutoComplete OFF (or ON).
|
||||
Bool old_autocomplete=FALSE,
|
||||
old_preempt=Preempt;
|
||||
if (val) {
|
||||
while (Bt(&ac.flags,ACf_INIT_IN_PROGRESS))
|
||||
Sleep(10);
|
||||
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)) {
|
||||
old_autocomplete=TRUE;
|
||||
Kill(ac.task);
|
||||
while (TaskValidate(ac.task))
|
||||
Yield;
|
||||
ac.task=NULL;
|
||||
}
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
return old_autocomplete;
|
||||
}
|
||||
|
||||
U0 ACProgressTask(Bool *_start_flag)
|
||||
{
|
||||
I64 start=dsk.write_cnt;
|
||||
progress1=0;
|
||||
progress1_max=(Size(ACD_DEF_FILENAME_Z,"+x+s")+BLK_SIZE-1)>>BLK_SIZE_BITS;
|
||||
StrCpy(progress1_desc,"Uncompressing Dictionary");
|
||||
start=dsk.write_cnt;
|
||||
*_start_flag=TRUE;
|
||||
while (progress1<progress1_max) {
|
||||
progress1=dsk.write_cnt-start;
|
||||
Sleep(10);
|
||||
}
|
||||
*progress1_desc=progress1=progress1_max=0;
|
||||
}
|
||||
|
||||
public U0 ACInit(U8 *mask=NULL)
|
||||
{//Read files and build AutoComplete statistics.
|
||||
Bool start_flag;
|
||||
CBlkDev *bd=Let2BlkDev;
|
||||
|
||||
while (LBts(&ac.flags,ACf_INIT_IN_PROGRESS))
|
||||
Yield;
|
||||
AutoComplete;
|
||||
|
||||
if (DrvIsWritable && FileFind(ACD_DEF_FILENAME_Z) &&
|
||||
!FileFind(ACD_DEF_FILENAME)) {
|
||||
if (bd->type!=BDT_RAM) {
|
||||
start_flag=FALSE;
|
||||
Spawn(&ACProgressTask,&start_flag);
|
||||
while (!start_flag)
|
||||
Yield;
|
||||
}
|
||||
Move(ACD_DEF_FILENAME_Z,ACD_DEF_FILENAME);
|
||||
}
|
||||
|
||||
HashTableDel(ac.hash_table);
|
||||
ac.hash_table=HashTableNew(2048,adam_task);
|
||||
|
||||
ac.num_words=0;
|
||||
Free(ac.cur_word);
|
||||
ac.cur_word=NULL;
|
||||
|
||||
if (mask)
|
||||
ACMainFileLstTraverse(mask);
|
||||
|
||||
ACDWordsLoad;
|
||||
LBtr(&ac.flags,ACf_INIT_IN_PROGRESS);
|
||||
AutoComplete(ON);
|
||||
}
|
||||
|
||||
I64 AutoCompleteSize()
|
||||
{
|
||||
if (ac.hash_table)
|
||||
return HashTableSize2(ac.hash_table)+MSize2(acd.word_lst);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
#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->text_attr =Fs->border_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;
|
||||
if (val) {
|
||||
while (Bt(&ac.flags,ACf_INIT_IN_PROGRESS))
|
||||
Sleep(10);
|
||||
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)) {
|
||||
old_autocomplete=TRUE;
|
||||
Kill(ac.task);
|
||||
while (TaskValidate(ac.task))
|
||||
Yield;
|
||||
}
|
||||
}
|
||||
return old_autocomplete;
|
||||
}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
#help_index "AutoComplete"
|
||||
#help_file "::/Doc/AutoComplete"
|
||||
|
||||
//See $LK,"::/Doc/AutoComplete.TXT"$
|
||||
|
||||
#define ACf_INIT_IN_PROGRESS 0
|
||||
|
||||
#define AC_MAX_FILLINS 10
|
||||
|
||||
public class CAutoCompleteGlbls
|
||||
{
|
||||
I64 num_words;
|
||||
CHashTable *hash_table;
|
||||
U8 *cur_word;
|
||||
I64 flags;
|
||||
CTask *task;
|
||||
I64 partial_len,num_fillins,
|
||||
fillin_hits [AC_MAX_FILLINS+1];
|
||||
CHashAC *fillin_matches[AC_MAX_FILLINS+1];
|
||||
|
||||
} ac={0,NULL,NULL,0,NULL,0,0,
|
||||
{0,0,0,0,0,0,0,0,0,0,0},
|
||||
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}};
|
||||
|
||||
//Dictionary Stuff
|
||||
#help_index "AutoComplete/Dictionary"
|
||||
|
||||
#define ACD_WORD_FILENAME "/Adam/AutoComplete/ACWords.DAT.Z"
|
||||
#define ACD_DEF_FILENAME "/Adam/AutoComplete/ACDefs.DAT"
|
||||
#define ACD_DEF_FILENAME_Z "/Adam/AutoComplete/ACDefs.DAT.Z"
|
||||
|
||||
#define ACD_H1 0
|
||||
#define ACD_H1_END 1
|
||||
#define ACD_DEF 2
|
||||
#define ACD_DEF_END 3
|
||||
#define ACD_PRONUNCIATION 4
|
||||
#define ACD_PRONUNCIATION_END 5
|
||||
#define ACD_POS 6
|
||||
#define ACD_POS_END 7
|
||||
#define ACD_EXTRA 8
|
||||
#define ACD_EXTRA_END 9
|
||||
#define ACD_BLK_SIZE 0x4000
|
||||
|
||||
#define ACD_END_CHAR 0x00
|
||||
#define ACD_WORD_CHAR 0x01
|
||||
#define ACD_DEF_CHAR 0x02
|
||||
#define ACD_PRONUNCIATION_CHAR 0x03
|
||||
#define ACD_POS_CHAR 0x04
|
||||
#define ACD_EXTRA_CHAR 0x05
|
||||
|
||||
#define ACD_MAX_FILLINS 10
|
||||
|
||||
public class CAutoCompleteDictGlbls
|
||||
{
|
||||
U8 *word_lst;
|
||||
I64 word_lst_size,num_words,num_fillins;
|
||||
U8 *fillins[ACD_MAX_FILLINS];
|
||||
Bool has_words,has_defs;
|
||||
} acd={NULL,0,0,0,{0,0,0,0,0,0,0,0,0,0},FALSE,FALSE};
|
||||
acd.has_words=FileFind(ACD_WORD_FILENAME);
|
||||
acd.has_defs =FileFind(ACD_DEF_FILENAME)||FileFind(ACD_DEF_FILENAME_Z);
|
||||
|
||||
extern U0 ACDWordsLoad();
|
||||
extern U0 ACDDictWordsAdd(CDoc *doc,U8 *st);
|
||||
|
||||
#include "ACMain"
|
||||
#include "ACDict"
|
||||
@@ -0,0 +1,6 @@
|
||||
//See $LK,"::/Doc/AutoComplete.TXT"$
|
||||
Cd(__DIR__);;
|
||||
#include "ACFill"
|
||||
#include "ACTask"
|
||||
#include "ACInit"
|
||||
Cd("..");;
|
||||
@@ -1,164 +0,0 @@
|
||||
#define CD_BOOT_LOADER_SIZE CD_BLK_SIZE*1 //Max CD_BLK_SIZE*4, I think
|
||||
#define BOOT_HIGH_LOC_CD ((BOOT_RAM_LIMIT-\
|
||||
(BOOT_STK_SIZE+CD_BOOT_LOADER_SIZE))>>4)
|
||||
|
||||
DefinePrint(
|
||||
"DD_BOOT_HIGH_LOC_CD","%08X",BOOT_HIGH_LOC_CD<<4);
|
||||
DefinePrint(
|
||||
"DD_BOOT_HIGH_LOC_CD_END","%08X",BOOT_RAM_LIMIT-1);
|
||||
|
||||
asm {
|
||||
USE16
|
||||
BCD_START::
|
||||
//DL is supposed to have the BIOS drive number
|
||||
CLD
|
||||
MOV AX,BOOT_HIGH_LOC_CD
|
||||
MOV ES,AX
|
||||
|
||||
CLI
|
||||
MOV SS,AX
|
||||
MOV SP,BOOT_STK_SIZE+CD_BOOT_LOADER_SIZE
|
||||
STI
|
||||
|
||||
CALL BCD_GET_IP
|
||||
BCD_GET_IP:
|
||||
POP BX
|
||||
SUB BX,BCD_GET_IP-BCD_START
|
||||
SHR BX,4
|
||||
//This copies this bootloader's code to 0x$TX,"00096600",D="DD_BOOT_HIGH_LOC_CD"$
|
||||
MOV AX,CS
|
||||
ADD AX,BX
|
||||
MOV DS,AX
|
||||
MOV CX,CD_BOOT_LOADER_SIZE
|
||||
XOR SI,SI
|
||||
XOR DI,DI
|
||||
REP_MOVSB
|
||||
|
||||
MOV AX,BOOT_HIGH_LOC_CD
|
||||
MOV DS,AX
|
||||
|
||||
//My assembler doesn't support 16-bit very well.
|
||||
DU8 0xEA; //JMP BOOT_HIGH_LOC_CD:BCD_MAIN
|
||||
DU16 BCD_MAIN-BCD_START,BOOT_HIGH_LOC_CD;
|
||||
|
||||
BCD_BIOS_DRV_NUM: DU8 0;
|
||||
BCD_PAGE: DU8 0;
|
||||
|
||||
BCD_DAP: DU8 16,0,1,0; //One blk at a time
|
||||
BCD_DAP_BUF: DU16 0,0;
|
||||
BCD_DAP_BLK: DU64 0;
|
||||
|
||||
BCD_TEMPLEOS_MSG:
|
||||
DU8 "Loading TempleOS",0;
|
||||
|
||||
BCD_NOT64_MSG:
|
||||
DU8 "TempleOS requires a 64-bit capable processor.\n\r",0;
|
||||
|
||||
//These get patched.
|
||||
BCD_BLK_LO:: DU16 0;
|
||||
BCD_BLK_HI:: DU16 0;
|
||||
BCD_BLK_CNT:: DU16 0;
|
||||
|
||||
BCD_PROGRESS_STEP:: DU32 0;
|
||||
BCD_PROGRESS_VAL:: DU32 0;
|
||||
|
||||
BCD_PUTCHAR::
|
||||
MOV AH,0xE
|
||||
MOV BL,7 //Might be foreground color on some BIOS's
|
||||
MOV BH,U8 [BCD_PAGE-BCD_START]
|
||||
INT 0x10
|
||||
BCD_RET::
|
||||
RET
|
||||
BCD_PUTS::
|
||||
@@1: LODSB
|
||||
TEST AL,AL
|
||||
JZ BCD_RET
|
||||
CALL BCD_PUTCHAR
|
||||
JMP @@1
|
||||
|
||||
BCD_MAIN::
|
||||
MOV U8 [BCD_BIOS_DRV_NUM-BCD_START],DL //Passed in by BIOS
|
||||
|
||||
MOV AH,0xF
|
||||
INT 0x10
|
||||
MOV U8 [BCD_PAGE-BCD_START],BH //video page
|
||||
|
||||
MOV EAX,0x80000000
|
||||
CPUID
|
||||
CMP EAX,0x80000001
|
||||
JB @@05
|
||||
|
||||
MOV EAX,0x80000001
|
||||
CPUID
|
||||
BT EDX,29
|
||||
JC @@15
|
||||
@@05: MOV SI,BCD_NOT64_MSG-BCD_START
|
||||
CALL BCD_PUTS
|
||||
@@10: JMP @@10
|
||||
|
||||
@@15: MOV SI,BCD_TEMPLEOS_MSG-BCD_START
|
||||
CALL BCD_PUTS
|
||||
|
||||
MOV AX,BOOT_RAM_BASE/16
|
||||
MOV ES,AX
|
||||
XOR ECX,ECX
|
||||
MOV CX,U16 [BCD_BLK_CNT-BCD_START]
|
||||
|
||||
MOV EAX,(80-7-9)*65536 //80 columns
|
||||
XOR EDX,EDX
|
||||
DIV ECX
|
||||
MOV U32 [BCD_PROGRESS_STEP-BCD_START],EAX
|
||||
MOV U32 [BCD_PROGRESS_VAL-BCD_START],0
|
||||
|
||||
MOV AX,U16 [BCD_BLK_LO-BCD_START]
|
||||
MOV DX,U16 [BCD_BLK_HI-BCD_START]
|
||||
|
||||
@@20: PUSH CX //Blk cnt
|
||||
|
||||
//READ BLK
|
||||
PUSH AX //Blk lo
|
||||
PUSH DX //Blk hi
|
||||
PUSH ES //Buf seg
|
||||
MOV U16 [BCD_DAP_BLK-BCD_START],AX
|
||||
MOV U16 [BCD_DAP_BLK+2-BCD_START],DX
|
||||
MOV AX,ES
|
||||
MOV U16 [BCD_DAP_BUF+2-BCD_START],AX //ES:0000
|
||||
MOV SI,BCD_DAP-BCD_START //DS:SI=DAP
|
||||
MOV AH,0x42
|
||||
MOV DL,U8 [BCD_BIOS_DRV_NUM-BCD_START]
|
||||
INT 0x13
|
||||
|
||||
POP AX //ES
|
||||
ADD AX,CD_BLK_SIZE/16
|
||||
MOV ES,AX
|
||||
POP DX
|
||||
POP AX
|
||||
INC AX
|
||||
JNZ @@25
|
||||
INC DX
|
||||
|
||||
@@25: PUSH AX
|
||||
MOV BX,U16 [BCD_PROGRESS_VAL+2-BCD_START]
|
||||
MOV EAX,U32 [BCD_PROGRESS_STEP-BCD_START]
|
||||
ADD U32 [BCD_PROGRESS_VAL-BCD_START],EAX
|
||||
CMP U16 [BCD_PROGRESS_VAL+2-BCD_START],BX
|
||||
JE @@30
|
||||
MOV AL,'.'
|
||||
CALL BCD_PUTCHAR
|
||||
@@30: POP AX
|
||||
|
||||
POP CX
|
||||
LOOP @@20
|
||||
|
||||
//See $LK,"BootCdProbe",A="MN:BootCdProbe"$().
|
||||
MOV EBX,U32 [BCD_BLK_LO-BCD_START] //TODO: oops overflow?
|
||||
SHL EBX,16
|
||||
MOV BX,BOOT_SRC_CDROM //$MA-X+PU,"See sys_boot_src",LM="Find(\"sys_boot_src\",\"/*\");View;\n"$
|
||||
|
||||
//My assembler doesn't support 16-bit very well.
|
||||
DU8 0xEA; //JMP BOOT_RAM_BASE:0000
|
||||
DU16 0,BOOT_RAM_BASE/16;
|
||||
//Continues here $LK,"::/Kernel/KStart.CPP",A="FL:::/Kernel/KStart.CPP,1"$
|
||||
BCD_END::
|
||||
#assert BCD_END-BCD_START<CD_BOOT_LOADER_SIZE
|
||||
}
|
||||
+1
-18
@@ -1,23 +1,18 @@
|
||||
public CCtrl *CtrlFindUnique(CTask *haystack_task,I64 needle_type)
|
||||
{//Find task ctrl given $LK,"ctrl_type",A="MN:CTRLT_VIEWING_ANGLES"$.
|
||||
CCtrl *c;
|
||||
Bool old_preempt=Preempt;
|
||||
c=haystack_task->next_ctrl;
|
||||
while (c!=&haystack_task->next_ctrl) {
|
||||
if (c->type==needle_type) {
|
||||
Preempt(old_preempt);
|
||||
if (c->type==needle_type)
|
||||
return c;
|
||||
}
|
||||
c=c->next;
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U0 CtrlsUpdate(CTask *task)
|
||||
{
|
||||
CCtrl *c;
|
||||
Bool old_preempt=Preempt;
|
||||
c=task->next_ctrl;
|
||||
while (c!=&task->next_ctrl) {
|
||||
if (c->update_derived_vals)
|
||||
@@ -35,7 +30,6 @@ U0 CtrlsUpdate(CTask *task)
|
||||
}
|
||||
c=c->next;
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
fp_update_ctrls=&CtrlsUpdate;
|
||||
@@ -64,7 +58,6 @@ U0 DrawCtrls(CTask *task)
|
||||
{
|
||||
CCtrl *c;
|
||||
CDC *dc=DCAlias(gr.dc2,task);
|
||||
Bool old_preempt=Preempt;
|
||||
c=task->next_ctrl;
|
||||
while (c!=&task->next_ctrl) {
|
||||
if (c->flags&CTRLF_SHOW) {
|
||||
@@ -107,7 +100,6 @@ U0 DrawCtrls(CTask *task)
|
||||
}
|
||||
c=c->next;
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
DCDel(dc);
|
||||
}
|
||||
|
||||
@@ -116,7 +108,6 @@ U0 DrawCtrls(CTask *task)
|
||||
U0 DrawWinScroll(CDC *dc,CCtrl *c)
|
||||
{
|
||||
CWinScroll *s=c->state;
|
||||
Bool old_preempt=Preempt;
|
||||
|
||||
if (c->flags&CTRLF_CLICKED)
|
||||
dc->color=s->color>>4;
|
||||
@@ -129,7 +120,6 @@ U0 DrawWinScroll(CDC *dc,CCtrl *c)
|
||||
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);
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
U0 WinDerivedScrollValsUpdate(CCtrl *c)
|
||||
@@ -208,7 +198,6 @@ U0 WheelChangeWinScroll(CCtrl *c,I64 delta)
|
||||
|
||||
U0 WinScrollsInit(CTask *task)
|
||||
{
|
||||
Bool old_preempt=Preempt;
|
||||
CCtrl *c;
|
||||
|
||||
if (!CtrlFindUnique(task,CTRLT_WIN_HSCROLL)) {
|
||||
@@ -236,7 +225,6 @@ U0 WinScrollsInit(CTask *task)
|
||||
QueIns(c,task->last_ctrl);
|
||||
}
|
||||
TaskDerivedValsUpdate(task);
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
#define VIEWANGLES_SPACING 22
|
||||
#define VIEWANGLES_RANGE 48
|
||||
@@ -363,7 +351,6 @@ U0 LeftClickViewAngles(CCtrl *c,I64 x,I64 y,Bool)
|
||||
|
||||
public CCtrl *ViewAnglesNew(CTask *task=NULL)
|
||||
{//Create view angle ctrl. See $LK,"::/Demo/Graphics/Shading.CPP"$.
|
||||
Bool old_preempt;
|
||||
CCtrl *c;
|
||||
CViewAngles *s;
|
||||
if (!task) task=Fs;
|
||||
@@ -383,10 +370,8 @@ public CCtrl *ViewAnglesNew(CTask *task=NULL)
|
||||
c->draw_it=&DrawViewAnglesCtrl;
|
||||
c->left_click=&LeftClickViewAngles;
|
||||
c->update_derived_vals=&UpdateDerivedViewAnglesCtrl;
|
||||
old_preempt=Preempt;
|
||||
QueIns(c,task->last_ctrl);
|
||||
TaskDerivedValsUpdate(task);
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
@@ -394,12 +379,10 @@ public CCtrl *ViewAnglesNew(CTask *task=NULL)
|
||||
public U0 ViewAnglesDel(CTask *task=NULL)
|
||||
{//Free view angle ctrl.
|
||||
CCtrl *c;
|
||||
Bool old_preempt=Preempt;
|
||||
if (!task) task=Fs;
|
||||
if (c=CtrlFindUnique(task,CTRLT_VIEWING_ANGLES)) {
|
||||
QueRem(c);
|
||||
Free(c->state);
|
||||
Free(c);
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
@@ -41,9 +41,8 @@ U0 LeftClickCtrlButton(CCtrl *c,I64,I64,Bool down)
|
||||
|
||||
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)
|
||||
I32 *state_colors,CCtrlButtonState *_s=NULL)
|
||||
{//Create button ctrl. See $LK,"::/Apps/Strut/Strut.CPP"$.
|
||||
Bool old_preempt;
|
||||
CCtrl *result;
|
||||
CCtrlButtonState *s;
|
||||
I64 i,j,l;
|
||||
@@ -79,17 +78,13 @@ public CCtrl *CtrlButtonNew(I64 x,I64 y,I64 width=-1,I64 height=-1,
|
||||
result->top=y;
|
||||
result->right=result->left+width-1;
|
||||
result->bottom=result->top+height-1;
|
||||
old_preempt=Preempt;
|
||||
QueIns(result,Fs->last_ctrl);
|
||||
Preempt(old_preempt);
|
||||
return result;
|
||||
}
|
||||
|
||||
public U0 CtrlButtonDel(CCtrl *c)
|
||||
{//Free button ctrl.
|
||||
Bool old_preempt=Preempt;
|
||||
QueRem(c);
|
||||
Preempt(old_preempt);
|
||||
if (!(c->flags&BTF_DONT_FREE))
|
||||
Free(c->state);
|
||||
Free(c);
|
||||
|
||||
@@ -174,7 +174,6 @@ U0 LeftClickSlider(CCtrl *c,I64 x,I64 y,Bool down)
|
||||
|
||||
CCtrl *SliderNew()
|
||||
{
|
||||
Bool old_preempt;
|
||||
CCtrl *c=CAlloc(sizeof(CCtrl));
|
||||
c->win_task=Fs;
|
||||
c->flags=CTRLF_SHOW|CTRLF_CAPTURE_LEFT_IP;
|
||||
@@ -189,18 +188,14 @@ CCtrl *SliderNew()
|
||||
" c->draw_it=&DrawCtrlSlider;
|
||||
c->left_click=&LeftClickSlider;
|
||||
c->update_derived_vals=&UpdateDerivedCtrlSlider;
|
||||
old_preempt=Preempt;
|
||||
QueIns(c,Fs->last_ctrl);
|
||||
TaskDerivedValsUpdate;
|
||||
Preempt(old_preempt);
|
||||
return c;
|
||||
}
|
||||
|
||||
U0 SliderDel(CCtrl *c)
|
||||
{
|
||||
Bool old_preempt=Preempt;
|
||||
QueRem(c);
|
||||
Preempt(old_preempt);
|
||||
");
|
||||
if (!*m->glbl_name)
|
||||
DocPrint(doc," Free(c->state);\n");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
Cd(__DIR__);;
|
||||
|
||||
#help_index "Ctrls"
|
||||
#help_file "::/Doc/Ctrls"
|
||||
|
||||
#include "CtrlsA"
|
||||
#include "CtrlsButton"
|
||||
#include "CtrlsSlider"
|
||||
Cd("..");;
|
||||
@@ -1,103 +0,0 @@
|
||||
#help_index "DolDoc"
|
||||
#help_file "::/Doc/DolDoc"
|
||||
|
||||
/*$AN,"",A="Doc"$
|
||||
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"$
|
||||
*/
|
||||
|
||||
extern I64 EdLeftClickLink(CDoc *doc,CDocEntry *doc_e);
|
||||
extern I64 TermRightClickLink(CDoc *doc,CDocEntry *doc_e);
|
||||
extern U0 DocPrintPartial(CDoc *doc,U8 *fmt,...);
|
||||
extern U0 DocFormBwd(CDoc *doc,Bool giveup=FALSE);
|
||||
extern U0 EdUndoFilter(CDoc *doc);
|
||||
extern U8 *PopUpPickLst(U8 *lst);
|
||||
|
||||
#define DHT_DOC_CMD 1
|
||||
#define DHT_DOC_FLAG 2
|
||||
#define DHT_COLOR 4
|
||||
|
||||
/* See $LK,"TempleOS Link Types",A="MN:ST_LINK_TYPES"$.
|
||||
|
||||
"filename"
|
||||
"FI:filename"
|
||||
"FA:haystack_filename,needle_anchor_str"
|
||||
"FF:haystack_filename,needle_str"
|
||||
"FF:haystack_filename,needle_str:occurnum"
|
||||
"FL:filename,linenum"
|
||||
"MN:SymName"
|
||||
"PI:filename"
|
||||
"PF:haystack_filename,needle_str"
|
||||
"PF:haystack_filename,needle_str:occurnum"
|
||||
"PL:filename,linenum"
|
||||
"BF:haystack_bible_book,needle_str"
|
||||
"DF:word"
|
||||
"DF:word,defnum"
|
||||
"HI:index"
|
||||
"AD:code_address_number"
|
||||
|
||||
To edit a doc structure already in memory. See $LK,"SpriteEdText",A="MN:SpriteEdText"$().
|
||||
"AI:doc_address"
|
||||
"AA:haystack_doc_address,needle_anchor_str"
|
||||
"AF:haystack_doc_address,needle_str"
|
||||
"AF:haystack_doc_address,needle_str:occurnum"
|
||||
"AL:doc_address,linenum"
|
||||
|
||||
*/
|
||||
#define LK_FILE 0
|
||||
#define LK_FILE_ANCHOR 1
|
||||
#define LK_FILE_FIND 2
|
||||
#define LK_FILE_LINE 3
|
||||
#define LK_MAN_PAGE 4
|
||||
#define LK_PLAIN 5
|
||||
#define LK_PLAIN_FIND 6
|
||||
#define LK_PLAIN_LINE 7
|
||||
#define LK_BIBLE_FIND 8
|
||||
#define LK_DEF 9
|
||||
#define LK_HELP_INDEX 10
|
||||
#define LK_ADDR 11
|
||||
#define LK_DOC 12 //See $LK,"SpriteEdText",A="MN:SpriteEdText"$()
|
||||
#define LK_DOC_ANCHOR 13
|
||||
#define LK_DOC_FIND 14
|
||||
#define LK_DOC_LINE 15
|
||||
|
||||
#define LK_PLACE_ANCHOR 16
|
||||
|
||||
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],
|
||||
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 "DocNew"
|
||||
#include "DocPlain"
|
||||
#include "DocInit"
|
||||
#include "DocHighlight"
|
||||
#include "DocRecalcA"
|
||||
#include "DocRecalcB"
|
||||
sys_clipboard_doc=DocNew;
|
||||
#include "DocFile"
|
||||
#include "DocOpt"
|
||||
#include "DocPopUp"
|
||||
#include "DocCtrlL"
|
||||
#include "DocMacro"
|
||||
#include "DocFind"
|
||||
#include "DocEdA"
|
||||
#include "DocEdB"
|
||||
#include "DocCodeTools"
|
||||
#include "DocTree"
|
||||
#include "DocMain"
|
||||
@@ -0,0 +1,142 @@
|
||||
#help_index "DolDoc/Bin"
|
||||
|
||||
CDocBin *DocBinFindNum(CDoc *haystack_doc,I64 needle_num)
|
||||
{
|
||||
CDocBin *b=haystack_doc->bin_root.next;
|
||||
while (b!=&haystack_doc->bin_root) {
|
||||
if (b->num==needle_num)
|
||||
return b;
|
||||
b=b->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CDocBin *DocBinFindTag(CDoc *haystack_doc,U8 *needle_tag)
|
||||
{
|
||||
CDocBin *b;
|
||||
if (needle_tag) {
|
||||
b=haystack_doc->bin_root.next;
|
||||
while (b!=&haystack_doc->bin_root) {
|
||||
if (b->tag && !StrCmp(b->tag,needle_tag))
|
||||
return b;
|
||||
b=b->next;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U0 DocBinsValidate(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocBin *b,*b1;
|
||||
CDocEntry *doc_e,*doc_e2;
|
||||
I64 renum_num=0;
|
||||
b=doc->bin_root.next;
|
||||
while (b!=&doc->bin_root) {
|
||||
b->use_cnt=0;
|
||||
b->temp_use_cnt=0;
|
||||
b->renum_num=-1;
|
||||
Free(b->tag);
|
||||
b->tag=NULL;
|
||||
b=b->next;
|
||||
}
|
||||
doc_e=doc->root.next;
|
||||
while (doc_e!=doc) {
|
||||
doc_e2=doc_e->next;
|
||||
if (doc_e->de_flags & DOCEF_HAS_BIN) {
|
||||
if (b=doc_e->bin_data=DocBinFindNum(doc,doc_e->bin_num)) {
|
||||
if (doc_e->de_flags & DOCEF_BIN_PTR_LINK)
|
||||
b->temp_use_cnt=MAX_I32;
|
||||
if (!b->use_cnt++)
|
||||
b->renum_num=++renum_num;
|
||||
doc_e->bin_num=b->renum_num;
|
||||
if (!b->tag && doc_e->de_flags&DOCEF_TAG && doc_e->tag && *doc_e->tag)
|
||||
b->tag=StrNew(doc_e->tag,doc->mem_task);
|
||||
} else {
|
||||
RawPrint(3000,"Bin Not Found");
|
||||
doc_e->type=doc_e->de_flags=0;
|
||||
doc_e->type_u8=DOCT_ERROR;
|
||||
}
|
||||
}
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
|
||||
b=doc->bin_root.next;
|
||||
doc->cur_bin_num=1;
|
||||
while (b!=&doc->bin_root) {
|
||||
b1=b->next;
|
||||
if (!b->use_cnt) {
|
||||
QueRem(b);
|
||||
Free(b->data);
|
||||
Free(b);
|
||||
} else {
|
||||
b->num=b->renum_num;
|
||||
if (b->num>=doc->cur_bin_num)
|
||||
doc->cur_bin_num=b->num+1;
|
||||
}
|
||||
b=b1;
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 DocBinDel(CDoc *doc,CDocBin *b)
|
||||
{
|
||||
if (doc && b && b->use_cnt) {
|
||||
b->use_cnt--;
|
||||
if (!b->use_cnt) {
|
||||
QueRem(b);
|
||||
Free(b->tag);
|
||||
Free(b->data);
|
||||
Free(b);
|
||||
}
|
||||
} else
|
||||
RawPrint(3000,"DocBinDel");
|
||||
}
|
||||
|
||||
I64 DocBinPtrRst(CDoc *doc,CDocEntry *doc_e)
|
||||
{
|
||||
U8 *st,*st2;
|
||||
CDoc *doc2;
|
||||
CDocBin *tempb,*tempb2;
|
||||
I64 i,bin_num=0;
|
||||
if (doc_e->de_flags&DOCEF_HAS_BIN &&
|
||||
doc_e->bin_ptr_link && StrLen(doc_e->bin_ptr_link)) {
|
||||
bin_num=doc_e->bin_num;
|
||||
st=StrNew(doc_e->bin_ptr_link);
|
||||
st2=StrNew(st);
|
||||
StrLastRem(st,",",st2);
|
||||
i=Str2I64(st2);
|
||||
if (i>0||*st2) {
|
||||
doc2=DocRead(st);
|
||||
if (i>0 && (tempb2=DocBinFindNum(doc2,i)) ||
|
||||
i==0 && (tempb2=DocBinFindTag(doc2,st2))) {
|
||||
i=1;
|
||||
if (bin_num>0) {
|
||||
if (tempb=DocBinFindNum(doc,bin_num)) {
|
||||
i=tempb->use_cnt;
|
||||
DocBinDel(doc,tempb);
|
||||
}
|
||||
} else
|
||||
bin_num=doc->cur_bin_num++;
|
||||
tempb=MAllocIdentical(tempb2,doc->mem_task);
|
||||
tempb->use_cnt=i;
|
||||
tempb->data=MAllocIdentical(tempb2->data,doc->mem_task);
|
||||
tempb->num=bin_num;
|
||||
doc_e->bin_data=tempb;
|
||||
if (doc_e->de_flags&DOCEF_TAG && doc_e->tag && *doc_e->tag)
|
||||
tempb->tag=StrNew(doc_e->tag,doc->mem_task);
|
||||
else
|
||||
tempb->tag=NULL;
|
||||
QueIns(tempb,doc->bin_root.last);
|
||||
} else
|
||||
bin_num=0;
|
||||
DocDel(doc2);
|
||||
} else
|
||||
bin_num=0;
|
||||
Free(st2);
|
||||
Free(st);
|
||||
doc_e->bin_num=bin_num;
|
||||
}
|
||||
return bin_num;
|
||||
}
|
||||
@@ -456,8 +456,8 @@ U0 EdInsChar(I64 ch,I64 sc,CDoc *doc)
|
||||
goto ic_cont;
|
||||
} else {
|
||||
doc->dollar_buf[doc->dollar_buf_ptr]=0;
|
||||
DocPrint(doc,doc->dollar_buf);
|
||||
doc->flags&=~DOCF_IN_DOLLAR;
|
||||
DocPrint(doc,doc->dollar_buf);
|
||||
doc->dollar_buf_ptr=0;
|
||||
goto ic_done;
|
||||
}
|
||||
@@ -646,125 +646,3 @@ U0 EdDelLine(CDoc *doc)
|
||||
doc_ce=doc_ce2;
|
||||
}
|
||||
}
|
||||
|
||||
U0 DocEntryToggle(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc),old_color_names;
|
||||
CDocEntry *doc_ce=doc->cur_entry,*cl1,*doc_ce2;
|
||||
U8 ch,*st,*st2;
|
||||
I64 i,j,k;
|
||||
if (doc_ce!=doc &&
|
||||
!(doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS))) {
|
||||
if (doc_ce->type_u8==DOCT_TEXT && !(doc_ce->de_flags &
|
||||
~(DOCEF_TAG|DOCG_BL_IV_UL|DOCEF_WORD_WRAP|DOCEF_HIGHLIGHT|
|
||||
DOCEF_SKIP|DOCEF_HARD_SKIP|DOCEF_FILTER_SKIP)) &&
|
||||
!(doc_ce->type&DOCG_BL_IV_UL)) {
|
||||
doc_ce2=doc_ce->last;
|
||||
for (k=0;k<20;k++) {
|
||||
if (doc_ce2!=doc) {
|
||||
cl1=doc_ce2->last;
|
||||
if (doc_ce2->type_u8==DOCT_TEXT &&
|
||||
doc_ce->de_flags==doc_ce2->de_flags &&
|
||||
doc_ce->type==doc_ce2->type) {
|
||||
i=StrLen(doc_ce2->tag);
|
||||
j=StrLen(doc_ce->tag);
|
||||
st=MAlloc(i+j+1,doc->mem_task);
|
||||
MemCpy(st,doc_ce2->tag,i);
|
||||
MemCpy(st+i,doc_ce->tag,j+1);
|
||||
Free(doc_ce->tag);
|
||||
doc_ce->tag=st;
|
||||
doc_ce->max_col=i+j;
|
||||
doc->cur_col+=i;
|
||||
DocEntryDel(doc,doc_ce2);
|
||||
} else if (doc_ce2->type_u8==DOCT_SOFT_NEW_LINE)
|
||||
DocEntryDel(doc,doc_ce2);
|
||||
else
|
||||
break;
|
||||
doc_ce2=cl1;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
doc_ce2=doc_ce->next;
|
||||
for (k=0;k<20;k++) {
|
||||
if (doc_ce2!=doc) {
|
||||
cl1=doc_ce2->next;
|
||||
if (doc_ce2->type_u8==DOCT_TEXT &&
|
||||
doc_ce->de_flags==doc_ce2->de_flags &&
|
||||
doc_ce->type==doc_ce2->type) {
|
||||
i=StrLen(doc_ce->tag);
|
||||
j=StrLen(doc_ce2->tag);
|
||||
st=MAlloc(i+j+1,doc->mem_task);
|
||||
MemCpy(st,doc_ce->tag,i);
|
||||
MemCpy(st+i,doc_ce2->tag,j+1);
|
||||
Free(doc_ce->tag);
|
||||
doc_ce->tag=st;
|
||||
doc_ce->max_col=i+j;
|
||||
DocEntryDel(doc,doc_ce2);
|
||||
} else if (doc_ce2->type_u8==DOCT_SOFT_NEW_LINE)
|
||||
DocEntryDel(doc,doc_ce2);
|
||||
else
|
||||
break;
|
||||
doc_ce2=cl1;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
i=doc->cur_col;
|
||||
while (i>doc_ce->min_col && doc_ce->tag[i]!='$$')
|
||||
i--;
|
||||
j=doc->cur_col+1;
|
||||
while (j<doc_ce->max_col && doc_ce->tag[j]!='$$')
|
||||
j++;
|
||||
if (i<j-1 && doc_ce->min_col<=i<j<doc_ce->max_col &&
|
||||
doc_ce->tag[i]=='$$' && doc_ce->tag[j]=='$$') {
|
||||
ch=doc_ce->tag[j+1];
|
||||
doc_ce->tag[j+1]=0;
|
||||
st=StrNew(doc_ce->tag+i);
|
||||
doc_ce->tag[j+1]=ch;
|
||||
StrCpy(doc_ce->tag+i,doc_ce->tag+j+1);
|
||||
doc->cur_col=i;
|
||||
st2=MStrPrint("%q",st);
|
||||
if (doc_ce=DocPrint(doc,st2)) {
|
||||
doc->cur_entry=doc_ce;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
}
|
||||
Free(st);
|
||||
Free(st2);
|
||||
}
|
||||
} else {
|
||||
old_color_names=LBts(&doc->flags,DOCf_COLOR_NAMES);
|
||||
st=Doc2PlainText(doc,doc_ce);
|
||||
LBEqu(&doc->flags,DOCf_COLOR_NAMES,old_color_names);
|
||||
DocEntryDel(doc,doc_ce);
|
||||
DocPrint(doc,"$$$$%Q$$$$",st);
|
||||
}
|
||||
DocRecalc(doc);
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 DocFlagsToggle(CDoc *doc,I64 tog_flags)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
I64 size,flags=doc->flags^tog_flags;
|
||||
U8 *st;
|
||||
CDocUndo *u_next,*u_last;
|
||||
|
||||
doc->flags|=DOCF_COLOR_NAMES;
|
||||
st=DocSave(doc,&size);
|
||||
|
||||
u_next=doc->undo_root.next;
|
||||
u_last=doc->undo_root.last;
|
||||
doc->undo_root.next=doc->undo_root.last=&doc->undo_root;
|
||||
|
||||
DocRst(doc,TRUE);
|
||||
doc->undo_root.next=u_next;
|
||||
doc->undo_root.last=u_last;
|
||||
DocUndoCntSet(doc);
|
||||
doc->flags=flags & ~(DOCG_BL_IV_UL|DOCF_WORD_WRAP);
|
||||
DocLoad(doc,st,size);
|
||||
DocCenter(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
Free(st);
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
#help_index "DolDoc/Clipboard"
|
||||
|
||||
sys_clipboard_doc=DocNew;
|
||||
|
||||
public U0 ClipboardDel()
|
||||
{//Delete everything on clipboard.
|
||||
DocRst(sys_clipboard_doc,TRUE);
|
||||
}
|
||||
|
||||
public U0 EdCopyToClipboard(CDoc *doc)
|
||||
{//Copy $LK,"DOCET_SELECTED",A="MN:DOCET_SELECTED"$ flagged entries to clipboard.
|
||||
CDoc *doc2=sys_clipboard_doc;
|
||||
Bool unlock_doc=DocLock(doc),
|
||||
unlock_doc2=DocLock(doc2);
|
||||
CDocEntry *doc_e=doc->root.next,*doc_ne;
|
||||
ClipboardDel;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type & DOCET_SELECTED) {
|
||||
doc_e->type&=~DOCET_SELECTED;
|
||||
if (!Bt(doldoc.type_flags_data,doc_e->type_u8)) {
|
||||
doc_ne=DocEntryCopy(doc2,doc_e);
|
||||
QueIns(doc_ne,doc2->root.last);
|
||||
}
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
if (unlock_doc2)
|
||||
DocUnlock(doc2);
|
||||
if (unlock_doc)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 EdCutToClipboard(CDoc *doc)
|
||||
{//Remove selected entries and place on clipboard.
|
||||
CDoc *doc2=sys_clipboard_doc;
|
||||
Bool unlock_doc=DocLock(doc),
|
||||
unlock_doc2=DocLock(doc2);
|
||||
CDocEntry *doc_e=doc->root.next,*doc_e1,*doc_ne,*doc_e2=NULL;
|
||||
ClipboardDel;
|
||||
while (doc_e!=doc) {
|
||||
doc_e1=doc_e->next;
|
||||
if (doc_e->type & DOCET_SELECTED) {
|
||||
doc_e->type&=~DOCET_SELECTED;
|
||||
if (!Bt(doldoc.type_flags_data,doc_e->type_u8)) {
|
||||
doc_ne=DocEntryCopy(doc2,doc_e);
|
||||
QueIns(doc_ne,doc2->root.last);
|
||||
}
|
||||
if (doc_e==doc->cur_entry || doc_e==doc_e2)
|
||||
doc_e2=doc_e->next;
|
||||
DocEntryDel(doc,doc_e);
|
||||
}
|
||||
doc_e=doc_e1;
|
||||
}
|
||||
if (doc_e2) {
|
||||
doc->cur_entry=doc_e2;
|
||||
doc->cur_col=doc_e2->min_col;
|
||||
}
|
||||
DocRemSoftNewLines(doc,NULL);
|
||||
if (unlock_doc2)
|
||||
DocUnlock(doc2);
|
||||
if (unlock_doc)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 EdPasteClipboard(CDoc *doc)
|
||||
{//Insert copy of clipboard at insert pt, cur_entry.
|
||||
CDoc *doc2=sys_clipboard_doc;
|
||||
Bool unlock_doc=DocLock(doc),
|
||||
unlock_doc2=DocLock(doc2);
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_e;
|
||||
if (doc_ce->type_u8==DOCT_DATA) {
|
||||
doc_e=doc2->root.next;
|
||||
while (doc_e!=doc2) {
|
||||
if (doc_e->de_flags&DOCEF_TAG)
|
||||
DocPrintPartial(doc,"%s",doc_e->tag);
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
} else
|
||||
DocInsDoc(doc,doc2);
|
||||
if (unlock_doc2)
|
||||
DocUnlock(doc2);
|
||||
if (unlock_doc)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocCut(CDoc *doc,CDocEntry *start,CDocEntry *end)
|
||||
{//Del start to end entry, including end points.
|
||||
Bool unlock_doc=DocLock(doc);
|
||||
CDocEntry *doc_e1;
|
||||
while (start!=doc) {
|
||||
doc_e1=start->next;
|
||||
if (start==doc->cur_entry) {
|
||||
doc->cur_entry=start->next;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
}
|
||||
DocEntryDel(doc,start);
|
||||
if (start==end)
|
||||
break;
|
||||
start=doc_e1;
|
||||
}
|
||||
DocRemSoftNewLines(doc,NULL);
|
||||
if (unlock_doc)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public CDoc *DocCopy(CDoc *doc,CDocEntry *start,CDocEntry *end)
|
||||
{//Copies start to end entry, including end points.
|
||||
CDoc *doc2=DocNew;
|
||||
Bool unlock_doc=DocLock(doc);
|
||||
CDocEntry *doc_ne;
|
||||
while (start!=doc) {
|
||||
if (!Bt(doldoc.type_flags_data,start->type_u8)) {
|
||||
doc_ne=DocEntryCopy(doc2,start);
|
||||
QueIns(doc_ne,doc2->root.last);
|
||||
}
|
||||
if (start==end)
|
||||
break;
|
||||
start=start->next;
|
||||
}
|
||||
if (unlock_doc)
|
||||
DocUnlock(doc);
|
||||
return doc2;
|
||||
}
|
||||
@@ -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 *result;
|
||||
if (!task) task=Fs;
|
||||
if ((result=task->put_doc) && result->doc_signature==DOC_SIGNATURE_VAL)
|
||||
return result;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CDoc *DocDisplay(CTask *task=NULL)
|
||||
{//StdOut displayed unless double buffering.
|
||||
CDoc *result;
|
||||
if (!task) task=Fs;
|
||||
if ((result=task->display_doc) && result->doc_signature==DOC_SIGNATURE_VAL)
|
||||
return result;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CDoc *DocBorder(CTask *task=NULL)
|
||||
{//Doc holding border of window text.
|
||||
CDoc *result;
|
||||
if (!task) task=Fs;
|
||||
if ((result=task->border_doc) && result->doc_signature==DOC_SIGNATURE_VAL)
|
||||
return result;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CDoc *DocDblBufStart(CTask *task=NULL)
|
||||
{//See $LK,"::/Demo/Spy.CPP"$
|
||||
Bool unlock_ddoc;
|
||||
CDoc *pdoc=DocPut(task),*ddoc=DocDisplay(task),*result;
|
||||
if (!pdoc || !ddoc || pdoc!=ddoc)
|
||||
result=NULL; //Already Double buffering
|
||||
else {
|
||||
if (!task) task=Fs;
|
||||
unlock_ddoc=DocLock(ddoc); //dont change during winupdate, so lock DocPut$WW,0$
|
||||
result=DocNew(,task);
|
||||
result->win_task =ddoc->win_task;
|
||||
result->max_entries =ddoc->max_entries;
|
||||
MemCpy(result->find_replace,ddoc->find_replace,sizeof(CEdFindText));
|
||||
MemCpy(&result->filename,&ddoc->filename,sizeof(CEdFileName));
|
||||
result->left_click_link =ddoc->left_click_link;
|
||||
result->right_click_link =ddoc->right_click_link;
|
||||
result->user_put_data =ddoc->user_put_data;
|
||||
result->user_put_key =ddoc->user_put_key;
|
||||
result->user_put_s =ddoc->user_put_s;
|
||||
result->parent_doc =ddoc->parent_doc;
|
||||
result->desc =ddoc->desc;
|
||||
result->user_data =ddoc->user_data;
|
||||
result->flags|=ddoc->flags&DOCG_DBL_BUF_FLAGS | DOCF_DONT_SHOW;
|
||||
task->put_doc=result;
|
||||
if (unlock_ddoc)
|
||||
DocUnlock(ddoc);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Bool DocDblBufEnd(CTask *task=NULL)
|
||||
{//See $LK,"::/Demo/Spy.CPP"$
|
||||
Bool result=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);
|
||||
result=TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Bool DocDblBufSwap(CTask *task=NULL)
|
||||
{//See $LK,"::/Demo/Spy.CPP"$
|
||||
Bool result=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;
|
||||
result=TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
#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 result,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,TASK_TITLE_LEN);
|
||||
}
|
||||
doc_e=DocPrint(bdoc,"$$DA-TRM-P+BD+RD+CX+IV,140,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,32,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,32,A=\"Line:%%04d \"$$");
|
||||
doc_e->data=&doc->line;
|
||||
DocDataFmt(bdoc,doc_e);
|
||||
doc_e=DocPrint(bdoc,"$$DA+BD+RD-TRM,32,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);
|
||||
}
|
||||
result=View;
|
||||
|
||||
DocLock(doc);
|
||||
if (result) {
|
||||
doc_e=doc->root.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 result;
|
||||
}
|
||||
|
||||
#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,result=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))
|
||||
result=TRUE;
|
||||
break;
|
||||
default:
|
||||
if (IsRaw)
|
||||
result=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)
|
||||
result=DocFileEd(i,filename,needle_str,&num,edf_dof_flags);
|
||||
}
|
||||
}
|
||||
Free(filename);
|
||||
Free(needle_str);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Bool Plain(U8 *filename,I64 edf_dof_flags=0)
|
||||
{//Edit document in plain text mode, so dollar signs are not special.
|
||||
Bool result;
|
||||
U8 *st=MStrPrint("PI:%s",filename);
|
||||
result=Ed(st,edf_dof_flags);
|
||||
Free(st);
|
||||
return result;
|
||||
}
|
||||
|
||||
#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 result=PopUp(st,parent,_pu_task);
|
||||
Free(st);
|
||||
return result;
|
||||
}
|
||||
@@ -1,980 +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,sc2,ext_ascii_cnt=0;
|
||||
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
|
||||
EdInsChar(ch,sc,doc);
|
||||
} else {
|
||||
doc_ce=doc->cur_entry;
|
||||
x=doc->x; y=doc->y;
|
||||
sc2=sc.u8[0];
|
||||
switch (ch) {
|
||||
case CH_CTRLA:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Save As");
|
||||
else
|
||||
DocWrite(doc,TRUE);
|
||||
break;
|
||||
case CH_CTRLB:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Win/Toggle Border");
|
||||
else
|
||||
WinBorder(Bt(&doc->win_task->display_flags,
|
||||
DISPLAYf_NO_BORDER),doc->win_task);
|
||||
break;
|
||||
case CH_CTRLC:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Copy to Clipboard");
|
||||
else
|
||||
EdCopyToClipboard(doc);
|
||||
break;
|
||||
case CH_CTRLD:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd/Jump to File Manager");
|
||||
else {
|
||||
DocUnlock(doc);
|
||||
FileMgr;
|
||||
DocLock(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLF:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd/Find Wizard");
|
||||
else
|
||||
FindWiz;
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Find & Replace");
|
||||
else
|
||||
EdFindReplace(doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLG:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/GoTo Line Num");
|
||||
else
|
||||
EdGoToLine(doc);
|
||||
break;
|
||||
case CH_BACKSPACE: //<CTRL-H>
|
||||
if (sc&SCF_ALT && !(sc&SCF_CTRL)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Undo");
|
||||
else
|
||||
DocUndoRestore(doc);
|
||||
} else {
|
||||
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--;
|
||||
EdDelChar(doc);
|
||||
}
|
||||
} else {
|
||||
doc->cur_col--;
|
||||
EdDelChar(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLI:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dollar/Indent Out");
|
||||
else
|
||||
DocPrint(doc,"$$ID,-2$$");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dollar/Indent In");
|
||||
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
|
||||
EdInsChar(ch,sc,doc);
|
||||
break;
|
||||
case CH_CTRLK:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dollar/Toggle Blinking Text");
|
||||
else if (sc&SCF_SHIFT)
|
||||
DocPrint(doc,"$$BK,0$$");
|
||||
else
|
||||
DocPrint(doc,"$$BK,1$$");
|
||||
break;
|
||||
case CH_CTRLL:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Code Tools");
|
||||
else
|
||||
KeyDescSet("Dollar/Wizard");
|
||||
} else {
|
||||
if (sc&SCF_SHIFT)
|
||||
EdCodeTools(doc);
|
||||
else {
|
||||
DocUnlock(doc);
|
||||
EdInsDollarCmd;
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLM:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Cmd/Jump to Notes File");
|
||||
else
|
||||
KeyDescSet("Cmd/Jump to Menu");
|
||||
} else {
|
||||
if (sc&SCF_SHIFT)
|
||||
Ed("::/Home/PersonalNotes.TXT.Z");
|
||||
else {
|
||||
m=DocRead("::/Home/PersonalMenu.TXT.Z");
|
||||
DocMenu(m);
|
||||
DocDel(m);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLO:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Collapse");
|
||||
else
|
||||
KeyDescSet("Edit/Uncolapse");
|
||||
} else {
|
||||
if (sc&SCF_SHIFT)
|
||||
DocCollapse(TRUE,doc);
|
||||
else
|
||||
DocCollapse(FALSE,doc);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLP:
|
||||
if (doc->flags & (DOCF_SUPERSCRIPT_MODE | DOCF_SUBSCRIPT_MODE)) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dollar/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("Dollar/Toggle Subscript");
|
||||
else {
|
||||
DocPrint(doc,"$$SY,3$$");
|
||||
doc->flags|=DOCF_SUBSCRIPT_MODE;
|
||||
}
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dollar/Toggle Superscript");
|
||||
else {
|
||||
DocPrint(doc,"$$SY,-3$$");
|
||||
doc->flags|=DOCF_SUPERSCRIPT_MODE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLQ:
|
||||
break;
|
||||
case CH_CTRLR:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dollar/Edit or Create Graphic");
|
||||
else {
|
||||
if (!(doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS))) {
|
||||
DocUnlock(doc);
|
||||
if (doc_ce->type_u8==DOCT_SPRITE)
|
||||
EdSpriteEd(doc,
|
||||
(doc_ce->x-doc->line_start_col+doc_ce->max_col)*FONT_WIDTH,
|
||||
(doc_ce->y-doc->top_line_num)*FONT_HEIGHT);
|
||||
else
|
||||
EdSpriteIns(doc,
|
||||
(doc_ce->x+doc->cur_col-doc->line_start_col)*FONT_WIDTH,
|
||||
(doc_ce->y-doc->top_line_num)*FONT_HEIGHT);
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLS:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Find Misspelled");
|
||||
else
|
||||
ACFindMisspelled(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
|
||||
DocEntryToggle(doc);
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Toggle Plain Text Display");
|
||||
else
|
||||
if (!(doc->flags&DOCF_FORM) ||
|
||||
doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS))
|
||||
DocFlagsToggle(doc,DOCF_PLAIN_TEXT);
|
||||
}
|
||||
break;
|
||||
case CH_CTRLU:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dollar/Toggle Underline");
|
||||
else if (sc&SCF_SHIFT)
|
||||
DocPrint(doc,"$$UL,0$$");
|
||||
else
|
||||
DocPrint(doc,"$$UL,1$$");
|
||||
break;
|
||||
case CH_CTRLV:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Paste Clipboard");
|
||||
else
|
||||
EdPasteClipboard(doc);
|
||||
break;
|
||||
case CH_CTRLW:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dollar/Toggle Word Wrap");
|
||||
else if (sc&SCF_SHIFT)
|
||||
DocPrint(doc,"$$WW,0$$");
|
||||
else
|
||||
DocPrint(doc,"$$WW,1$$");
|
||||
break;
|
||||
case CH_CTRLX:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Cut To Clipboard");
|
||||
else
|
||||
EdCutToClipboard(doc);
|
||||
break;
|
||||
case CH_CTRLY:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Delete Line");
|
||||
else
|
||||
EdDelLine(doc);
|
||||
break;
|
||||
case CH_CTRLZ:
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dollar/Toggle Inverted Text");
|
||||
else if (sc&SCF_SHIFT)
|
||||
DocPrint(doc,"$$IV,0$$");
|
||||
else
|
||||
DocPrint(doc,"$$IV,1$$");
|
||||
break;
|
||||
case '0'...'9':
|
||||
if (!(sc&SCF_ALT)) {
|
||||
if (sc&SCF_CTRL) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Jump to 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Enter extended-ASCII");
|
||||
else {
|
||||
if (++doc->ext_ascii_cnt==1)
|
||||
doc->ext_ascii_val=ch-'0';
|
||||
else
|
||||
doc->ext_ascii_val=doc->ext_ascii_val*10+ch-'0';
|
||||
if (doc->ext_ascii_cnt==3)
|
||||
EdInsChar(doc->ext_ascii_val.u8[0],sc,doc);
|
||||
else
|
||||
ext_ascii_cnt=doc->ext_ascii_cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '[':
|
||||
if (!(sc&SCF_ALT) && 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_ALT) && 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;
|
||||
default:
|
||||
switch (sc2) {
|
||||
case SC_F1...SC_F10:
|
||||
if (!(sc&SCF_ALT)) {
|
||||
if (sc&SCF_CTRL) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Jump to Src of Sym");
|
||||
else
|
||||
KeyDescSet("Edit/Autocomplete Sym");
|
||||
} else {
|
||||
DocUnlock(doc);
|
||||
if (AutoComplete(ON)) {
|
||||
if (sc&SCF_SHIFT)
|
||||
ACMan(sc2-SC_F1+1,Fs);
|
||||
else
|
||||
ACFillIn(sc2-SC_F1+1);
|
||||
}
|
||||
DocLock(doc);
|
||||
}
|
||||
} else {
|
||||
switch (sc2) {
|
||||
case SC_F1:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("About");
|
||||
else
|
||||
KeyDescSet("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_util_task))
|
||||
PostMsgWait(sys_macro_util_task,
|
||||
MSG_KEY_DOWN_UP,CH_SHIFT_ESC,0);
|
||||
SysMacroStripKey(&sys_macro_root,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("Misc/Insert Directory Name");
|
||||
else
|
||||
KeyDescSet("Misc/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);Dbg/Go");
|
||||
} 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("God Doodle");
|
||||
else
|
||||
KeyDescSet("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("God Passage");
|
||||
else
|
||||
KeyDescSet("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;
|
||||
case SC_CURSOR_DOWN:
|
||||
case SC_END:
|
||||
if (sc2==SC_END || sc&SCF_CTRL) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/GoTo Doc End, Select");
|
||||
else
|
||||
KeyDescSet("Edit/GoTo Doc End");
|
||||
} else {
|
||||
while (doc_ce!=doc) {
|
||||
BEqu(&doc_ce->type,DOCEt_SELECTED,sc&SCF_SHIFT);
|
||||
doc_ce=doc->cur_entry=doc_ce->next;
|
||||
}
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
DocFormBwd(doc);
|
||||
}
|
||||
} else if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Cursor Down, Select");
|
||||
else
|
||||
KeyDescSet("Edit/Cursor Down");
|
||||
} else
|
||||
EdLineDown(doc,sc);
|
||||
break;
|
||||
case SC_CURSOR_UP:
|
||||
case SC_HOME:
|
||||
if (sc2==SC_HOME || sc&SCF_CTRL) {
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/GoTo Top of Doc, Select");
|
||||
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_SELECTED,sc&SCF_SHIFT);
|
||||
doc_ce=doc->cur_entry=doc_ce->last;
|
||||
}
|
||||
doc_ce=doc->cur_entry=doc->root.next;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
DocFormFwd(doc);
|
||||
}
|
||||
} else if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Cursor Up, Select");
|
||||
else
|
||||
KeyDescSet("Edit/Cursor Up");
|
||||
} else
|
||||
EdLineUp(doc,sc);
|
||||
break;
|
||||
case SC_PAGE_DOWN:
|
||||
if (sc&SCF_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Page Down, Select");
|
||||
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_KEY_DESC) {
|
||||
if (sc&SCF_SHIFT)
|
||||
KeyDescSet("Edit/Page Up, Select");
|
||||
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->root.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, Select");
|
||||
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, Select");
|
||||
else
|
||||
KeyDescSet("Edit/Cursor Right");
|
||||
}
|
||||
} else
|
||||
EdCursorRight(doc,sc);
|
||||
break;
|
||||
case SC_DELETE:
|
||||
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
|
||||
EdDelChar(doc);
|
||||
}
|
||||
break;
|
||||
case SC_INS:
|
||||
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;
|
||||
} //switch (sc2)
|
||||
}
|
||||
}
|
||||
doc->ext_ascii_cnt=ext_ascii_cnt;
|
||||
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;
|
||||
}
|
||||
|
||||
public U0 DocPrintPartial(CDoc *doc,U8 *fmt,...)
|
||||
{//Lets you print half a doc cmd, if you like.
|
||||
U8 *buf,*b,*src,*dst,*ptr,*ptr2;
|
||||
Bool unlock;
|
||||
CDocEntry *doc_ce,*doc_ne;
|
||||
I64 ch,i,j;
|
||||
if (!fmt)
|
||||
return;
|
||||
buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
ptr=buf;
|
||||
if (doc->user_put_s && (*doc->user_put_s)(doc,doc->user_put_data,buf)) {
|
||||
Free(buf);
|
||||
return;
|
||||
}
|
||||
unlock=DocLock(doc);
|
||||
if (doc->cur_entry->type_u8==DOCT_DATA)
|
||||
while (ch=*ptr++)
|
||||
DocPutKey(doc,ch,0);
|
||||
else
|
||||
while (ch=*ptr) {
|
||||
if (!Bt(chars_bmp_safe_dollar,ch) ||
|
||||
doc->flags & (DOCF_OVERSTRIKE | DOCF_IN_DOLLAR)) {
|
||||
DocPutKey(doc,ch,0);
|
||||
ptr++;
|
||||
} else {
|
||||
ptr2=ptr++;
|
||||
while (TRUE) {
|
||||
ch=*ptr++;
|
||||
if (!Bt(chars_bmp_safe_dollar,ch))
|
||||
break;
|
||||
}
|
||||
ptr--;
|
||||
*ptr=0;
|
||||
doc_ce=doc->cur_entry;
|
||||
j=ptr-ptr2;
|
||||
if (IsEditableText(doc_ce)) {
|
||||
dst=b=MAlloc(doc_ce->max_col+j+1,doc->mem_task);
|
||||
src=doc_ce->tag;
|
||||
i=doc->cur_col;
|
||||
doc->cur_col+=j;
|
||||
doc_ce->max_col+=j;
|
||||
while (i-->0)
|
||||
*dst++=*src++;
|
||||
while (j-->0)
|
||||
*dst++=*ptr2++;
|
||||
while (*dst++=*src++);
|
||||
Free(doc_ce->tag);
|
||||
doc_ce->tag=b;
|
||||
} else {
|
||||
dst=MAlloc(j+1,doc->mem_task);
|
||||
MemCpy(dst,ptr2,j+1);
|
||||
doc_ne=DocEntryNew(doc,doc_ce,dst);
|
||||
doc_ne->type=DOCT_TEXT | doc->settings_root.dft_text_attr<<8;
|
||||
doc_ne->de_flags=doldoc.dft_de_flags[DOCT_TEXT];
|
||||
QueIns(doc_ne,doc_ce->last);
|
||||
doc->cur_entry=doc_ne;
|
||||
doc->cur_col=StrLen(ptr2);
|
||||
}
|
||||
*ptr=ch;
|
||||
DocRemSoftNewLines(doc,doc->cur_entry);
|
||||
}
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
if (!(doc->flags&DOCF_DONT_SWAP_OUT))
|
||||
Yield;
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
#help_index "DolDoc"
|
||||
Bool DocFileEd(I64 _type,U8 *filename,
|
||||
U8 *needle_str,I64 *_num,I64 edf_dof_flags)
|
||||
{
|
||||
I64 type=_type,flags=0,old_border_src=Fs->border_src;
|
||||
CDocEntry *doc_e;
|
||||
CDoc *doc;
|
||||
Bool old_silent=Bt(&Fs->display_flags,DISPLAYf_SILENT),
|
||||
result=FALSE,other_found=FALSE;
|
||||
U8 *st1,*st2;
|
||||
try {
|
||||
switch (type) {
|
||||
case LK_PLAIN:
|
||||
flags=DOCF_PLAIN_TEXT;
|
||||
case LK_DOC:
|
||||
type=LK_FILE;
|
||||
break;
|
||||
case LK_DOC_ANCHOR:
|
||||
type=LK_FILE_ANCHOR;
|
||||
break;
|
||||
case LK_PLAIN_FIND:
|
||||
flags=DOCF_PLAIN_TEXT;
|
||||
case LK_DOC_FIND:
|
||||
type=LK_FILE_FIND;
|
||||
break;
|
||||
case LK_PLAIN_LINE:
|
||||
flags=DOCF_PLAIN_TEXT;
|
||||
case LK_DOC_LINE:
|
||||
type=LK_FILE_LINE;
|
||||
break;
|
||||
case LK_BIBLE_FIND:
|
||||
flags=DOCF_PLAIN_TEXT;
|
||||
break;
|
||||
}
|
||||
|
||||
flags|=DOCF_ALLOW_UNDO;
|
||||
|
||||
if (LK_DOC<=_type<=LK_DOC_LINE) {
|
||||
doc=Str2I64(filename);//See $LK,"SpriteEdText",A="MN:SpriteEdText"$()
|
||||
result=TRUE;
|
||||
} else {
|
||||
|
||||
st1=StrNew(filename);
|
||||
st2=StrNew(filename);
|
||||
StrLastRem(st1,"/",st2); //st2 is name without dir
|
||||
|
||||
if (!FileNameChk(st2))
|
||||
doc=NULL;
|
||||
else {
|
||||
Silent;
|
||||
if (Bt(&edf_dof_flags,EDf_BAIL)) //if bail, scan parents
|
||||
result=FileFind(filename,,
|
||||
FUF_JUST_FILES|FUF_Z_OR_NOT_Z|FUF_SCAN_PARENTS);
|
||||
else if (!(result=FileFind(filename,,
|
||||
FUF_JUST_FILES)))
|
||||
other_found=FileFind(filename,,
|
||||
FUF_JUST_FILES|FUF_Z_OR_NOT_Z|FUF_SCAN_PARENTS);
|
||||
doc=DocRead(filename,flags);
|
||||
doc->desc='Edit';
|
||||
Silent(old_silent);
|
||||
Fs->border_src=BDS_ED_FILENAME_DRV;
|
||||
}
|
||||
|
||||
Free(st1);
|
||||
Free(st2);
|
||||
}
|
||||
if (!doc||doc->doc_signature!=DOC_SIGNATURE_VAL)
|
||||
result=FALSE;
|
||||
else {
|
||||
if (Bt(&edf_dof_flags,EDf_COLLAPSE))
|
||||
DocCollapse(TRUE,doc);
|
||||
else if (Bt(&edf_dof_flags,EDf_UNCOLLAPSE))
|
||||
DocCollapse(FALSE,doc);
|
||||
|
||||
if (result || other_found)
|
||||
switch (type) {
|
||||
case LK_FILE_LINE:
|
||||
result=DocLineNumGoTo(doc,*_num);
|
||||
break;
|
||||
case LK_FILE_ANCHOR:
|
||||
result=DocAnchorFind(doc,needle_str);
|
||||
break;
|
||||
case LK_FILE_FIND:
|
||||
result=DocFind(doc,,needle_str,*_num);
|
||||
break;
|
||||
case LK_BIBLE_FIND:
|
||||
result=DocFind(doc,*_num,needle_str);
|
||||
break;
|
||||
default:
|
||||
DocCenter(doc);
|
||||
}
|
||||
*_num=doc->cur_entry->y+1;
|
||||
|
||||
if (edf_dof_flags&EDF_WAS_WRITE)
|
||||
result=FALSE;
|
||||
if (!(edf_dof_flags&EDF_BAIL) && DocEd(doc,edf_dof_flags|DOF_DONT_HOME)) {
|
||||
DocLock(doc);
|
||||
doc_e=doc->cur_entry;
|
||||
if (doc_e!=doc)
|
||||
DocEntryRun(doc,doc_e,TRUE);
|
||||
DocUnlock(doc);
|
||||
if (!(LK_DOC<=_type<=LK_DOC_LINE)) {
|
||||
DocWrite(doc);
|
||||
if (edf_dof_flags&EDF_WAS_WRITE)
|
||||
result=TRUE;
|
||||
}
|
||||
}
|
||||
if (!(LK_DOC<=_type<=LK_DOC_LINE))
|
||||
DocDel(doc);
|
||||
}
|
||||
} catch {
|
||||
Silent(old_silent);
|
||||
result=FALSE;
|
||||
}
|
||||
Fs->border_src=old_border_src;
|
||||
return result;
|
||||
}
|
||||
|
||||
public I64 EdLinkCvt(U8 *link_st,U8 **_filename=NULL,U8 **_needle_str=NULL,
|
||||
I64 *_num=NULL,I64 edf_dof_flags=0)
|
||||
{//$LK,"Editor Link",A="MN:LK_FILE"$ --> filename, needle_str and line number.
|
||||
U8 *st,*ptr,*filename=NULL,*needle_str=NULL,*filename2;
|
||||
I64 result,i,num=1;
|
||||
CHashSrcSym *temph;
|
||||
if (!link_st||!*link_st) {
|
||||
if (edf_dof_flags&EDF_BAIL)
|
||||
return -1;
|
||||
link_st=dsk.temp_filename;
|
||||
}
|
||||
st=StrNew(link_st);
|
||||
result=LK_FILE;
|
||||
if (StrLen(st)>3 && st[2]==':') {
|
||||
st[2]=0;
|
||||
filename2=st+3;
|
||||
switch (result=DefineMatch(st,"ST_LINK_TYPES",LMF_IGNORE_CASE)) {
|
||||
case LK_MAN_PAGE:
|
||||
if (temph=HashFind(filename2,Fs->hash_table,HTG_SRC_SYM))
|
||||
result=EdLinkCvt(temph->src_link,&filename,
|
||||
&needle_str,&num,edf_dof_flags);
|
||||
else
|
||||
result=-1;
|
||||
goto lc_done;
|
||||
case LK_ADDR:
|
||||
if (ptr=StrLastOcc(filename2,",")) {
|
||||
*ptr=0;
|
||||
i=Str2I64(ptr+1);
|
||||
} else
|
||||
i=DFT_ADDR_LINK_BIN_SIZE;
|
||||
if (ptr=SrcEdLink(ExePrint("%s;",filename2),i)) {
|
||||
result=EdLinkCvt(ptr,&filename,&needle_str,&num,edf_dof_flags);
|
||||
Free(ptr);
|
||||
} else
|
||||
result=-1;
|
||||
goto lc_done;
|
||||
case LK_DEF:
|
||||
if (ptr=StrLastOcc(filename2,",")) {
|
||||
*ptr=0;
|
||||
i=Str2I64(ptr+1);
|
||||
} else
|
||||
i=-1;
|
||||
filename=StrNew(filename2);
|
||||
num=i;
|
||||
goto lc_done;
|
||||
case LK_HELP_INDEX:
|
||||
filename=StrNew(filename2);
|
||||
goto lc_done;
|
||||
case LK_BIBLE_FIND:
|
||||
if (ptr=StrLastOcc(filename2,",")) {
|
||||
*ptr=0;
|
||||
needle_str=StrNew(ptr+1);
|
||||
}
|
||||
i=DefineMatch(filename2,"ST_BIBLE_BOOKS",LMF_IGNORE_CASE);
|
||||
if (i<0)
|
||||
result=-1;
|
||||
else {
|
||||
num=Str2I64(DefineSub(i,"ST_BIBLE_BOOK_LINES"));
|
||||
filename2=BIBLE_FILENAME;
|
||||
}
|
||||
break;
|
||||
case LK_FILE_LINE:
|
||||
case LK_PLAIN_LINE:
|
||||
case LK_DOC_LINE:
|
||||
if (ptr=StrLastOcc(filename2,",")) {
|
||||
*ptr=0;
|
||||
num=Str2I64(ptr+1);
|
||||
}
|
||||
break;
|
||||
case LK_FILE_ANCHOR:
|
||||
case LK_DOC_ANCHOR:
|
||||
if (ptr=StrLastOcc(filename2,",")) {
|
||||
*ptr=0;
|
||||
needle_str=StrNew(ptr+1);
|
||||
}
|
||||
break;
|
||||
case LK_FILE_FIND:
|
||||
case LK_PLAIN_FIND:
|
||||
case LK_DOC_FIND:
|
||||
if (ptr=StrLastOcc(filename2,",")) {
|
||||
*ptr=0;
|
||||
needle_str=StrNew(ptr+1);
|
||||
if (ptr=StrLastOcc(needle_str,":")) {
|
||||
*ptr=0;
|
||||
num=Str2I64(ptr+1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else
|
||||
filename2=st;
|
||||
if (result>=0) {
|
||||
if (LK_DOC<=result<=LK_DOC_LINE)
|
||||
filename=StrNew(filename2); //Holds document address as number.
|
||||
else
|
||||
filename=FileNameAbs(filename2,FUF_Z_OR_NOT_Z);
|
||||
}
|
||||
lc_done:
|
||||
Free(st);
|
||||
if (_filename)
|
||||
*_filename=filename;
|
||||
else
|
||||
Free(filename);
|
||||
if (_needle_str)
|
||||
*_needle_str=needle_str;
|
||||
else
|
||||
Free(needle_str);
|
||||
if (_num)
|
||||
*_num=num;
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#help_index "DolDoc"
|
||||
extern Bool DocEd(CDoc *doc,I64 dof_flags=0);
|
||||
extern I64 DocEntryRun(CDoc *doc,CDocEntry *doc_e,
|
||||
Bool exited,I64 *_has_action=NULL);
|
||||
extern U0 DocFormBwd(CDoc *doc,Bool giveup=FALSE);
|
||||
extern U0 DocLoad(CDoc *doc,U8 *src2,I64 size);
|
||||
extern U0 DocPrintAtomic(CDoc *doc,U8 *fmt,...);
|
||||
extern U0 DocPrintPartial(CDoc *doc,U8 *fmt,...);
|
||||
extern CDocEntry *DocPutS(CDoc *doc,U8 *st);
|
||||
extern U8 *DocSave(CDoc *doc,I64 *_size=NULL);
|
||||
extern I64 EdLeftClickLink(CDoc *doc,CDocEntry *doc_e);
|
||||
extern U8 *PopUpPickLst(U8 *lst);
|
||||
extern I64 TermRightClickLink(CDoc *doc,CDocEntry *doc_e);
|
||||
+1
-124
@@ -38,7 +38,7 @@ public CDoc *DocRead(U8 *name=NULL,I64 flags=0)
|
||||
CDoc *doc=DocNew;
|
||||
U8 *src,*name2;
|
||||
I64 size=0;
|
||||
if (!name) name=dsk.temp_filename;
|
||||
if (!name) name=blkdev.temp_filename;
|
||||
doc->flags|=flags;
|
||||
name2=FileNameAbs(name);
|
||||
StrCpy(doc->filename.name,name2);
|
||||
@@ -242,129 +242,7 @@ public U0 DocInsDoc(CDoc *doc=NULL,CDoc *doc2)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Clipboard"
|
||||
public U0 ClipboardDel()
|
||||
{//Delete everything on clipboard.
|
||||
DocRst(sys_clipboard_doc,TRUE);
|
||||
}
|
||||
|
||||
public U0 EdCopyToClipboard(CDoc *doc)
|
||||
{//Copy $LK,"DOCET_SELECTED",A="MN:DOCET_SELECTED"$ flagged entries to clipboard.
|
||||
CDoc *doc2=sys_clipboard_doc;
|
||||
Bool unlock_doc=DocLock(doc),
|
||||
unlock_doc2=DocLock(doc2);
|
||||
CDocEntry *doc_e=doc->root.next,*doc_ne;
|
||||
ClipboardDel;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type & DOCET_SELECTED) {
|
||||
doc_e->type&=~DOCET_SELECTED;
|
||||
if (!Bt(doldoc.type_flags_data,doc_e->type_u8)) {
|
||||
doc_ne=DocEntryCopy(doc2,doc_e);
|
||||
QueIns(doc_ne,doc2->root.last);
|
||||
}
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
if (unlock_doc2)
|
||||
DocUnlock(doc2);
|
||||
if (unlock_doc)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 EdCutToClipboard(CDoc *doc)
|
||||
{//Remove selected entries and place on clipboard.
|
||||
CDoc *doc2=sys_clipboard_doc;
|
||||
Bool unlock_doc=DocLock(doc),
|
||||
unlock_doc2=DocLock(doc2);
|
||||
CDocEntry *doc_e=doc->root.next,*doc_e1,*doc_ne,*doc_e2=NULL;
|
||||
ClipboardDel;
|
||||
while (doc_e!=doc) {
|
||||
doc_e1=doc_e->next;
|
||||
if (doc_e->type & DOCET_SELECTED) {
|
||||
doc_e->type&=~DOCET_SELECTED;
|
||||
if (!Bt(doldoc.type_flags_data,doc_e->type_u8)) {
|
||||
doc_ne=DocEntryCopy(doc2,doc_e);
|
||||
QueIns(doc_ne,doc2->root.last);
|
||||
}
|
||||
if (doc_e==doc->cur_entry || doc_e==doc_e2)
|
||||
doc_e2=doc_e->next;
|
||||
DocEntryDel(doc,doc_e);
|
||||
}
|
||||
doc_e=doc_e1;
|
||||
}
|
||||
if (doc_e2) {
|
||||
doc->cur_entry=doc_e2;
|
||||
doc->cur_col=doc_e2->min_col;
|
||||
}
|
||||
DocRemSoftNewLines(doc,NULL);
|
||||
if (unlock_doc2)
|
||||
DocUnlock(doc2);
|
||||
if (unlock_doc)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 EdPasteClipboard(CDoc *doc)
|
||||
{//Insert copy of clipboard at insert pt, cur_entry.
|
||||
CDoc *doc2=sys_clipboard_doc;
|
||||
Bool unlock_doc=DocLock(doc),
|
||||
unlock_doc2=DocLock(doc2);
|
||||
CDocEntry *doc_ce=doc->cur_entry,*doc_e;
|
||||
if (doc_ce->type_u8==DOCT_DATA) {
|
||||
doc_e=doc2->root.next;
|
||||
while (doc_e!=doc2) {
|
||||
if (doc_e->de_flags&DOCEF_TAG)
|
||||
DocPrintPartial(doc,"%s",doc_e->tag);
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
} else
|
||||
DocInsDoc(doc,doc2);
|
||||
if (unlock_doc2)
|
||||
DocUnlock(doc2);
|
||||
if (unlock_doc)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocCut(CDoc *doc,CDocEntry *start,CDocEntry *end)
|
||||
{//Del start to end entry, including end points.
|
||||
Bool unlock_doc=DocLock(doc);
|
||||
CDocEntry *doc_e1;
|
||||
while (start!=doc) {
|
||||
doc_e1=start->next;
|
||||
if (start==doc->cur_entry) {
|
||||
doc->cur_entry=start->next;
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
}
|
||||
DocEntryDel(doc,start);
|
||||
if (start==end)
|
||||
break;
|
||||
start=doc_e1;
|
||||
}
|
||||
DocRemSoftNewLines(doc,NULL);
|
||||
if (unlock_doc)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public CDoc *DocCopy(CDoc *doc,CDocEntry *start,CDocEntry *end)
|
||||
{//Copies start to end entry, including end points.
|
||||
CDoc *doc2=DocNew;
|
||||
Bool unlock_doc=DocLock(doc);
|
||||
CDocEntry *doc_ne;
|
||||
while (start!=doc) {
|
||||
if (!Bt(doldoc.type_flags_data,start->type_u8)) {
|
||||
doc_ne=DocEntryCopy(doc2,start);
|
||||
QueIns(doc_ne,doc2->root.last);
|
||||
}
|
||||
if (start==end)
|
||||
break;
|
||||
start=start->next;
|
||||
}
|
||||
if (unlock_doc)
|
||||
DocUnlock(doc);
|
||||
return doc2;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Compiler;Compiler/Directive"
|
||||
|
||||
public U0 StreamDoc(CDoc *doc)
|
||||
{//Inject doc into compile stream. Use inside #exe{}.
|
||||
//TODO: $LK,"DocRst",A="MN:DocRst"$
|
||||
@@ -384,7 +262,6 @@ public U0 StreamDoc(CDoc *doc)
|
||||
}
|
||||
|
||||
#help_index "DolDoc"
|
||||
|
||||
Bool DocCaptureUndo(CDoc *doc,Bool force=FALSE)
|
||||
{
|
||||
Bool result=FALSE,unlock;
|
||||
|
||||
+18
-12
@@ -362,17 +362,23 @@ sf_done:
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 EdUndoFilter(CDoc *doc)
|
||||
#define RSAC_REPLACE 0
|
||||
#define RSAC_SKIP 1
|
||||
#define RSAC_ALL 2
|
||||
|
||||
I64 PopUpReplaceSkipAllCancel(U8 *header=NULL,U8 *footer=NULL)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocEntry *doc_ce=doc->root.next;
|
||||
while (doc_ce!=doc) {
|
||||
doc_ce->de_flags&=~DOCEF_FILTER_SKIP;
|
||||
doc_ce=doc_ce->next;
|
||||
}
|
||||
doc->find_replace->filter_lines=0;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
if (header) DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"$$CM+LX,1,4$$$$BT,\"REPLACE\",LE=RSAC_REPLACE$$"
|
||||
"$$CM+LX,17,0$$$$BT,\"SKIP\",LE=RSAC_SKIP$$"
|
||||
"$$CM+LX,1,3$$$$BT,\"ALL\",LE=RSAC_ALL$$"
|
||||
"$$CM+LX,17,0$$$$BT,\"CANCEL\",LE=DOCM_CANCEL$$\n");
|
||||
if (footer) DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
I64 EdFindReplace(CDoc *doc)
|
||||
@@ -481,8 +487,6 @@ I64 EdFindReplace(CDoc *doc)
|
||||
doc->cur_entry=doc_e;
|
||||
if (cmd!=RSAC_ALL)
|
||||
DocCenter(doc);
|
||||
doc_e=doc->cur_entry;
|
||||
src=doc->cur_col+doc_e->tag;
|
||||
if (cmd!=RSAC_ALL) {
|
||||
DocUnlock(doc);
|
||||
cmd=PopUpReplaceSkipAllCancel("");
|
||||
@@ -490,6 +494,8 @@ I64 EdFindReplace(CDoc *doc)
|
||||
if (cmd<0)
|
||||
goto fr_unlock_done;
|
||||
}
|
||||
doc_e=doc->cur_entry;
|
||||
src=doc->cur_col+doc_e->tag;
|
||||
if (cmd==RSAC_REPLACE || cmd==RSAC_ALL) {
|
||||
dlen=StrLen(doc_e->tag);
|
||||
doc_e->max_col=dlen+rlen-plen;
|
||||
|
||||
@@ -0,0 +1,284 @@
|
||||
#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;
|
||||
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_DATA_IS_PTR) {
|
||||
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) {
|
||||
StrPrint(doc_e->tag,doc_e->aux_str,d,doc_e->my_fmt_data);
|
||||
if (doc_e->de_flags & DOCEF_HAS_TERMINATOR) {
|
||||
i=StrLen(doc_e->tag);
|
||||
doc_e->tag[i++]='_';
|
||||
doc_e->tag[i]=0;
|
||||
}
|
||||
doc_e->max_col=StrLen(doc_e->tag);
|
||||
} 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_lst[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_DATA_IS_PTR) {
|
||||
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) {
|
||||
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;
|
||||
CDoc *doc;
|
||||
Bool result=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);
|
||||
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->root.next!=doc) {
|
||||
Fs->border_src=BDS_CONST;
|
||||
DocRecalc(doc);
|
||||
if (DocEd(doc,dof_flags)) {
|
||||
doc_e=doc->cur_entry;
|
||||
result=TRUE;
|
||||
if (doc_e!=doc) {
|
||||
if (DocEntryRun(doc,doc_e,TRUE,&has_action)==DOCM_CANCEL && has_action)
|
||||
result=FALSE;
|
||||
DocUnlock(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
DocDel(doc);
|
||||
Fs->border_src=old_border_src;
|
||||
return result;
|
||||
}
|
||||
|
||||
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,result=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) {
|
||||
result=DocEntryRun(m,doc_e,TRUE,&has_action);
|
||||
DocUnlock(m);
|
||||
if (!has_action) {
|
||||
result=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 result;
|
||||
}
|
||||
|
||||
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,224 @@
|
||||
#help_index "DolDoc"
|
||||
|
||||
U0 EdUndoFilter(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocEntry *doc_ce=doc->root.next;
|
||||
while (doc_ce!=doc) {
|
||||
doc_ce->de_flags&=~DOCEF_FILTER_SKIP;
|
||||
doc_ce=doc_ce->next;
|
||||
}
|
||||
doc->find_replace->filter_lines=0;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public I64 DocGetKey(I64 *_sc=NULL)
|
||||
{//Called by $LK,"View",A="MN:View"$. You probably don't need this.
|
||||
I64 ch,sc;
|
||||
Bool cont,old_key_desc;
|
||||
do {
|
||||
old_key_desc=LBtr(&Fs->win_inhibit,WIf_SELF_KEY_DESC);
|
||||
do ch=GetKey(&sc,TRUE);
|
||||
while (sc&SCF_KEY_DESC);
|
||||
LBEqu(&Fs->win_inhibit,WIf_SELF_KEY_DESC,old_key_desc);
|
||||
|
||||
DocRecalc(DocPut);
|
||||
cont=FALSE;
|
||||
if ((ch==CH_ESC || ch==CH_SHIFT_ESC) && //Check for exit filter mode
|
||||
DocPut && DocPut->find_replace->filter_lines) {
|
||||
EdUndoFilter(DocPut);
|
||||
cont=TRUE;
|
||||
}
|
||||
} while (cont);
|
||||
if (_sc) *_sc=sc;
|
||||
return ch;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;StdIn/DolDoc"
|
||||
public U8 *DocScanLine(CDoc *doc,CDocEntry *doc_e,
|
||||
I64 *cur_col=NULL,CDocEntry **_do_e_end=NULL)
|
||||
{//Start at entry in doc,make and return one line as str.
|
||||
CDocEntry *doc_e2=doc_e;
|
||||
Bool unlock=DocLock(doc);
|
||||
U8 *dst,*src,*start,*result;
|
||||
I64 i=0;
|
||||
if (cur_col)
|
||||
*cur_col=-1;
|
||||
while (doc_e2!=doc && doc_e2->type_u8!=DOCT_NEW_LINE) {
|
||||
if (doc_e2->de_flags&DOCEF_TAG && doc_e2->tag) {
|
||||
src=doc_e2->tag;
|
||||
i+=StrLen(src);
|
||||
} else if (doc_e2->type_u8==DOCT_TAB)
|
||||
i++;
|
||||
doc_e2=doc_e2->next;
|
||||
}
|
||||
result=MAlloc(i+1);
|
||||
dst=result;
|
||||
while (doc_e!=doc && doc_e->type_u8!=DOCT_NEW_LINE) {
|
||||
start=dst;
|
||||
if (doc_e->de_flags&DOCEF_TAG && doc_e->tag) {
|
||||
src=doc_e->tag;
|
||||
while (*src)
|
||||
*dst++=*src++;
|
||||
} else if (doc_e->type_u8==DOCT_TAB)
|
||||
*dst++='\t';
|
||||
if (doc_e==doc->cur_entry && cur_col)
|
||||
*cur_col=start-result+doc->cur_col;
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
if (_do_e_end) *_do_e_end=doc_e;
|
||||
*dst=0;
|
||||
if (doc_e==doc->cur_entry && cur_col && !doc->cur_col)
|
||||
*cur_col=dst-result;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return result;
|
||||
}
|
||||
|
||||
U8 *DocGetStr2(I64 flags=0)
|
||||
{//$LK,"Flags",A="MN:GSF_SHIFT_ESC_EXIT"$
|
||||
CDoc *doc;
|
||||
CDocEntry *doc_e,*doc_e_end;
|
||||
U8 *st,*st2,*result;
|
||||
I64 ch,sc;
|
||||
"$$PT$$";
|
||||
do {
|
||||
ch=DocGetKey(&sc);
|
||||
if (ch==CH_ESC) {
|
||||
if (doc=DocPut) {
|
||||
DocLock(doc);
|
||||
if (doc->doc_signature==DOC_SIGNATURE_VAL && doc->cur_entry!=doc) {
|
||||
doc_e=DocEntryCopy(doc,doc->cur_entry);
|
||||
DocBottom(doc);
|
||||
DocEntryRun(doc,doc_e,TRUE);
|
||||
DocEntryDel(doc,doc_e);
|
||||
}
|
||||
DocUnlock(doc);
|
||||
}
|
||||
if (flags&GSF_WITH_NEW_LINE)
|
||||
break;
|
||||
} if (ch==CH_SHIFT_ESC) {
|
||||
if (flags&GSF_SHIFT_ESC_EXIT)
|
||||
Exit;
|
||||
else {
|
||||
result=StrNew("");
|
||||
goto gs_done;
|
||||
}
|
||||
}
|
||||
//<CTRL-SHIFT-ENTER> is a blank line without entry
|
||||
} while (flags&GSF_WITH_NEW_LINE || ch!='\n' ||
|
||||
sc&SCF_CTRL && sc&SCF_SHIFT);
|
||||
|
||||
doc=DocPut;
|
||||
DocLock(doc);
|
||||
if (flags&GSF_WITH_NEW_LINE) {
|
||||
doc_e=doc->cur_entry;
|
||||
do doc_e=doc_e->last;
|
||||
while (doc_e!=doc && doc_e->type_u8!=DOCT_PMT);
|
||||
doc_e=doc_e->next;
|
||||
if (result=DocScanLine(doc,doc_e,NULL,&doc_e_end)) {
|
||||
while (doc_e_end!=doc && doc_e_end->type_u8==DOCT_NEW_LINE) {
|
||||
st2=MStrPrint("%s\n",result);
|
||||
Free(result);
|
||||
result=st2;
|
||||
if (st=DocScanLine(doc,doc_e_end->next,NULL,&doc_e_end)) {
|
||||
st2=MStrPrint("%s%s",result,st);
|
||||
Free(st);
|
||||
Free(result);
|
||||
result=st2;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
doc_e=doc->cur_entry;
|
||||
do doc_e=doc_e->last;
|
||||
while (doc_e!=doc && doc_e->type_u8!=DOCT_NEW_LINE &&
|
||||
doc_e->type_u8!=DOCT_PMT);
|
||||
if (doc_e!=doc && doc_e->type_u8!=DOCT_PMT) {
|
||||
do doc_e=doc_e->last;
|
||||
while (doc_e!=doc && doc_e->type_u8!=DOCT_NEW_LINE &&
|
||||
doc_e->type_u8!=DOCT_PMT);
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
result=DocScanLine(doc,doc_e,NULL);
|
||||
}
|
||||
DocUnlock(doc);
|
||||
gs_done:
|
||||
"$$PT$$$$FG$$$$BG$$";
|
||||
return result;
|
||||
}
|
||||
|
||||
#help_index "Keyboard Devices;Char/Input;StdIn"
|
||||
public I64 GetI64(U8 *msg=NULL,I64 dft=0,I64 lo=MIN_I64,I64 hi=MAX_I64)
|
||||
{//Prompt user for I64 expression.
|
||||
Bool okay;
|
||||
U8 *st;
|
||||
I64 result;
|
||||
while (TRUE) {
|
||||
if (msg)
|
||||
"" msg,dft;
|
||||
st=GetStr;
|
||||
if (!*st) {
|
||||
Free(st);
|
||||
return dft;
|
||||
}
|
||||
try {
|
||||
result=ExePrint2("ToI64(%s);",st);
|
||||
okay=TRUE;
|
||||
} catch {
|
||||
Fs->catch_except=TRUE;
|
||||
okay=FALSE;
|
||||
}
|
||||
Free(st);
|
||||
if (okay && lo<=result<=hi)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public F64 GetF64(U8 *msg=NULL,F64 dft=0,F64 lo=MIN_F64,F64 hi=MAX_F64)
|
||||
{//Prompt user for F64 expression.
|
||||
Bool okay;
|
||||
U8 *st;
|
||||
F64 result;
|
||||
while (TRUE) {
|
||||
if (msg)
|
||||
"" msg,dft;
|
||||
st=GetStr;
|
||||
if (!*st) {
|
||||
Free(st);
|
||||
return dft;
|
||||
}
|
||||
try {
|
||||
result=ExePrint2("ToF64(%s);",st)(F64);
|
||||
okay=TRUE;
|
||||
} catch {
|
||||
Fs->catch_except=TRUE;
|
||||
okay=FALSE;
|
||||
}
|
||||
Free(st);
|
||||
if (okay && lo<=result<=hi)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public CDate GetDate(U8 *msg=NULL,CDate dft=MIN_I64,
|
||||
CDate lo=MIN_I64,CDate hi=MAX_I64)
|
||||
{//Prompt user for date expression. (Use $LK,"Now",A="MN:Now"$() if you want current time.)
|
||||
U8 *st;
|
||||
CDate result;
|
||||
if (dft==MIN_I64) dft=Now;
|
||||
while (TRUE) {
|
||||
if (msg)
|
||||
"" msg,dft,dft;
|
||||
st=GetStr;
|
||||
if (!*st) {
|
||||
Free(st);
|
||||
return dft;
|
||||
}
|
||||
result=Str2Date(st);
|
||||
Free(st);
|
||||
if (result>=lo && result<=hi)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
#help_index "Graphics/Input"
|
||||
|
||||
public I64 PopUpColor(U8 *header=NULL,
|
||||
Bool allow_transparent=TRUE,Bool allow_dft=TRUE)
|
||||
{//Chooser for 16-color, default or transparent.
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
if (header)
|
||||
DocPrint(doc,"%s",header);
|
||||
if (allow_transparent)
|
||||
DocPrint(doc,"$$MU,\"TRANSPARENT\",LE=TRANSPARENT$$\n");
|
||||
for (i=0;i<NUM_COLORS;i++)
|
||||
DocPrint(doc,"$$BG,%d$$$$MU,\"__%-8Z__\",LE=%d$$$$BG$$\n",i,i,"ST_COLORS",i);
|
||||
if (allow_dft)
|
||||
DocPrint(doc,"$$BG,WHITE$$$$MU,\"DEFAULT\",LE=DOC_DFT$$$$BG$$");
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
public I64 PopUpColorLighting(U8 *header=NULL)
|
||||
{//Chooser for std TempleOS $LK,"DCLighting",A="MN:DCLighting"$() color.
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
if (header)
|
||||
DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"\nSingle-Sided means both sides same color."
|
||||
"\nDouble-Sided means back side darker."
|
||||
"\n"
|
||||
"\nHalf-Range means 0 to [0,7]"
|
||||
"\n [8,15]-8 to [8,15]"
|
||||
"\nFull-Range means 0 to [0,7] to [0,7]+8"
|
||||
"\n");
|
||||
DocPrint(doc,
|
||||
"\n$$LTPURPLE$$Single-Sided Full-Range Double-Sided Full-Range\n$$BLACK$$");
|
||||
for (i=0;i<NUM_COLORS/2;i++) {
|
||||
DocPrint(doc,"$$BG,%d$$$$MU,\"__%-19Z__\",LE=%d$$$$BG$$ ",i,i,"ST_COLORS",i);
|
||||
DocPrint(doc,"$$BG,%d$$$$MU,\"__%-19Z__\",LE=%d$$$$BG$$\n",i,i,"ST_COLORS",
|
||||
ROPF_TWO_SIDED+i);
|
||||
}
|
||||
DocPrint(doc,
|
||||
"\n$$LTPURPLE$$Single-Sided Half-Range Double-Sided Half-Range\n$$BLACK$$");
|
||||
for (i=0;i<NUM_COLORS;i++) {
|
||||
DocPrint(doc,"$$BG,%d$$$$MU,\"__%-19Z__\",LE=%d$$$$BG$$ ",
|
||||
i,i,"ST_COLORS",ROPF_HALF_RANGE_COLOR+i);
|
||||
DocPrint(doc,"$$BG,%d$$$$MU,\"__%-19Z__\",LE=%d$$$$BG$$\n",
|
||||
i,i,"ST_COLORS",ROPF_TWO_SIDED+ROPF_HALF_RANGE_COLOR+i);
|
||||
}
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
class CTransformForm
|
||||
{
|
||||
F64 x_scale fmtstr "$$DA-TRM,32,RT=F64,A=\"X Scale :%12.6f\"$$\n";
|
||||
F64 y_scale fmtstr "$$DA-TRM,32,RT=F64,A=\"Y Scale :%12.6f\"$$\n";
|
||||
F64 z_scale fmtstr "$$DA-TRM,32,RT=F64,A=\"Z Scale :%12.6f\"$$\n";
|
||||
F64 é_z fmtstr
|
||||
"\nAngles are in degrees\n$$DA-TRM,32,RT=F64,A=\"Z-Axis :%12.6f\"$$\n";
|
||||
F64 é_y fmtstr "$$DA-TRM,32,RT=F64,A=\"Y-Axis :%12.6f\"$$\n";
|
||||
F64 é_x fmtstr "$$DA-TRM,32,RT=F64,A=\"X-Axis :%12.6f\"$$\n";
|
||||
F64 x_offset fmtstr "\n$$DA-TRM,32,RT=F64,A=\"X Offset:%12.6f\"$$\n";
|
||||
F64 y_offset fmtstr "$$DA-TRM,32,RT=F64,A=\"Y Offset:%12.6f\"$$\n";
|
||||
F64 z_offset fmtstr "$$DA-TRM,32,RT=F64,A=\"Z Offset:%12.6f\"$$\n";
|
||||
};
|
||||
|
||||
Bool PopUpTransform(I64 *r)
|
||||
{
|
||||
CTransformForm *tf=MAlloc(sizeof(CTransformForm));
|
||||
tf->x_scale=1.0;
|
||||
tf->y_scale=1.0;
|
||||
tf->z_scale=1.0;
|
||||
tf->é_x=0.0;
|
||||
tf->é_y=0.0;
|
||||
tf->é_z=0.0;
|
||||
tf->x_offset=0.0;
|
||||
tf->y_offset=0.0;
|
||||
tf->z_offset=0.0;
|
||||
if (PopUpForm(tf)) {
|
||||
MemSet(r,0,16*sizeof(I64));
|
||||
r[0] =tf->x_scale*GR_SCALE;
|
||||
r[5] =tf->y_scale*GR_SCALE;
|
||||
r[10]=tf->z_scale*GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
|
||||
Mat4x4RotZ(r,tf->é_z*ã/180.0);
|
||||
Mat4x4RotY(r,tf->é_y*ã/180.0);
|
||||
Mat4x4RotX(r,tf->é_x*ã/180.0);
|
||||
|
||||
r[3] =tf->x_offset*GR_SCALE;
|
||||
r[7] =tf->y_offset*GR_SCALE;
|
||||
r[11]=tf->z_offset*GR_SCALE;
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define PU_SPACING 10
|
||||
U0 DrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 i,j,i1,j1;
|
||||
CDoc *doc=DocPut(task);
|
||||
for (j=0;j<17;j++)
|
||||
for (i=0;i<17;i++) {
|
||||
if (j<16)
|
||||
j1=j;
|
||||
else
|
||||
j1=TRANSPARENT;
|
||||
if (i<16)
|
||||
i1=i;
|
||||
else
|
||||
i1=TRANSPARENT;
|
||||
dc->color=j1+i1<<16+ROPF_DITHER;
|
||||
GrRect(dc,i*PU_SPACING,j*PU_SPACING+FramePtr("DitherFrame",task),
|
||||
PU_SPACING,PU_SPACING);
|
||||
}
|
||||
i=(17*PU_SPACING+FONT_WIDTH-1)/FONT_WIDTH;
|
||||
if (doc->max_x>i) i=doc->max_x;
|
||||
WinHorz(task->win_left,task->win_left+i,task);
|
||||
WinVert(task->win_top,task->win_top+doc->max_y+
|
||||
(17*PU_SPACING+FONT_WIDTH-1)/FONT_WIDTH,task);
|
||||
}
|
||||
|
||||
I64 DitherColor2(U8 *header=NULL)
|
||||
{
|
||||
I64 msg_code,a1,a2,result=-1,i,j;
|
||||
DocClear;
|
||||
"%s",header;
|
||||
DocRecalc(DocPut);
|
||||
FramePtrAdd("DitherFrame",(DocPut->max_y+1)*FONT_HEIGHT);
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
Fs->draw_it=&DrawIt;
|
||||
do {
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_DOWN|1<<MSG_KEY_DOWN);
|
||||
if (msg_code==MSG_IP_L_DOWN) {
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_UP);
|
||||
i=a1/PU_SPACING;
|
||||
j=(a2-FramePtr("DitherFrame"))/PU_SPACING;
|
||||
if (a1>=0 && a2>=0 && 0<=j<17 && 0<=i<17) {
|
||||
if (j==16) j=TRANSPARENT;
|
||||
if (i==16) i=TRANSPARENT;
|
||||
result=j+i<<16+ROPF_DITHER;
|
||||
goto dc_done;
|
||||
}
|
||||
}
|
||||
} while (!(msg_code==MSG_KEY_DOWN && (a1==CH_ESC || a1==CH_SHIFT_ESC)));
|
||||
do GetMsg(&a1,&a2,1<<MSG_KEY_UP);
|
||||
while (!a1);
|
||||
dc_done:
|
||||
SettingsPop;
|
||||
FramePtrDel("DitherFrame");
|
||||
return result;
|
||||
}
|
||||
|
||||
public I64 PopUpColorDither(U8 *header=NULL)
|
||||
{//Chooser for 2 x 16 colors or transparent.
|
||||
U8 buf[STR_LEN];
|
||||
StrPrint(buf,"DitherColor2(0x%X);",header);
|
||||
return PopUp(buf,Fs);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#help_index "DolDoc/Misc"
|
||||
|
||||
U32 *DocHighlight(CDocEntry *doc_e,U8 *src,I64 len,I64 _temp_u32_attr)
|
||||
{//Be aware of $LK,"::/Adam/Utils/ToHtml.CPP"$.
|
||||
{//Be aware of $LK,"::/Adam/Opt/Utils/ToHtml.CPP"$.
|
||||
U32 *result=MAlloc((len+1)*sizeof(U32)),*dst=result;
|
||||
U8 *ptr;
|
||||
CDocSettings *s=&doc_e->settings;
|
||||
|
||||
@@ -0,0 +1,344 @@
|
||||
#help_index "DolDoc/Link"
|
||||
|
||||
/* See $LK,"TempleOS Link Types",A="MN:ST_LINK_TYPES"$.
|
||||
"filename"
|
||||
"FI:filename"
|
||||
"FA:haystack_filename,needle_anchor_str"
|
||||
"FF:haystack_filename,needle_str"
|
||||
"FF:haystack_filename,needle_str:occurnum"
|
||||
"FL:filename,linenum"
|
||||
"MN:SymName"
|
||||
"PI:filename"
|
||||
"PF:haystack_filename,needle_str"
|
||||
"PF:haystack_filename,needle_str:occurnum"
|
||||
"PL:filename,linenum"
|
||||
"BF:haystack_bible_book,needle_str"
|
||||
"DF:word"
|
||||
"DF:word,defnum"
|
||||
"HI:index"
|
||||
"AD:code_address_number"
|
||||
|
||||
To edit a doc structure already in memory. See $LK,"SpriteEdText",A="MN:SpriteEdText"$().
|
||||
"AI:doc_address"
|
||||
"AA:haystack_doc_address,needle_anchor_str"
|
||||
"AF:haystack_doc_address,needle_str"
|
||||
"AF:haystack_doc_address,needle_str:occurnum"
|
||||
"AL:doc_address,linenum"
|
||||
*/
|
||||
|
||||
#define LK_FILE 0
|
||||
#define LK_FILE_ANCHOR 1
|
||||
#define LK_FILE_FIND 2
|
||||
#define LK_FILE_LINE 3
|
||||
#define LK_MAN_PAGE 4
|
||||
#define LK_PLAIN 5
|
||||
#define LK_PLAIN_FIND 6
|
||||
#define LK_PLAIN_LINE 7
|
||||
#define LK_BIBLE_FIND 8
|
||||
#define LK_DEF 9
|
||||
#define LK_HELP_INDEX 10
|
||||
#define LK_ADDR 11
|
||||
#define LK_DOC 12 //See $LK,"SpriteEdText",A="MN:SpriteEdText"$()
|
||||
#define LK_DOC_ANCHOR 13
|
||||
#define LK_DOC_FIND 14
|
||||
#define LK_DOC_LINE 15
|
||||
#define LK_PLACE_ANCHOR 16
|
||||
|
||||
public U8 *DocEntryLink(CDoc *doc,CDocEntry *doc_e)
|
||||
{//MAlloc new str, either tag or aux_str if link.
|
||||
if (doc_e->de_flags&DOCEF_LINK) {
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR)
|
||||
return StrNew(doc_e->aux_str,doc->mem_task);
|
||||
else if (doc_e->de_flags & DOCEF_TAG)
|
||||
return StrNew(doc_e->tag,doc->mem_task);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Bool DocFileEd(I64 _type,U8 *filename,
|
||||
U8 *needle_str,I64 *_num,I64 edf_dof_flags)
|
||||
{
|
||||
I64 type=_type,flags=0,old_border_src=Fs->border_src;
|
||||
CDocEntry *doc_e;
|
||||
CDoc *doc;
|
||||
Bool old_silent=Bt(&Fs->display_flags,DISPLAYf_SILENT),
|
||||
result=FALSE,other_found=FALSE;
|
||||
U8 *st1,*st2;
|
||||
try {
|
||||
switch (type) {
|
||||
case LK_PLAIN:
|
||||
flags=DOCF_PLAIN_TEXT;
|
||||
case LK_DOC:
|
||||
type=LK_FILE;
|
||||
break;
|
||||
case LK_DOC_ANCHOR:
|
||||
type=LK_FILE_ANCHOR;
|
||||
break;
|
||||
case LK_PLAIN_FIND:
|
||||
flags=DOCF_PLAIN_TEXT;
|
||||
case LK_DOC_FIND:
|
||||
type=LK_FILE_FIND;
|
||||
break;
|
||||
case LK_PLAIN_LINE:
|
||||
flags=DOCF_PLAIN_TEXT;
|
||||
case LK_DOC_LINE:
|
||||
type=LK_FILE_LINE;
|
||||
break;
|
||||
case LK_BIBLE_FIND:
|
||||
flags=DOCF_PLAIN_TEXT;
|
||||
break;
|
||||
}
|
||||
|
||||
flags|=DOCF_ALLOW_UNDO;
|
||||
|
||||
if (LK_DOC<=_type<=LK_DOC_LINE) {
|
||||
doc=Str2I64(filename);//See $LK,"SpriteEdText",A="MN:SpriteEdText"$()
|
||||
result=TRUE;
|
||||
} else {
|
||||
|
||||
st1=StrNew(filename);
|
||||
st2=StrNew(filename);
|
||||
StrLastRem(st1,"/",st2); //st2 is name without dir
|
||||
|
||||
if (!FileNameChk(st2))
|
||||
doc=NULL;
|
||||
else {
|
||||
Silent;
|
||||
if (Bt(&edf_dof_flags,EDf_BAIL)) //if bail, scan parents
|
||||
result=FileFind(filename,,
|
||||
FUF_JUST_FILES|FUF_Z_OR_NOT_Z|FUF_SCAN_PARENTS);
|
||||
else if (!(result=FileFind(filename,,
|
||||
FUF_JUST_FILES)))
|
||||
other_found=FileFind(filename,,
|
||||
FUF_JUST_FILES|FUF_Z_OR_NOT_Z|FUF_SCAN_PARENTS);
|
||||
doc=DocRead(filename,flags);
|
||||
doc->desc='Edit';
|
||||
Silent(old_silent);
|
||||
Fs->border_src=BDS_ED_FILENAME_DRV;
|
||||
}
|
||||
|
||||
Free(st1);
|
||||
Free(st2);
|
||||
}
|
||||
if (!doc||doc->doc_signature!=DOC_SIGNATURE_VAL)
|
||||
result=FALSE;
|
||||
else {
|
||||
if (Bt(&edf_dof_flags,EDf_COLLAPSE))
|
||||
DocCollapse(TRUE,doc);
|
||||
else if (Bt(&edf_dof_flags,EDf_UNCOLLAPSE))
|
||||
DocCollapse(FALSE,doc);
|
||||
|
||||
if (result || other_found)
|
||||
switch (type) {
|
||||
case LK_FILE_LINE:
|
||||
result=DocLineNumGoTo(doc,*_num);
|
||||
break;
|
||||
case LK_FILE_ANCHOR:
|
||||
result=DocAnchorFind(doc,needle_str);
|
||||
break;
|
||||
case LK_FILE_FIND:
|
||||
result=DocFind(doc,,needle_str,*_num);
|
||||
break;
|
||||
case LK_BIBLE_FIND:
|
||||
result=DocFind(doc,*_num,needle_str);
|
||||
break;
|
||||
default:
|
||||
DocCenter(doc);
|
||||
}
|
||||
*_num=doc->cur_entry->y+1;
|
||||
|
||||
if (edf_dof_flags&EDF_WAS_WRITE)
|
||||
result=FALSE;
|
||||
if (!(edf_dof_flags&EDF_BAIL) && DocEd(doc,edf_dof_flags|DOF_DONT_HOME)) {
|
||||
DocLock(doc);
|
||||
doc_e=doc->cur_entry;
|
||||
if (doc_e!=doc)
|
||||
DocEntryRun(doc,doc_e,TRUE);
|
||||
DocUnlock(doc);
|
||||
if (!(LK_DOC<=_type<=LK_DOC_LINE)) {
|
||||
DocWrite(doc);
|
||||
if (edf_dof_flags&EDF_WAS_WRITE)
|
||||
result=TRUE;
|
||||
}
|
||||
}
|
||||
if (!(LK_DOC<=_type<=LK_DOC_LINE))
|
||||
DocDel(doc);
|
||||
}
|
||||
} catch {
|
||||
Silent(old_silent);
|
||||
result=FALSE;
|
||||
}
|
||||
Fs->border_src=old_border_src;
|
||||
return result;
|
||||
}
|
||||
|
||||
#define DFT_ADDR_LINK_BIN_SIZE 64
|
||||
|
||||
public I64 EdLinkCvt(U8 *link_st,U8 **_filename=NULL,U8 **_needle_str=NULL,
|
||||
I64 *_num=NULL,I64 edf_dof_flags=0)
|
||||
{//$LK,"Editor Link",A="MN:LK_FILE"$--> filename, needle_str and line number.
|
||||
U8 *st,*ptr,*filename=NULL,*needle_str=NULL,*filename2;
|
||||
I64 result,i,num=1;
|
||||
CHashSrcSym *temph;
|
||||
if (!link_st||!*link_st) {
|
||||
if (edf_dof_flags&EDF_BAIL)
|
||||
return -1;
|
||||
link_st=blkdev.temp_filename;
|
||||
}
|
||||
st=StrNew(link_st);
|
||||
result=LK_FILE;
|
||||
if (StrLen(st)>3 && st[2]==':') {
|
||||
st[2]=0;
|
||||
filename2=st+3;
|
||||
switch (result=DefineMatch(st,"ST_LINK_TYPES",LMF_IGNORE_CASE)) {
|
||||
case LK_MAN_PAGE:
|
||||
if (temph=HashFind(filename2,Fs->hash_table,HTG_SRC_SYM))
|
||||
result=EdLinkCvt(temph->src_link,&filename,
|
||||
&needle_str,&num,edf_dof_flags);
|
||||
else
|
||||
result=-1;
|
||||
goto lc_done;
|
||||
case LK_ADDR:
|
||||
if (ptr=StrLastOcc(filename2,",")) {
|
||||
*ptr=0;
|
||||
i=Str2I64(ptr+1);
|
||||
} else
|
||||
i=DFT_ADDR_LINK_BIN_SIZE;
|
||||
if (ptr=SrcEdLink(ExePrint("%s;",filename2),i)) {
|
||||
result=EdLinkCvt(ptr,&filename,&needle_str,&num,edf_dof_flags);
|
||||
Free(ptr);
|
||||
} else
|
||||
result=-1;
|
||||
goto lc_done;
|
||||
case LK_DEF:
|
||||
if (ptr=StrLastOcc(filename2,",")) {
|
||||
*ptr=0;
|
||||
i=Str2I64(ptr+1);
|
||||
} else
|
||||
i=-1;
|
||||
filename=StrNew(filename2);
|
||||
num=i;
|
||||
goto lc_done;
|
||||
case LK_HELP_INDEX:
|
||||
filename=StrNew(filename2);
|
||||
goto lc_done;
|
||||
case LK_BIBLE_FIND:
|
||||
if (ptr=StrLastOcc(filename2,",")) {
|
||||
*ptr=0;
|
||||
needle_str=StrNew(ptr+1);
|
||||
}
|
||||
i=DefineMatch(filename2,"ST_BIBLE_BOOKS",LMF_IGNORE_CASE);
|
||||
if (i<0)
|
||||
result=-1;
|
||||
else {
|
||||
num=Str2I64(DefineSub(i,"ST_BIBLE_BOOK_LINES"));
|
||||
filename2=BIBLE_FILENAME;
|
||||
}
|
||||
break;
|
||||
case LK_FILE_LINE:
|
||||
case LK_PLAIN_LINE:
|
||||
case LK_DOC_LINE:
|
||||
if (ptr=StrLastOcc(filename2,",")) {
|
||||
*ptr=0;
|
||||
num=Str2I64(ptr+1);
|
||||
}
|
||||
break;
|
||||
case LK_FILE_ANCHOR:
|
||||
case LK_DOC_ANCHOR:
|
||||
if (ptr=StrLastOcc(filename2,",")) {
|
||||
*ptr=0;
|
||||
needle_str=StrNew(ptr+1);
|
||||
}
|
||||
break;
|
||||
case LK_FILE_FIND:
|
||||
case LK_PLAIN_FIND:
|
||||
case LK_DOC_FIND:
|
||||
if (ptr=StrLastOcc(filename2,",")) {
|
||||
*ptr=0;
|
||||
needle_str=StrNew(ptr+1);
|
||||
if (ptr=StrLastOcc(needle_str,":")) {
|
||||
*ptr=0;
|
||||
num=Str2I64(ptr+1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else
|
||||
filename2=st;
|
||||
if (result>=0) {
|
||||
if (LK_DOC<=result<=LK_DOC_LINE)
|
||||
filename=StrNew(filename2); //Holds document address as number.
|
||||
else
|
||||
filename=FileNameAbs(filename2,FUF_Z_OR_NOT_Z);
|
||||
}
|
||||
lc_done:
|
||||
Free(st);
|
||||
if (_filename)
|
||||
*_filename=filename;
|
||||
else
|
||||
Free(filename);
|
||||
if (_needle_str)
|
||||
*_needle_str=needle_str;
|
||||
else
|
||||
Free(needle_str);
|
||||
if (_num)
|
||||
*_num=num;
|
||||
return result;
|
||||
}
|
||||
|
||||
public Bool DocLinkChk(U8 *link_st)
|
||||
{//Check for bad $LK,"Editor Link",A="MN:LK_FILE"$.
|
||||
U8 *filename,*st;
|
||||
Bool result=FALSE;
|
||||
if (link_st) {
|
||||
switch (EdLinkCvt(link_st,&filename)) {
|
||||
case -1:
|
||||
break;
|
||||
case LK_FILE_LINE:
|
||||
case LK_PLAIN_LINE:
|
||||
case LK_FILE:
|
||||
//We don't check line number
|
||||
result=FileFind(filename,,
|
||||
FUF_JUST_FILES|FUF_Z_OR_NOT_Z|FUF_SCAN_PARENTS);
|
||||
break;
|
||||
case LK_BIBLE_FIND:
|
||||
st=StrNew(link_st+3);
|
||||
if (StrOcc(st,','))
|
||||
StrLastRem(st,",");
|
||||
if (DefineMatch(st,"ST_BIBLE_BOOKS",LMF_IGNORE_CASE)>=0)
|
||||
result=TRUE;
|
||||
Free(st);
|
||||
break;
|
||||
default://TODO: Need to validate HI: and DF:
|
||||
if (Ed(link_st,EDF_BAIL))
|
||||
result=TRUE;
|
||||
}
|
||||
Free(filename);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public U8 *DocLinkFile(U8 *link_st,CTask *mem_task=NULL)
|
||||
{//Return the file for an $LK,"Editor Link Types",A="MN:LK_FILE"$.
|
||||
U8 *filename=NULL,*st,*result=NULL;
|
||||
if (link_st) {
|
||||
switch (EdLinkCvt(link_st,&filename)) {
|
||||
case LK_FILE:
|
||||
case LK_FILE_ANCHOR:
|
||||
case LK_FILE_FIND:
|
||||
case LK_FILE_LINE:
|
||||
case LK_PLAIN:
|
||||
case LK_PLAIN_FIND:
|
||||
case LK_PLAIN_LINE:
|
||||
st=FileNameAbs(filename,FUF_Z_OR_NOT_Z|FUF_SCAN_PARENTS);
|
||||
result=StrNew(st);
|
||||
Free(st);
|
||||
break;
|
||||
case LK_BIBLE_FIND:
|
||||
result=StrNew(BIBLE_FILENAME,mem_task);
|
||||
break;
|
||||
}
|
||||
Free(filename);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -58,7 +58,6 @@ U8 *SysMacro2Str(CSrvCmd *macro_root)
|
||||
I64 cnt=1; //terminating zero
|
||||
U8 *ptr,*m;
|
||||
CMacroTemp *tempmt,*tempmt1,root;
|
||||
Bool old_preempt=Preempt;
|
||||
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
|
||||
|
||||
QueInit(&root);
|
||||
@@ -102,18 +101,15 @@ U8 *SysMacro2Str(CSrvCmd *macro_root)
|
||||
tempmt=tempmt1;
|
||||
}
|
||||
*ptr=0;
|
||||
Preempt(old_preempt);
|
||||
return m;
|
||||
}
|
||||
|
||||
U0 PlaySysMacro(I64 n=1)
|
||||
{
|
||||
CTask *task=sys_focus_task;
|
||||
Bool old_preempt;
|
||||
U8 *m;
|
||||
if (TaskValidate(task)) {
|
||||
LBtr(&sys_semas[SYS_SEMA_RECORD_MACRO],0);
|
||||
old_preempt=Preempt;
|
||||
m=SysMacro2Str(&sys_macro_root);
|
||||
while (n-- && TaskValidate(task)) {
|
||||
if (task==Fs)
|
||||
@@ -122,20 +118,17 @@ U0 PlaySysMacro(I64 n=1)
|
||||
XTalkStrWait(task,"%s",m);
|
||||
}
|
||||
Free(m);
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
}
|
||||
|
||||
U0 EdInsCapturedMacro()
|
||||
{
|
||||
Bool old_preempt=Preempt;
|
||||
U8 *st=SysMacro2Str(&sys_macro_root);
|
||||
if (sys_focus_task) {
|
||||
XTalk(sys_focus_task,"$$MA+LA,T=\"%s\",LM=\"%Q\"$$",
|
||||
captured_macro_name,st);
|
||||
Free(st);
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
#define SM_RECORD 0
|
||||
|
||||
@@ -1,602 +0,0 @@
|
||||
#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,result=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))
|
||||
result=TRUE;
|
||||
break;
|
||||
default:
|
||||
if (IsRaw)
|
||||
result=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)
|
||||
result=DocFileEd(i,filename,needle_str,&num,edf_dof_flags);
|
||||
}
|
||||
}
|
||||
Free(filename);
|
||||
Free(needle_str);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Bool Plain(U8 *filename,I64 edf_dof_flags=0)
|
||||
{//Edit document in plain text mode, so dollar signs are not special.
|
||||
Bool result;
|
||||
U8 *st=MStrPrint("PI:%s",filename);
|
||||
result=Ed(st,edf_dof_flags);
|
||||
Free(st);
|
||||
return result;
|
||||
}
|
||||
|
||||
#help_index "DolDoc"
|
||||
public Bool DocLinkChk(U8 *link_st)
|
||||
{//Check for bad $LK,"Editor Link",A="MN:LK_FILE"$.
|
||||
U8 *filename,*st;
|
||||
Bool result=FALSE;
|
||||
if (link_st) {
|
||||
switch (EdLinkCvt(link_st,&filename)) {
|
||||
case -1:
|
||||
break;
|
||||
case LK_FILE_LINE:
|
||||
case LK_PLAIN_LINE:
|
||||
case LK_FILE:
|
||||
//We don't check line number
|
||||
result=FileFind(filename,,
|
||||
FUF_JUST_FILES|FUF_Z_OR_NOT_Z|FUF_SCAN_PARENTS);
|
||||
break;
|
||||
case LK_BIBLE_FIND:
|
||||
st=StrNew(link_st+3);
|
||||
if (StrOcc(st,','))
|
||||
StrLastRem(st,",");
|
||||
if (DefineMatch(st,"ST_BIBLE_BOOKS",LMF_IGNORE_CASE)>=0)
|
||||
result=TRUE;
|
||||
Free(st);
|
||||
break;
|
||||
default://TODO: Need to validate HI: and DF:
|
||||
if (Ed(link_st,EDF_BAIL))
|
||||
result=TRUE;
|
||||
}
|
||||
Free(filename);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public U8 *DocLinkFile(U8 *link_st,CTask *mem_task=NULL)
|
||||
{//Return the file for an $LK,"Editor Link Types",A="MN:LK_FILE"$.
|
||||
U8 *filename=NULL,*st,*result=NULL;
|
||||
if (link_st) {
|
||||
switch (EdLinkCvt(link_st,&filename)) {
|
||||
case LK_FILE:
|
||||
case LK_FILE_ANCHOR:
|
||||
case LK_FILE_FIND:
|
||||
case LK_FILE_LINE:
|
||||
case LK_PLAIN:
|
||||
case LK_PLAIN_FIND:
|
||||
case LK_PLAIN_LINE:
|
||||
st=FileNameAbs(filename,FUF_Z_OR_NOT_Z|FUF_SCAN_PARENTS);
|
||||
result=StrNew(st);
|
||||
Free(st);
|
||||
break;
|
||||
case LK_BIBLE_FIND:
|
||||
result=StrNew(BIBLE_FILENAME,mem_task);
|
||||
break;
|
||||
}
|
||||
Free(filename);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#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,140,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.
|
||||
Bool old_preempt=Preempt;
|
||||
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);
|
||||
Preempt(old_preempt);
|
||||
Raw(OFF);
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;StdIn/DolDoc"
|
||||
public U8 *DocScanLine(CDoc *doc,CDocEntry *doc_e,
|
||||
I64 *cur_col=NULL,CDocEntry **_do_e_end=NULL)
|
||||
{//Start at entry in doc,make and return one line as str.
|
||||
CDocEntry *doc_e2=doc_e;
|
||||
Bool unlock=DocLock(doc);
|
||||
U8 *dst,*src,*start,*result;
|
||||
I64 i=0;
|
||||
if (cur_col)
|
||||
*cur_col=-1;
|
||||
while (doc_e2!=doc && doc_e2->type_u8!=DOCT_NEW_LINE) {
|
||||
if (doc_e2->de_flags&DOCEF_TAG && doc_e2->tag) {
|
||||
src=doc_e2->tag;
|
||||
i+=StrLen(src);
|
||||
} else if (doc_e2->type_u8==DOCT_TAB)
|
||||
i++;
|
||||
doc_e2=doc_e2->next;
|
||||
}
|
||||
result=MAlloc(i+1);
|
||||
dst=result;
|
||||
while (doc_e!=doc && doc_e->type_u8!=DOCT_NEW_LINE) {
|
||||
start=dst;
|
||||
if (doc_e->de_flags&DOCEF_TAG && doc_e->tag) {
|
||||
src=doc_e->tag;
|
||||
while (*src)
|
||||
*dst++=*src++;
|
||||
} else if (doc_e->type_u8==DOCT_TAB)
|
||||
*dst++='\t';
|
||||
if (doc_e==doc->cur_entry && cur_col)
|
||||
*cur_col=start-result+doc->cur_col;
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
if (_do_e_end) *_do_e_end=doc_e;
|
||||
*dst=0;
|
||||
if (doc_e==doc->cur_entry && cur_col && !doc->cur_col)
|
||||
*cur_col=dst-result;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return result;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
U0 DocDump(CDoc *doc,I64 uS_delay=0)
|
||||
{
|
||||
U8 *st;
|
||||
CDocEntry *doc_e,*doc_e2;
|
||||
Bool unlock=DocLock(doc);
|
||||
doc_e=doc->root.next;
|
||||
while (doc_e!=doc) {
|
||||
st=DocScanLine(doc,doc_e,NULL,&doc_e2);
|
||||
"%s",st;
|
||||
Free(st);
|
||||
doc_e=doc_e2;
|
||||
if (doc_e->type_u8==DOCT_NEW_LINE) {
|
||||
'\n';
|
||||
BusyWait(uS_delay);
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public CDocEntry *DocPutLine(CDoc *doc=NULL,CDocEntry *doc_e)
|
||||
{//Send line from other doc to StdOut $LK,"DocPut",A="MN:DocPut"$.
|
||||
I64 ch;
|
||||
U8 *ptr,*ptr2;
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut) || doc->doc_signature!=DOC_SIGNATURE_VAL)
|
||||
return NULL;
|
||||
unlock=DocLock(doc);
|
||||
while (doc_e!=doc && doc_e->type_u8!=DOCT_NEW_LINE) {
|
||||
if (doc_e->de_flags&DOCEF_TAG) {
|
||||
ptr=doc_e->tag;
|
||||
do {
|
||||
ptr2=ptr;
|
||||
while (ch=*ptr)
|
||||
if (ch=='$$')
|
||||
break;
|
||||
else
|
||||
ptr++;
|
||||
*ptr=0;
|
||||
"%s",ptr2;
|
||||
*ptr=ch;
|
||||
if (ch=='$$') {
|
||||
"$$$$";
|
||||
ptr++;
|
||||
}
|
||||
} while (ch);
|
||||
} else if (doc_e->type_u8==DOCT_TAB)
|
||||
'\t';
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
'\n';
|
||||
if (doc_e!=doc)
|
||||
doc_e=doc_e->next;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return doc_e;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;StdIn/DolDoc"
|
||||
U8 *DocGetStr2(I64 flags=0)
|
||||
{//$LK,"Flags",A="MN:GSF_SHIFT_ESC_EXIT"$
|
||||
CDoc *doc;
|
||||
CDocEntry *doc_e,*doc_e_end;
|
||||
Bool old_preempt=IsPreempt;
|
||||
U8 *st,*st2,*result;
|
||||
I64 ch,sc;
|
||||
"$$PT$$";
|
||||
do {
|
||||
ch=DocGetKey(&sc);
|
||||
if (ch==CH_ESC) {
|
||||
if (doc=DocPut) {
|
||||
DocLock(doc);
|
||||
if (doc->doc_signature==DOC_SIGNATURE_VAL && doc->cur_entry!=doc) {
|
||||
doc_e=DocEntryCopy(doc,doc->cur_entry);
|
||||
DocBottom(doc);
|
||||
DocEntryRun(doc,doc_e,TRUE);
|
||||
DocEntryDel(doc,doc_e);
|
||||
}
|
||||
DocUnlock(doc);
|
||||
}
|
||||
if (flags&GSF_WITH_NEW_LINE)
|
||||
break;
|
||||
} if (ch==CH_SHIFT_ESC) {
|
||||
if (flags&GSF_SHIFT_ESC_EXIT)
|
||||
Exit;
|
||||
else {
|
||||
result=StrNew("");
|
||||
goto gs_done;
|
||||
}
|
||||
}
|
||||
//<CTRL-SHIFT-ENTER> is a blank line without entry
|
||||
} while (flags&GSF_WITH_NEW_LINE || ch!='\n' ||
|
||||
sc & SCF_CTRL && sc & SCF_SHIFT);
|
||||
|
||||
Preempt;
|
||||
doc=DocPut;
|
||||
DocLock(doc);
|
||||
if (flags&GSF_WITH_NEW_LINE) {
|
||||
doc_e=doc->cur_entry;
|
||||
do doc_e=doc_e->last;
|
||||
while (doc_e!=doc && doc_e->type_u8!=DOCT_PMT);
|
||||
doc_e=doc_e->next;
|
||||
if (result=DocScanLine(doc,doc_e,NULL,&doc_e_end)) {
|
||||
while (doc_e_end!=doc && doc_e_end->type_u8==DOCT_NEW_LINE) {
|
||||
st2=MStrPrint("%s\n",result);
|
||||
Free(result);
|
||||
result=st2;
|
||||
if (st=DocScanLine(doc,doc_e_end->next,NULL,&doc_e_end)) {
|
||||
st2=MStrPrint("%s%s",result,st);
|
||||
Free(st);
|
||||
Free(result);
|
||||
result=st2;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
doc_e=doc->cur_entry;
|
||||
do doc_e=doc_e->last;
|
||||
while (doc_e!=doc && doc_e->type_u8!=DOCT_NEW_LINE &&
|
||||
doc_e->type_u8!=DOCT_PMT);
|
||||
if (doc_e!=doc && doc_e->type_u8!=DOCT_PMT) {
|
||||
do doc_e=doc_e->last;
|
||||
while (doc_e!=doc && doc_e->type_u8!=DOCT_NEW_LINE &&
|
||||
doc_e->type_u8!=DOCT_PMT);
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
result=DocScanLine(doc,doc_e,NULL);
|
||||
}
|
||||
DocUnlock(doc);
|
||||
gs_done:
|
||||
"$$PT$$$$FG$$$$BG$$";
|
||||
Preempt(old_preempt);
|
||||
return result;
|
||||
}
|
||||
|
||||
#help_index "Keyboard Devices;Char/Input;StdIn"
|
||||
|
||||
public I64 GetI64(U8 *msg=NULL,I64 dft=0,I64 lo=MIN_I64,I64 hi=MAX_I64)
|
||||
{//Prompt user for I64 expression.
|
||||
Bool okay;
|
||||
U8 *st;
|
||||
I64 result;
|
||||
while (TRUE) {
|
||||
if (msg)
|
||||
"" msg,dft;
|
||||
st=GetStr;
|
||||
if (!*st) {
|
||||
Free(st);
|
||||
return dft;
|
||||
}
|
||||
try {
|
||||
result=ExePrint2("ToI64(%s);",st);
|
||||
okay=TRUE;
|
||||
} catch {
|
||||
Fs->catch_except=TRUE;
|
||||
okay=FALSE;
|
||||
}
|
||||
Free(st);
|
||||
if (okay && lo<=result<=hi)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public F64 GetF64(U8 *msg=NULL,F64 dft=0,F64 lo=MIN_F64,F64 hi=MAX_F64)
|
||||
{//Prompt user for F64 expression.
|
||||
Bool okay;
|
||||
U8 *st;
|
||||
F64 result;
|
||||
while (TRUE) {
|
||||
if (msg)
|
||||
"" msg,dft;
|
||||
st=GetStr;
|
||||
if (!*st) {
|
||||
Free(st);
|
||||
return dft;
|
||||
}
|
||||
try {
|
||||
result=ExePrint2("ToF64(%s);",st)(F64);
|
||||
okay=TRUE;
|
||||
} catch {
|
||||
Fs->catch_except=TRUE;
|
||||
okay=FALSE;
|
||||
}
|
||||
Free(st);
|
||||
if (okay && lo<=result<=hi)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public CDate GetDate(U8 *msg=NULL,CDate dft=MIN_I64,
|
||||
CDate lo=MIN_I64,CDate hi=MAX_I64)
|
||||
{//Prompt user for date expression. (Use $LK,"Now",A="MN:Now"$() if you want current time.)
|
||||
U8 *st;
|
||||
CDate result;
|
||||
if (dft==MIN_I64) dft=Now;
|
||||
while (TRUE) {
|
||||
if (msg)
|
||||
"" msg,dft,dft;
|
||||
st=GetStr;
|
||||
if (!*st) {
|
||||
Free(st);
|
||||
return dft;
|
||||
}
|
||||
result=Str2Date(st);
|
||||
Free(st);
|
||||
if (result>=lo && result<=hi)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
#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_PLAIN 7
|
||||
#define RIGHT_AUTOFILE 8
|
||||
|
||||
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,\"PLAIN ED TXT\",LE=RIGHT_PLAIN$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"CANCEL \",LE=DOCM_CANCEL$$"
|
||||
"$$CM+LX,26,0$$$$BT,\"AUTOFILE AUT\",LE=RIGHT_AUTOFILE$$\n",
|
||||
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 result;
|
||||
U8 *st;
|
||||
if (st=DocEntryLink(doc,doc_e)) {
|
||||
DocUnlock(doc);
|
||||
if (doc_e->de_flags & DOCEF_POPUP)
|
||||
result=PopUpEd(st);
|
||||
else
|
||||
result=Ed(st);
|
||||
Free(st);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
I64 TermRightClickLink(CDoc *doc,CDocEntry *doc_e)
|
||||
{//Called with doc locked, exit unlocked
|
||||
Bool send_new_line=FALSE,result=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);
|
||||
result=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);
|
||||
result=TRUE;
|
||||
break;
|
||||
case RIGHT_COPY:
|
||||
StrCpy(fn.name,st);
|
||||
if (DocForm(&fn)) {
|
||||
result=ToBool(Copy(st,fn.name));
|
||||
} else
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
case RIGHT_MOVE:
|
||||
StrCpy(fn.name,st);
|
||||
if (DocForm(&fn))
|
||||
result=Move(st,fn.name);
|
||||
else
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
case RIGHT_DELETE:
|
||||
result=ToBool(Del(st));
|
||||
break;
|
||||
case RIGHT_TYPE:
|
||||
result=Type(st);
|
||||
break;
|
||||
case RIGHT_ED:
|
||||
"Ed(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
|
||||
result=Ed(st);
|
||||
break;
|
||||
case RIGHT_PLAIN:
|
||||
"Plain(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
|
||||
result=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);
|
||||
result=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 result;
|
||||
}
|
||||
|
||||
#help_index "Debugging/Dump;DolDoc/Cmd Line (Typically);"\
|
||||
"Cmd Line (Typically);DolDoc/Output;StdOut/DolDoc"
|
||||
public U0 DocDm(U8 *buf,I64 cnt=0x80)
|
||||
{//Dump live chunk of mem showing addresses. Can be edited.
|
||||
CDocEntry *doc_e;
|
||||
CDoc *doc=DocPut;
|
||||
Bool unlock=DocLock(doc);
|
||||
doc_e=DocPrint(doc,"$$HX-Z,%d,16$$",cnt);
|
||||
doc_e->data=buf;
|
||||
doc->cur_entry=doc_e->next;
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocD(U8 *buf,I64 cnt=0x80)
|
||||
{//Dump live chunk of mem showing offsets. Can be edited.
|
||||
CDocEntry *doc_e;
|
||||
CDoc *doc=DocPut;
|
||||
Bool unlock=DocLock(doc);
|
||||
doc_e=DocPrint(doc,"$$HX,%d,16$$",cnt);
|
||||
doc_e->data=buf;
|
||||
doc->cur_entry=doc_e->next;
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
Bool KDDocPutS(U8 *st)
|
||||
{
|
||||
CDoc *doc;
|
||||
if (doc=DocPut)
|
||||
DocPrintPartial(doc,"%s",st);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
KeyDevAdd(&KDDocPutKey,&KDDocPutS,0x80000000,TRUE);
|
||||
fp_getstr2=&DocGetStr2;
|
||||
fp_doc_put=&DocPut;
|
||||
+51
-446
@@ -27,100 +27,6 @@ public Bool DocUnlock(CDoc *doc)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CDocBin *DocBinFindNum(CDoc *haystack_doc,I64 needle_num)
|
||||
{
|
||||
CDocBin *b=haystack_doc->bin_root.next;
|
||||
while (b!=&haystack_doc->bin_root) {
|
||||
if (b->num==needle_num)
|
||||
return b;
|
||||
b=b->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CDocBin *DocBinFindTag(CDoc *haystack_doc,U8 *needle_tag)
|
||||
{
|
||||
CDocBin *b;
|
||||
if (needle_tag) {
|
||||
b=haystack_doc->bin_root.next;
|
||||
while (b!=&haystack_doc->bin_root) {
|
||||
if (b->tag && !StrCmp(b->tag,needle_tag))
|
||||
return b;
|
||||
b=b->next;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U0 DocBinsValidate(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocBin *b,*b1;
|
||||
CDocEntry *doc_e,*doc_e2;
|
||||
I64 renum_num=0;
|
||||
b=doc->bin_root.next;
|
||||
while (b!=&doc->bin_root) {
|
||||
b->use_cnt=0;
|
||||
b->temp_use_cnt=0;
|
||||
b->renum_num=-1;
|
||||
Free(b->tag);
|
||||
b->tag=NULL;
|
||||
b=b->next;
|
||||
}
|
||||
doc_e=doc->root.next;
|
||||
while (doc_e!=doc) {
|
||||
doc_e2=doc_e->next;
|
||||
if (doc_e->de_flags & DOCEF_HAS_BIN) {
|
||||
if (b=doc_e->bin_data=DocBinFindNum(doc,doc_e->bin_num)) {
|
||||
if (doc_e->de_flags & DOCEF_BIN_PTR_LINK)
|
||||
b->temp_use_cnt=MAX_I32;
|
||||
if (!b->use_cnt++)
|
||||
b->renum_num=++renum_num;
|
||||
doc_e->bin_num=b->renum_num;
|
||||
if (!b->tag && doc_e->de_flags&DOCEF_TAG && doc_e->tag && *doc_e->tag)
|
||||
b->tag=StrNew(doc_e->tag,doc->mem_task);
|
||||
} else {
|
||||
RawPrint(3000,"Bin Not Found");
|
||||
doc_e->type=doc_e->de_flags=0;
|
||||
doc_e->type_u8=DOCT_ERROR;
|
||||
}
|
||||
}
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
|
||||
b=doc->bin_root.next;
|
||||
doc->cur_bin_num=1;
|
||||
while (b!=&doc->bin_root) {
|
||||
b1=b->next;
|
||||
if (!b->use_cnt) {
|
||||
QueRem(b);
|
||||
Free(b->data);
|
||||
Free(b);
|
||||
} else {
|
||||
b->num=b->renum_num;
|
||||
if (b->num>=doc->cur_bin_num)
|
||||
doc->cur_bin_num=b->num+1;
|
||||
}
|
||||
b=b1;
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 DocBinDel(CDoc *doc,CDocBin *b)
|
||||
{
|
||||
if (doc && b && b->use_cnt) {
|
||||
b->use_cnt--;
|
||||
if (!b->use_cnt) {
|
||||
QueRem(b);
|
||||
Free(b->tag);
|
||||
Free(b->data);
|
||||
Free(b);
|
||||
}
|
||||
} else
|
||||
RawPrint(3000,"DocBinDel");
|
||||
}
|
||||
|
||||
Bool IsEditableText(CDocEntry *doc_e)
|
||||
{
|
||||
if (doc_e->type_u8==DOCT_TEXT&&!(doc_e->de_flags&DOCEG1_DONT_EDIT))
|
||||
@@ -249,88 +155,63 @@ public CDocEntry *DocEntryCopy(CDoc *doc,CDocEntry *doc_e)
|
||||
return doc_ne;
|
||||
}
|
||||
|
||||
public U8 *DocEntryLink(CDoc *doc,CDocEntry *doc_e)
|
||||
{//MAlloc new str, either tag or aux_str if link.
|
||||
if (doc_e->de_flags&DOCEF_LINK) {
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR)
|
||||
return StrNew(doc_e->aux_str,doc->mem_task);
|
||||
else if (doc_e->de_flags & DOCEF_TAG)
|
||||
return StrNew(doc_e->tag,doc->mem_task);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
U0 DocFormFwd(CDoc *doc,Bool giveup=FALSE)
|
||||
U0 DocRemSoftNewLines(CDoc *doc=NULL,CDocEntry *doc_e=NULL)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public U0 DocTop(CDoc *doc=NULL)
|
||||
{//Move cursor, cur_entry, to top.
|
||||
CDocEntry *doc_e2,*saved_ll=doc_e;
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
unlock=DocLock(doc);
|
||||
doc->cur_entry=doc->root.next;
|
||||
if (!doc_e) doc_e=doc->root.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;
|
||||
doc->x=0;
|
||||
doc->y=0;
|
||||
doc->line_start_col=0;
|
||||
doc->top_line_num=0;
|
||||
}
|
||||
DocEntryDel(doc,doc_e);
|
||||
} else if (saved_ll && doc_e->type_u8==DOCT_NEW_LINE)
|
||||
break;
|
||||
doc_e=doc_e2;
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
DocFormFwd(doc);
|
||||
DocRecalc(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=DocEntryNew(doc,doc_ce,StrNew(dst,doc->mem_task));
|
||||
*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);
|
||||
}
|
||||
@@ -376,7 +257,6 @@ public U0 DocRst(CDoc *doc,Bool is_old)
|
||||
doc->undo_cnt=0;
|
||||
doc->cur_bin_num=1;
|
||||
doc->dollar_buf_ptr=0;
|
||||
doc->ext_ascii_cnt=doc->ext_ascii_val=0;
|
||||
doc->cmd_U8=CH_SPACE;
|
||||
doc->page_line_num=0;
|
||||
doc->best_d=MAX_I64;
|
||||
@@ -462,169 +342,6 @@ public I64 DocSize(CDoc *doc)
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 DocDataFmt(CDoc *doc,CDocEntry *doc_e,I64 d=DOCM_CANCEL)
|
||||
{
|
||||
I64 i;
|
||||
U8 *ptr;
|
||||
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_DATA_IS_PTR) {
|
||||
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) {
|
||||
StrPrint(doc_e->tag,doc_e->aux_str,d,doc_e->my_fmt_data);
|
||||
if (doc_e->de_flags & DOCEF_HAS_TERMINATOR) {
|
||||
i=StrLen(doc_e->tag);
|
||||
doc_e->tag[i++]='_';
|
||||
doc_e->tag[i]=0;
|
||||
}
|
||||
doc_e->max_col=StrLen(doc_e->tag);
|
||||
} 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_lst[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_DATA_IS_PTR) {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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->root.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);
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Cmd Line (Typically);Cmd Line (Typically)"
|
||||
|
||||
public I64 DocMax(I64 i=MAX_I64)
|
||||
{//Set max document entries. (Cmd line buffer.)
|
||||
//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/DocMain.CPP,max_entries"$.
|
||||
I64 result;
|
||||
CDoc *doc;
|
||||
if (doc=DocPut) {
|
||||
result=doc->max_entries;
|
||||
doc->max_entries=i;
|
||||
return result;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#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.)
|
||||
@@ -634,7 +351,7 @@ public CDoc *DocNew(U8 *filename=NULL,CTask *task=NULL)
|
||||
if (filename)
|
||||
StrCpy(doc->filename.name,filename);
|
||||
else
|
||||
StrCpy(doc->filename.name,dsk.temp_filename);
|
||||
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;
|
||||
@@ -649,115 +366,3 @@ public CDoc *DocNew(U8 *filename=NULL,CTask *task=NULL)
|
||||
doc->doc_signature=DOC_SIGNATURE_VAL;
|
||||
return doc;
|
||||
}
|
||||
|
||||
#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 *result;
|
||||
if (!task) task=Fs;
|
||||
if ((result=task->put_doc) && result->doc_signature==DOC_SIGNATURE_VAL)
|
||||
return result;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CDoc *DocDisplay(CTask *task=NULL)
|
||||
{//StdOut displayed unless double buffering.
|
||||
CDoc *result;
|
||||
if (!task) task=Fs;
|
||||
if ((result=task->display_doc) && result->doc_signature==DOC_SIGNATURE_VAL)
|
||||
return result;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CDoc *DocBorder(CTask *task=NULL)
|
||||
{//Doc holding border of window text.
|
||||
CDoc *result;
|
||||
if (!task) task=Fs;
|
||||
if ((result=task->border_doc) && result->doc_signature==DOC_SIGNATURE_VAL)
|
||||
return result;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CDoc *DocDblBufStart(CTask *task=NULL)
|
||||
{//See $LK,"::/Demo/Spy.CPP"$
|
||||
Bool unlock_ddoc,old_preempt=Preempt;
|
||||
CDoc *pdoc=DocPut(task),*ddoc=DocDisplay(task),*result;
|
||||
if (!pdoc || !ddoc || pdoc!=ddoc)
|
||||
result=NULL; //Already Double buffering
|
||||
else {
|
||||
if (!task) task=Fs;
|
||||
unlock_ddoc=DocLock(ddoc); //dont change during winupdate, so lock DocPut$WW,0$
|
||||
result=DocNew(,task);
|
||||
result->win_task =ddoc->win_task;
|
||||
result->max_entries =ddoc->max_entries;
|
||||
MemCpy(result->find_replace,ddoc->find_replace,sizeof(CEdFindText));
|
||||
MemCpy(&result->filename,&ddoc->filename,sizeof(CEdFileName));
|
||||
result->left_click_link =ddoc->left_click_link;
|
||||
result->right_click_link =ddoc->right_click_link;
|
||||
result->user_put_data =ddoc->user_put_data;
|
||||
result->user_put_key =ddoc->user_put_key;
|
||||
result->user_put_s =ddoc->user_put_s;
|
||||
result->parent_doc =ddoc->parent_doc;
|
||||
result->desc =ddoc->desc;
|
||||
result->user_data =ddoc->user_data;
|
||||
result->flags|=ddoc->flags&DOCG_DBL_BUF_FLAGS | DOCF_DONT_SHOW;
|
||||
task->put_doc=result;
|
||||
if (unlock_ddoc)
|
||||
DocUnlock(ddoc);
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Bool DocDblBufEnd(CTask *task=NULL)
|
||||
{//See $LK,"::/Demo/Spy.CPP"$
|
||||
Bool result=FALSE,old_preempt=Preempt;
|
||||
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);
|
||||
result=TRUE;
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Bool DocDblBufSwap(CTask *task=NULL)
|
||||
{//See $LK,"::/Demo/Spy.CPP"$
|
||||
Bool result=FALSE,old_preempt=Preempt;
|
||||
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;
|
||||
result=TRUE;
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
return result;
|
||||
}
|
||||
+12
-12
@@ -32,18 +32,18 @@ I64 DocOptEntry(CDoc *,CDocEntry *doc_e)
|
||||
Free(st);
|
||||
}
|
||||
/* !!! Dangerous, but handy !!!
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR) {
|
||||
if (st=StrMatch(".Z",doc_e->aux_str)) {
|
||||
StrCpy(st,st+2);
|
||||
result++;
|
||||
}
|
||||
}
|
||||
if (doc_e->de_flags&DOCEF_TAG) {
|
||||
if (st=StrMatch(".Z",doc_e->tag)) {
|
||||
StrCpy(st,st+2);
|
||||
result++;
|
||||
}
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_AUX_STR) {
|
||||
if (st=StrMatch(".Z",doc_e->aux_str)) {
|
||||
StrCpy(st,st+2);
|
||||
result++;
|
||||
}
|
||||
}
|
||||
if (doc_e->de_flags&DOCEF_TAG) {
|
||||
if (st=StrMatch(".Z",doc_e->tag)) {
|
||||
StrCpy(st,st+2);
|
||||
result++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
return result;
|
||||
|
||||
+109
-246
@@ -40,53 +40,6 @@ I64 PrsDocFlags(CCmpCtrl *cc,I64 *_de_flags,U32 *_type)
|
||||
return result;
|
||||
}
|
||||
|
||||
I64 DocBinPtrRst(CDoc *doc,CDocEntry *doc_e)
|
||||
{
|
||||
U8 *st,*st2;
|
||||
CDoc *doc2;
|
||||
CDocBin *tempb,*tempb2;
|
||||
I64 i,bin_num=0;
|
||||
if (doc_e->de_flags&DOCEF_HAS_BIN &&
|
||||
doc_e->bin_ptr_link && StrLen(doc_e->bin_ptr_link)) {
|
||||
bin_num=doc_e->bin_num;
|
||||
st=StrNew(doc_e->bin_ptr_link);
|
||||
st2=StrNew(st);
|
||||
StrLastRem(st,",",st2);
|
||||
i=Str2I64(st2);
|
||||
if (i>0||*st2) {
|
||||
doc2=DocRead(st);
|
||||
if (i>0 && (tempb2=DocBinFindNum(doc2,i)) ||
|
||||
i==0 && (tempb2=DocBinFindTag(doc2,st2))) {
|
||||
i=1;
|
||||
if (bin_num>0) {
|
||||
if (tempb=DocBinFindNum(doc,bin_num)) {
|
||||
i=tempb->use_cnt;
|
||||
DocBinDel(doc,tempb);
|
||||
}
|
||||
} else
|
||||
bin_num=doc->cur_bin_num++;
|
||||
tempb=MAllocIdentical(tempb2,doc->mem_task);
|
||||
tempb->use_cnt=i;
|
||||
tempb->data=MAllocIdentical(tempb2->data,doc->mem_task);
|
||||
tempb->num=bin_num;
|
||||
doc_e->bin_data=tempb;
|
||||
if (doc_e->de_flags&DOCEF_TAG && doc_e->tag && *doc_e->tag)
|
||||
tempb->tag=StrNew(doc_e->tag,doc->mem_task);
|
||||
else
|
||||
tempb->tag=NULL;
|
||||
QueIns(tempb,doc->bin_root.last);
|
||||
} else
|
||||
bin_num=0;
|
||||
DocDel(doc2);
|
||||
} else
|
||||
bin_num=0;
|
||||
Free(st2);
|
||||
Free(st);
|
||||
doc_e->bin_num=bin_num;
|
||||
}
|
||||
return bin_num;
|
||||
}
|
||||
|
||||
U8 *Doc2PlainText(CDoc *doc,CDocEntry *doc_e)
|
||||
{//TODO: break strs
|
||||
I64 i,j,attr=doc_e->attr,
|
||||
@@ -537,214 +490,124 @@ pd_err:
|
||||
return doc_e;
|
||||
}
|
||||
|
||||
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_HTML_LINK|DOCEF_BIN_PTR_LINK)) &&
|
||||
doc->cur_col<doc_ce->max_col) {
|
||||
dst=doc_ce->tag+doc->cur_col;
|
||||
doc_ne=DocEntryNew(doc,doc_ce,StrNew(dst,doc->mem_task));
|
||||
*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;
|
||||
U0 DocEntryToggle(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc),old_color_names;
|
||||
CDocEntry *doc_ce=doc->cur_entry,*cl1,*doc_ce2;
|
||||
U8 ch,*st,*st2;
|
||||
I64 i,j,k;
|
||||
if (doc_ce!=doc &&
|
||||
!(doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS))) {
|
||||
if (doc_ce->type_u8==DOCT_TEXT && !(doc_ce->de_flags &
|
||||
~(DOCEF_TAG|DOCG_BL_IV_UL|DOCEF_WORD_WRAP|DOCEF_HIGHLIGHT|
|
||||
DOCEF_SKIP|DOCEF_HARD_SKIP|DOCEF_FILTER_SKIP)) &&
|
||||
!(doc_ce->type&DOCG_BL_IV_UL)) {
|
||||
doc_ce2=doc_ce->last;
|
||||
for (k=0;k<20;k++) {
|
||||
if (doc_ce2!=doc) {
|
||||
cl1=doc_ce2->last;
|
||||
if (doc_ce2->type_u8==DOCT_TEXT &&
|
||||
doc_ce->de_flags==doc_ce2->de_flags &&
|
||||
doc_ce->type==doc_ce2->type) {
|
||||
i=StrLen(doc_ce2->tag);
|
||||
j=StrLen(doc_ce->tag);
|
||||
st=MAlloc(i+j+1,doc->mem_task);
|
||||
MemCpy(st,doc_ce2->tag,i);
|
||||
MemCpy(st+i,doc_ce->tag,j+1);
|
||||
Free(doc_ce->tag);
|
||||
doc_ce->tag=st;
|
||||
doc_ce->max_col=i+j;
|
||||
doc->cur_col+=i;
|
||||
DocEntryDel(doc,doc_ce2);
|
||||
} else if (doc_ce2->type_u8==DOCT_SOFT_NEW_LINE)
|
||||
DocEntryDel(doc,doc_ce2);
|
||||
else
|
||||
break;
|
||||
doc_ce2=cl1;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
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_ce2=doc_ce->next;
|
||||
for (k=0;k<20;k++) {
|
||||
if (doc_ce2!=doc) {
|
||||
cl1=doc_ce2->next;
|
||||
if (doc_ce2->type_u8==DOCT_TEXT &&
|
||||
doc_ce->de_flags==doc_ce2->de_flags &&
|
||||
doc_ce->type==doc_ce2->type) {
|
||||
i=StrLen(doc_ce->tag);
|
||||
j=StrLen(doc_ce2->tag);
|
||||
st=MAlloc(i+j+1,doc->mem_task);
|
||||
MemCpy(st,doc_ce->tag,i);
|
||||
MemCpy(st+i,doc_ce2->tag,j+1);
|
||||
Free(doc_ce->tag);
|
||||
doc_ce->tag=st;
|
||||
doc_ce->max_col=i+j;
|
||||
DocEntryDel(doc,doc_ce2);
|
||||
} else if (doc_ce2->type_u8==DOCT_SOFT_NEW_LINE)
|
||||
DocEntryDel(doc,doc_ce2);
|
||||
else
|
||||
break;
|
||||
doc_ce2=cl1;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
i=doc->cur_col;
|
||||
while (i>doc_ce->min_col && doc_ce->tag[i]!='$$')
|
||||
i--;
|
||||
j=doc->cur_col+1;
|
||||
while (j<doc_ce->max_col && doc_ce->tag[j]!='$$')
|
||||
j++;
|
||||
if (i<j-1 && doc_ce->min_col<=i<j<doc_ce->max_col &&
|
||||
doc_ce->tag[i]=='$$' && doc_ce->tag[j]=='$$') {
|
||||
ch=doc_ce->tag[j+1];
|
||||
doc_ce->tag[j+1]=0;
|
||||
st=StrNew(doc_ce->tag+i);
|
||||
doc_ce->tag[j+1]=ch;
|
||||
StrCpy(doc_ce->tag+i,doc_ce->tag+j+1);
|
||||
doc->cur_col=i;
|
||||
st2=MStrPrint("%q",st);
|
||||
if (doc_ce=DocPrint(doc,st2)) {
|
||||
doc->cur_entry=doc_ce;
|
||||
doc->cur_col=doc_ce->min_col;
|
||||
}
|
||||
doc->cur_col=doc->cur_entry->min_col;
|
||||
DocRemSoftNewLines(doc,doc->cur_entry);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
CDocEntry *DocPutS(CDoc *doc,U8 *st)
|
||||
{//Don't use this. Use $LK-UL,"DocPrint",A="MN:DocPrint"$().
|
||||
//Does not handle partial Doc entries
|
||||
//Returns last newly created dollar-sign CDocEntry.
|
||||
U8 *ptr=st,*ptr2,*st2,*ptr3,*ptr4,*src,
|
||||
*char_bitmap;
|
||||
Bool unlock;
|
||||
I64 ch,j;
|
||||
CDocEntry *doc_e=NULL,*result=NULL,*doc_ce;
|
||||
if (!st || !doc && !(doc=DocPut) || doc->doc_signature!=DOC_SIGNATURE_VAL)
|
||||
return NULL;
|
||||
unlock=DocLock(doc);
|
||||
if (doc->flags & DOCF_PLAIN_TEXT_WITH_TABS)
|
||||
char_bitmap=chars_bmp_zero_cr_nl_cursor;
|
||||
else if (doc->flags & DOCF_PLAIN_TEXT)
|
||||
char_bitmap=chars_bmp_zero_tab_ff_cr_nl_cursor;
|
||||
else
|
||||
char_bitmap=chars_bmp_zero_tab_ff_cr_nl_cursor_dollar;
|
||||
doc_ce=doc->cur_entry;
|
||||
while (*ptr) {
|
||||
ptr2=ptr;
|
||||
do ch=*ptr++;
|
||||
while (!Bt(char_bitmap,ch) || ch==CH_CURSOR && doc->flags&DOCF_NO_CURSOR);
|
||||
ptr--;
|
||||
if (!ch) {
|
||||
if (j=ptr-ptr2) {
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_TEXT | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_TEXT];
|
||||
if (doc->flags & DOCF_NO_CURSOR) {
|
||||
src=MAlloc(j+1);
|
||||
MemCpy(src,ptr2,j+1);
|
||||
StrUtil(src,SUF_REM_CTRL_CHARS);
|
||||
j=StrLen(src);
|
||||
} else
|
||||
src=ptr2;
|
||||
doc_e->tag=MAlloc(j+1,doc->mem_task);
|
||||
MemCpy(doc_e->tag,src,j+1);
|
||||
doc_e->max_col=j;
|
||||
DocInsEntry(doc,doc_e);
|
||||
if (doc->flags & DOCF_NO_CURSOR)
|
||||
Free(src);
|
||||
}
|
||||
} else {
|
||||
if (j=ptr-ptr2) {
|
||||
*ptr=0;
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_TEXT | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_TEXT];
|
||||
if (doc->flags & DOCF_NO_CURSOR) {
|
||||
src=MAlloc(j+1);
|
||||
MemCpy(src,ptr2,j+1);
|
||||
ptr3=src;
|
||||
ptr4=src;
|
||||
while (*ptr3)
|
||||
if (*ptr3!=CH_CURSOR)
|
||||
*ptr4++=*ptr3++;
|
||||
else
|
||||
ptr3++;
|
||||
*ptr4=0;
|
||||
j=ptr4-src;
|
||||
} else
|
||||
src=ptr2;
|
||||
doc_e->tag=MAlloc(j+1,doc->mem_task);
|
||||
MemCpy(doc_e->tag,src,j+1);
|
||||
doc_e->max_col=j;
|
||||
DocInsEntry(doc,doc_e);
|
||||
if (doc->flags & DOCF_NO_CURSOR)
|
||||
Free(src);
|
||||
*ptr=ch;
|
||||
}
|
||||
switch (ch) {
|
||||
case CH_CURSOR:
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_CURSOR | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_CURSOR];
|
||||
DocInsEntry(doc,doc_e);
|
||||
ptr++;
|
||||
break;
|
||||
case CH_FORM_FEED:
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_PAGE_BREAK | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_PAGE_BREAK];
|
||||
DocInsEntry(doc,doc_e);
|
||||
ptr++;
|
||||
break;
|
||||
case '\t':
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_TAB | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_TAB];
|
||||
DocInsEntry(doc,doc_e);
|
||||
ptr++;
|
||||
break;
|
||||
case '$$':
|
||||
ptr++; //skip first dollar
|
||||
ptr2=ptr;
|
||||
while (*ptr && *ptr!='$$')
|
||||
ptr++;
|
||||
if (*ptr) {
|
||||
*ptr=0; //zero second dollar
|
||||
if (ptr-1==ptr2 && *ptr2==CH_CURSOR) {
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_CURSOR | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_CURSOR];
|
||||
DocInsEntry(doc,doc_e);
|
||||
ptr2++;
|
||||
}
|
||||
if (ptr==ptr2) {
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_TEXT | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->max_col=1;
|
||||
if (doc->flags & DOCF_DBL_DOLLARS)
|
||||
doc_e->tag=StrNew("$$$$",doc->mem_task);
|
||||
else
|
||||
doc_e->tag=StrNew("$$",doc->mem_task);
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_TEXT];
|
||||
DocInsEntry(doc,doc_e);
|
||||
} else {
|
||||
st2=MAlloc(ptr-ptr2+1);
|
||||
ptr3=ptr2;
|
||||
ptr4=st2;
|
||||
while (ch=*ptr3++) {
|
||||
if (ch==CH_CURSOR) {
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_CURSOR | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_CURSOR];
|
||||
DocInsEntry(doc,doc_e);
|
||||
} else if (ch==CH_FORM_FEED) {
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_PAGE_BREAK |
|
||||
doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_PAGE_BREAK];
|
||||
DocInsEntry(doc,doc_e);
|
||||
} else
|
||||
*ptr4++=ch;
|
||||
}
|
||||
*ptr4=0;
|
||||
if (doc_e=PrsDollarCmd(doc,st2)) {
|
||||
result=doc_e;
|
||||
DocInsEntry(doc,doc_e);
|
||||
}
|
||||
Free(st);
|
||||
Free(st2);
|
||||
}
|
||||
*ptr++='$$';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_NEW_LINE | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_NEW_LINE];
|
||||
DocInsEntry(doc,doc_e);
|
||||
if (ch=='\r')
|
||||
while (*ptr=='\r')
|
||||
ptr++;
|
||||
if (*ptr=='\n')
|
||||
ptr++;
|
||||
while (*ptr=='\r')
|
||||
ptr++;
|
||||
}
|
||||
} else {
|
||||
old_color_names=LBts(&doc->flags,DOCf_COLOR_NAMES);
|
||||
st=Doc2PlainText(doc,doc_ce);
|
||||
LBEqu(&doc->flags,DOCf_COLOR_NAMES,old_color_names);
|
||||
DocEntryDel(doc,doc_ce);
|
||||
DocPrint(doc,"$$$$%Q$$$$",st);
|
||||
}
|
||||
DocRecalc(doc);
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return result;
|
||||
}
|
||||
|
||||
public CDocEntry *DocPrint(CDoc *doc,U8 *fmt,...)
|
||||
{//You must not print partial doc cmds.
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
CDocEntry *result=DocPutS(doc,buf);
|
||||
Free(buf);
|
||||
return result;
|
||||
U0 DocFlagsToggle(CDoc *doc,I64 tog_flags)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
I64 size,flags=doc->flags^tog_flags;
|
||||
U8 *st;
|
||||
CDocUndo *u_next,*u_last;
|
||||
|
||||
doc->flags|=DOCF_COLOR_NAMES;
|
||||
st=DocSave(doc,&size);
|
||||
|
||||
u_next=doc->undo_root.next;
|
||||
u_last=doc->undo_root.last;
|
||||
doc->undo_root.next=doc->undo_root.last=&doc->undo_root;
|
||||
|
||||
DocRst(doc,TRUE);
|
||||
doc->undo_root.next=u_next;
|
||||
doc->undo_root.last=u_last;
|
||||
DocUndoCntSet(doc);
|
||||
doc->flags=flags & ~(DOCG_BL_IV_UL|DOCF_WORD_WRAP);
|
||||
DocLoad(doc,st,size);
|
||||
DocCenter(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
Free(st);
|
||||
}
|
||||
+1
-611
@@ -1,423 +1,7 @@
|
||||
#help_index "DolDoc"
|
||||
|
||||
public I64 DocEntryRun(CDoc *doc,CDocEntry *doc_e,
|
||||
Bool exited,I64 *_has_action=NULL)
|
||||
{//Do action on final entry selected by user.
|
||||
//Sometimes returns locked, sometimes unlocked
|
||||
U8 ch=doc->cmd_U8,*st;
|
||||
I64 result=DOCM_CANCEL,has_action=FALSE;
|
||||
CHashDefineStr *temph;
|
||||
DocLock(doc);
|
||||
if (!exited) {
|
||||
if (doc_e->de_flags & DOCEF_ESC) {
|
||||
Msg(MSG_KEY_DOWN,CH_ESC,0,1<<SVCf_DONT_FILTER);
|
||||
has_action=TRUE;
|
||||
goto er_done;
|
||||
} if (doc_e->de_flags & DOCEF_QUIT) {
|
||||
Msg(MSG_KEY_DOWN,CH_SHIFT_ESC,0,1<<SVCf_DONT_FILTER);
|
||||
has_action=TRUE;
|
||||
goto er_done;
|
||||
} else if (doc_e->de_flags & DOCEF_CHECK_COLLAPSABLE) {
|
||||
doc_e->de_flags^=DOCEF_CHECKED_COLLAPSED;
|
||||
has_action=TRUE;
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (ch==CH_SPACE) {
|
||||
if (doc_e->de_flags & DOCEF_LINK && doc->left_click_link) {
|
||||
result=(*doc->left_click_link)(doc,doc_e);
|
||||
has_action=TRUE;
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_LEFT_EXP) {
|
||||
result=doc_e->left_exp;
|
||||
has_action=TRUE;
|
||||
Msg(MSG_CMD,result,0,1<<SVCf_DONT_FILTER);
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_LEFT_CB && doc_e->left_cb) {
|
||||
DocUnlock(doc);
|
||||
result=(*doc_e->left_cb)(doc,doc_e);
|
||||
has_action=TRUE;
|
||||
Msg(MSG_CMD,result,0,1<<SVCf_DONT_FILTER);
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_LEFT_MACRO) {
|
||||
if (doc_e->de_flags & DOCEF_POPUP) {
|
||||
st=StrNew(doc_e->left_macro);
|
||||
DocUnlock(doc);
|
||||
PopUp(st,Fs);
|
||||
Free(st);
|
||||
} else {
|
||||
if (doc_e->de_flags & DOCEF_LEFT_AUTO)
|
||||
AutoStr("%s",doc_e->left_macro);
|
||||
else
|
||||
Auto("%s",doc_e->left_macro);
|
||||
}
|
||||
has_action=TRUE;
|
||||
}
|
||||
if (!exited && doc_e->de_flags & DOCEF_LST &&
|
||||
doc_e->de_flags & DOCEF_DEFINE &&
|
||||
(temph=HashFind(doc_e->define_str,
|
||||
doc->win_task->hash_table,HTT_DEFINE_STR)) &&
|
||||
(result=PopUpPickLst(temph->data))!=DOCM_CANCEL) {
|
||||
DocDataFmt(doc,doc_e,result);
|
||||
DocDataScan(doc,doc_e);
|
||||
has_action=TRUE;
|
||||
}
|
||||
} else if (ch=='\n') {
|
||||
if (doc_e->de_flags & DOCEF_LINK && doc->right_click_link) {
|
||||
result=(*doc->right_click_link)(doc,doc_e);
|
||||
has_action=TRUE;
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_EXP) {
|
||||
result=doc_e->right_exp;
|
||||
has_action=TRUE;
|
||||
Msg(MSG_CMD,result,0,1<<SVCf_DONT_FILTER);
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_CB && doc_e->right_cb) {
|
||||
DocUnlock(doc);
|
||||
result=(*doc_e->right_cb)(doc,doc_e);
|
||||
has_action=TRUE;
|
||||
Msg(MSG_CMD,result,0,1<<SVCf_DONT_FILTER);
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_MACRO) {
|
||||
if (doc_e->de_flags & DOCEF_POPUP) {
|
||||
st=StrNew(doc_e->right_macro);
|
||||
DocUnlock(doc);
|
||||
PopUp(st,Fs);
|
||||
Free(st);
|
||||
} else {
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_AUTO)
|
||||
AutoStr("%s",doc_e->right_macro);
|
||||
else
|
||||
Auto("%s",doc_e->right_macro);
|
||||
}
|
||||
has_action=TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
DocBottom(doc);
|
||||
doc->cmd_U8=CH_SPACE;
|
||||
er_done:
|
||||
if (_has_action) *_has_action=has_action;
|
||||
return result;
|
||||
}
|
||||
|
||||
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 I64 DocGetKey(I64 *_sc=NULL)
|
||||
{//Called by $LK,"View",A="MN:View"$. You probably don't need this.
|
||||
I64 ch,sc;
|
||||
Bool cont,old_preempt=IsPreempt;
|
||||
do {
|
||||
ch=GetKey(&sc,TRUE);
|
||||
DocRecalc(DocPut);
|
||||
cont=FALSE;
|
||||
if (ch==CH_ESC || ch==CH_SHIFT_ESC) {//Check for exit filter mode
|
||||
Preempt;
|
||||
if (DocPut && DocPut->find_replace->filter_lines) {
|
||||
EdUndoFilter(DocPut);
|
||||
cont=TRUE;
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
} while (cont);
|
||||
if (_sc) *_sc=sc;
|
||||
return ch;
|
||||
}
|
||||
|
||||
#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"
|
||||
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 result,unlock,old_preempt;
|
||||
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,TASK_TITLE_LEN);
|
||||
}
|
||||
doc_e=DocPrint(bdoc,"$$DA-TRM-P+BD+RD+CX+IV,140,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,32,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,32,A=\"Line:%%04d \"$$");
|
||||
doc_e->data=&doc->line;
|
||||
DocDataFmt(bdoc,doc_e);
|
||||
doc_e=DocPrint(bdoc,"$$DA+BD+RD-TRM,32,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);
|
||||
old_preempt=Preempt;
|
||||
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;
|
||||
|
||||
Preempt(old_preempt);
|
||||
DocUnlock(doc);
|
||||
if (!(dof_flags&DOF_DONT_WINMGR_SYNC)) {
|
||||
WinMgrSync(2,TRUE);
|
||||
if (doc->flags&DOCF_MIN_SIZE)
|
||||
WinMgrSync(2,TRUE);
|
||||
}
|
||||
result=View;
|
||||
|
||||
Preempt;
|
||||
DocLock(doc);
|
||||
if (result) {
|
||||
doc_e=doc->root.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);
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
return result;
|
||||
}
|
||||
|
||||
#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;
|
||||
CDoc *doc;
|
||||
Bool result=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;
|
||||
while (ml) {
|
||||
if (fmtstr=MemberMetaData("fmtstr",ml)) {
|
||||
doc_e=DocPrint(doc,"%s",fmtstr);
|
||||
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->root.next!=doc) {
|
||||
Fs->border_src=BDS_CONST;
|
||||
DocRecalc(doc);
|
||||
if (DocEd(doc,dof_flags)) {
|
||||
doc_e=doc->cur_entry;
|
||||
result=TRUE;
|
||||
if (doc_e!=doc) {
|
||||
if (DocEntryRun(doc,doc_e,TRUE,&has_action)==DOCM_CANCEL && has_action)
|
||||
result=FALSE;
|
||||
DocUnlock(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
DocDel(doc);
|
||||
Fs->border_src=old_border_src;
|
||||
return result;
|
||||
}
|
||||
|
||||
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,result=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) {
|
||||
result=DocEntryRun(m,doc_e,TRUE,&has_action);
|
||||
DocUnlock(m);
|
||||
if (!has_action) {
|
||||
result=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 result;
|
||||
}
|
||||
|
||||
#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 result=PopUp(st,parent,_pu_task);
|
||||
Free(st);
|
||||
return result;
|
||||
}
|
||||
|
||||
#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("Preempt(ON);DocEd(0x%X,0x%X);",doc,dof_flags);
|
||||
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);
|
||||
@@ -443,20 +27,6 @@ public CTask *PopUpViewPrint(U8 *fmt,...)
|
||||
return task;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;StdIn/DolDoc"
|
||||
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);
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Input;File/FileNames;StdIn/DolDoc"
|
||||
public U8 *PopUpPickFile(U8 *dir=NULL)
|
||||
{//Filename chooser. Uses $LK,"FileMgr",A="MN:FileMgr"$().
|
||||
@@ -594,25 +164,6 @@ public Bool PopUpCancelOk(U8 *header=NULL,U8 *footer=NULL)
|
||||
return PopUp2("OKAY",1,"CANCEL",0,header,footer)>0;
|
||||
}
|
||||
|
||||
#define RSAC_REPLACE 0
|
||||
#define RSAC_SKIP 1
|
||||
#define RSAC_ALL 2
|
||||
|
||||
I64 PopUpReplaceSkipAllCancel(U8 *header=NULL,U8 *footer=NULL)
|
||||
{
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
if (header) DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"$$CM+LX,1,4$$$$BT,\"REPLACE\",LE=RSAC_REPLACE$$"
|
||||
"$$CM+LX,17,0$$$$BT,\"SKIP\",LE=RSAC_SKIP$$"
|
||||
"$$CM+LX,1,3$$$$BT,\"ALL\",LE=RSAC_ALL$$"
|
||||
"$$CM+LX,17,0$$$$BT,\"CANCEL\",LE=DOCM_CANCEL$$\n");
|
||||
if (footer) DocPrint(doc,"%s",footer);
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
U8 *PopUpGetStr2(U8 *header,CTask *mem_task)
|
||||
{
|
||||
U8 *result,*st;
|
||||
@@ -753,164 +304,3 @@ public I64 PopUpFile(U8 *filename,Bool warn_ext=TRUE,
|
||||
Free(name);
|
||||
return result;
|
||||
}
|
||||
|
||||
#help_index "Graphics/Input"
|
||||
public I64 PopUpColor(U8 *header=NULL,
|
||||
Bool allow_transparent=TRUE,Bool allow_dft=TRUE)
|
||||
{//Chooser for 16-color, default or transparent.
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
if (header)
|
||||
DocPrint(doc,"%s",header);
|
||||
if (allow_transparent)
|
||||
DocPrint(doc,"$$MU,\"TRANSPARENT\",LE=TRANSPARENT$$\n");
|
||||
for (i=0;i<NUM_COLORS;i++)
|
||||
DocPrint(doc,"$$BG,%d$$$$MU,\"__%-8Z__\",LE=%d$$$$BG$$\n",i,i,"ST_COLORS",i);
|
||||
if (allow_dft)
|
||||
DocPrint(doc,"$$BG,WHITE$$$$MU,\"DEFAULT\",LE=DOC_DFT$$$$BG$$");
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
public I64 PopUpColorLighting(U8 *header=NULL)
|
||||
{//Chooser for std TempleOS $LK,"DCLighting",A="MN:DCLighting"$() color.
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
if (header)
|
||||
DocPrint(doc,"%s",header);
|
||||
DocPrint(doc,"\nSingle-Sided means both sides same color."
|
||||
"\nDouble-Sided means back side darker."
|
||||
"\n"
|
||||
"\nHalf-Range means 0 to [0,7]"
|
||||
"\n [8,15]-8 to [8,15]"
|
||||
"\nFull-Range means 0 to [0,7] to [0,7]+8"
|
||||
"\n");
|
||||
DocPrint(doc,
|
||||
"\n$$LTPURPLE$$Single-Sided Full-Range Double-Sided Full-Range\n$$BLACK$$");
|
||||
for (i=0;i<NUM_COLORS/2;i++) {
|
||||
DocPrint(doc,"$$BG,%d$$$$MU,\"__%-19Z__\",LE=%d$$$$BG$$ ",i,i,"ST_COLORS",i);
|
||||
DocPrint(doc,"$$BG,%d$$$$MU,\"__%-19Z__\",LE=%d$$$$BG$$\n",i,i,"ST_COLORS",
|
||||
ROPF_TWO_SIDED+i);
|
||||
}
|
||||
DocPrint(doc,
|
||||
"\n$$LTPURPLE$$Single-Sided Half-Range Double-Sided Half-Range\n$$BLACK$$");
|
||||
for (i=0;i<NUM_COLORS;i++) {
|
||||
DocPrint(doc,"$$BG,%d$$$$MU,\"__%-19Z__\",LE=%d$$$$BG$$ ",
|
||||
i,i,"ST_COLORS",ROPF_HALF_RANGE_COLOR+i);
|
||||
DocPrint(doc,"$$BG,%d$$$$MU,\"__%-19Z__\",LE=%d$$$$BG$$\n",
|
||||
i,i,"ST_COLORS",ROPF_TWO_SIDED+ROPF_HALF_RANGE_COLOR+i);
|
||||
}
|
||||
i=PopUpMenu(doc);
|
||||
DocDel(doc);
|
||||
return i;
|
||||
}
|
||||
|
||||
class CTransformForm
|
||||
{
|
||||
F64 x_scale fmtstr "$$DA-TRM,32,RT=F64,A=\"X Scale :%12.6f\"$$\n";
|
||||
F64 y_scale fmtstr "$$DA-TRM,32,RT=F64,A=\"Y Scale :%12.6f\"$$\n";
|
||||
F64 z_scale fmtstr "$$DA-TRM,32,RT=F64,A=\"Z Scale :%12.6f\"$$\n";
|
||||
F64 é_z fmtstr
|
||||
"\nAngles are in degrees\n$$DA-TRM,32,RT=F64,A=\"Z-Axis :%12.6f\"$$\n";
|
||||
F64 é_y fmtstr "$$DA-TRM,32,RT=F64,A=\"Y-Axis :%12.6f\"$$\n";
|
||||
F64 é_x fmtstr "$$DA-TRM,32,RT=F64,A=\"X-Axis :%12.6f\"$$\n";
|
||||
F64 x_offset fmtstr "\n$$DA-TRM,32,RT=F64,A=\"X Offset:%12.6f\"$$\n";
|
||||
F64 y_offset fmtstr "$$DA-TRM,32,RT=F64,A=\"Y Offset:%12.6f\"$$\n";
|
||||
F64 z_offset fmtstr "$$DA-TRM,32,RT=F64,A=\"Z Offset:%12.6f\"$$\n";
|
||||
};
|
||||
|
||||
Bool PopUpTransform(I64 *r)
|
||||
{
|
||||
CTransformForm *tf=MAlloc(sizeof(CTransformForm));
|
||||
tf->x_scale=1.0;
|
||||
tf->y_scale=1.0;
|
||||
tf->z_scale=1.0;
|
||||
tf->é_x=0.0;
|
||||
tf->é_y=0.0;
|
||||
tf->é_z=0.0;
|
||||
tf->x_offset=0.0;
|
||||
tf->y_offset=0.0;
|
||||
tf->z_offset=0.0;
|
||||
if (PopUpForm(tf)) {
|
||||
MemSet(r,0,16*sizeof(I64));
|
||||
r[0] =tf->x_scale*GR_SCALE;
|
||||
r[5] =tf->y_scale*GR_SCALE;
|
||||
r[10]=tf->z_scale*GR_SCALE;
|
||||
r[15]=GR_SCALE;
|
||||
|
||||
Mat4x4RotZ(r,tf->é_z*ã/180.0);
|
||||
Mat4x4RotY(r,tf->é_y*ã/180.0);
|
||||
Mat4x4RotX(r,tf->é_x*ã/180.0);
|
||||
|
||||
r[3] =tf->x_offset*GR_SCALE;
|
||||
r[7] =tf->y_offset*GR_SCALE;
|
||||
r[11]=tf->z_offset*GR_SCALE;
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define PU_SPACING 10
|
||||
U0 DrawIt(CTask *task,CDC *dc)
|
||||
{
|
||||
I64 i,j,i1,j1;
|
||||
CDoc *doc=DocPut(task);
|
||||
for (j=0;j<17;j++)
|
||||
for (i=0;i<17;i++) {
|
||||
if (j<16)
|
||||
j1=j;
|
||||
else
|
||||
j1=TRANSPARENT;
|
||||
if (i<16)
|
||||
i1=i;
|
||||
else
|
||||
i1=TRANSPARENT;
|
||||
dc->color=j1+i1<<16+ROPF_DITHER;
|
||||
GrRect(dc,i*PU_SPACING,j*PU_SPACING+FramePtr("DitherFrame",task),
|
||||
PU_SPACING,PU_SPACING);
|
||||
}
|
||||
i=(17*PU_SPACING+FONT_WIDTH-1)/FONT_WIDTH;
|
||||
if (doc->max_x>i) i=doc->max_x;
|
||||
WinHorz(task->win_left,task->win_left+i,task);
|
||||
WinVert(task->win_top,task->win_top+doc->max_y+
|
||||
(17*PU_SPACING+FONT_WIDTH-1)/FONT_WIDTH,task);
|
||||
}
|
||||
|
||||
I64 DitherColor2(U8 *header=NULL)
|
||||
{
|
||||
I64 msg_code,a1,a2,result=-1,i,j;
|
||||
DocClear;
|
||||
"%s",header;
|
||||
DocRecalc(DocPut);
|
||||
FramePtrAdd("DitherFrame",(DocPut->max_y+1)*FONT_HEIGHT);
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
Fs->draw_it=&DrawIt;
|
||||
do {
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_DOWN|1<<MSG_KEY_DOWN);
|
||||
if (msg_code==MSG_IP_L_DOWN) {
|
||||
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_UP);
|
||||
i=a1/PU_SPACING;
|
||||
j=(a2-FramePtr("DitherFrame"))/PU_SPACING;
|
||||
if (a1>=0 && a2>=0 && 0<=j<17 && 0<=i<17) {
|
||||
if (j==16) j=TRANSPARENT;
|
||||
if (i==16) i=TRANSPARENT;
|
||||
result=j+i<<16+ROPF_DITHER;
|
||||
goto dc_done;
|
||||
}
|
||||
}
|
||||
} while (!(msg_code==MSG_KEY_DOWN && (a1==CH_ESC || a1==CH_SHIFT_ESC)));
|
||||
do GetMsg(&a1,&a2,1<<MSG_KEY_UP);
|
||||
while (!a1);
|
||||
dc_done:
|
||||
SettingsPop;
|
||||
FramePtrDel("DitherFrame");
|
||||
return result;
|
||||
}
|
||||
|
||||
public I64 PopUpColorDither(U8 *header=NULL)
|
||||
{//Chooser for 2 x 16 colors or transparent.
|
||||
U8 buf[STR_LEN];
|
||||
StrPrint(buf,"DitherColor2(0x%X);",header);
|
||||
return PopUp(buf,Fs);
|
||||
}
|
||||
@@ -0,0 +1,729 @@
|
||||
#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
|
||||
EdInsChar(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, Select");
|
||||
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, Select");
|
||||
else
|
||||
KeyDescSet("Edit/GoTo Doc End");
|
||||
} else {
|
||||
while (doc_ce!=doc) {
|
||||
BEqu(&doc_ce->type,DOCEt_SELECTED,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, Select");
|
||||
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, Select");
|
||||
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_SELECTED,sc&SCF_SHIFT);
|
||||
doc_ce=doc->cur_entry=doc_ce->last;
|
||||
}
|
||||
doc_ce=doc->cur_entry=doc->root.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, Select");
|
||||
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, Select");
|
||||
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->root.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, Select");
|
||||
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, Select");
|
||||
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
|
||||
EdDelChar(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_util_task))
|
||||
PostMsgWait(sys_macro_util_task,
|
||||
MSG_KEY_DOWN_UP,CH_SHIFT_ESC,0);
|
||||
SysMacroStripKey(&sys_macro_root,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--;
|
||||
EdDelChar(doc);
|
||||
}
|
||||
} else {
|
||||
doc->cur_col--;
|
||||
EdDelChar(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLI:
|
||||
if (sc.u8[0]!=SC_TAB) {
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Indent Out");
|
||||
else
|
||||
DocPrint(doc,"$$ID,-2$$");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Dol /Indent In");
|
||||
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
|
||||
EdInsChar(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
|
||||
EdCodeTools(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("::/Home/PersonalNotes.TXT.Z");
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Cmd /Personal Menu");
|
||||
else {
|
||||
m=DocRead("::/Home/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_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS))) {
|
||||
DocUnlock(doc);
|
||||
if (doc_ce->type_u8==DOCT_SPRITE)
|
||||
EdSpriteEd(doc,
|
||||
(doc_ce->x-doc->line_start_col+doc_ce->max_col)*
|
||||
FONT_WIDTH,(doc_ce->y-doc->top_line_num)*FONT_HEIGHT);
|
||||
else
|
||||
EdSpriteIns(doc,
|
||||
(doc_ce->x+doc->cur_col-doc->line_start_col)*FONT_WIDTH,
|
||||
(doc_ce->y-doc->top_line_num)*FONT_HEIGHT);
|
||||
DocLock(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CH_CTRLS:
|
||||
if (sc&SCF_SHIFT) {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Find Misspelled");
|
||||
else
|
||||
ACFindMisspelled(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
|
||||
DocEntryToggle(doc);
|
||||
} else {
|
||||
if (sc&SCF_KEY_DESC)
|
||||
KeyDescSet("Edit/Toggle Plain Text Display");
|
||||
else
|
||||
if (!(doc->flags&DOCF_FORM) ||
|
||||
doc->flags&(DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_WITH_TABS))
|
||||
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
|
||||
EdDelLine(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,358 @@
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
|
||||
CDocEntry *DocPutS(CDoc *doc,U8 *st)
|
||||
{//Don't use this. Use $LK-UL,"DocPrint",A="MN:DocPrint"$().
|
||||
//Does not handle partial Doc entries
|
||||
//Returns last newly created dollar-sign CDocEntry.
|
||||
U8 *ptr=st,*ptr2,*st2,*ptr3,*ptr4,*src,
|
||||
*char_bitmap;
|
||||
Bool unlock;
|
||||
I64 ch,j;
|
||||
CDocEntry *doc_e=NULL,*result=NULL,*doc_ce;
|
||||
if (!st || !doc && !(doc=DocPut) || doc->doc_signature!=DOC_SIGNATURE_VAL)
|
||||
return NULL;
|
||||
unlock=DocLock(doc);
|
||||
if (doc->flags & DOCF_PLAIN_TEXT_WITH_TABS)
|
||||
char_bitmap=chars_bmp_zero_cr_nl_cursor;
|
||||
else if (doc->flags & DOCF_PLAIN_TEXT)
|
||||
char_bitmap=chars_bmp_zero_tab_ff_cr_nl_cursor;
|
||||
else
|
||||
char_bitmap=chars_bmp_zero_tab_ff_cr_nl_cursor_dollar;
|
||||
doc_ce=doc->cur_entry;
|
||||
while (*ptr) {
|
||||
ptr2=ptr;
|
||||
do ch=*ptr++;
|
||||
while (!Bt(char_bitmap,ch) || ch==CH_CURSOR && doc->flags&DOCF_NO_CURSOR);
|
||||
ptr--;
|
||||
if (!ch) {
|
||||
if (j=ptr-ptr2) {
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_TEXT | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_TEXT];
|
||||
if (doc->flags & DOCF_NO_CURSOR) {
|
||||
src=MAlloc(j+1);
|
||||
MemCpy(src,ptr2,j+1);
|
||||
StrUtil(src,SUF_REM_CTRL_CHARS);
|
||||
j=StrLen(src);
|
||||
} else
|
||||
src=ptr2;
|
||||
doc_e->tag=MAlloc(j+1,doc->mem_task);
|
||||
MemCpy(doc_e->tag,src,j+1);
|
||||
doc_e->max_col=j;
|
||||
DocInsEntry(doc,doc_e);
|
||||
if (doc->flags & DOCF_NO_CURSOR)
|
||||
Free(src);
|
||||
}
|
||||
} else {
|
||||
if (j=ptr-ptr2) {
|
||||
*ptr=0;
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_TEXT | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_TEXT];
|
||||
if (doc->flags & DOCF_NO_CURSOR) {
|
||||
src=MAlloc(j+1);
|
||||
MemCpy(src,ptr2,j+1);
|
||||
ptr3=src;
|
||||
ptr4=src;
|
||||
while (*ptr3)
|
||||
if (*ptr3!=CH_CURSOR)
|
||||
*ptr4++=*ptr3++;
|
||||
else
|
||||
ptr3++;
|
||||
*ptr4=0;
|
||||
j=ptr4-src;
|
||||
} else
|
||||
src=ptr2;
|
||||
doc_e->tag=MAlloc(j+1,doc->mem_task);
|
||||
MemCpy(doc_e->tag,src,j+1);
|
||||
doc_e->max_col=j;
|
||||
DocInsEntry(doc,doc_e);
|
||||
if (doc->flags & DOCF_NO_CURSOR)
|
||||
Free(src);
|
||||
*ptr=ch;
|
||||
}
|
||||
switch (ch) {
|
||||
case CH_CURSOR:
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_CURSOR | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_CURSOR];
|
||||
DocInsEntry(doc,doc_e);
|
||||
ptr++;
|
||||
break;
|
||||
case CH_FORM_FEED:
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_PAGE_BREAK | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_PAGE_BREAK];
|
||||
DocInsEntry(doc,doc_e);
|
||||
ptr++;
|
||||
break;
|
||||
case '\t':
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_TAB | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_TAB];
|
||||
DocInsEntry(doc,doc_e);
|
||||
ptr++;
|
||||
break;
|
||||
case '$$':
|
||||
ptr++; //skip first dollar
|
||||
ptr2=ptr;
|
||||
while (*ptr && *ptr!='$$')
|
||||
ptr++;
|
||||
if (*ptr) {
|
||||
*ptr=0; //zero second dollar
|
||||
if (ptr-1==ptr2 && *ptr2==CH_CURSOR) {
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_CURSOR | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_CURSOR];
|
||||
DocInsEntry(doc,doc_e);
|
||||
ptr2++;
|
||||
}
|
||||
if (ptr==ptr2) {
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_TEXT | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->max_col=1;
|
||||
if (doc->flags & DOCF_DBL_DOLLARS)
|
||||
doc_e->tag=StrNew("$$$$",doc->mem_task);
|
||||
else
|
||||
doc_e->tag=StrNew("$$",doc->mem_task);
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_TEXT];
|
||||
DocInsEntry(doc,doc_e);
|
||||
} else {
|
||||
st2=MAlloc(ptr-ptr2+1);
|
||||
ptr3=ptr2;
|
||||
ptr4=st2;
|
||||
while (ch=*ptr3++) {
|
||||
if (ch==CH_CURSOR) {
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_CURSOR | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_CURSOR];
|
||||
DocInsEntry(doc,doc_e);
|
||||
} else if (ch==CH_FORM_FEED) {
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_PAGE_BREAK |
|
||||
doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_PAGE_BREAK];
|
||||
DocInsEntry(doc,doc_e);
|
||||
} else
|
||||
*ptr4++=ch;
|
||||
}
|
||||
*ptr4=0;
|
||||
if (doc_e=PrsDollarCmd(doc,st2)) {
|
||||
result=doc_e;
|
||||
DocInsEntry(doc,doc_e);
|
||||
}
|
||||
Free(st2);
|
||||
}
|
||||
*ptr++='$$';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
doc_e=CAlloc(sizeof(CDocEntryBase),doc->mem_task);
|
||||
doc_e->type=DOCT_NEW_LINE | doc->settings_root.dft_text_attr<<8;
|
||||
doc_e->de_flags=doldoc.dft_de_flags[DOCT_NEW_LINE];
|
||||
DocInsEntry(doc,doc_e);
|
||||
if (ch=='\r')
|
||||
while (*ptr=='\r')
|
||||
ptr++;
|
||||
if (*ptr=='\n')
|
||||
ptr++;
|
||||
while (*ptr=='\r')
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return result;
|
||||
}
|
||||
|
||||
public CDocEntry *DocPrint(CDoc *doc,U8 *fmt,...)
|
||||
{//You must not print partial doc cmds.
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
CDocEntry *result=DocPutS(doc,buf);
|
||||
Free(buf);
|
||||
return result;
|
||||
}
|
||||
|
||||
public U0 DocPrintPartial(CDoc *doc,U8 *fmt,...)
|
||||
{//Lets you print half a doc cmd, if you like.
|
||||
U8 *buf,*b,*src,*dst,*ptr,*ptr2;
|
||||
Bool unlock;
|
||||
CDocEntry *doc_ce,*doc_ne;
|
||||
I64 ch,i,j;
|
||||
if (!fmt)
|
||||
return;
|
||||
buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
ptr=buf;
|
||||
if (doc->user_put_s && (*doc->user_put_s)(doc,doc->user_put_data,buf)) {
|
||||
Free(buf);
|
||||
return;
|
||||
}
|
||||
unlock=DocLock(doc);
|
||||
if (doc->cur_entry->type_u8==DOCT_DATA)
|
||||
while (ch=*ptr++)
|
||||
DocPutKey(doc,ch,0);
|
||||
else
|
||||
while (ch=*ptr) {
|
||||
if (!Bt(chars_bmp_safe_dollar,ch) ||
|
||||
doc->flags & (DOCF_OVERSTRIKE | DOCF_IN_DOLLAR)) {
|
||||
DocPutKey(doc,ch,0);
|
||||
ptr++;
|
||||
} else {
|
||||
ptr2=ptr++;
|
||||
while (TRUE) {
|
||||
ch=*ptr++;
|
||||
if (!Bt(chars_bmp_safe_dollar,ch))
|
||||
break;
|
||||
}
|
||||
ptr--;
|
||||
*ptr=0;
|
||||
doc_ce=doc->cur_entry;
|
||||
j=ptr-ptr2;
|
||||
if (IsEditableText(doc_ce)) {
|
||||
dst=b=MAlloc(doc_ce->max_col+j+1,doc->mem_task);
|
||||
src=doc_ce->tag;
|
||||
i=doc->cur_col;
|
||||
doc->cur_col+=j;
|
||||
doc_ce->max_col+=j;
|
||||
while (i-->0)
|
||||
*dst++=*src++;
|
||||
while (j-->0)
|
||||
*dst++=*ptr2++;
|
||||
while (*dst++=*src++);
|
||||
Free(doc_ce->tag);
|
||||
doc_ce->tag=b;
|
||||
} else {
|
||||
dst=MAlloc(j+1,doc->mem_task);
|
||||
MemCpy(dst,ptr2,j+1);
|
||||
doc_ne=DocEntryNew(doc,doc_ce,dst);
|
||||
doc_ne->type=DOCT_TEXT | doc->settings_root.dft_text_attr<<8;
|
||||
doc_ne->de_flags=doldoc.dft_de_flags[DOCT_TEXT];
|
||||
QueIns(doc_ne,doc_ce->last);
|
||||
doc->cur_entry=doc_ne;
|
||||
doc->cur_col=StrLen(ptr2);
|
||||
}
|
||||
*ptr=ch;
|
||||
DocRemSoftNewLines(doc,doc->cur_entry);
|
||||
}
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
if (!(doc->flags&DOCF_DONT_SWAP_OUT))
|
||||
Yield;
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
Bool KDDocPutS(U8 *st)
|
||||
{
|
||||
CDoc *doc;
|
||||
if (doc=DocPut)
|
||||
DocPrintPartial(doc,"%s",st);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public U0 DocPrintAtomic(CDoc *doc,U8 *fmt,...)
|
||||
{//Prints multiple whole cmds all-at-once. Might need this when printing trees.
|
||||
U8 *buf;
|
||||
Bool unlock;
|
||||
I64 old_flags;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
unlock=DocLock(doc);
|
||||
old_flags=doc->flags;
|
||||
doc->flags|=DOCF_NO_CURSOR;
|
||||
DocPrint(doc,"%s",buf);
|
||||
DocRecalc(doc);
|
||||
doc->flags=old_flags;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
Free(buf);
|
||||
}
|
||||
|
||||
U0 DocDump(CDoc *doc,I64 uS_delay=0)
|
||||
{
|
||||
U8 *st;
|
||||
CDocEntry *doc_e,*doc_e2;
|
||||
Bool unlock=DocLock(doc);
|
||||
doc_e=doc->root.next;
|
||||
while (doc_e!=doc) {
|
||||
st=DocScanLine(doc,doc_e,NULL,&doc_e2);
|
||||
"%s",st;
|
||||
Free(st);
|
||||
doc_e=doc_e2;
|
||||
if (doc_e->type_u8==DOCT_NEW_LINE) {
|
||||
'\n';
|
||||
BusyWait(uS_delay);
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
}
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public CDocEntry *DocPutLine(CDoc *doc=NULL,CDocEntry *doc_e)
|
||||
{//Send line from other doc to StdOut $LK,"DocPut",A="MN:DocPut"$.
|
||||
I64 ch;
|
||||
U8 *ptr,*ptr2;
|
||||
Bool unlock;
|
||||
if (!doc && !(doc=DocPut) || doc->doc_signature!=DOC_SIGNATURE_VAL)
|
||||
return NULL;
|
||||
unlock=DocLock(doc);
|
||||
while (doc_e!=doc && doc_e->type_u8!=DOCT_NEW_LINE) {
|
||||
if (doc_e->de_flags&DOCEF_TAG) {
|
||||
ptr=doc_e->tag;
|
||||
do {
|
||||
ptr2=ptr;
|
||||
while (ch=*ptr)
|
||||
if (ch=='$$')
|
||||
break;
|
||||
else
|
||||
ptr++;
|
||||
*ptr=0;
|
||||
"%s",ptr2;
|
||||
*ptr=ch;
|
||||
if (ch=='$$') {
|
||||
"$$$$";
|
||||
ptr++;
|
||||
}
|
||||
} while (ch);
|
||||
} else if (doc_e->type_u8==DOCT_TAB)
|
||||
'\t';
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
'\n';
|
||||
if (doc_e!=doc)
|
||||
doc_e=doc_e->next;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
return doc_e;
|
||||
}
|
||||
|
||||
#help_index "Debugging/Dump;DolDoc/Cmd Line (Typically);"\
|
||||
"Cmd Line (Typically);DolDoc/Output;StdOut/DolDoc"
|
||||
public U0 DocDm(U8 *buf,I64 cnt=0x80)
|
||||
{//Dump live chunk of mem showing addresses. Can be edited.
|
||||
CDocEntry *doc_e;
|
||||
CDoc *doc=DocPut;
|
||||
Bool unlock=DocLock(doc);
|
||||
doc_e=DocPrint(doc,"$$HX-Z,%d,16$$",cnt);
|
||||
doc_e->data=buf;
|
||||
doc->cur_entry=doc_e->next;
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
public U0 DocD(U8 *buf,I64 cnt=0x80)
|
||||
{//Dump live chunk of mem showing offsets. Can be edited.
|
||||
CDocEntry *doc_e;
|
||||
CDoc *doc=DocPut;
|
||||
Bool unlock=DocLock(doc);
|
||||
doc_e=DocPrint(doc,"$$HX,%d,16$$",cnt);
|
||||
doc_e->data=buf;
|
||||
doc->cur_entry=doc_e->next;
|
||||
DocRecalc(doc);
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
@@ -606,7 +606,7 @@ public Bool DocRecalc(CDoc *doc,Bool has_cursor=FALSE,I64 recalc=DOC_RECALC)
|
||||
case DOCT_TEXT:
|
||||
if (!col2 && !(doc_e->de_flags
|
||||
&(DOCEF_TREE|DOCEF_LST|DOCEF_TAG_CB|DOCEF_DEFINE|
|
||||
DOCEF_HTML_LINK|DOCEF_BIN_PTR_LINK)))
|
||||
DOCEF_AUX_STR|DOCEF_HTML_LINK|DOCEF_BIN_PTR_LINK)))
|
||||
del_cl=TRUE;
|
||||
break;
|
||||
case DOCT_HEX_ED:
|
||||
@@ -6,21 +6,6 @@ I64 DocCharDist(CDoc *doc,I64 x,I64 y)
|
||||
return (SqrI64(doc->x-x)+SqrI64(doc->y-y))*FONT_WIDTH*FONT_WIDTH;
|
||||
}
|
||||
|
||||
public U0 DocCenter(CDoc *doc=NULL,I64 recalc=DOC_RECALC)
|
||||
{//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,FALSE,recalc);
|
||||
if (!(doc->flags&DOCF_BORDER_DOC))
|
||||
doc->top_line_num=doc->y-(task->win_height+1)>>1;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
U0 DocDelToNum(CDoc *doc,I64 num)
|
||||
{
|
||||
CDocEntry *doc_e=doc->root.next,*doc_e2;
|
||||
@@ -62,7 +47,6 @@ U0 DocBorderLstDraw(CDoc *doc)
|
||||
U64 ch;
|
||||
CDoc *templ=doc;
|
||||
CD3I64 saved_scroll;
|
||||
Bool old_preempt=Preempt;
|
||||
while (templ && templ->doc_signature==DOC_SIGNATURE_VAL) {
|
||||
y+=(Bsr(templ->desc)+7)>>3+1; //StrLen+1
|
||||
templ=templ->parent_doc;
|
||||
@@ -84,7 +68,40 @@ U0 DocBorderLstDraw(CDoc *doc)
|
||||
templ=templ->parent_doc;
|
||||
}
|
||||
WinScrollRestore(win_task,&saved_scroll);
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
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->root.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=DOC_RECALC)
|
||||
{//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,FALSE,recalc);
|
||||
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)
|
||||
@@ -145,25 +162,21 @@ public U0 DocCollapse(Bool collapse=TRUE,CDoc *doc=NULL)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Output;StdOut/DolDoc"
|
||||
public U0 DocPrintAtomic(CDoc *doc,U8 *fmt,...)
|
||||
{//Necessary when hidden text might screw-up
|
||||
//inserts. It does multiple whole doc cmds all-at-once.
|
||||
U8 *buf;
|
||||
Bool unlock;
|
||||
I64 old_flags;
|
||||
if (!doc && !(doc=DocPut))
|
||||
return;
|
||||
buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
unlock=DocLock(doc);
|
||||
old_flags=doc->flags;
|
||||
doc->flags|=DOCF_NO_CURSOR;
|
||||
DocPrint(doc,"%s",buf);
|
||||
DocRecalc(doc);
|
||||
doc->flags=old_flags;
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
Free(buf);
|
||||
#help_index "DolDoc/Cmd Line (Typically);Cmd Line (Typically)"
|
||||
public I64 DocMax(I64 i=MAX_I64)
|
||||
{//Set max document entries. (Cmd line buffer.)
|
||||
//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 result;
|
||||
CDoc *doc;
|
||||
if (doc=DocPut) {
|
||||
result=doc->max_entries;
|
||||
doc->max_entries=i;
|
||||
return result;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#help_index "DolDoc/Task;StdOut/Task"
|
||||
@@ -172,7 +185,6 @@ U0 DocUpdateTaskDocs(CTask *task)
|
||||
CDrv *dv;
|
||||
CDoc *doc;
|
||||
CD3I64 saved_scroll;
|
||||
Bool old_preempt=Preempt;
|
||||
I64 border_attr;
|
||||
if (task->border_src==BDS_CUR_DRV && task->cur_dv) {
|
||||
border_attr=task->cur_dv->text_attr;
|
||||
@@ -193,14 +205,11 @@ U0 DocUpdateTaskDocs(CTask *task)
|
||||
Fs->catch_except=TRUE;
|
||||
if (task->title_src==TTS_ED_FILENAME)
|
||||
MemCpy(task->task_title,doc->filename.name,TASK_TITLE_LEN);
|
||||
Preempt(old_preempt);
|
||||
DocRecalc(doc,TRUE,DOC_RECALC_TO_SCREEN);
|
||||
Preempt;
|
||||
}
|
||||
if ((doc=DocBorder(task)) && !(doc->flags&DOCF_DONT_SHOW)) {
|
||||
WinScrollNull(task,&saved_scroll);
|
||||
DocRecalc(doc,FALSE,DOC_RECALC_TO_SCREEN);
|
||||
WinScrollRestore(task,&saved_scroll);
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
#help_index "DolDoc"
|
||||
|
||||
public I64 DocEntryRun(CDoc *doc,CDocEntry *doc_e,
|
||||
Bool exited,I64 *_has_action=NULL)
|
||||
{//Do action on final entry selected by user.
|
||||
//Sometimes returns locked, sometimes unlocked
|
||||
U8 ch=doc->cmd_U8,*st;
|
||||
I64 result=DOCM_CANCEL,has_action=FALSE;
|
||||
CHashDefineStr *temph;
|
||||
DocLock(doc);
|
||||
if (!exited) {
|
||||
if (doc_e->de_flags & DOCEF_ESC) {
|
||||
Msg(MSG_KEY_DOWN,CH_ESC,0,1<<SVCf_DONT_FILTER);
|
||||
has_action=TRUE;
|
||||
goto er_done;
|
||||
} if (doc_e->de_flags & DOCEF_QUIT) {
|
||||
Msg(MSG_KEY_DOWN,CH_SHIFT_ESC,0,1<<SVCf_DONT_FILTER);
|
||||
has_action=TRUE;
|
||||
goto er_done;
|
||||
} else if (doc_e->de_flags & DOCEF_CHECK_COLLAPSABLE) {
|
||||
doc_e->de_flags^=DOCEF_CHECKED_COLLAPSED;
|
||||
has_action=TRUE;
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (ch==CH_SPACE) {
|
||||
if (doc_e->de_flags & DOCEF_LINK && doc->left_click_link) {
|
||||
result=(*doc->left_click_link)(doc,doc_e);
|
||||
has_action=TRUE;
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_LEFT_EXP) {
|
||||
result=doc_e->left_exp;
|
||||
has_action=TRUE;
|
||||
Msg(MSG_CMD,result,0,1<<SVCf_DONT_FILTER);
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_LEFT_CB && doc_e->left_cb) {
|
||||
DocUnlock(doc);
|
||||
result=(*doc_e->left_cb)(doc,doc_e);
|
||||
has_action=TRUE;
|
||||
Msg(MSG_CMD,result,0,1<<SVCf_DONT_FILTER);
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_LEFT_MACRO) {
|
||||
if (doc_e->de_flags & DOCEF_POPUP) {
|
||||
st=StrNew(doc_e->left_macro);
|
||||
DocUnlock(doc);
|
||||
PopUp(st,Fs);
|
||||
Free(st);
|
||||
} else {
|
||||
if (doc_e->de_flags & DOCEF_LEFT_AUTO)
|
||||
AutoStr("%s",doc_e->left_macro);
|
||||
else
|
||||
Auto("%s",doc_e->left_macro);
|
||||
}
|
||||
has_action=TRUE;
|
||||
}
|
||||
if (!exited && doc_e->de_flags & DOCEF_LST &&
|
||||
doc_e->de_flags & DOCEF_DEFINE &&
|
||||
(temph=HashFind(doc_e->define_str,
|
||||
doc->win_task->hash_table,HTT_DEFINE_STR)) &&
|
||||
(result=PopUpPickLst(temph->data))!=DOCM_CANCEL) {
|
||||
DocDataFmt(doc,doc_e,result);
|
||||
DocDataScan(doc,doc_e);
|
||||
has_action=TRUE;
|
||||
}
|
||||
} else if (ch=='\n') {
|
||||
if (doc_e->de_flags & DOCEF_LINK && doc->right_click_link) {
|
||||
result=(*doc->right_click_link)(doc,doc_e);
|
||||
has_action=TRUE;
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_EXP) {
|
||||
result=doc_e->right_exp;
|
||||
has_action=TRUE;
|
||||
Msg(MSG_CMD,result,0,1<<SVCf_DONT_FILTER);
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_CB && doc_e->right_cb) {
|
||||
DocUnlock(doc);
|
||||
result=(*doc_e->right_cb)(doc,doc_e);
|
||||
has_action=TRUE;
|
||||
Msg(MSG_CMD,result,0,1<<SVCf_DONT_FILTER);
|
||||
}
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_MACRO) {
|
||||
if (doc_e->de_flags & DOCEF_POPUP) {
|
||||
st=StrNew(doc_e->right_macro);
|
||||
DocUnlock(doc);
|
||||
PopUp(st,Fs);
|
||||
Free(st);
|
||||
} else {
|
||||
if (doc_e->de_flags & DOCEF_RIGHT_AUTO)
|
||||
AutoStr("%s",doc_e->right_macro);
|
||||
else
|
||||
Auto("%s",doc_e->right_macro);
|
||||
}
|
||||
has_action=TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
DocBottom(doc);
|
||||
doc->cmd_U8=CH_SPACE;
|
||||
er_done:
|
||||
if (_has_action) *_has_action=has_action;
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
#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,140,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_PLAIN 7
|
||||
#define RIGHT_AUTOFILE 8
|
||||
|
||||
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,\"PLAIN ED TXT\",LE=RIGHT_PLAIN$$"
|
||||
"$$CM+LX,1,3 $$$$BT,\"CANCEL \",LE=DOCM_CANCEL$$"
|
||||
"$$CM+LX,26,0$$$$BT,\"AUTOFILE AUT\",LE=RIGHT_AUTOFILE$$\n",
|
||||
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 result;
|
||||
U8 *st;
|
||||
if (st=DocEntryLink(doc,doc_e)) {
|
||||
DocUnlock(doc);
|
||||
if (doc_e->de_flags & DOCEF_POPUP)
|
||||
result=PopUpEd(st);
|
||||
else
|
||||
result=Ed(st);
|
||||
Free(st);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
I64 TermRightClickLink(CDoc *doc,CDocEntry *doc_e)
|
||||
{//Called with doc locked, exit unlocked
|
||||
Bool send_new_line=FALSE,result=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);
|
||||
result=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);
|
||||
result=TRUE;
|
||||
break;
|
||||
case RIGHT_COPY:
|
||||
StrCpy(fn.name,st);
|
||||
if (DocForm(&fn)) {
|
||||
result=ToBool(Copy(st,fn.name));
|
||||
} else
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
case RIGHT_MOVE:
|
||||
StrCpy(fn.name,st);
|
||||
if (DocForm(&fn))
|
||||
result=Move(st,fn.name);
|
||||
else
|
||||
send_new_line=TRUE;
|
||||
break;
|
||||
case RIGHT_DELETE:
|
||||
result=ToBool(Del(st));
|
||||
break;
|
||||
case RIGHT_TYPE:
|
||||
result=Type(st);
|
||||
break;
|
||||
case RIGHT_ED:
|
||||
"Ed(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
|
||||
result=Ed(st);
|
||||
break;
|
||||
case RIGHT_PLAIN:
|
||||
"Plain(\"%s\");\n$$PT$$$$FG$$$$BG$$",st;
|
||||
result=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);
|
||||
result=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 result;
|
||||
}
|
||||
@@ -4,8 +4,6 @@ U8 *ctrl_L_footer=
|
||||
"\n$$MU-X+Q,\"Abort\",LE=DOCM_CANCEL$$\n"
|
||||
"\n\n$$LK+PU,\"Click for Help\",A=\"FI:::/Doc/Widget.TXT\"$$\n";
|
||||
|
||||
#define DFT_ADDR_LINK_BIN_SIZE 64
|
||||
|
||||
I64 PopUpLinkType(Bool include_anchor)
|
||||
{
|
||||
I64 i;
|
||||
@@ -34,8 +32,9 @@ I64 PopUpLinkType(Bool include_anchor)
|
||||
class CEdFileLink
|
||||
{
|
||||
U8 tag[512] fmtstr "$$DA-P,511,A=\"Tag Text :%s\"$$\n",
|
||||
file[512] fmtstr "$$DA-P,511,A=\"File :%s\"$$\n",
|
||||
aux[512];
|
||||
file[512] fmtstr "$$DA-P,511,A=\"File :%s\"$$\n";
|
||||
I64 book;
|
||||
U8 aux[512];
|
||||
I64 num;
|
||||
U8 html_link[512] fmtstr "$$DA-P,511,A=\"Html Link :%s\"$$\n";
|
||||
Bool pop_up fmtstr "$$CB,\"PopUp\"$$\n",
|
||||
@@ -46,8 +45,9 @@ class CEdFileLink
|
||||
class CEdFileAnchorLink
|
||||
{
|
||||
U8 tag[512] fmtstr "$$DA-P,511,A=\"Tag Text :%s\"$$\n",
|
||||
file[512] fmtstr "$$DA-P,511,A=\"File :%s\"$$\n",
|
||||
aux[512] fmtstr "$$DA-P,511,A=\"Anchor Label :%s\"$$\n";
|
||||
file[512] fmtstr "$$DA-P,511,A=\"File :%s\"$$\n";
|
||||
I64 book;
|
||||
U8 aux[512] fmtstr "$$DA-P,511,A=\"Anchor Label :%s\"$$\n";
|
||||
I64 num;
|
||||
U8 html_link[512] fmtstr "$$DA-P,511,A=\"Html Link :%s\"$$\n";
|
||||
Bool pop_up fmtstr "$$CB,\"PopUp\"$$\n",
|
||||
@@ -58,8 +58,9 @@ class CEdFileAnchorLink
|
||||
class CEdFileFindLink
|
||||
{
|
||||
U8 tag[512] fmtstr "$$DA-P,511,A=\"Tag Text :%s\"$$\n",
|
||||
file[512] fmtstr "$$DA-P,511,A=\"File :%s\"$$\n",
|
||||
aux[512] fmtstr "$$DA-P,511,A=\"Str :%s\"$$\n";
|
||||
file[512] fmtstr "$$DA-P,511,A=\"File :%s\"$$\n";
|
||||
I64 book;
|
||||
U8 aux[512] fmtstr "$$DA-P,511,A=\"Str :%s\"$$\n";
|
||||
I64 num fmtstr "$$DA-TRM,511,A=\"Occurrence Num:%04d\"$$\n";
|
||||
U8 html_link[512] fmtstr "$$DA-P,511,A=\"Html Link :%s\"$$\n";
|
||||
Bool pop_up fmtstr "$$CB,\"PopUp\"$$\n",
|
||||
@@ -70,8 +71,9 @@ class CEdFileFindLink
|
||||
class CEdFileLineLink
|
||||
{
|
||||
U8 tag[512] fmtstr "$$DA-P,511,A=\"Tag Text :%s\"$$\n",
|
||||
file[512] fmtstr "$$DA-P,511,A=\"File :%s\"$$\n",
|
||||
aux[512];
|
||||
file[512] fmtstr "$$DA-P,511,A=\"File :%s\"$$\n";
|
||||
I64 book;
|
||||
U8 aux[512];
|
||||
I64 num fmtstr "$$DA-TRM,511,A=\"Line Num :%04d\"$$\n";
|
||||
U8 html_link[512] fmtstr "$$DA-P,511,A=\"Html Link :%s\"$$\n";
|
||||
Bool pop_up fmtstr "$$CB,\"PopUp\"$$\n",
|
||||
@@ -82,8 +84,9 @@ class CEdFileLineLink
|
||||
class CEdManPageLink
|
||||
{
|
||||
U8 tag[512] fmtstr "$$DA-P,511,A=\"Tag Text :%s\"$$\n",
|
||||
file[512],
|
||||
aux[512] fmtstr "$$DA-P,511,A=\"Label :%s\"$$\n";
|
||||
file[512];
|
||||
I64 book;
|
||||
U8 aux[512] fmtstr "$$DA-P,511,A=\"Label :%s\"$$\n";
|
||||
I64 num;
|
||||
U8 html_link[512] fmtstr "$$DA-P,511,A=\"Html Link :%s\"$$\n";
|
||||
Bool pop_up fmtstr "$$CB,\"PopUp\"$$\n",
|
||||
@@ -94,8 +97,9 @@ class CEdManPageLink
|
||||
class CEdAddrLink
|
||||
{
|
||||
U8 tag[512] fmtstr "$$DA-P,511,A=\"Tag Text :%s\"$$\n",
|
||||
file[512],
|
||||
aux[512] fmtstr "$$DA-P,511,A=\"Addr Exp :%s\"$$\n";
|
||||
file[512];
|
||||
I64 book;
|
||||
U8 aux[512] fmtstr "$$DA-P,511,A=\"Addr Exp :%s\"$$\n";
|
||||
I64 num fmtstr "$$DA-TRM,511,A=\"Bin Size :%04d\"$$\n";
|
||||
U8 html_link[512] fmtstr "$$DA-P,511,A=\"Html Link :%s\"$$\n";
|
||||
Bool pop_up fmtstr "$$CB,\"PopUp\"$$\n",
|
||||
@@ -106,8 +110,9 @@ class CEdAddrLink
|
||||
class CEdPlaceAnchor
|
||||
{
|
||||
U8 tag[512] fmtstr "$$DA-P,511,A=\"Tag Text :%s\"$$\n",
|
||||
file[512],
|
||||
aux[512] fmtstr "$$DA-P,511,A=\"Anchor Label :%s\"$$\n";
|
||||
file[512];
|
||||
I64 book;
|
||||
U8 aux[512] fmtstr "$$DA-P,511,A=\"Anchor Label :%s\"$$\n";
|
||||
I64 num;
|
||||
U8 html_link[512] fmtstr "$$DA-P,511,A=\"Html Link :%s\"$$\n";
|
||||
Bool pop_up,
|
||||
@@ -118,9 +123,11 @@ class CEdPlaceAnchor
|
||||
class CEdBibleLink
|
||||
{
|
||||
U8 tag[512] fmtstr "$$DA-P,511,A=\"Tag Text :%s\"$$\n",
|
||||
file[512],
|
||||
aux[512] fmtstr "$$DA-P,511,A=\"Chapter Verse :%s\"$$\n";
|
||||
file[512];
|
||||
I64 book fmtstr "$$LS,D=\"ST_BIBLE_BOOKS\"$$\n";
|
||||
U8 aux[512] fmtstr "$$DA-P,511,A=\"Chapter Verse :%s\"$$\n";
|
||||
I64 num;
|
||||
|
||||
U8 html_link[512] fmtstr "$$DA-P,511,A=\"Html Link :%s\"$$\n";
|
||||
Bool pop_up fmtstr "$$CB,\"PopUp\"$$\n",
|
||||
quote fmtstr "$$CB,\"Quote\"$$\n",
|
||||
@@ -130,8 +137,9 @@ class CEdBibleLink
|
||||
class CEdDefLink
|
||||
{
|
||||
U8 tag[512] fmtstr "$$DA-P,511,A=\"Tag Text :%s\"$$\n",
|
||||
file[512],
|
||||
aux[512] fmtstr "$$DA-P,511,A=\"Word :%s\"$$\n";
|
||||
file[512];
|
||||
I64 book;
|
||||
U8 aux[512] fmtstr "$$DA-P,511,A=\"Word :%s\"$$\n";
|
||||
I64 num fmtstr "$$DA-TRM,511,A=\"Def Num :%4d\"$$\n";
|
||||
U8 html_link[512] fmtstr "$$DA-P,511,A=\"Html Link :%s\"$$\n";
|
||||
Bool pop_up fmtstr "$$CB,\"PopUp\"$$\n",
|
||||
@@ -142,8 +150,9 @@ class CEdDefLink
|
||||
class CEdProject
|
||||
{
|
||||
U8 tag[512] fmtstr "$$DA-P,511,A=\"Tag Text :%s\"$$\n",
|
||||
file[512] fmtstr "$$DA-P,511,A=\"File :%s\"$$\n",
|
||||
aux[512];
|
||||
file[512] fmtstr "$$DA-P,511,A=\"File :%s\"$$\n";
|
||||
I64 book;
|
||||
U8 aux[512];
|
||||
I64 num;
|
||||
U8 html_link[512] fmtstr "$$DA-P,511,A=\"Html Link :%s\"$$\n";
|
||||
Bool pop_up fmtstr "$$CB,\"PopUp\"$$\n",
|
||||
@@ -154,7 +163,6 @@ class CEdProject
|
||||
Bool GetLink(I64 type,U8 **_tag,U8 **_link,Bool *_pop_up,
|
||||
Bool *_quote,U8 **_html_link)
|
||||
{
|
||||
I64 i;
|
||||
CEdFileLink *e=CAlloc(sizeof(CEdFileLink));
|
||||
Bool result=FALSE;
|
||||
if (type>=0) {
|
||||
@@ -269,17 +277,14 @@ Bool GetLink(I64 type,U8 **_tag,U8 **_link,Bool *_pop_up,
|
||||
*_link=StrNew(e->aux);
|
||||
}
|
||||
break;
|
||||
case LK_BIBLE_FIND: //TODO
|
||||
i=PopUpPickDefineSub("ST_BIBLE_BOOKS");
|
||||
if (i>=0) {
|
||||
case LK_BIBLE_FIND:
|
||||
if (DocForm(e,"CEdBibleLink",,,ctrl_L_footer)) {
|
||||
result=TRUE;
|
||||
if (!*e->tag)
|
||||
*_tag=MStrPrint("%Z,%s",i,"ST_BIBLE_BOOKS",e->aux);
|
||||
*_tag=MStrPrint("%Z,%s",e->book,"ST_BIBLE_BOOKS",e->aux);
|
||||
else
|
||||
*_tag=StrNew(e->tag);
|
||||
*_link=MStrPrint("BF:%Z,%s",i,"ST_BIBLE_BOOKS",e->aux);
|
||||
}
|
||||
*_link=MStrPrint("BF:%Z,%s",e->book,"ST_BIBLE_BOOKS",e->aux);
|
||||
}
|
||||
break;
|
||||
case LK_DEF:
|
||||
@@ -469,11 +474,11 @@ U0 EdInsPageSetting()
|
||||
Free(e);
|
||||
}
|
||||
|
||||
I64 PopUpDollarType()
|
||||
I64 PopUpWidgetType()
|
||||
{
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
DocPrint(doc,"$$PURPLE$$$$TX+CX,\"Text Widget Menu\"$$\n"
|
||||
DocPrint(doc,"$$PURPLE$$$$TX+CX,\"Text Widgets Menu\"$$\n"
|
||||
"\n$$LTBLUE$$$$MU,\"Link\",LE=DOCT_LINK$$\n"
|
||||
"$$MU,\"Text\",LE=DOCT_TEXT$$\n"
|
||||
"$$MU,\"Tree Branch\",LE=DOCT_TREE$$\n"
|
||||
@@ -496,7 +501,7 @@ I64 PopUpDollarType()
|
||||
return i;
|
||||
}
|
||||
|
||||
class CEdDollarText
|
||||
class CEdText
|
||||
{
|
||||
U8 tag[512] fmtstr "$$DA-P,511,A=\"Tag Text :%s\"$$\n";
|
||||
Bool left_x fmtstr "$$CB,\"Left X\"$$\n",
|
||||
@@ -520,10 +525,10 @@ class CEdDollarText
|
||||
fmtstr "$$DA-P,511,A=\"Html Link :%s\"$$\n";
|
||||
};
|
||||
|
||||
U0 EdInsDollarText()
|
||||
U0 EdInsText()
|
||||
{
|
||||
U8 *st,buf[512];
|
||||
CEdDollarText *e=CAlloc(sizeof(CEdDollarText));
|
||||
CEdText *e=CAlloc(sizeof(CEdText));
|
||||
if (DocForm(e,,,,ctrl_L_footer)) {
|
||||
*buf=0;
|
||||
if (e->left_x ) CatPrint(buf,"+LX");
|
||||
@@ -964,9 +969,9 @@ U0 EdInsTree()
|
||||
Free(e);
|
||||
}
|
||||
|
||||
U0 EdInsDollarCmd()
|
||||
U0 EdInsWidgetWiz()
|
||||
{
|
||||
I64 type=PopUpDollarType;
|
||||
I64 type=PopUpWidgetType;
|
||||
switch (type) {
|
||||
case DOCT_FOREGROUND:
|
||||
EdInsColor;
|
||||
@@ -978,7 +983,7 @@ U0 EdInsDollarCmd()
|
||||
EdInsLink;
|
||||
break;
|
||||
case DOCT_TEXT:
|
||||
EdInsDollarText;
|
||||
EdInsText;
|
||||
break;
|
||||
case DOCT_TREE:
|
||||
EdInsTree;
|
||||
@@ -1030,7 +1035,7 @@ I64 PopUpSpriteType()
|
||||
{
|
||||
I64 i;
|
||||
CDoc *doc=DocNew;
|
||||
DocPrint(doc,"$$PURPLE$$$$TX+CX,\"Graphic Resource Menu\"$$\n"
|
||||
DocPrint(doc,"$$PURPLE$$$$TX+CX,\"Graphic Sprite Resource Menu\"$$\n"
|
||||
"$$LK+PU+CX,\"Click for Help\",A=\"FI:::/Doc/Resource.TXT.Z\"$$\n"
|
||||
"\n$$LTBLUE$$$$MU,\"Make Sprite\",LE=EST_SPRITE$$\n"
|
||||
"$$MU,\"Pointer to Sprite\",LE=EST_SPRITE_PTR$$\n"
|
||||
@@ -0,0 +1,69 @@
|
||||
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],
|
||||
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("..");;
|
||||
@@ -269,3 +269,18 @@ public U0 BibleVerse(CDoc *doc_out=NULL,U8 *verse,I64 lines)
|
||||
Free(st2);
|
||||
}
|
||||
}
|
||||
|
||||
U0 BibleView()
|
||||
{
|
||||
U8 buf[STR_LEN];
|
||||
I64 book=PopUpPickDefineSub("ST_BIBLE_BOOKS");
|
||||
if (book>=0) {
|
||||
StrPrint(buf,"BF:%Z,1:1",book,"ST_BIBLE_BOOKS");
|
||||
Ed(buf);
|
||||
}
|
||||
}
|
||||
U0 CtrlAltB(I64)
|
||||
{
|
||||
PopUp("BibleView;");
|
||||
}
|
||||
CtrlAltCBSet('B',&CtrlAltB,"Cmd /Bible");
|
||||
@@ -101,9 +101,9 @@ public U8 *GodDoodleSprite(U8 *hex=NULL)
|
||||
if (god.doodle_dc) return NULL;
|
||||
god.doodle_done=FALSE;
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
WinMax;
|
||||
WinBorder;
|
||||
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.");
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ god.doodle_fifo =FifoU8New(2048*8);
|
||||
god.fifo =FifoU8New(2048*8);
|
||||
|
||||
extern U0 GodBitsIns(I64 num_bits,I64 n);
|
||||
extern U0 GodWord();
|
||||
extern U0 GodDoodle(U8 *hex=NULL);
|
||||
extern U0 GodPassage(I64 num_lines=20);
|
||||
extern U0 GodSong();
|
||||
extern U0 GodDoodle(U8 *hex=NULL);
|
||||
extern U0 GodWord();
|
||||
@@ -153,6 +153,7 @@ 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.(Maybe, glory of Creation)$FG$
|
||||
Twelfth commandment? $FG,4$Don't slaughter unarmed men in war.$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$
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
Cd(__DIR__);;
|
||||
|
||||
#help_index "God"
|
||||
#help_file "::/Doc/God"
|
||||
#include "GodBible"
|
||||
#include "HolySpirit"
|
||||
#include "GodSong"
|
||||
#include "GodDoodle"
|
||||
Cd("..");;
|
||||
@@ -1,24 +1,3 @@
|
||||
#help_index "Graphics"
|
||||
U0 GrInit1()
|
||||
{
|
||||
DefineLstLoad("ST_SPRITE_ELEM_TYPES",
|
||||
"End\0Color\0Dither Color\0"
|
||||
"Width\0Planar Symmetry\0Transform On\0Transform Off\0Shift\0"
|
||||
"Point\0PolyPoint\0Line\0PolyLine\0Rect\0Rotated Rect\0"
|
||||
"Circle\0Ellipse\0Polygon\0BSpline2\0BSpline2 Closed\0"
|
||||
"BSpline3\0BSpline3 Closed\0"
|
||||
"Flood Fill\0Flood Fill Not Color\0BitMap\0Mesh\0Shiftable Mesh\0"
|
||||
"Arrow\0Text\0Text Box\0Text Diamond\0");
|
||||
DefineLstLoad("ST_SPRITE_ELEM_CODES",
|
||||
"End\0Color\0Color\0"
|
||||
"Width\0PlanarSymmetry\0Transform\0Transform\0Shift\0"
|
||||
"Pt\0PolyPt\0Line\0PolyLine\0Rect\0Rect\0"
|
||||
"Circle\0Ellipse\0Polygon\0BSpline2\0BSpline2\0BSpline3\0BSpline3\0"
|
||||
"FloodFill\0FloodFill\0BitMap\0Mesh\0Mesh\0"
|
||||
"Arrow\0Text\0TextBox\0TextDiamond\0");
|
||||
}
|
||||
GrInit1;
|
||||
|
||||
#help_index "Sprites/Binary"
|
||||
|
||||
class CMeshTri
|
||||
@@ -195,35 +174,3 @@ public class CSprite
|
||||
CSpritePtStr ps;
|
||||
}
|
||||
};
|
||||
|
||||
#help_index "Graphics"
|
||||
|
||||
extern I64 GrBlot3(CDC *dc,I64 x1,I64 y1,I64 z1,CDC *img);
|
||||
extern U8 *GrBitMap4ToBitMap8(U8 *dst,U8 *src,I64 src_size,I64 bkcolor);
|
||||
extern I64 *Mat4x4New(I64 *src,CTask *mem_task=NULL);
|
||||
extern U8 *SpriteQue2Sprite(CSprite *root,I64 *_size=NULL);
|
||||
|
||||
#include "GrGlbls"
|
||||
#include "GrTextBase"
|
||||
#include "GrAsm"
|
||||
#include "GrPalette"
|
||||
#include "GrDC"
|
||||
#include "GrInit"
|
||||
#include "GrMath"
|
||||
#include "GrScreen"
|
||||
#include "GrBitMap"
|
||||
#include "GrPrimatives"
|
||||
#include "GrComposites"
|
||||
|
||||
#define GE_ABORT (-1)
|
||||
#define GE_EXIT 0
|
||||
#define GE_CONT 1
|
||||
#include "SpriteNew"
|
||||
#include "GrSpritePlot"
|
||||
#include "SpriteMesh"
|
||||
#include "SpriteBitMap"
|
||||
#include "SpriteCode"
|
||||
#include "SpriteEd"
|
||||
#include "SpriteMain"
|
||||
|
||||
#include "GrEnd"
|
||||
@@ -71,7 +71,7 @@ public I64 GrBlot(CDC *dc=gr.dc,I64 x,I64 y,CDC *img)
|
||||
reg bit_shift,win_z_buf_line_inc,win_z_buf_line_dec,win_z_num,
|
||||
color_mask;
|
||||
U8 reg *dst,*src;
|
||||
I32 db;
|
||||
I32 *db;
|
||||
U16 reg *win_z_buf_ptr;
|
||||
CColorROPU32 color,c,old_color;
|
||||
CTask *win_task;
|
||||
|
||||
@@ -296,7 +296,7 @@ mesh_done:
|
||||
|
||||
#help_index "Graphics/Misc;Input Pointer/Displayed Image"
|
||||
public U0 DrawStdInputPtr(CDC *dc,I64 x,I64 y)
|
||||
{//This is a callback. See $LK,"::/Demo/Graphics/Grid.CPP.Z"$.
|
||||
{//This is a callback. See $LK,"::/Demo/Graphics/Grid.CPP"$.
|
||||
//Called by $LK,"DrawInputPtr",A="MN:DrawInputPtr"$() which is
|
||||
//called by $LK,"WinFinalUpdate",A="MN:WinFinalUpdate"$().
|
||||
dc->pen_width=1;
|
||||
@@ -307,7 +307,7 @@ public U0 DrawStdInputPtr(CDC *dc,I64 x,I64 y)
|
||||
gr.fp_draw_input_ptr=&DrawStdInputPtr;
|
||||
|
||||
public U0 DrawWaitInputPtr(CDC *dc,I64 x,I64 y)
|
||||
{//This is a callback. See $LK,"::/Demo/Graphics/Grid.CPP.Z"$.
|
||||
{//This is a callback. See $LK,"::/Demo/Graphics/Grid.CPP"$.
|
||||
I64 old_pen_width=dc->pen_width;
|
||||
CColorROPU32 old_color=dc->color;
|
||||
dc->pen_width=3;
|
||||
|
||||
+14
-14
@@ -3,12 +3,12 @@
|
||||
|
||||
#define GR_SCALE (1<<32)
|
||||
|
||||
public U0 Mat4x4MulXYZ(I64 r[4][4],I64 *_x,I64 *_y,I64 *_z)
|
||||
public U0 Mat4x4MulXYZ(I64 *r,I64 *_x,I64 *_y,I64 *_z)
|
||||
{//Rotate 3D point using 4x4 matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
I64 x1,y1,z1,xx=*_x,yy=*_y,zz=*_z;
|
||||
x1=(r[0][0]*xx+r[0][1]*yy+r[0][2]*zz+r[0][3])>>32;
|
||||
y1=(r[1][0]*xx+r[1][1]*yy+r[1][2]*zz+r[1][3])>>32;
|
||||
z1=(r[2][0]*xx+r[2][1]*yy+r[2][2]*zz+r[2][3])>>32;
|
||||
x1=(r[0*4+0]*xx+r[0*4+1]*yy+r[0*4+2]*zz+r[0*4+3])>>32;
|
||||
y1=(r[1*4+0]*xx+r[1*4+1]*yy+r[1*4+2]*zz+r[1*4+3])>>32;
|
||||
z1=(r[2*4+0]*xx+r[2*4+1]*yy+r[2*4+2]*zz+r[2*4+3])>>32;
|
||||
*_x=x1;*_y=y1;*_z=z1;
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ public U0 DCTransform(CDC *dc,I64 *_x,I64 *_y,I64 *_z)
|
||||
*_z+=dc->z;
|
||||
}
|
||||
|
||||
public I64 *Mat4x4IdentEqu(I64 r[4][4])
|
||||
public I64 *Mat4x4IdentEqu(I64 *r)
|
||||
{//Set matrix to identity. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
MemSet(r,0,sizeof(I64)*16);
|
||||
r[0][0].i32[1]=1;
|
||||
r[1][1].i32[1]=1;
|
||||
r[2][2].i32[1]=1;
|
||||
r[3][3].i32[1]=1;
|
||||
r[0*4+0].i32[1]=1;
|
||||
r[1*4+1].i32[1]=1;
|
||||
r[2*4+2].i32[1]=1;
|
||||
r[3*4+3].i32[1]=1;
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -36,15 +36,15 @@ public I64 *Mat4x4IdentNew(CTask *mem_task=NULL)
|
||||
return Mat4x4IdentEqu(MAlloc(sizeof(I64)*16,mem_task));
|
||||
}
|
||||
|
||||
public I64 Mat4x4NormSqr65536(I64 r[4][4])
|
||||
public I64 Mat4x4NormSqr65536(I64 *r)
|
||||
{//Norm Squared of r.
|
||||
//(1.0/Sqrt(3))*65536=37837.22
|
||||
return SqrI64((r[0][0]*37838+r[0][1]*37838+r[0][2]*37838)>>32)+
|
||||
SqrI64((r[1][0]*37837+r[1][1]*37837+r[1][2]*37837)>>32)+
|
||||
SqrI64((r[2][0]*37837+r[2][1]*37837+r[2][2]*37837)>>32);
|
||||
return SqrI64((r[0*4+0]*37838+r[0*4+1]*37838+r[0*4+2]*37838)>>32)+
|
||||
SqrI64((r[1*4+0]*37837+r[1*4+1]*37837+r[1*4+2]*37837)>>32)+
|
||||
SqrI64((r[2*4+0]*37837+r[2*4+1]*37837+r[2*4+2]*37837)>>32);
|
||||
}
|
||||
|
||||
public U0 DCMat4x4Set(CDC *dc=NULL,I64 r[4][4])
|
||||
public U0 DCMat4x4Set(CDC *dc=NULL,I64 *r)
|
||||
{//Set device context's rot matrix. Will be $LK,"Free",A="MN:Free"$d() in $LK,"DCDel",A="MN:DCDel"$().Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
//The main purpose is to set matrix norm for pen width scaling.
|
||||
//NULL as dc means gr.dc
|
||||
|
||||
+3
-2
@@ -7,7 +7,8 @@ U0 CtrlAltZ(I64 sc)
|
||||
else
|
||||
GrScaleZoom(2.0);
|
||||
}
|
||||
CtrlAltLetCBSet('Z',&CtrlAltZ,"Sys/Zoom In or Out");
|
||||
CtrlAltCBSet('Z',&CtrlAltZ,"Cmd /Zoom In",
|
||||
"Cmd /Zoom Out");
|
||||
|
||||
U0 Screen2Clipboard(I64)
|
||||
{
|
||||
@@ -25,4 +26,4 @@ U0 CtrlAltS(I64)
|
||||
{
|
||||
Spawn(&Screen2Clipboard);
|
||||
}
|
||||
CtrlAltLetCBSet('S',&CtrlAltS,"Sys/Screen Shot to Clipboard");
|
||||
CtrlAltCBSet('S',&CtrlAltS,"Cmd /Screen Shot to Clipboard");
|
||||
@@ -0,0 +1,5 @@
|
||||
#help_index "Graphics"
|
||||
extern U8 *GrBitMap4ToBitMap8(U8 *dst,U8 *src,I64 src_size,I64 bkcolor);
|
||||
extern I64 GrBlot3(CDC *dc,I64 x1,I64 y1,I64 z1,CDC *img);
|
||||
extern I64 *Mat4x4New(I64 *src,CTask *mem_task=NULL);
|
||||
extern U8 *SpriteQue2Sprite(CSprite *root,I64 *_size=NULL);
|
||||
+2
-2
@@ -23,7 +23,7 @@ public class CGrGlbls
|
||||
U0 (*fp_wall_paper)(CTask *task);
|
||||
U0 (*fp_draw_input_ptr)(CDC *dc,I64 x,I64 y);
|
||||
U0 (*fp_draw_grab_input_ptr)(CDC *dc,I64 x,I64 y,Bool closed);
|
||||
U8 *empty_sprite; //Gets assigned $LK,"gr.empty_sprite",A="FF:::/Adam/WallPaper.CPP,empty_sprite"$
|
||||
U8 *empty_sprite; //Gets assigned $LK,"gr.empty_sprite",A="FF:::/Adam/AInputPointer.CPP,empty_sprite"$
|
||||
|
||||
#define GR_NUM_PEN_BRUSHES 64
|
||||
CDC *pen_brushes[GR_NUM_PEN_BRUSHES],
|
||||
@@ -45,7 +45,7 @@ public class CGrGlbls
|
||||
HashPublic("GR_WIDTH",HTT_DEFINE_STR);;
|
||||
HashPublic("GR_HEIGHT",HTT_DEFINE_STR);;
|
||||
|
||||
#help_index "Char"
|
||||
#help_index "Char;TextBase Layer/Char"
|
||||
DefinePrint("TEXT_ROWS","%d",text.rows);;;
|
||||
HashPublic("TEXT_ROWS",HTT_DEFINE_STR);;;
|
||||
DefinePrint("TEXT_COLS","%d",text.cols);;;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#help_index "Graphics"
|
||||
|
||||
U0 GrInit1()
|
||||
{
|
||||
DefineLstLoad("ST_SPRITE_ELEM_TYPES",
|
||||
"End\0Color\0Dither Color\0"
|
||||
"Width\0Planar Symmetry\0Transform On\0Transform Off\0Shift\0"
|
||||
"Point\0PolyPoint\0Line\0PolyLine\0Rect\0Rotated Rect\0"
|
||||
"Circle\0Ellipse\0Polygon\0BSpline2\0BSpline2 Closed\0"
|
||||
"BSpline3\0BSpline3 Closed\0"
|
||||
"Flood Fill\0Flood Fill Not Color\0BitMap\0Mesh\0Shiftable Mesh\0"
|
||||
"Arrow\0Text\0Text Box\0Text Diamond\0");
|
||||
DefineLstLoad("ST_SPRITE_ELEM_CODES",
|
||||
"End\0Color\0Color\0"
|
||||
"Width\0PlanarSymmetry\0Transform\0Transform\0Shift\0"
|
||||
"Pt\0PolyPt\0Line\0PolyLine\0Rect\0Rect\0"
|
||||
"Circle\0Ellipse\0Polygon\0BSpline2\0BSpline2\0BSpline3\0BSpline3\0"
|
||||
"FloodFill\0FloodFill\0BitMap\0Mesh\0Mesh\0"
|
||||
"Arrow\0Text\0TextBox\0TextDiamond\0");
|
||||
}
|
||||
GrInit1;
|
||||
@@ -1,4 +1,5 @@
|
||||
#help_index "Graphics/Screen"
|
||||
|
||||
U0 GrSetUpTables()
|
||||
{
|
||||
CDC *dc;
|
||||
@@ -138,7 +139,6 @@ public U0 WinZBufUpdate()
|
||||
I64 i,z=1;
|
||||
U16 *ptr;
|
||||
CTask *task,*task1;
|
||||
Bool old_preempt=Preempt;
|
||||
if (gr.win_z_buf) {
|
||||
LBtr(&sys_semas[SYS_SEMA_UPDATE_WIN_Z_BUF],0);
|
||||
task1=task=sys_winmgr_task;
|
||||
@@ -156,7 +156,6 @@ public U0 WinZBufUpdate()
|
||||
for (ptr=gr.win_z_buf,i=TEXT_ROWS*TEXT_COLS;i;i--)
|
||||
Bts(gr.win_uncovered_bitmap,*ptr++);
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
#help_index "Graphics"
|
||||
+10
-10
@@ -179,21 +179,21 @@ public U0 DCPenWidthScale(CDC *dc=gr.dc)
|
||||
}
|
||||
}
|
||||
|
||||
public I64 *Mat4x4TranslationEqu(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
public I64 *Mat4x4TranslationEqu(I64 *r,I64 x,I64 y,I64 z)
|
||||
{//Set translation values in 4x4 matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
r[0][3]=x<<32;
|
||||
r[1][3]=y<<32;
|
||||
r[2][3]=z<<32;
|
||||
r[3][3]=GR_SCALE;
|
||||
r[0*4+3]=x<<32;
|
||||
r[1*4+3]=y<<32;
|
||||
r[2*4+3]=z<<32;
|
||||
r[3*4+3]=GR_SCALE;
|
||||
return r;
|
||||
}
|
||||
|
||||
public I64 *Mat4x4TranslationAdd(I64 r[4][4],I64 x,I64 y,I64 z)
|
||||
public I64 *Mat4x4TranslationAdd(I64 *r,I64 x,I64 y,I64 z)
|
||||
{//Add translation to 4x4 matrix. Uses $LK,"fixed-point",A="FI:::/Demo/Lectures/FixedPoint.CPP"$.
|
||||
r[0][3]+=x<<32;
|
||||
r[1][3]+=y<<32;
|
||||
r[2][3]+=z<<32;
|
||||
r[3][3]=GR_SCALE;
|
||||
r[0*4+3]+=x<<32;
|
||||
r[1*4+3]+=y<<32;
|
||||
r[2*4+3]+=z<<32;
|
||||
r[3*4+3]=GR_SCALE;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,6 @@ U0 GrFixZoomScale()
|
||||
|
||||
public U0 GrScaleZoom(F64 scale)
|
||||
{//Multiply zoom factor larger or smaller.
|
||||
Bool old_preempt=Preempt;
|
||||
F64 s=gr.screen_zoom;
|
||||
gr.screen_zoom=gr.screen_zoom*scale;
|
||||
GrFixZoomScale;
|
||||
@@ -120,7 +119,6 @@ public U0 GrScaleZoom(F64 scale)
|
||||
gr.sx=ip.pos.x-gr.zoomed_dc->width >>1/gr.screen_zoom;
|
||||
gr.sy=ip.pos.y-gr.zoomed_dc->height>>1/gr.screen_zoom;
|
||||
GrFixZoomScale;
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
U0 GrZoomInScreen()
|
||||
@@ -403,7 +401,6 @@ U0 GrUpdateVGAGraphics()
|
||||
U0 GrUpdateScreen()
|
||||
{//Called by the Window Manager $LK,"HERE",A="FF:::/Adam/WinB.CPP,GrUpdateScreen"$, 60 times a second.
|
||||
CDC *dc;
|
||||
Preempt(ON);
|
||||
if (!Bt(&sys_run_level,RLf_VGA)) //if text mode
|
||||
GrUpdateTasks;
|
||||
else {
|
||||
@@ -412,7 +409,6 @@ U0 GrUpdateScreen()
|
||||
GrUpdateTasks;
|
||||
DCBlotColor8(gr.dc2,gr.dc);
|
||||
}
|
||||
Preempt;
|
||||
|
||||
dc=DCAlias(gr.dc2,Fs);
|
||||
dc->flags|=DCF_ON_TOP;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
Cd(__DIR__);;
|
||||
|
||||
#include "GrInitA"
|
||||
#include "Gr.HPP"
|
||||
#include "GrExt"
|
||||
#include "GrGlbls"
|
||||
#include "GrTextBase"
|
||||
#include "GrAsm"
|
||||
#include "GrPalette"
|
||||
#include "GrDC"
|
||||
#include "GrInitB"
|
||||
#include "GrMath"
|
||||
#include "GrScreen"
|
||||
#include "GrBitMap"
|
||||
#include "GrPrimatives"
|
||||
#include "GrComposites"
|
||||
|
||||
#define GE_ABORT (-1)
|
||||
#define GE_EXIT 0
|
||||
#define GE_CONT 1
|
||||
#include "SpriteNew"
|
||||
#include "GrSpritePlot"
|
||||
#include "SpriteMesh"
|
||||
#include "SpriteBitMap"
|
||||
#include "SpriteCode"
|
||||
#include "SpriteEd"
|
||||
#include "SpriteMain"
|
||||
|
||||
#include "GrEnd"
|
||||
|
||||
Cd("..");;
|
||||
@@ -144,7 +144,7 @@ U0 SpriteSetOrigin(CSprite *root,I64 dx,I64 dy,I64 dz)
|
||||
}
|
||||
}
|
||||
|
||||
CSprite *SpriteTransformCircle(I64 r[4][4],CSprite *tempg)
|
||||
CSprite *SpriteTransformCircle(I64 *r,CSprite *tempg)
|
||||
{
|
||||
I64 x,y,z;
|
||||
F64 m1,a1,m2,radius=tempg->pr.radius<<16;
|
||||
@@ -171,7 +171,7 @@ CSprite *SpriteTransformCircle(I64 r[4][4],CSprite *tempg)
|
||||
return tempg1;
|
||||
}
|
||||
|
||||
CSprite *SpriteTransformEllipse(I64 r[4][4],CSprite *tempg)
|
||||
CSprite *SpriteTransformEllipse(I64 *r,CSprite *tempg)
|
||||
{
|
||||
I64 x,y,z;
|
||||
F64 m1,a1,m2,a2,s,c,x_radius=tempg->pwha.width<<16,
|
||||
@@ -211,7 +211,7 @@ CSprite *SpriteTransformEllipse(I64 r[4][4],CSprite *tempg)
|
||||
return tempg1;
|
||||
}
|
||||
|
||||
CSprite *SpriteTransformRect(I64 r[4][4],CSprite *tempg,F64 é)
|
||||
CSprite *SpriteTransformRect(I64 *r,CSprite *tempg,F64 é)
|
||||
{
|
||||
I64 x,y,z,w,h;
|
||||
F64 m1,a1,m2,a2,s,c,
|
||||
@@ -252,7 +252,7 @@ CSprite *SpriteTransformRect(I64 r[4][4],CSprite *tempg,F64
|
||||
return tempg1;
|
||||
}
|
||||
|
||||
CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
|
||||
CSprite *SpriteTransformBitmap(I64 *r,CSprite *tempg)
|
||||
{
|
||||
CDC *img,*tempb;
|
||||
U8 *elems;
|
||||
@@ -334,7 +334,7 @@ CSprite *SpriteTransformBitmap(I64 r[4][4],CSprite *tempg)
|
||||
return tempg1;
|
||||
}
|
||||
|
||||
U0 SpriteTransform(I64 r[4][4],CSprite *root)
|
||||
U0 SpriteTransform(I64 *r,CSprite *root)
|
||||
{
|
||||
I64 i,j,k,num,
|
||||
x,y,z,x1,y1,z1,x2,y2,z2,x3,y3,z3;
|
||||
@@ -886,14 +886,13 @@ U0 SpriteCtrlPtsMove(CEdSprite *root,I64 dx,I64 dy)
|
||||
Bool SpriteShiftPts(U8 *elems,I64 x,I64 y,I64 *_cur_elem_num,I64 mode)
|
||||
{
|
||||
I64 msg_code,a1,a2,xx,yy,xx2,yy2,dd,best_dd,cur_elem_num;
|
||||
Bool old_preempt,result=TRUE;
|
||||
Bool result=TRUE;
|
||||
CDC *dc=DCAlias;
|
||||
CEdSprite root,*temppe,*best_pe;
|
||||
|
||||
SpritePtQueNew(elems,x,y,&root);
|
||||
cur_elem_num=0;
|
||||
if (root.next!=&root) {
|
||||
old_preempt=Preempt;
|
||||
while (TRUE) {
|
||||
SpriteCtrlPtsDraw(dc,&root); //has WinMgrSync
|
||||
switch (msg_code=ScanMsg(&a1,&a2,
|
||||
@@ -999,7 +998,6 @@ gs_key:
|
||||
}
|
||||
}
|
||||
gs_done:
|
||||
Preempt(old_preempt);
|
||||
QueDel(&root,TRUE);
|
||||
}
|
||||
DCFill(dc);
|
||||
|
||||
@@ -965,7 +965,6 @@ $WW,0$*/
|
||||
|
||||
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
|
||||
AutoComplete;
|
||||
Preempt; //We don't really want window update while modifying links
|
||||
RegOneTimePopUp(ARf_MESH_ED,
|
||||
"$$GREEN$$Right Mouse$$FG$$: Hold and move to shift cursor z\n"
|
||||
"$$GREEN$$'j'$$FG$$: Jump cursor Z to nearest vertex's Z\n"
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
Cd(__DIR__);;
|
||||
#include "AExts"
|
||||
#include "AMath"
|
||||
#include "Training"
|
||||
#include "AMem"
|
||||
#include "TaskRep"
|
||||
#include "AMathODE"
|
||||
#include "Gr/MakeGr"
|
||||
#include "Snd/MakeSnd"
|
||||
#include "ABlkDev/MakeABlkDev"
|
||||
#include "Menu"
|
||||
#include "WinA"
|
||||
#include "WinB"
|
||||
#include "ADbg"
|
||||
#include "::/Adam/God/GodExt"
|
||||
#include "DolDoc/MakeDoc"
|
||||
LBts(&sys_run_level,RLf_DOC);
|
||||
#include "Ctrls/MakeCtrls"
|
||||
#include "AutoFile"
|
||||
#include "ARegistry"
|
||||
#include "AutoComplete/MakeAC"
|
||||
#include "God/MakeGod"
|
||||
#include "AHash"
|
||||
#include "TaskSettings"
|
||||
#include "DevInfo"
|
||||
#include "ADefine"
|
||||
#include "WallPaper"
|
||||
#include "AInputPointer"
|
||||
Cd("..");;
|
||||
@@ -0,0 +1,164 @@
|
||||
#define DVD_BOOT_LOADER_SIZE DVD_BLK_SIZE*1 //Max DVD_BLK_SIZE*4, I think
|
||||
#define BOOT_HIGH_LOC_DVD ((BOOT_RAM_LIMIT-\
|
||||
(BOOT_STK_SIZE+DVD_BOOT_LOADER_SIZE))>>4)
|
||||
|
||||
DefinePrint(
|
||||
"DD_BOOT_HIGH_LOC_DVD","%08X",BOOT_HIGH_LOC_DVD<<4);
|
||||
DefinePrint(
|
||||
"DD_BOOT_HIGH_LOC_DVD_END","%08X",BOOT_RAM_LIMIT-1);
|
||||
|
||||
asm {
|
||||
USE16
|
||||
BDVD_START::
|
||||
//DL is supposed to have the BIOS drive number
|
||||
CLD
|
||||
MOV AX,BOOT_HIGH_LOC_DVD
|
||||
MOV ES,AX
|
||||
|
||||
CLI
|
||||
MOV SS,AX
|
||||
MOV SP,BOOT_STK_SIZE+DVD_BOOT_LOADER_SIZE
|
||||
STI
|
||||
|
||||
CALL BDVD_GET_IP
|
||||
BDVD_GET_IP:
|
||||
POP BX
|
||||
SUB BX,BDVD_GET_IP-BDVD_START
|
||||
SHR BX,4
|
||||
//This copies this bootloader's code to 0x$TX,"00096600",D="DD_BOOT_HIGH_LOC_DVD"$
|
||||
MOV AX,CS
|
||||
ADD AX,BX
|
||||
MOV DS,AX
|
||||
MOV CX,DVD_BOOT_LOADER_SIZE
|
||||
XOR SI,SI
|
||||
XOR DI,DI
|
||||
REP_MOVSB
|
||||
|
||||
MOV AX,BOOT_HIGH_LOC_DVD
|
||||
MOV DS,AX
|
||||
|
||||
//My assembler doesn't support 16-bit very well.
|
||||
DU8 0xEA; //JMP BOOT_HIGH_LOC_DVD:BDVD_MAIN
|
||||
DU16 BDVD_MAIN-BDVD_START,BOOT_HIGH_LOC_DVD;
|
||||
|
||||
BDVD_BIOS_DRV_NUM: DU8 0;
|
||||
BDVD_PAGE: DU8 0;
|
||||
|
||||
BDVD_DAP: DU8 16,0,1,0; //One blk at a time
|
||||
BDVD_DAP_BUF: DU16 0,0;
|
||||
BDVD_DAP_BLK: DU64 0;
|
||||
|
||||
BDVD_TEMPLEOS_MSG:
|
||||
DU8 "Loading TempleOS",0;
|
||||
|
||||
BDVD_NOT64_MSG:
|
||||
DU8 "TempleOS requires a 64-bit capable processor.\n\r",0;
|
||||
|
||||
//These get patched.
|
||||
BDVD_BLK_LO:: DU16 0;
|
||||
BDVD_BLK_HI:: DU16 0;
|
||||
BDVD_BLK_CNT:: DU16 0;
|
||||
|
||||
BDVD_PROGRESS_STEP:: DU32 0;
|
||||
BDVD_PROGRESS_VAL:: DU32 0;
|
||||
|
||||
BDVD_PUTCHAR::
|
||||
MOV AH,0xE
|
||||
MOV BL,7 //Might be foreground color on some BIOS's
|
||||
MOV BH,U8 [BDVD_PAGE-BDVD_START]
|
||||
INT 0x10
|
||||
BDVD_RET::
|
||||
RET
|
||||
BDVD_PUTS::
|
||||
@@1: LODSB
|
||||
TEST AL,AL
|
||||
JZ BDVD_RET
|
||||
CALL BDVD_PUTCHAR
|
||||
JMP @@1
|
||||
|
||||
BDVD_MAIN::
|
||||
MOV U8 [BDVD_BIOS_DRV_NUM-BDVD_START],DL //Passed in by BIOS
|
||||
|
||||
MOV AH,0xF
|
||||
INT 0x10
|
||||
MOV U8 [BDVD_PAGE-BDVD_START],BH //video page
|
||||
|
||||
MOV EAX,0x80000000
|
||||
CPUID
|
||||
CMP EAX,0x80000001
|
||||
JB @@05
|
||||
|
||||
MOV EAX,0x80000001
|
||||
CPUID
|
||||
BT EDX,29
|
||||
JC @@15
|
||||
@@05: MOV SI,BDVD_NOT64_MSG-BDVD_START
|
||||
CALL BDVD_PUTS
|
||||
@@10: JMP @@10
|
||||
|
||||
@@15: MOV SI,BDVD_TEMPLEOS_MSG-BDVD_START
|
||||
CALL BDVD_PUTS
|
||||
|
||||
MOV AX,BOOT_RAM_BASE/16
|
||||
MOV ES,AX
|
||||
XOR ECX,ECX
|
||||
MOV CX,U16 [BDVD_BLK_CNT-BDVD_START]
|
||||
|
||||
MOV EAX,(80-7-9)*65536 //80 columns
|
||||
XOR EDX,EDX
|
||||
DIV ECX
|
||||
MOV U32 [BDVD_PROGRESS_STEP-BDVD_START],EAX
|
||||
MOV U32 [BDVD_PROGRESS_VAL-BDVD_START],0
|
||||
|
||||
MOV AX,U16 [BDVD_BLK_LO-BDVD_START]
|
||||
MOV DX,U16 [BDVD_BLK_HI-BDVD_START]
|
||||
|
||||
@@20: PUSH CX //Blk cnt
|
||||
|
||||
//READ BLK
|
||||
PUSH AX //Blk lo
|
||||
PUSH DX //Blk hi
|
||||
PUSH ES //Buf seg
|
||||
MOV U16 [BDVD_DAP_BLK-BDVD_START],AX
|
||||
MOV U16 [BDVD_DAP_BLK+2-BDVD_START],DX
|
||||
MOV AX,ES
|
||||
MOV U16 [BDVD_DAP_BUF+2-BDVD_START],AX //ES:0000
|
||||
MOV SI,BDVD_DAP-BDVD_START //DS:SI=DAP
|
||||
MOV AH,0x42
|
||||
MOV DL,U8 [BDVD_BIOS_DRV_NUM-BDVD_START]
|
||||
INT 0x13
|
||||
|
||||
POP AX //ES
|
||||
ADD AX,DVD_BLK_SIZE/16
|
||||
MOV ES,AX
|
||||
POP DX
|
||||
POP AX
|
||||
INC AX
|
||||
JNZ @@25
|
||||
INC DX
|
||||
|
||||
@@25: PUSH AX
|
||||
MOV BX,U16 [BDVD_PROGRESS_VAL+2-BDVD_START]
|
||||
MOV EAX,U32 [BDVD_PROGRESS_STEP-BDVD_START]
|
||||
ADD U32 [BDVD_PROGRESS_VAL-BDVD_START],EAX
|
||||
CMP U16 [BDVD_PROGRESS_VAL+2-BDVD_START],BX
|
||||
JE @@30
|
||||
MOV AL,'.'
|
||||
CALL BDVD_PUTCHAR
|
||||
@@30: POP AX
|
||||
|
||||
POP CX
|
||||
LOOP @@20
|
||||
|
||||
//See $LK,"BootDVDProve",A="MN:BootDVDProve"$().
|
||||
MOV EBX,U32 [BDVD_BLK_LO-BDVD_START] //TODO: oops overflow?
|
||||
SHL EBX,16
|
||||
MOV BX,BOOT_SRC_DVD //$MA-X+PU,"See sys_boot_src",LM="Find(\"sys_boot_src\",\"/*\");View;\n"$
|
||||
|
||||
//My assembler doesn't support 16-bit very well.
|
||||
DU8 0xEA; //JMP BOOT_RAM_BASE:0000
|
||||
DU16 0,BOOT_RAM_BASE/16;
|
||||
//Continues here $LK,"::/Kernel/KStart.CPP",A="FL:::/Kernel/KStart.CPP,1"$
|
||||
BDVD_END::
|
||||
#assert BDVD_END-BDVD_START<DVD_BOOT_LOADER_SIZE
|
||||
}
|
||||
File renamed without changes.
@@ -22,13 +22,13 @@ public U0 MakeAll()
|
||||
}
|
||||
|
||||
public Bool MakeOSDrvBootInstall(U8 src_drv=0,U8 dst_drv=0)
|
||||
{// Does $LK,"MakeAll",A="MN:MakeAll"$ and installs new boot-loader.
|
||||
{// Does $LK,"MakeAll",A="MN:MakeAll"$and installs new boot-loader.
|
||||
|
||||
//Normally, you just supply a src_drv. It will compile
|
||||
//the code on that drive and update the boot sect.
|
||||
|
||||
//If you are making a bootable CD-ROM, you supply a dst_drv.
|
||||
//See $LK,"::/Misc/MakeDistro.CPP"$
|
||||
//If you are making a bootable CD/DVD, you supply a dst_drv.
|
||||
//See $LK,"::/Misc/DoDistro.CPP"$
|
||||
|
||||
//See $LK,"Install Documentation",A="FI:::/Doc/Install.TXT"$
|
||||
|
||||
@@ -39,16 +39,23 @@ public Bool MakeOSDrvBootInstall(U8 src_drv=0,U8 dst_drv=0)
|
||||
CFAT32Boot br;
|
||||
CDirEntry de;
|
||||
Bool result=FALSE;
|
||||
I64 i;
|
||||
I64 i,type;
|
||||
try {
|
||||
if (!src_drv) src_drv=Drv2Let(Fs->cur_dv);
|
||||
if (!dst_drv) dst_drv=src_drv;
|
||||
if (!Drv(src_drv))
|
||||
throw;
|
||||
MakeAll;
|
||||
try {
|
||||
bd=Let2BlkDev(dst_drv);
|
||||
dv=Let2Drv (dst_drv);
|
||||
switch (bd->type) {
|
||||
dv=Let2Drv(dst_drv);
|
||||
type=bd->type;
|
||||
} catch {
|
||||
Fs->catch_except=TRUE;
|
||||
type=BDT_ATAPI;
|
||||
PrintWarn("Defaulting to CD/DVD dst.\n");
|
||||
}
|
||||
switch (type) {
|
||||
case BDT_ATAPI:
|
||||
Move("/Kernel/Kernel.BIN.Z",BOOT_DIR_KERNEL_BIN_C);
|
||||
result=TRUE;
|
||||
@@ -104,7 +104,7 @@ BMHD_HISTART:
|
||||
//My assembler doesn't support 16-bit very well.
|
||||
DU8 0xEA; //JMP BOOT_RAM_BASE:0000
|
||||
DU16 0,BOOT_RAM_BASE/16;
|
||||
//Continues here $LK,"BMHD2_START",A="FF:::/Adam/Boot/BootMHD2.CPP,BMHD2_START"$
|
||||
//Continues here $LK,"BMHD2_START",A="FF:::/Adam/Opt/Boot/BootMHD2.CPP,BMHD2_START"$
|
||||
BMHD_END::
|
||||
#assert BMHD_END-BMHD_START<=440
|
||||
}
|
||||
@@ -118,6 +118,6 @@ BMHD2_HISTART:
|
||||
BMHD2_OLD_CS_IP:
|
||||
DU16 0,0;
|
||||
BMHD2_END::
|
||||
//Continues here $LK,"::/Adam/Boot/BootHD.CPP",A="FF:::/Adam/Boot/BootHD.CPP,START"$
|
||||
//Continues here $LK,"::/Adam/Opt/Boot/BootHD.CPP",A="FF:::/Adam/Opt/Boot/BootHD.CPP,START"$
|
||||
#assert BMHD2_END-BMHD2_START<MODULE_SIZE
|
||||
}
|
||||
@@ -12,25 +12,25 @@ U0 FillU32Palindrome(CPalindromeU32 *dst,I64 d)
|
||||
dst->little=d;
|
||||
}
|
||||
|
||||
class CCCDUserData //Create CD
|
||||
class CCDVDUserData //Create DVD
|
||||
{
|
||||
I64 loc,path_entry_num,
|
||||
short_dir_blks,long_dir_blks;
|
||||
};
|
||||
|
||||
I64 CDFileCreate2(CFile *out_file,CDirEntry *tempde,
|
||||
I64 DVDFileCreate2(CFile *out_file,CDirEntry *tempde,
|
||||
CISO1DirEntry *tempi,CISO1DirEntry *tempi2,
|
||||
I64 *_cur_blk,
|
||||
CDirEntry *parent,Bool write,
|
||||
U8 *stage2_filename,I64 *_stage2_blk)
|
||||
{
|
||||
CCCDUserData *tempc;
|
||||
CCDVDUserData *tempc;
|
||||
CDirEntry *tempde1,*tempde2;
|
||||
CFile *in_file;
|
||||
U8 *buf=MAlloc(CD_BLK_SIZE),*ptr1,*ptr2;
|
||||
CISO1DirEntry *dir_blk_buf =CAlloc(CD_BLK_SIZE*128),
|
||||
U8 *buf=MAlloc(DVD_BLK_SIZE),*ptr1,*ptr2;
|
||||
CISO1DirEntry *dir_blk_buf =CAlloc(DVD_BLK_SIZE*128),
|
||||
*de =dir_blk_buf, *de1,
|
||||
*dir_blk_buf2=CAlloc(CD_BLK_SIZE*128),
|
||||
*dir_blk_buf2=CAlloc(DVD_BLK_SIZE*128),
|
||||
*de2=dir_blk_buf2,*de12;
|
||||
I64 i,n;
|
||||
|
||||
@@ -49,7 +49,7 @@ I64 CDFileCreate2(CFile *out_file,CDirEntry *tempde,
|
||||
de->len=sizeof(CISO1DirEntry)-1;
|
||||
de->ext_attr_len=0;
|
||||
FillU32Palindrome(&de->loc,tempc->loc);
|
||||
FillU32Palindrome(&de->size,tempc->short_dir_blks*CD_BLK_SIZE);
|
||||
FillU32Palindrome(&de->size,tempc->short_dir_blks*DVD_BLK_SIZE);
|
||||
FillU16Palindrome(&de->vol_seq_num,1);
|
||||
Date2ISO1(&de->date,parent->datetime);
|
||||
de->flags=ISO1_ATTR_DIR;
|
||||
@@ -71,7 +71,7 @@ I64 CDFileCreate2(CFile *out_file,CDirEntry *tempde,
|
||||
de2->len=sizeof(CISO1DirEntry)-1;
|
||||
de2->ext_attr_len=0;
|
||||
FillU32Palindrome(&de2->loc,tempc->loc+tempc->short_dir_blks);
|
||||
FillU32Palindrome(&de2->size,tempc->long_dir_blks*CD_BLK_SIZE);
|
||||
FillU32Palindrome(&de2->size,tempc->long_dir_blks*DVD_BLK_SIZE);
|
||||
FillU16Palindrome(&de2->vol_seq_num,1);
|
||||
Date2ISO1(&de2->date,parent->datetime);
|
||||
de2->flags=ISO1_ATTR_DIR;
|
||||
@@ -83,11 +83,11 @@ I64 CDFileCreate2(CFile *out_file,CDirEntry *tempde,
|
||||
tempde1=tempde->sub;
|
||||
while (tempde1) {
|
||||
tempde2=tempde1->next;
|
||||
if (!write) tempde1->user_data=CAlloc(sizeof(CCCDUserData));
|
||||
if (!write) tempde1->user_data=CAlloc(sizeof(CCDVDUserData));
|
||||
de1=de;
|
||||
de12=de2;
|
||||
if (tempde1->attr & RS_ATTR_DIR) {
|
||||
n=CDFileCreate2(out_file,tempde1,de,de2,_cur_blk,
|
||||
n=DVDFileCreate2(out_file,tempde1,de,de2,_cur_blk,
|
||||
tempde,write,stage2_filename,_stage2_blk);
|
||||
de(U8 *)+=sizeof(CISO1DirEntry)-1+n;
|
||||
de2(U8 *)+=sizeof(CISO1DirEntry)-1+n<<1;
|
||||
@@ -131,11 +131,11 @@ I64 CDFileCreate2(CFile *out_file,CDirEntry *tempde,
|
||||
de2(U8 *)+=de2->len;
|
||||
|
||||
in_file=FOpen(tempde1->full_name,"r");
|
||||
for (i=0;i<(FSize(in_file)+CD_BLK_SIZE-1)/CD_BLK_SIZE;i++) {
|
||||
for (i=0;i<(FSize(in_file)+DVD_BLK_SIZE-1)/DVD_BLK_SIZE;i++) {
|
||||
n=4;
|
||||
if ((i+1)<<2>(FSize(in_file)+BLK_SIZE-1)>>BLK_SIZE_BITS) {
|
||||
n=(FSize(in_file)+BLK_SIZE-1)>>BLK_SIZE_BITS&3;
|
||||
MemSet(buf,0,CD_BLK_SIZE);
|
||||
MemSet(buf,0,DVD_BLK_SIZE);
|
||||
}
|
||||
if (write) {
|
||||
FRBlks(in_file,buf,i<<2,n);
|
||||
@@ -145,23 +145,23 @@ I64 CDFileCreate2(CFile *out_file,CDirEntry *tempde,
|
||||
}
|
||||
FClose(in_file);
|
||||
}
|
||||
if ((de1(U8 *)-dir_blk_buf(U8 *))/CD_BLK_SIZE!=
|
||||
(de(U8 *) -dir_blk_buf(U8 *))/CD_BLK_SIZE) {
|
||||
if ((de1(U8 *)-dir_blk_buf(U8 *))/DVD_BLK_SIZE!=
|
||||
(de(U8 *) -dir_blk_buf(U8 *))/DVD_BLK_SIZE) {
|
||||
i=de1->len;
|
||||
MemCpy(buf,de1,i);
|
||||
MemSet(de1,0,i);
|
||||
de=dir_blk_buf(U8 *)+(de(U8 *)
|
||||
-dir_blk_buf(U8 *))/CD_BLK_SIZE*CD_BLK_SIZE;
|
||||
-dir_blk_buf(U8 *))/DVD_BLK_SIZE*DVD_BLK_SIZE;
|
||||
MemCpy(de,buf,i);
|
||||
de(U8 *)+=i;
|
||||
}
|
||||
if ((de12(U8 *)-dir_blk_buf2(U8 *))/CD_BLK_SIZE!=
|
||||
(de2(U8 *) -dir_blk_buf2(U8 *))/CD_BLK_SIZE) {
|
||||
if ((de12(U8 *)-dir_blk_buf2(U8 *))/DVD_BLK_SIZE!=
|
||||
(de2(U8 *) -dir_blk_buf2(U8 *))/DVD_BLK_SIZE) {
|
||||
i=de12->len;
|
||||
MemCpy(buf,de12,i);
|
||||
MemSet(de12,0,i);
|
||||
de2(U8 *)=dir_blk_buf2(U8 *)+(de2(U8 *)
|
||||
-dir_blk_buf2(U8 *))/CD_BLK_SIZE*CD_BLK_SIZE;
|
||||
-dir_blk_buf2(U8 *))/DVD_BLK_SIZE*DVD_BLK_SIZE;
|
||||
MemCpy(de2,buf,i);
|
||||
de2(U8 *)+=i;
|
||||
}
|
||||
@@ -183,12 +183,12 @@ I64 CDFileCreate2(CFile *out_file,CDirEntry *tempde,
|
||||
tempi->len+=tempi->name_len;
|
||||
|
||||
n=de(U8 *)+1-dir_blk_buf(U8 *);
|
||||
n=(n+CD_BLK_SIZE-1)/CD_BLK_SIZE;
|
||||
FillU32Palindrome(&tempi->size,n*CD_BLK_SIZE);
|
||||
n=(n+DVD_BLK_SIZE-1)/DVD_BLK_SIZE;
|
||||
FillU32Palindrome(&tempi->size,n*DVD_BLK_SIZE);
|
||||
FillU32Palindrome(&tempi->loc,*_cur_blk);
|
||||
tempc->short_dir_blks=n;
|
||||
tempc->loc=*_cur_blk;
|
||||
FillU32Palindrome(&dir_blk_buf->size,n*CD_BLK_SIZE);
|
||||
FillU32Palindrome(&dir_blk_buf->size,n*DVD_BLK_SIZE);
|
||||
FillU32Palindrome(&dir_blk_buf->loc,*_cur_blk);
|
||||
FillU16Palindrome(&tempi->vol_seq_num,1);
|
||||
Date2ISO1(&tempi->date,tempde->datetime);
|
||||
@@ -215,11 +215,11 @@ I64 CDFileCreate2(CFile *out_file,CDirEntry *tempde,
|
||||
}
|
||||
tempi2->len+=tempi2->name_len;
|
||||
n=de2(U8 *)+1-dir_blk_buf2(U8 *);
|
||||
n=(n+CD_BLK_SIZE-1)/CD_BLK_SIZE;
|
||||
FillU32Palindrome(&tempi2->size,n*CD_BLK_SIZE);
|
||||
n=(n+DVD_BLK_SIZE-1)/DVD_BLK_SIZE;
|
||||
FillU32Palindrome(&tempi2->size,n*DVD_BLK_SIZE);
|
||||
FillU32Palindrome(&tempi2->loc,*_cur_blk);
|
||||
tempc->long_dir_blks=n;
|
||||
FillU32Palindrome(&dir_blk_buf2->size,n*CD_BLK_SIZE);
|
||||
FillU32Palindrome(&dir_blk_buf2->size,n*DVD_BLK_SIZE);
|
||||
FillU32Palindrome(&dir_blk_buf2->loc,*_cur_blk);
|
||||
FillU16Palindrome(&tempi2->vol_seq_num,1);
|
||||
Date2ISO1(&tempi2->date,tempde->datetime);
|
||||
@@ -235,7 +235,7 @@ I64 CDFileCreate2(CFile *out_file,CDirEntry *tempde,
|
||||
return tempi->name_len;
|
||||
}
|
||||
|
||||
I64 CDTableLen(CDirEntry *tempde,I64 *size1,I64 *size2,I64 cur_depth)
|
||||
I64 DVDTableLen(CDirEntry *tempde,I64 *size1,I64 *size2,I64 cur_depth)
|
||||
{//Returns depth
|
||||
CDirEntry *tempde1=tempde->sub;
|
||||
I64 max_depth=cur_depth,i;
|
||||
@@ -243,7 +243,7 @@ I64 CDTableLen(CDirEntry *tempde,I64 *size1,I64 *size2,I64 cur_depth)
|
||||
if (tempde1->attr & RS_ATTR_DIR) {
|
||||
*size1+=sizeof(CISO1PathEntry)-2+ (StrLen(tempde1->name)+1)&-0x2;
|
||||
*size2+=sizeof(CISO1PathEntry)-2+StrLen(tempde1->name)<<1;
|
||||
i=CDTableLen(tempde1,size1,size2,cur_depth+1);
|
||||
i=DVDTableLen(tempde1,size1,size2,cur_depth+1);
|
||||
if (i>max_depth) max_depth=i;
|
||||
}
|
||||
tempde1=tempde1->next;
|
||||
@@ -251,7 +251,7 @@ I64 CDTableLen(CDirEntry *tempde,I64 *size1,I64 *size2,I64 cur_depth)
|
||||
return max_depth;
|
||||
}
|
||||
|
||||
U0 CDFillPathTable(CDirEntry *tempde,
|
||||
U0 DVDFillPathTable(CDirEntry *tempde,
|
||||
CISO1PathEntry **_itabbuf,CISO1PathEntry **_itabbuf2,
|
||||
I64 parent_entry_num,Bool big_endian,I64 *first_free,
|
||||
I64 cur_level,I64 output_level)
|
||||
@@ -260,7 +260,7 @@ U0 CDFillPathTable(CDirEntry *tempde,
|
||||
I64 i;
|
||||
CISO1PathEntry *tabbuf=*_itabbuf,*tabbuf2=*_itabbuf2;
|
||||
CDirEntry *tempde1=tempde->sub,*tempde2;
|
||||
CCCDUserData *tempc;
|
||||
CCDVDUserData *tempc;
|
||||
|
||||
if (cur_level==output_level) {
|
||||
while (tempde1) {
|
||||
@@ -308,7 +308,7 @@ U0 CDFillPathTable(CDirEntry *tempde,
|
||||
tempde2=tempde1->next;
|
||||
if (tempde1->attr & RS_ATTR_DIR) {
|
||||
tempc=tempde1->user_data;
|
||||
CDFillPathTable(tempde1,_itabbuf,_itabbuf2,tempc->path_entry_num,
|
||||
DVDFillPathTable(tempde1,_itabbuf,_itabbuf2,tempc->path_entry_num,
|
||||
big_endian,first_free,cur_level+1,output_level);
|
||||
}
|
||||
tempde1=tempde2;
|
||||
@@ -330,31 +330,31 @@ class CElTorito
|
||||
|
||||
public I64 ISOFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,
|
||||
U8 *fu_flags=NULL,U8 *_stage2_filename=NULL)
|
||||
{//See $LK,"::/Misc/MakeDistro.CPP"$
|
||||
{//See $LK,"::/Misc/DoDistro.CPP"$
|
||||
//Use "C:/Distro/*" if you want all files in the C:/Distro directory.
|
||||
//Default flags are "+r" recurse.
|
||||
CISO1PriDesc *iso_pri=CAlloc(CD_BLK_SIZE),
|
||||
*iso_boot=CAlloc(CD_BLK_SIZE),
|
||||
*iso_sup=CAlloc(CD_BLK_SIZE),
|
||||
*iso_term=CAlloc(CD_BLK_SIZE);
|
||||
CISO1PriDesc *iso_pri=CAlloc(DVD_BLK_SIZE),
|
||||
*iso_boot=CAlloc(DVD_BLK_SIZE),
|
||||
*iso_sup=CAlloc(DVD_BLK_SIZE),
|
||||
*iso_term=CAlloc(DVD_BLK_SIZE);
|
||||
CDirEntry *rootdir=CAlloc(sizeof(CDirEntry));
|
||||
I64 i,j,stage2_blk=(CD_FILE_OFFSET+1<<2+CD_BOOT_LOADER_SIZE/BLK_SIZE)>>2,
|
||||
I64 i,j,stage2_blk=(DVD_FILE_OFFSET+1<<2+DVD_BOOT_LOADER_SIZE/BLK_SIZE)>>2,
|
||||
stage2_size,cur_blk=0,tabsize,tabsize2,first_free,max_depth,fuf_flags=0;
|
||||
U32 *d;
|
||||
CElTorito *et=CAlloc(CD_BLK_SIZE);
|
||||
CElTorito *et=CAlloc(DVD_BLK_SIZE);
|
||||
U8 *filename,*stage2_filename,
|
||||
*stage1_buf=CAlloc(CD_BOOT_LOADER_SIZE),
|
||||
*zero_buf=CAlloc(CD_BLK_SIZE);
|
||||
*stage1_buf=CAlloc(DVD_BOOT_LOADER_SIZE),
|
||||
*zero_buf=CAlloc(DVD_BLK_SIZE);
|
||||
CISO1PathEntry *tabbuf=NULL,*tabbuf2=NULL,*itabbuf,*itabbuf2;
|
||||
CFile *out_file=NULL;
|
||||
CISO1DirEntry *tempi;
|
||||
CCCDUserData *tempc;
|
||||
CCDVDUserData *tempc;
|
||||
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),"+r");
|
||||
ScanFlags(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);
|
||||
|
||||
if (!_filename)
|
||||
_filename=dsk.dft_iso_filename;
|
||||
_filename=blkdev.dft_iso_filename;
|
||||
filename=DftExt(_filename,"ISO");
|
||||
|
||||
if (_stage2_filename)
|
||||
@@ -365,25 +365,25 @@ public I64 ISOFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,
|
||||
rootdir->attr=RS_ATTR_DIR;
|
||||
rootdir->sub=FilesFind(src_files_find_mask,fuf_flags);
|
||||
rootdir->datetime=Now;
|
||||
rootdir->user_data=CAlloc(sizeof(CCCDUserData));
|
||||
rootdir->user_data=CAlloc(sizeof(CCDVDUserData));
|
||||
tempc=rootdir->user_data;
|
||||
tempc->path_entry_num=1;
|
||||
|
||||
cur_blk=CD_FILE_OFFSET>>2;
|
||||
cur_blk=DVD_FILE_OFFSET>>2;
|
||||
if (stage2_filename) //preboot and bootloader
|
||||
cur_blk+=1+CD_BOOT_LOADER_SIZE/CD_BLK_SIZE;
|
||||
CDFileCreate2(out_file,rootdir,
|
||||
cur_blk+=1+DVD_BOOT_LOADER_SIZE/DVD_BLK_SIZE;
|
||||
DVDFileCreate2(out_file,rootdir,
|
||||
&iso_pri->root_dir_record,
|
||||
&iso_sup->root_dir_record,
|
||||
&cur_blk,rootdir,FALSE,stage2_filename,&stage2_blk);
|
||||
tabsize=sizeof(CISO1PathEntry);
|
||||
tabsize2=sizeof(CISO1PathEntry);
|
||||
max_depth=CDTableLen(rootdir,&tabsize,&tabsize2,1);
|
||||
max_depth=DVDTableLen(rootdir,&tabsize,&tabsize2,1);
|
||||
FillU32Palindrome(&iso_pri->path_table_size,tabsize);
|
||||
FillU32Palindrome(&iso_sup->path_table_size,tabsize2);
|
||||
tabsize=(tabsize+CD_BLK_SIZE-1)/CD_BLK_SIZE;
|
||||
tabsize=(tabsize+DVD_BLK_SIZE-1)/DVD_BLK_SIZE;
|
||||
cur_blk+=tabsize<<1;
|
||||
tabsize2=(tabsize2+CD_BLK_SIZE-1)/CD_BLK_SIZE;
|
||||
tabsize2=(tabsize2+DVD_BLK_SIZE-1)/DVD_BLK_SIZE;
|
||||
cur_blk+=tabsize2<<1;
|
||||
|
||||
if (FileAttr(filename) & RS_ATTR_CONTIGUOUS)
|
||||
@@ -394,7 +394,7 @@ public I64 ISOFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,
|
||||
if (!out_file)
|
||||
goto cf_done;
|
||||
|
||||
while (cur_blk<CD_FILE_OFFSET>>2)
|
||||
while (cur_blk<DVD_FILE_OFFSET>>2)
|
||||
FWBlks(out_file,zero_buf,cur_blk++<<2,4);
|
||||
|
||||
iso_pri->type=ISO1T_PRI_VOL_DESC;
|
||||
@@ -402,7 +402,7 @@ public I64 ISOFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,
|
||||
iso_pri->version=1;
|
||||
FillU16Palindrome(&iso_pri->vol_set_size,1);
|
||||
FillU16Palindrome(&iso_pri->vol_seq_num,1);
|
||||
FillU16Palindrome(&iso_pri->log_block_size,CD_BLK_SIZE);
|
||||
FillU16Palindrome(&iso_pri->log_block_size,DVD_BLK_SIZE);
|
||||
iso_pri->file_structure_version=1;
|
||||
|
||||
iso_sup->type=ISO1T_SUPPLEMENTARY_DESC;
|
||||
@@ -410,7 +410,7 @@ public I64 ISOFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,
|
||||
iso_sup->version=1;
|
||||
FillU16Palindrome(&iso_sup->vol_set_size,1);
|
||||
FillU16Palindrome(&iso_sup->vol_seq_num,1);
|
||||
FillU16Palindrome(&iso_sup->log_block_size,CD_BLK_SIZE);
|
||||
FillU16Palindrome(&iso_sup->log_block_size,DVD_BLK_SIZE);
|
||||
iso_sup->file_structure_version=1;
|
||||
|
||||
iso_boot->type=ISO1T_BOOT_RECORD;
|
||||
@@ -418,7 +418,7 @@ public I64 ISOFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,
|
||||
iso_boot->version=1;
|
||||
StrCpy(iso_boot(U8 *)+7,"EL TORITO SPECIFICATION");
|
||||
|
||||
cur_blk=CD_FILE_OFFSET>>2;
|
||||
cur_blk=DVD_FILE_OFFSET>>2;
|
||||
|
||||
if (stage2_filename) {
|
||||
d=iso_boot(U8 *)+0x47;
|
||||
@@ -437,20 +437,20 @@ public I64 ISOFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,
|
||||
"%X: Pre Boot Blk\n",cur_blk;
|
||||
FWBlks(out_file,et,cur_blk++<<2,4);
|
||||
"%X: Boot Stage 1\n",cur_blk;
|
||||
cur_blk+=CD_BOOT_LOADER_SIZE/CD_BLK_SIZE;
|
||||
cur_blk+=DVD_BOOT_LOADER_SIZE/DVD_BLK_SIZE;
|
||||
}
|
||||
|
||||
CDFileCreate2(out_file,rootdir,&iso_pri->root_dir_record,
|
||||
DVDFileCreate2(out_file,rootdir,&iso_pri->root_dir_record,
|
||||
&iso_sup->root_dir_record,&cur_blk,rootdir,TRUE,
|
||||
stage2_filename,&stage2_blk);
|
||||
|
||||
tabbuf=CAlloc(tabsize*CD_BLK_SIZE);
|
||||
tabbuf=CAlloc(tabsize*DVD_BLK_SIZE);
|
||||
iso_pri->type_l_path_table=cur_blk;
|
||||
tabbuf->name_len=2; //Fill-in adam entry
|
||||
tempi=&iso_pri->root_dir_record;
|
||||
tabbuf->blk=tempi->loc.little;
|
||||
tabbuf->parent_entry_num=1;
|
||||
tabbuf2=CAlloc(tabsize2*CD_BLK_SIZE);
|
||||
tabbuf2=CAlloc(tabsize2*DVD_BLK_SIZE);
|
||||
iso_sup->type_l_path_table=cur_blk+tabsize;
|
||||
tabbuf2->name_len=2; //Fill-in adam entry
|
||||
tempi=&iso_sup->root_dir_record;
|
||||
@@ -460,7 +460,7 @@ public I64 ISOFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,
|
||||
itabbuf2=tabbuf2+1;
|
||||
first_free=2;
|
||||
for (i=1;i<=max_depth;i++)
|
||||
CDFillPathTable(rootdir,&itabbuf,&itabbuf2,1,FALSE,&first_free,1,i);
|
||||
DVDFillPathTable(rootdir,&itabbuf,&itabbuf2,1,FALSE,&first_free,1,i);
|
||||
"%X: Path Table 0\n",cur_blk;
|
||||
FWBlks(out_file,tabbuf,cur_blk<<2,tabsize<<2);
|
||||
cur_blk+=tabsize;
|
||||
@@ -468,13 +468,13 @@ public I64 ISOFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,
|
||||
FWBlks(out_file,tabbuf2,cur_blk<<2,tabsize2<<2);
|
||||
cur_blk+=tabsize2;
|
||||
|
||||
MemSet(tabbuf,0,tabsize*CD_BLK_SIZE);
|
||||
MemSet(tabbuf,0,tabsize*DVD_BLK_SIZE);
|
||||
iso_pri->type_m_path_table=EndianU32(cur_blk);
|
||||
tabbuf->name_len=2; //Fill-in adam entry
|
||||
tempi=&iso_pri->root_dir_record;
|
||||
tabbuf->blk=tempi->loc.big;
|
||||
tabbuf->parent_entry_num=EndianU16(1);
|
||||
MemSet(tabbuf2,0,tabsize2*CD_BLK_SIZE);
|
||||
MemSet(tabbuf2,0,tabsize2*DVD_BLK_SIZE);
|
||||
iso_sup->type_m_path_table=EndianU32(cur_blk+tabsize);
|
||||
tabbuf2->name_len=2; //Fill-in adam entry
|
||||
tempi=&iso_sup->root_dir_record;
|
||||
@@ -484,7 +484,7 @@ public I64 ISOFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,
|
||||
itabbuf2=tabbuf2+1;
|
||||
first_free=2;
|
||||
for (i=1;i<=max_depth;i++)
|
||||
CDFillPathTable(rootdir,&itabbuf,&itabbuf2,1,TRUE,&first_free,1,i);
|
||||
DVDFillPathTable(rootdir,&itabbuf,&itabbuf2,1,TRUE,&first_free,1,i);
|
||||
"%X: Path Table 2\n",cur_blk;
|
||||
FWBlks(out_file,tabbuf,cur_blk<<2,tabsize<<2);
|
||||
cur_blk+=tabsize;
|
||||
@@ -504,14 +504,14 @@ public I64 ISOFileCreate(U8 *_filename=NULL,U8 *src_files_find_mask,
|
||||
FWBlks(out_file,iso_boot,17<<2,4);
|
||||
FWBlks(out_file,iso_sup,18<<2,4);
|
||||
FWBlks(out_file,iso_term,19<<2,4);
|
||||
stage2_size=(Size(stage2_filename,"+s")+CD_BLK_SIZE-1)/CD_BLK_SIZE;
|
||||
MemCpy(stage1_buf,BCD_START,BCD_END-BCD_START);
|
||||
*(BCD_BLK_CNT-BCD_START+stage1_buf)(U16 *)=stage2_size;
|
||||
*(BCD_BLK_LO -BCD_START+stage1_buf)(U32 *)=stage2_blk;
|
||||
stage2_size=(Size(stage2_filename,"+s")+DVD_BLK_SIZE-1)/DVD_BLK_SIZE;
|
||||
MemCpy(stage1_buf,BDVD_START,BDVD_END-BDVD_START);
|
||||
*(BDVD_BLK_CNT-BDVD_START+stage1_buf)(U16 *)=stage2_size;
|
||||
*(BDVD_BLK_LO -BDVD_START+stage1_buf)(U32 *)=stage2_blk;
|
||||
"$$RED$$!!! Boot Stage 2 !!! %X-%X$$FG$$\n",
|
||||
stage2_blk,stage2_blk+stage2_size-1;
|
||||
FWBlks(out_file,stage1_buf,
|
||||
CD_FILE_OFFSET+1<<2,CD_BOOT_LOADER_SIZE/BLK_SIZE);
|
||||
DVD_FILE_OFFSET+1<<2,DVD_BOOT_LOADER_SIZE/BLK_SIZE);
|
||||
} else {
|
||||
FWBlks(out_file,iso_sup,17<<2,4);
|
||||
FWBlks(out_file,iso_term,18<<2,4);
|
||||
@@ -0,0 +1,9 @@
|
||||
Cd(__DIR__);;
|
||||
#include "BootDVD"
|
||||
#include "BootHD"
|
||||
#include "BootMHD"
|
||||
#include "BootMHD2"
|
||||
#include "DskISOFile"
|
||||
#include "BootIns"
|
||||
#include "Reboot"
|
||||
Cd("..");;
|
||||
@@ -1,10 +1,3 @@
|
||||
#include "BootCD"
|
||||
#include "BootHD"
|
||||
#include "BootMHD"
|
||||
#include "BootMHD2"
|
||||
#include "DskISOFile"
|
||||
#include "BootIns"
|
||||
|
||||
#help_index "Call"
|
||||
asm {
|
||||
_HI_CALL::
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,15 @@
|
||||
Cd(__DIR__);;
|
||||
#include "Diff"
|
||||
#include "FileBMP"
|
||||
#include "Find"
|
||||
#include "HeapLog"
|
||||
#include "LineRep"
|
||||
#include "LinkChk"
|
||||
#include "MemRep"
|
||||
#include "Merge"
|
||||
#include "Profiler"
|
||||
#include "StrUtils"
|
||||
#include "ToDolDoc"
|
||||
#include "ToHtml"
|
||||
#include "ToTXT"
|
||||
Cd("..");;
|
||||
@@ -63,10 +63,10 @@ I64 TaskQueSize(CTask *task)
|
||||
|
||||
I64 BlkDevsSize()
|
||||
{
|
||||
I64 i,result=MSize2(dsk.blkdevs);
|
||||
I64 i,result=MSize2(blkdev.blkdevs);
|
||||
CBlkDev *bd;
|
||||
for (i=0;i<NUM_BLKDEVS;i++) {
|
||||
bd=&dsk.blkdevs[i];
|
||||
bd=&blkdev.blkdevs[i];
|
||||
if (bd->bd_signature==BD_SIGNATURE_VAL) {
|
||||
if (bd->type==BDT_RAM)
|
||||
"RAMDsk %C\t:%010X Unused:%010X\n",
|
||||
@@ -80,9 +80,9 @@ I64 BlkDevsSize()
|
||||
|
||||
I64 DrvsSize()
|
||||
{
|
||||
I64 i,result=MSize2(dsk.drvs);
|
||||
I64 i,result=MSize2(blkdev.drvs);
|
||||
for (i=0;i<NUM_DRVS;i++)
|
||||
result+=MSize2(dsk.drvs[i].cur_map_blk)+MSize2(dsk.drvs[i].fis);
|
||||
result+=MSize2(blkdev.drvs[i].cur_fat_blk)+MSize2(blkdev.drvs[i].fis);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -165,10 +165,10 @@ Bool MemRepTask(CTask *task,Bool override_validate=FALSE)
|
||||
"TaskQues\t:%010X\n",n;
|
||||
"BlkDevs\t:%010X\n",BlkDevsSize;
|
||||
"Drvs\t:%010X\n",DrvsSize;
|
||||
if (dsk.cache_base)
|
||||
if (blkdev.cache_base)
|
||||
"DskCache\t:%010X\n",
|
||||
MSize2(dsk.cache_base)+MSize2(dsk.cache_hash_table)+
|
||||
MSize2(dsk.cache_ctrl);
|
||||
MSize2(blkdev.cache_base)+MSize2(blkdev.cache_hash_table)+
|
||||
MSize2(blkdev.cache_ctrl);
|
||||
"Clipboard\t:%010X\n",DocSize(sys_clipboard_doc);
|
||||
"AutoComplete:%010X\n",CallExtStr("AutoCompleteSize");
|
||||
"gr.to_8_bits\t:%010X\n",MSize2(gr.to_8_bits);
|
||||
@@ -193,7 +193,6 @@ public U0 MemRep()
|
||||
I64 i;
|
||||
CTask *task;
|
||||
CCPU *c;
|
||||
Bool old_preempt=Preempt;
|
||||
CBinFile *bfh=sys_boot_base-sizeof(CBinFile);
|
||||
bfh(I64)+=bfh->file_size-1;
|
||||
|
||||
@@ -233,5 +232,4 @@ public U0 MemRep()
|
||||
"$$BLACK$$dev.uncached_heap:%010X Used:%010X$$FG$$\n",
|
||||
dev.uncached_heap->bp->alloced_u8s,dev.uncached_heap->used_u8s;
|
||||
"$$ID,-2$$\n";
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
File renamed without changes.
@@ -9,7 +9,7 @@ I64 pf_buf_in_ptr=0,pf_depth;
|
||||
I64 pf_prof_active=0;
|
||||
|
||||
U0 ProfTimerInt(CTask *task)
|
||||
{//See $LK,"profiler_timer_irq",A="FF:::/Kernel/Ints.CPP,profiler_timer_irq"$.
|
||||
{//See $LK,"profiler_timer_irq",A="FF:::/Kernel/KInts.CPP,profiler_timer_irq"$.
|
||||
I64 i,k;
|
||||
if (Bt(&pf_prof_active,0))
|
||||
for (k=0;k<=pf_depth;k++) {
|
||||
File renamed without changes.
@@ -1,5 +1,7 @@
|
||||
#help_index "Cmd Line (Typically);DolDoc/Conversion;DolDoc/Cmd Line (Typically)"
|
||||
|
||||
public U0 ToDolDoc(U8 *files_find_mask,U8 *fu_flags=NULL)
|
||||
{//Convert text file to $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$.
|
||||
{//Convert text file to $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.TXT"$ by making double $$'s.
|
||||
CDoc *doc;
|
||||
I64 fuf_flags=0;
|
||||
CDirEntry *tempde,*tempde1;
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,6 @@
|
||||
#help_index "Snd"
|
||||
Cd(__DIR__);;
|
||||
|
||||
#help_index "Snd"
|
||||
class CSndWaveCtrl
|
||||
{
|
||||
I64 sample_rate,sample_bits,channels;
|
||||
@@ -17,3 +18,4 @@ public U0 SndTaskEndCB()
|
||||
#include "SndMusic"
|
||||
#include "SndEffects"
|
||||
#include "SndFile"
|
||||
Cd("..");;
|
||||
@@ -128,7 +128,7 @@ per second. It defaults to
|
||||
*/
|
||||
U8 *word,*last_st;
|
||||
I64 note,i=0,timeout_val,timeout_val2;
|
||||
Bool tie,old_preempt=Preempt;
|
||||
Bool tie;
|
||||
F64 f,d,on_jiffies,off_jiffies;
|
||||
music.play_note_num=0;
|
||||
while (*st) {
|
||||
@@ -186,7 +186,6 @@ per second. It defaults to
|
||||
|
||||
music.play_note_num++;
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
U0 MusicSettingsRst()
|
||||
@@ -214,7 +213,6 @@ MusicSettingsRst;
|
||||
|
||||
U0 CurSongTask()
|
||||
{
|
||||
Preempt(ON);
|
||||
Fs->task_end_cb=&SndTaskEndCB;
|
||||
while (TRUE)
|
||||
Play(music.cur_song);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#help_index "Info;Task"
|
||||
U0 TaskRepTask(CTask *task,I64 indent)
|
||||
{
|
||||
CTask *task1;
|
||||
U8 *st,*desc=MStrUtil(task->task_title,SUF_SAFE_DOLLAR);
|
||||
st=MStrPrint("$$MA,T=\"%08X\",LM=\"Kill(0x%X);\n\",$$",task,task,task);
|
||||
"%h*c%s $$TX,\"%Q...\",SCX=16$$ Mem:%08X\n",indent,CH_SPACE,
|
||||
st,desc,TaskMemAlloced(task);
|
||||
"%h*cFlags:%04X:%04X Time:%0.2fm\n",indent+2,CH_SPACE,
|
||||
task->task_flags,task->display_flags,
|
||||
task->total_time/60.0/cnts.time_stamp_freq_initial;
|
||||
Free(st);
|
||||
Free(desc);
|
||||
task1=task->next_child_task;
|
||||
while (task1!=(&task->next_child_task)(U8 *)
|
||||
-offset(CTask.next_sibling_task)) {
|
||||
TaskRepTask(task1,indent+2);
|
||||
task1=task1->next_sibling_task;
|
||||
}
|
||||
}
|
||||
|
||||
public U0 TaskRep()
|
||||
{//Report current tasks on all cores.
|
||||
I64 i;
|
||||
CCPU *c;
|
||||
PUSHFD
|
||||
CLI
|
||||
for (i=0;i<mp_cnt;i++) {
|
||||
c=&cpu_structs[i];
|
||||
"$$RED$$CPU:%d$$FG$$\n",i;
|
||||
TaskRepTask(c->seth_task,2);
|
||||
}
|
||||
POPFD
|
||||
}
|
||||
@@ -48,7 +48,6 @@ public CTaskSettings *SettingsPush(CTask *task=NULL,I64 flags=0)
|
||||
tempse->border_attr=task->border_attr;
|
||||
tempse->border_src =task->border_src;
|
||||
tempse->border=!Bt(&task->display_flags,DISPLAYf_NO_BORDER);
|
||||
tempse->preempt=Bt(&task->task_flags,TASKf_PREEMPT);
|
||||
if (TaskValidate(ac.task))
|
||||
tempse->autocomplete=TRUE;
|
||||
else
|
||||
@@ -88,12 +87,9 @@ U0 SettingsPop2(CTask *task,CTaskSettings *tempse)
|
||||
public U0 SettingsPop(CTask *task=NULL,I64 flags=0)
|
||||
{//Typically, called at end of an application.
|
||||
CTaskSettings *tempse;
|
||||
Bool old_preempt=Preempt;
|
||||
if (!task) task=Fs;
|
||||
if (!TaskValidate(task)) {
|
||||
Preempt(old_preempt);
|
||||
if (!TaskValidate(task))
|
||||
return;
|
||||
}
|
||||
if (tempse=task->next_settings) {
|
||||
task->next_settings=tempse->next;
|
||||
Cd(tempse->cur_dir);
|
||||
@@ -117,9 +113,6 @@ public U0 SettingsPop(CTask *task=NULL,I64 flags=0)
|
||||
WinMgrSync(,TRUE);
|
||||
SettingsPop2(task,tempse); //Redo in case was lost by old update
|
||||
|
||||
Preempt(old_preempt);
|
||||
LBEqu(&task->task_flags,TASKf_PREEMPT,tempse->preempt);
|
||||
Free(tempse);
|
||||
} else
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
}
|
||||
+114
-155
@@ -1,178 +1,141 @@
|
||||
#help_index "Help System"
|
||||
|
||||
public U0 PressKeyHelp(CTask *task=NULL)
|
||||
{//Jump to key handlers src for key presses.
|
||||
I64 a1=0,a2=0;
|
||||
Bool old_preempt=Preempt;
|
||||
CTask *old_hash=Fs->hash_table;
|
||||
if (!task) task=Fs;
|
||||
|
||||
/*
|
||||
This feature is a burden in code. It would be nice to lst key
|
||||
cmds for all applications, but it makes the code too ugly.
|
||||
*/
|
||||
task=Fs;
|
||||
|
||||
U8 *KeyMapKeyMStrPrint(I64 sc,U0 (*fp_handler)(I64 sc),
|
||||
U8 *desc,CTask *task=NULL)
|
||||
{
|
||||
I64 i=9,k,c;
|
||||
U8 *st,*st2,*result,*ptr;
|
||||
CHashTable *old_hash=Fs->hash_table;
|
||||
st=ScanCode2KeyName(sc);
|
||||
if (sc&SCF_CTRL) i+=5;
|
||||
if (sc&SCF_ALT) i+=4;
|
||||
if (sc&(SCF_SHIFT|SCF_NO_SHIFT)) i+=6;
|
||||
if (TaskValidate(task))
|
||||
Fs->hash_table=task->hash_table;
|
||||
"Press keys to show handler code.\n"
|
||||
"<SHIFT-ESC> to exit.\n"
|
||||
"Do not press <CTRL-ALT-keys>.\n";
|
||||
while (a1!=CH_ESC && a1!=CH_SHIFT_ESC) {
|
||||
GetMsg(&a1,&a2,1<<MSG_KEY_DOWN);
|
||||
*keydev.desc=0;
|
||||
keydev.handler=NULL;
|
||||
if (task==Fs)
|
||||
PutKey(a1,a2|SCF_KEY_DESC);
|
||||
else if (TaskValidate(task)) {
|
||||
PostMsg(task,MSG_KEY_DOWN,a1,a2|SCF_KEY_DESC);
|
||||
while (!keydev.handler)
|
||||
Yield;
|
||||
}
|
||||
if (*keydev.desc)
|
||||
E(keydev.handler,512);
|
||||
}
|
||||
st2=SrcEdLink(fp_handler,256);
|
||||
Fs->hash_table=old_hash;
|
||||
Preempt(old_preempt);
|
||||
|
||||
k=*desc(U32 *);
|
||||
if (k=='Edit') c=BLUE;
|
||||
else if (k=='Dol ') c=GREEN;
|
||||
else if (k=='Cmd ') c=RED;
|
||||
else c=BLACK;
|
||||
|
||||
result=MStrPrint("%-*s $$FG,%d$$$$TX+UL+L+PU,\"%Q\",A=\"%s\"$$$$FG$$\n",
|
||||
i,st,c,desc,st2);
|
||||
Free(st);
|
||||
Free(st2);
|
||||
|
||||
ptr=result;
|
||||
while (*ptr) {
|
||||
if (*ptr==CH_SPACE)
|
||||
*ptr=CH_SHIFT_SPACE;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
U0 KeyMapCtrlAltFamily()
|
||||
U0 KeyMapKeyPrint(I64 sc,U0 (*fp_handler)(I64 sc),U8 *desc,CTask *task=NULL)
|
||||
{
|
||||
I64 i,a2;
|
||||
U8 *st,*st2;
|
||||
|
||||
a2=SC_DELETE+SCF_CTRL+SCF_ALT;
|
||||
st2=ScanCode2KeyName(a2);
|
||||
st=SrcEdLink(&Reboot,256);
|
||||
"%20s $$LK,\"%s\",A=\"%s\"$$\n",st2,"Sys/Reboot",st;
|
||||
U8 *st=KeyMapKeyMStrPrint(sc,fp_handler,desc,task);
|
||||
"%s",st;
|
||||
Free(st);
|
||||
Free(st2);
|
||||
}
|
||||
|
||||
a2=SC_ESC+SCF_CTRL+SCF_ALT;
|
||||
st2=ScanCode2KeyName(a2);
|
||||
st=SrcEdLink(&User,256);
|
||||
"%20s $$LK,\"%s\",A=\"%s\"$$\n",st2,"Sys/Spawn New User Task",st;
|
||||
Free(st);
|
||||
Free(st2);
|
||||
U0 KeyMapCtrlAltFamily(Bool no_shift,Bool shift)
|
||||
{
|
||||
I64 i,no_shift_f;
|
||||
if (no_shift && shift)
|
||||
no_shift_f=SCF_NO_SHIFT;
|
||||
else
|
||||
no_shift_f=0;
|
||||
if (no_shift) KeyMapKeyPrint(SC_DELETE+SCF_CTRL+SCF_ALT+no_shift_f,
|
||||
&Reboot,"Cmd /Reboot");
|
||||
if (no_shift) KeyMapKeyPrint(SC_ESC+SCF_CTRL+SCF_ALT+no_shift_f,
|
||||
&User,"Cmd /Spawn New User Task");
|
||||
if (no_shift) KeyMapKeyPrint(SC_TAB+SCF_CTRL+SCF_ALT+no_shift_f,
|
||||
&WinToTop,"Cmd /Switch Focus to Next Task");
|
||||
|
||||
a2=SC_TAB+SCF_CTRL+SCF_ALT;
|
||||
st2=ScanCode2KeyName(a2);
|
||||
st=SrcEdLink(&WinToTop,256);
|
||||
"%20s $$LK,\"%s\",A=\"%s\"$$\n",st2,"Sys/Switch Focus to Next Task",st;
|
||||
Free(st);
|
||||
Free(st2);
|
||||
|
||||
for (i=0;i<26;i++) {
|
||||
if (keydev.fp_ctrl_alt_let_cbs[i] &&
|
||||
keydev.ctrl_alt_let_descs[i]) {
|
||||
a2=Char2ScanCode(i+'a')+SCF_CTRL+SCF_ALT;
|
||||
st2=ScanCode2KeyName(a2);
|
||||
st=SrcEdLink(keydev.fp_ctrl_alt_let_cbs[i],256);
|
||||
"%20s $$LK,\"%s\",A=\"%s\"$$\n",st2,keydev.ctrl_alt_let_descs[i],st;
|
||||
Free(st);
|
||||
Free(st2);
|
||||
for (i=0;i<26;i++)
|
||||
if (keydev.fp_ctrl_alt_cbs[i]) {
|
||||
if (no_shift && keydev.ctrl_alt_no_shift_descs[i])
|
||||
KeyMapKeyPrint(Char2ScanCode(i+'a')+SCF_CTRL+SCF_ALT+no_shift_f,
|
||||
keydev.fp_ctrl_alt_cbs[i],keydev.ctrl_alt_no_shift_descs[i]);
|
||||
if (shift && keydev.ctrl_alt_shift_descs[i])
|
||||
KeyMapKeyPrint(Char2ScanCode(i+'a')+SCF_CTRL+SCF_ALT+SCF_SHIFT,
|
||||
keydev.fp_ctrl_alt_cbs[i],keydev.ctrl_alt_shift_descs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
U0 KMComparePrepare(U8 *buf,I64 *src)
|
||||
{
|
||||
I64 i,*dst=buf;
|
||||
U8 *ptr;
|
||||
if (src) {
|
||||
*dst++=*src++;
|
||||
*dst++=*src++;
|
||||
*dst++=*src++;
|
||||
*dst++=*src++;
|
||||
*dst(U8 *)=0;
|
||||
if (ptr=StrMatch("SHIFT",buf)) {
|
||||
for (i=0;i<5;i++)
|
||||
ptr[i]=CH_SHIFT_SPACE;
|
||||
if (ptr=StrMatch("$$",buf))
|
||||
*ptr=255;
|
||||
}
|
||||
} else
|
||||
*buf=0;
|
||||
}
|
||||
|
||||
I64 KMCompare(U8 *e1,U8 *e2)
|
||||
{
|
||||
I64 i,ch1,ch2;
|
||||
U8 *ee1,*ee2;
|
||||
Bool e1_shift=FALSE,e2_shift=FALSE;
|
||||
if (e1) {
|
||||
if (e2) {
|
||||
while (*e1==CH_SPACE)
|
||||
e1++;
|
||||
while (*e2==CH_SPACE)
|
||||
e2++;
|
||||
while (*e1 && *e1==*e2) {
|
||||
e1++;
|
||||
e2++;
|
||||
}
|
||||
if (!StrNCmp(e1,"SHIFT",5)) {
|
||||
e1+=6;
|
||||
e1_shift=TRUE;
|
||||
} else if (!StrNCmp(e1," ",5))
|
||||
e1+=6;
|
||||
if (!StrNCmp(e2,"SHIFT",5)) {
|
||||
e2+=6;
|
||||
e2_shift=TRUE;
|
||||
} else if (!StrNCmp(e2," ",5))
|
||||
e2+=6;
|
||||
|
||||
ee1=e1;
|
||||
while (*ee1 && *ee1!='$$')
|
||||
ee1++;
|
||||
ch1=*ee1;
|
||||
*ee1=0;
|
||||
|
||||
ee2=e2;
|
||||
while (*ee2 && *ee2!='$$')
|
||||
ee2++;
|
||||
ch2=*ee2;
|
||||
*ee2=0;
|
||||
|
||||
i=StrCmp(e1,e2);
|
||||
|
||||
*ee1=ch1;
|
||||
*ee2=ch2;
|
||||
|
||||
if (i)
|
||||
return i;
|
||||
else
|
||||
return e1_shift-e2_shift;
|
||||
} else
|
||||
return 1;
|
||||
} else {
|
||||
if (e2)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
U8 buf1[STR_LEN],buf2[STR_LEN];
|
||||
KMComparePrepare(buf1,e1);
|
||||
KMComparePrepare(buf2,e2);
|
||||
return StrCmp(buf1,buf2);
|
||||
}
|
||||
|
||||
U0 KeyMapFamily2(U8 **entries,U8 *family,CTask *task,I64 scf)
|
||||
U0 KeyMapFamily2(U8 **entries,CTask *task,I64 scf)
|
||||
{
|
||||
I64 i,a2,a1;
|
||||
U8 *st,*st2;
|
||||
CTask *old_hash=Fs->hash_table;
|
||||
Fs->hash_table=task->hash_table;
|
||||
I64 i,a1,a2;
|
||||
for (i=0;i<256;i++) {
|
||||
a2=scf|i|SCF_KEY_DESC;
|
||||
a1=ScanCode2Char(a2);
|
||||
*keydev.desc=0;
|
||||
keydev.handler=NULL;
|
||||
if (TaskValidate(task) && !Bt(&task->win_inhibit,WIf_SELF_KEY_DESC)) {
|
||||
if (task==Fs)
|
||||
PutKey(a1,a2);
|
||||
else if (TaskValidate(task)) {
|
||||
else
|
||||
PostMsg(task,MSG_KEY_DOWN,a1,a2);
|
||||
while (!keydev.handler)
|
||||
Yield;
|
||||
WinMgrSync(0,TRUE);
|
||||
Sleep(1);
|
||||
}
|
||||
if (*keydev.desc && StrNCmp(keydev.desc,"Char/",5)) {
|
||||
st=ScanCode2KeyName(a2&~(SCF_CTRL|SCF_ALT|SCF_SHIFT));
|
||||
st2=MStrPrint("%s %s",family,st);
|
||||
Free(st);
|
||||
st=SrcEdLink(keydev.handler,256);
|
||||
entries[i]=MStrPrint("%20s $$LK,\"%s\",A=\"%s\"$$\n",
|
||||
st2,keydev.desc,st);
|
||||
Free(st);
|
||||
Free(st2);
|
||||
if (*keydev.desc && StrNCmp(keydev.desc,"Char /",7))
|
||||
entries[i]=KeyMapKeyMStrPrint(a2,keydev.handler,keydev.desc,task);
|
||||
}
|
||||
}
|
||||
Fs->hash_table=old_hash;
|
||||
}
|
||||
|
||||
U0 KeyMapFamily(U8 *family,CTask *task,I64 scf)
|
||||
U0 KeyMapFamily(CTask *task,I64 scf,Bool no_shift,Bool shift)
|
||||
{
|
||||
I64 i;
|
||||
U8 **entries=CAlloc(2*256*sizeof(U8 *)),st1[32],st2[32];
|
||||
StrPrint(st1,"%s ",family);
|
||||
StrPrint(st2,"%s SHIFT",family);
|
||||
KeyMapFamily2(entries ,st1,task,scf);
|
||||
KeyMapFamily2(entries+256,st2,task,scf+SCF_SHIFT);
|
||||
QSortI64(entries,2*256,&KMCompare);
|
||||
for (i=0;i<2*256;i++)
|
||||
I64 i,cnt=0;
|
||||
U8 **entries=CAlloc(2*256*sizeof(U8 *)),**ptr=entries;
|
||||
if (no_shift) {
|
||||
if (shift)
|
||||
KeyMapFamily2(ptr,task,scf+SCF_NO_SHIFT);
|
||||
else
|
||||
KeyMapFamily2(ptr,task,scf);
|
||||
ptr+=256;
|
||||
cnt+=256;
|
||||
}
|
||||
if (shift) {
|
||||
KeyMapFamily2(ptr,task,scf+SCF_SHIFT);
|
||||
ptr+=256;
|
||||
cnt+=256;
|
||||
}
|
||||
QSortI64(entries,cnt,&KMCompare);
|
||||
for (i=0;i<cnt;i++)
|
||||
if (entries[i]) {
|
||||
"%s",entries[i];
|
||||
Free(entries[i]);
|
||||
@@ -182,20 +145,16 @@ U0 KeyMapFamily(U8 *family,CTask *task,I64 scf)
|
||||
|
||||
public U0 KeyMap(CTask *task=NULL)
|
||||
{//Report desc of all keys.
|
||||
Bool old_key_desc;
|
||||
if (!task) task=Fs;
|
||||
/*
|
||||
This feature is a burden in code. It would be nice to lst key
|
||||
cmds for all applications, but it makes the code too ugly.
|
||||
*/
|
||||
task=Fs;
|
||||
|
||||
old_key_desc=LBtr(&task->win_inhibit,WIf_SELF_KEY_DESC);
|
||||
DocMax;
|
||||
KeyMapFamily("",task,0);
|
||||
KeyMapFamily("CTRL",task,SCF_CTRL);
|
||||
KeyMapFamily("ALT",task,SCF_ALT);
|
||||
KeyMapCtrlAltFamily;
|
||||
"\n$$MA-X+PU,\"Click for help on key pressed\","
|
||||
"LM=\"PressKeyHelp(0x%X);\"$$\n",task;
|
||||
KeyMapFamily(task,0,TRUE,TRUE);
|
||||
KeyMapFamily(task,SCF_CTRL,TRUE,TRUE);
|
||||
KeyMapFamily(task,SCF_ALT,TRUE,TRUE);
|
||||
KeyMapCtrlAltFamily(TRUE,TRUE);
|
||||
LBEqu(&task->win_inhibit,WIf_SELF_KEY_DESC,old_key_desc);
|
||||
"\nKeyMap Completed.\n";
|
||||
}
|
||||
|
||||
#help_index "Help System/Training"
|
||||
|
||||
Loaded 100 of 549 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user