TempleOSCD_150720.ISO
This commit is contained in:
1 parent
401601816c
commit
f8c05f98f4
554 files changed
+26046
-24853
No files matched your search
Binary file not shown.
@@ -43,14 +43,15 @@ public U8 *ACDDefGet(U8 *st,I64 def_num=1)
|
||||
CFile *f;
|
||||
CHashGeneric *temph;
|
||||
U8 *result=NULL,*buf,*in_ptr,
|
||||
*st2=MStrUtil(st,SUF_TO_UPPER);
|
||||
*st2=MStrUtil(st,SUF_TO_UPPER);
|
||||
temph=HashFind(st2,ac.hash_table,HTT_DICT_WORD);
|
||||
Free(st2);
|
||||
if (temph) {
|
||||
if (f=FOpen(ACD_DEF_FILENAME,"r")) {
|
||||
buf=MAlloc(ACD_BLK_SIZE*2+1);
|
||||
buf[ACD_BLK_SIZE*2]=0; //terminate
|
||||
FRBlks(f,buf,temph->user_data0*ACD_BLK_SIZE/BLK_SIZE,ACD_BLK_SIZE*2/BLK_SIZE);
|
||||
FRBlks(f,buf,temph->user_data0*ACD_BLK_SIZE/BLK_SIZE,
|
||||
ACD_BLK_SIZE*2/BLK_SIZE);
|
||||
FClose(f);
|
||||
in_ptr=buf;
|
||||
while (in_ptr<buf+ACD_BLK_SIZE*2) {
|
||||
@@ -59,7 +60,7 @@ public U8 *ACDDefGet(U8 *st,I64 def_num=1)
|
||||
if (*in_ptr++==ACD_WORD_CHAR) {
|
||||
if (!StrICmp(st,in_ptr)) {
|
||||
while (def_num && *in_ptr!=ACD_WORD_CHAR
|
||||
&& in_ptr<buf+ACD_BLK_SIZE*2) {
|
||||
&& in_ptr<buf+ACD_BLK_SIZE*2) {
|
||||
if (*in_ptr==ACD_DEF_CHAR) {
|
||||
if (!--def_num)
|
||||
break;
|
||||
@@ -86,14 +87,15 @@ public U8 *ACDDefsGet(U8 *st)
|
||||
CFile *f;
|
||||
CHashGeneric *temph;
|
||||
U8 *result=NULL,*buf,*in_ptr,*in_ptr2,
|
||||
*st2=MStrUtil(st,SUF_TO_UPPER);
|
||||
*st2=MStrUtil(st,SUF_TO_UPPER);
|
||||
temph=HashFind(st2,ac.hash_table,HTT_DICT_WORD);
|
||||
Free(st2);
|
||||
if (temph) {
|
||||
if (f=FOpen(ACD_DEF_FILENAME,"r")) {
|
||||
buf=MAlloc(ACD_BLK_SIZE*2+1);
|
||||
buf[ACD_BLK_SIZE*2]=0; //terminate
|
||||
FRBlks(f,buf,temph->user_data0*ACD_BLK_SIZE/BLK_SIZE,ACD_BLK_SIZE*2/BLK_SIZE);
|
||||
FRBlks(f,buf,temph->user_data0*ACD_BLK_SIZE/BLK_SIZE,
|
||||
ACD_BLK_SIZE*2/BLK_SIZE);
|
||||
FClose(f);
|
||||
in_ptr=buf;
|
||||
while (in_ptr<buf+ACD_BLK_SIZE*2) {
|
||||
@@ -104,7 +106,7 @@ public U8 *ACDDefsGet(U8 *st)
|
||||
in_ptr2=in_ptr;
|
||||
in_ptr--;
|
||||
while (*in_ptr2!=ACD_WORD_CHAR
|
||||
&& in_ptr2<buf+ACD_BLK_SIZE*2) {
|
||||
&& in_ptr2<buf+ACD_BLK_SIZE*2) {
|
||||
in_ptr2++;
|
||||
}
|
||||
result=MAlloc(in_ptr2+1-in_ptr);
|
||||
@@ -129,7 +131,7 @@ public U8 *ACDWordPtAt(U8 *st)
|
||||
{//Point to word in word list.
|
||||
I64 i;
|
||||
U8 *start=acd.word_lst,*r=start,
|
||||
*end=acd.word_lst+acd.word_lst_size;
|
||||
*end=acd.word_lst+acd.word_lst_size;
|
||||
if (!st || !*st)
|
||||
return acd.word_lst;
|
||||
if (acd.word_lst_size) {
|
||||
@@ -219,7 +221,7 @@ public U0 ACDDefsPut(CDoc *doc=NULL,U8 *st,I64 num=-1)
|
||||
break;
|
||||
case ACD_DEF_CHAR:
|
||||
DocPrint(doc,"$$GREEN$$(%d)$$FG$$ %s\n",
|
||||
++i,st2);
|
||||
++i,st2);
|
||||
break;
|
||||
case ACD_PRONUNCIATION_CHAR:
|
||||
DocPrint(doc,"$$LTGREEN$$%s$$FG$$\n",st2);
|
||||
@@ -239,7 +241,7 @@ public U0 ACDDefsPut(CDoc *doc=NULL,U8 *st,I64 num=-1)
|
||||
while (st2=ACDDefGet(st,++i)) {
|
||||
if (i==num)
|
||||
DocPrint(doc,"$$GREEN$$(%d)$$FG$$ %s\n",
|
||||
i,st2);
|
||||
i,st2);
|
||||
Free(st2);
|
||||
}
|
||||
}
|
||||
@@ -263,22 +265,22 @@ U0 ACFindMisspelled(CDoc *doc)
|
||||
{
|
||||
Bool unlock=DocLock(doc);
|
||||
CDocEntry *doc_e=doc->cur_entry;
|
||||
I64 col=doc->cur_data_col,col2,ch;
|
||||
I64 col=doc->cur_col,col2,ch;
|
||||
do {
|
||||
if (doc_e!=doc && doc_e->de_flags&DOCEF_TAG) {
|
||||
while (col<doc_e->max_col) {
|
||||
while (col<doc_e->max_col && !Bt(chars_bitmap_word,doc_e->tag[col]))
|
||||
while (col<doc_e->max_col && !Bt(chars_bmp_word,doc_e->tag[col]))
|
||||
col++;
|
||||
if (col<doc_e->max_col) {
|
||||
col2=col;
|
||||
while (col2<doc_e->max_col && Bt(chars_bitmap_word,doc_e->tag[col2]))
|
||||
while (col2<doc_e->max_col && Bt(chars_bmp_word,doc_e->tag[col2]))
|
||||
col2++;
|
||||
ch=doc_e->tag[col2];
|
||||
doc_e->tag[col2]=0;
|
||||
if (StrICmp(&doc_e->tag[col],ACDWordPtAt(&doc_e->tag[col])+1)) {
|
||||
doc_e->tag[col2]=ch;
|
||||
doc->cur_entry=doc_e;
|
||||
doc->cur_data_col=col;
|
||||
doc->cur_col=col;
|
||||
goto fm_done;
|
||||
}
|
||||
doc_e->tag[col2]=ch;
|
||||
|
||||
@@ -4,19 +4,59 @@ which will regenerate processed dictionary
|
||||
files from a raw Project Gutenberg
|
||||
dictionary file.
|
||||
|
||||
Supply the raw dictionary filename in
|
||||
the call at the bottom of this file
|
||||
and #include this file.
|
||||
|
||||
I ran $LK,"::/Misc/ToDolDoc.CPP"$ on it, first.
|
||||
$TX,"http://www.templeos.org/files/DICTIONARY.TXT",HTML="http://www.templeos.org/files/DICTIONARY.TXT"$
|
||||
|
||||
See $LK,"::/Doc/Credits.TXT"$.
|
||||
*/
|
||||
|
||||
U0 ACDPreprocess(U8 *in_name,U8 *out_name)
|
||||
{/*
|
||||
<cr><nl>--> <nl>
|
||||
$$ --> $$$$
|
||||
\'89 --> ‰
|
||||
*/
|
||||
I64 ch,i;
|
||||
U8 *src,*dst;
|
||||
CDoc *doc;
|
||||
CDocEntry *doc_e;
|
||||
if (doc=DocRead(in_name,DOCF_PLAIN_TEXT_WITH_TABS|DOCF_DBL_DOLLARS)) {
|
||||
doc_e=doc->root.next;
|
||||
while (doc_e!=doc) {
|
||||
if (doc_e->type_u8==DOCT_TEXT) {
|
||||
src=dst=doc_e->tag;
|
||||
while (ch=*src++) {
|
||||
if (ch=='\\' && *src=='\'') {
|
||||
src++;
|
||||
i=0;
|
||||
ch=ToUpper(*src++);
|
||||
if ('0'<=ch<='9')
|
||||
i+=ch-'0';
|
||||
else if ('A'<=ch<='F')
|
||||
i+=ch-'A'+10;
|
||||
i<<=4;
|
||||
ch=ToUpper(*src++);
|
||||
if ('0'<=ch<='9')
|
||||
i+=ch-'0';
|
||||
else if ('A'<=ch<='F')
|
||||
i+=ch-'A'+10;
|
||||
*dst++=i;
|
||||
} else
|
||||
*dst++=ch;
|
||||
}
|
||||
*dst=0;
|
||||
}
|
||||
doc_e=doc_e->next;
|
||||
}
|
||||
StrCpy(doc->filename.name,out_name);
|
||||
DocWrite(doc);
|
||||
DocDel(doc);
|
||||
}
|
||||
}
|
||||
|
||||
I64 ACDNextCmd(U8 **_ptr)
|
||||
{
|
||||
U8 ch,*ptr=*_ptr,*ptr2;
|
||||
I64 result=-1;
|
||||
U8 *ptr=*_ptr,*ptr2;
|
||||
I64 ch,result=-1;
|
||||
do {
|
||||
do {
|
||||
if (!(ch=*ptr++)) goto ncmd_done;
|
||||
@@ -28,21 +68,22 @@ I64 ACDNextCmd(U8 **_ptr)
|
||||
} while (ch!='>');
|
||||
*--ptr2=0;
|
||||
result=LstMatch(ptr,"h1\0/h1\0def\0/def\0hw\0/hw\0tt\0/tt\0"
|
||||
"ety\0@fld\0@cd\0@blockquote\0@wordforms\0@note\0@altname\0@chform\0@cref\0@syn\0"
|
||||
"/ety\0@/fld\0@/cd\0@/blockquote\0@/wordforms\0@/note\0@/altname\0@/chform\0@/cref\0@/syn\0");
|
||||
"ety\0@fld\0@cd\0@blockquote\0@wordforms\0@note\0@altname\0@chform\0"
|
||||
"@cref\0@syn\0/ety\0@/fld\0@/cd\0@/blockquote\0@/wordforms\0@/note\0"
|
||||
"@/altname\0@/chform\0@/cref\0@/syn\0");
|
||||
*ptr2++='>';
|
||||
ptr=ptr2;
|
||||
} while (result<0);
|
||||
|
||||
ncmd_done:
|
||||
ncmd_done:
|
||||
*_ptr=ptr;
|
||||
return result;
|
||||
}
|
||||
|
||||
U8 *ACDNextEntry(U8 **_ptr)
|
||||
{
|
||||
U8 *result,*ignore,ch,*ptr=*_ptr,buf[ACD_BLK_SIZE],*out_ptr=buf;
|
||||
I64 l;
|
||||
U8 *result,*ignore,*ptr=*_ptr,buf[ACD_BLK_SIZE],*out_ptr=buf;
|
||||
I64 ch,l;
|
||||
while (TRUE) {
|
||||
while (TRUE) {
|
||||
if (!(ch=*ptr++)) goto nentry_done;
|
||||
@@ -54,9 +95,9 @@ U8 *ACDNextEntry(U8 **_ptr)
|
||||
break;
|
||||
}
|
||||
ignore="b>\0i>\0ppp>\0/b>\0/i>\0/p>\0"
|
||||
"ets>\0col>\0spn>\0/ets>\0/col>\0/spn>\0er>\0as>\0cs>\0cd>\0ex>\0"
|
||||
"/er>\0/as>\0/cs>\0/cd>\0/ex>\0"
|
||||
"note>\0/note>\0blockquote>\0/blockquote>\0";
|
||||
"ets>\0col>\0spn>\0/ets>\0/col>\0/spn>\0er>\0as>\0cs>\0cd>\0ex>\0"
|
||||
"/er>\0/as>\0/cs>\0/cd>\0/ex>\0"
|
||||
"note>\0/note>\0blockquote>\0/blockquote>\0";
|
||||
while (*ignore) {
|
||||
l=StrLen(ignore);
|
||||
if (!StrNCmp(ptr,ignore,l)) {
|
||||
@@ -83,8 +124,8 @@ I64 ACDCompareWords(U8 *e1,U8 *e2)
|
||||
U8 *ACDSortWords(U8 *start,I64 size,I64 word_cnt)
|
||||
{
|
||||
U8 **ptr_array=MAlloc(sizeof(U8 *)*word_cnt),
|
||||
*out_start=MAlloc(size),
|
||||
*ptr=start,*ptr2;
|
||||
*out_start=MAlloc(size),
|
||||
*ptr=start,*ptr2;
|
||||
I64 i=0;
|
||||
while (*ptr) {
|
||||
ptr_array[i++]=ptr;
|
||||
@@ -107,14 +148,14 @@ U8 *ACDSortWords(U8 *start,I64 size,I64 word_cnt)
|
||||
return out_start;
|
||||
}
|
||||
|
||||
U0 ACDGen(U8 *raw_dict_filename)
|
||||
U0 ACDGen(U8 *in_file)
|
||||
{
|
||||
I64 cmd,size,word_cnt=0,largest_entry=0;
|
||||
U8 *st,*in_ptr=FileRead(raw_dict_filename,&size),*in_start=in_ptr,
|
||||
*out_ptr=MAlloc(size),*out_start=out_ptr,
|
||||
*word_ptr=MAlloc(size),*word_start=word_ptr,
|
||||
*last_word="",*def_word_start=out_ptr,
|
||||
*sorted_word_start;
|
||||
U8 *st,*in_ptr=FileRead(in_file,&size),*in_start=in_ptr,
|
||||
*out_ptr=MAlloc(size),*out_start=out_ptr,
|
||||
*word_ptr=MAlloc(size),*word_start=word_ptr,
|
||||
*last_word="",*def_word_start=out_ptr,
|
||||
*sorted_word_start;
|
||||
U16 *d;
|
||||
if (!in_ptr) return;
|
||||
do {
|
||||
@@ -137,7 +178,7 @@ next_word:
|
||||
d=word_ptr;
|
||||
*d=(out_ptr-out_start)/ACD_BLK_SIZE;
|
||||
word_ptr+=2;
|
||||
|
||||
|
||||
*out_ptr++=ACD_WORD_CHAR;
|
||||
StrCpy(out_ptr,st);
|
||||
out_ptr+=StrLen(st)+1;
|
||||
@@ -149,7 +190,8 @@ next_word:
|
||||
cmd=ACDNextCmd(&in_ptr);
|
||||
if (cmd==ACD_H1)
|
||||
goto next_word;
|
||||
} while (cmd>=0 && !(cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||cmd==ACD_POS||cmd==ACD_EXTRA));
|
||||
} while (cmd>=0 && !(cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||
|
||||
cmd==ACD_POS||cmd==ACD_EXTRA));
|
||||
if (cmd==ACD_DEF) {
|
||||
if(st=ACDNextEntry(&in_ptr)) {
|
||||
if (*st) {
|
||||
@@ -187,7 +229,8 @@ next_word:
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
} while (cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||cmd==ACD_POS||cmd==ACD_EXTRA);
|
||||
} while (cmd==ACD_DEF||cmd==ACD_PRONUNCIATION||
|
||||
cmd==ACD_POS||cmd==ACD_EXTRA);
|
||||
} else
|
||||
Free(st);
|
||||
}
|
||||
@@ -215,4 +258,6 @@ next_word:
|
||||
Free(sorted_word_start);
|
||||
}
|
||||
|
||||
ACDGen("DICTIONARY.TXT");
|
||||
Cd(__DIR__);
|
||||
ACDPreprocess("DICTIONARY.TXT","DICTIONARY2.TXT");
|
||||
ACDGen("DICTIONARY2.TXT");
|
||||
@@ -24,7 +24,7 @@ U0 ACSingleFileAdd(U8 *buf)
|
||||
while (TRUE) {
|
||||
while (TRUE) {
|
||||
if (ch=*ptr++) {
|
||||
if (Bt(chars_bitmap_alpha_numeric,ch))
|
||||
if (Bt(chars_bmp_alpha_numeric,ch))
|
||||
break;
|
||||
} else
|
||||
return;
|
||||
@@ -34,7 +34,7 @@ U0 ACSingleFileAdd(U8 *buf)
|
||||
ptr--;
|
||||
while (TRUE) {
|
||||
if (ch=*ptr2++) {
|
||||
if (Bt(chars_bitmap_alpha_numeric,ch))
|
||||
if (Bt(chars_bmp_alpha_numeric,ch))
|
||||
*ptr3++=ch;
|
||||
else if (ch!=CH_CURSOR)
|
||||
break;
|
||||
@@ -54,7 +54,7 @@ I64 ACSkipCrap(U8 *src,I64 len)
|
||||
I64 j;
|
||||
j=len-1;
|
||||
while (j>=0) {
|
||||
if (Bt(chars_bitmap_alpha_numeric,src[j]))
|
||||
if (Bt(chars_bmp_alpha_numeric,src[j]))
|
||||
break;
|
||||
else
|
||||
j--;
|
||||
@@ -67,7 +67,7 @@ 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_bitmap_alpha_numeric,src[i]))
|
||||
if (!Bt(chars_bmp_alpha_numeric,src[i]))
|
||||
break;
|
||||
else
|
||||
i--;
|
||||
@@ -92,7 +92,7 @@ U0 ACMan(I64 n,CTask *parent_task=NULL)
|
||||
{
|
||||
CHashAC *tempw;
|
||||
CHashSrcSym *temph;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
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) {
|
||||
@@ -105,7 +105,8 @@ U0 ACMan(I64 n,CTask *parent_task=NULL)
|
||||
U0 ACFillInAdd(CHashAC *tempw)
|
||||
{
|
||||
I64 k;
|
||||
if (ac.num_fillins<AC_MAX_FILLINS || tempw->hits>ac.fillin_hits[ac.num_fillins-1]) {
|
||||
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;
|
||||
@@ -149,15 +150,15 @@ U0 ACPutChoices(CDoc *focus_l,CDocEntry *doc_e,CTask *focus_task)
|
||||
ac.num_fillins=0;
|
||||
if (*ac.cur_word) {
|
||||
Preempt(ON);
|
||||
for (i=0;i<=ac.hash_table->mask;i++) {
|
||||
for (i=0;i<=ac.hash_table->mask && tS<timeout_time;i++) {
|
||||
tempw=ac.hash_table->body[i];
|
||||
while (tempw && tS<timeout_time) {
|
||||
while (tempw) {
|
||||
if (!MemCmp(ac.cur_word,tempw->str,StrLen(ac.cur_word)))
|
||||
ACFillInAdd(tempw);
|
||||
tempw=tempw->next;
|
||||
}
|
||||
}
|
||||
Preempt(OFF);
|
||||
Preempt;
|
||||
}
|
||||
DocRst(doc,TRUE);
|
||||
doc->flags|=DOCF_MIN_SIZE;
|
||||
@@ -203,12 +204,14 @@ U0 ACTask(I64)
|
||||
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;
|
||||
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))
|
||||
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)) {
|
||||
@@ -244,7 +247,8 @@ 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);
|
||||
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);
|
||||
@@ -260,7 +264,7 @@ U0 ACMainFileLstTraverse(U8 *files_find_mask)
|
||||
public Bool AutoComplete(Bool val=OFF)
|
||||
{//Turn AutoComplete OFF (or ON).
|
||||
Bool old_autocomplete=FALSE,
|
||||
old_preempt=Preempt(OFF);
|
||||
old_preempt=Preempt;
|
||||
if (val) {
|
||||
while (Bt(&ac.flags,ACf_INIT_IN_PROGRESS))
|
||||
Sleep(10);
|
||||
@@ -308,7 +312,8 @@ public U0 ACInit(U8 *mask=NULL)
|
||||
Yield;
|
||||
AutoComplete;
|
||||
|
||||
if (IsDrvWritable && FileFind(ACD_DEF_FILENAME_Z) && !FileFind(ACD_DEF_FILENAME)) {
|
||||
if (DrvIsWritable && FileFind(ACD_DEF_FILENAME_Z) &&
|
||||
!FileFind(ACD_DEF_FILENAME)) {
|
||||
if (bd->type!=BDT_RAM) {
|
||||
start_flag=FALSE;
|
||||
Spawn(&ACProgressTask,&start_flag);
|
||||
|
||||
Binary file not shown.
@@ -19,8 +19,8 @@ public class CAutoCompleteGlbls
|
||||
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}};
|
||||
{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"
|
||||
|
||||
Reference in new issue
Block a user