TempleOSCDV4.13.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:48:03 +02:00
1 parent b84bbff6db
commit 122df6338e
78 files changed
+3570 -2729

No files matched your search

+100 -45
View File
@@ -2,27 +2,40 @@
//See $LK,"::/Doc/Credits.DD"$.
U0 HtmlPutS(CDoc *doc,I64 u32_attr,I64 *_old_u32_attr,
#define DOCET_UNDEF_COLOR 0x100000000
#define DOCET_LINK_UNDERLINE 0x200000000
U0 HtmlPutS(CDoc *doc,I64 u32_attr,I64 *_old_u32_attr,Bool underline_update,
U8 *st,I64 *_col,U8 *style_bitmap=NULL)
{
U8 *ch,*ptr;
u32_attr&=0xFFFFFF00;
if (u32_attr&DOCET_INVERT)
u32_attr.u8[1]=(u32_attr.u8[1]&15)<<4|u32_attr.u8[1]>>4;
if (u32_attr!=*_old_u32_attr) {
if (!(u32_attr&DOCET_BLINK) &&
*_old_u32_attr!=-1 && *_old_u32_attr&DOCET_BLINK)
DocPrint(doc,"</blink>");
if (*_old_u32_attr!=-1)
if (underline_update &&
!(u32_attr&DOCET_UNDERLINE) && *_old_u32_attr&DOCET_UNDERLINE) {
if (!(*_old_u32_attr&DOCET_LINK_UNDERLINE))
DocPrint(doc,"</u>");
*_old_u32_attr&=~DOCET_LINK_UNDERLINE;
}
if (!(u32_attr&DOCET_BLINK) && *_old_u32_attr&DOCET_BLINK)
DocPrint(doc,"</blink>");
if (u32_attr&0xFF00!=*_old_u32_attr&0xFF00) {
if (!(*_old_u32_attr&DOCET_UNDEF_COLOR))
DocPrint(doc,"</span>");
DocPrint(doc,"<span class=c%02X>",u32_attr.u8[1]);
if (u32_attr&DOCET_BLINK &&
(*_old_u32_attr==-1 || !(*_old_u32_attr&DOCET_BLINK)))
DocPrint(doc,"<blink>");
*_old_u32_attr=u32_attr;
if (style_bitmap)
LBts(style_bitmap,u32_attr.u8[1]);
}
if (u32_attr&DOCET_BLINK && !(*_old_u32_attr&DOCET_BLINK))
DocPrint(doc,"<blink>");
if (underline_update) {
if (u32_attr&DOCET_UNDERLINE && !(*_old_u32_attr&DOCET_UNDERLINE))
DocPrint(doc,"<u>");
} else //Keep same underline status.
u32_attr=u32_attr&~DOCET_UNDERLINE | *_old_u32_attr&DOCET_UNDERLINE;
*_old_u32_attr=u32_attr | *_old_u32_attr&DOCET_LINK_UNDERLINE;
while (ch=*st++) {
switch (ch) {
case '\t':
@@ -78,6 +91,27 @@ U8 *TOSLinkCvt2(U8 *filename,I64 line_num)
return res;
}
U8 *URLBibleGateway(U8 *src)
{
U8 buf[STR_LEN],*dst=buf;
if (!MemCmp(src,"BF:",3))
src+=3;
while (*src) {
if (*src==CH_SPACE || *src==',')
*dst++='+';
else
*dst++=*src;
src++;
}
*dst=0;
if (StrOcc(buf,'-'))
return MStrPrint(
"http://www.biblegateway.com/passage/?search=%s&version=NIV",buf);
else
return MStrPrint(
"http://www.biblegateway.com/verse/en/%s",buf);
}
U8 *TOSLinkCvt1(U8 *link_st)
{
static CDoc *bible=NULL;
@@ -105,7 +139,7 @@ U8 *TOSLinkCvt1(U8 *link_st)
if (!bible)
bible=Adam("DocRead(\"%s\");",filename);
if (DocFind(bible,num,needle))
res=TOSLinkCvt2(filename,bible->cur_entry->y+1);
res=URLBibleGateway(link_st);
LBtr(&locks,0);
break;
default:
@@ -120,10 +154,10 @@ U8 *TOSLinkCvt1(U8 *link_st)
public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
U8 *body_footer=NULL,U8 *html_footer=NULL,Bool line_anchors=TRUE,
U8 (*link_cvt)(U8 *link_st)=&TOSLinkCvt1)
U8 (*link_cvt)(U8 *link_st)=&TOSLinkCvt1,Bool line_nums=FALSE)
{//Cvt $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.DD"$doc to HTML file.
CDocEntry *doc_e,*style,*doc_e2;
I64 i,y,old_y=MIN_I64,col,old_u32_attr=-1,old_attr;
I64 i,y,old_y=MIN_I64,col,old_u32_attr=DOCET_UNDEF_COLOR,old_attr,digits;
U32 *hl,*src;
U8 *st,st_2[2],*link_st,*style_bitmap=CAlloc(256/8);
CBGR48 p[NUM_COLORS];
@@ -139,6 +173,8 @@ public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
DocRecalc(doc_in,RECALCt_NORMAL|RECALCF_TO_HTML);
digits=Log10(doc_in->head.last->y+1)+1;
st_2[0]=0; st_2[1]=0;
doc_out->flags|=DOCF_PLAIN_TEXT|DOCF_NO_CURSOR;
@@ -148,7 +184,7 @@ public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
"<head>\n"
"<meta http-equiv=\"Content-Type\" "
"content=\"text/html;charset=US-ASCII\">\n"
"<meta name=\"generator\" content=\"$TX,"TempleOS V4.12",D="DD_OS_NAME_VERSION"$\">\n";
"<meta name=\"generator\" content=\"$TX,"TempleOS V4.13",D="DD_OS_NAME_VERSION"$\">\n";
if (!body_header) body_header=
"<body>\n"
"<pre style=\"font-family:courier;font-size:10pt\">\n";
@@ -171,15 +207,21 @@ public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
y=doc_e->y;
while (doc_e!=doc_in) {
if (!(doc_e->de_flags&DOCEF_SKIP)) {
if (y!=old_y && line_anchors) {
DocPrint(doc_out,"<a name=\"l%d\"></a>",y+1);
if (y!=old_y) {
if (line_anchors)
DocPrint(doc_out,"<a name=\"l%d\"></a>",y+1);
if (line_nums)
DocPrint(doc_out,"%0*d ",digits,y+1);
old_y=y;
}
while (y<doc_e->y) {
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,
&old_u32_attr,"\n",&col,style_bitmap);
if (++y!=old_y && line_anchors) {
DocPrint(doc_out,"<a name=\"l%d\"></a>",y+1);
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&old_u32_attr,FALSE,
"\n",&col,style_bitmap);
if (++y!=old_y) {
if (line_anchors)
DocPrint(doc_out,"<a name=\"l%d\"></a>",y+1);
if (line_nums)
DocPrint(doc_out,"%0*d ",digits,y+1);
old_y=y;
}
col=0;
@@ -194,10 +236,11 @@ public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
}
doc_e2=doc_e2->next;
}
if (no_bwd)
while (col<doc_e->x)
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,
&old_u32_attr," ",&col,style_bitmap);
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&old_u32_attr,FALSE,
" ",&col,style_bitmap);
link_st=NULL;
if (doc_e->de_flags&DOCEF_HTML_LINK)
@@ -208,10 +251,13 @@ public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
}
if (link_st) {
if (old_u32_attr!=-1) {
if (old_u32_attr&DOCET_UNDERLINE &&!(old_u32_attr&DOCET_LINK_UNDERLINE))
DocPrint(doc_out,"</u>");
if (old_u32_attr&DOCET_BLINK)
DocPrint(doc_out,"</blink>");
if (!(old_u32_attr&DOCET_UNDEF_COLOR))
DocPrint(doc_out,"</span>");
old_u32_attr=-1;
}
old_u32_attr=DOCET_UNDEF_COLOR|DOCET_UNDERLINE|DOCET_LINK_UNDERLINE;
DocPrint(doc_out,"<a href=\"%s\">",link_st);
}
@@ -228,7 +274,8 @@ public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
doc_e->type&0xFF00);
while (*src) {
st_2[0]=*src&0xFF;
HtmlPutS(doc_out,*src++,&old_u32_attr,st_2,&col,style_bitmap);
HtmlPutS(doc_out,*src++,&old_u32_attr,TRUE,
st_2,&col,style_bitmap);
}
Free(hl);
} else
@@ -236,34 +283,41 @@ public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
&old_u32_attr,doc_e->tag,&col,style_bitmap);
break;
case DOCT_TAB:
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,
&old_u32_attr,"\t",&col,style_bitmap);
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,&old_u32_attr,TRUE,
"\t",&col,style_bitmap);
break;
case DOCT_HTML_CODE:
if (old_u32_attr!=-1) {
if (old_u32_attr&DOCET_UNDERLINE &&
!(old_u32_attr&DOCET_LINK_UNDERLINE))
DocPrint(doc_out,"</u>");
if (old_u32_attr&DOCET_BLINK)
DocPrint(doc_out,"</blink>");
if (!(old_u32_attr&DOCET_UNDEF_COLOR))
DocPrint(doc_out,"</span>");
old_u32_attr=-1;
}
old_u32_attr=DOCET_UNDEF_COLOR;
DocPrint(doc_out,"%s",doc_e->tag);
break;
case DOCT_SPRITE:
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,
&old_u32_attr,doc_e->tag,&col,style_bitmap);
&old_u32_attr,TRUE,doc_e->tag,&col,style_bitmap);
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,
&old_u32_attr,"/* Graphics Not Rendered in HTML */",
&old_u32_attr,TRUE,"/* Graphics Not Rendered in HTML */",
&col,style_bitmap);
break;
default:
if (doc_e->de_flags&DOCEF_TAG)
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,
&old_u32_attr,doc_e->tag,&col,style_bitmap);
&old_u32_attr,TRUE,doc_e->tag,&col,style_bitmap);
}
if (link_st) {
if (old_u32_attr!=-1) {
if (old_u32_attr&DOCET_UNDERLINE &&!(old_u32_attr&DOCET_LINK_UNDERLINE))
DocPrint(doc_out,"</u>");
if (old_u32_attr&DOCET_BLINK)
DocPrint(doc_out,"</blink>");
if (!(old_u32_attr&DOCET_UNDEF_COLOR))
DocPrint(doc_out,"</span>");
old_u32_attr=-1;
}
DocPrint(doc_out,"</a>");
old_u32_attr=DOCET_UNDEF_COLOR|DOCET_UNDERLINE|DOCET_LINK_UNDERLINE;
Free(link_st);
}
}
@@ -271,15 +325,16 @@ public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
}
while (y++<doc_e->y) {
HtmlPutS(doc_out,doc_e->settings.final_u32_attr,
&old_u32_attr,"\n",&col,style_bitmap);
&old_u32_attr,TRUE,"\n",&col,style_bitmap);
col=0;
}
if (old_u32_attr!=-1) {
if (old_u32_attr&DOCET_BLINK)
DocPrint(doc_out,"</blink>");
if (old_u32_attr&DOCET_UNDERLINE && !(old_u32_attr&DOCET_LINK_UNDERLINE))
DocPrint(doc_out,"</u>");
if (old_u32_attr&DOCET_BLINK)
DocPrint(doc_out,"</blink>");
if (!(old_u32_attr&DOCET_UNDEF_COLOR))
DocPrint(doc_out,"</span>");
old_u32_attr=-1;
}
old_u32_attr=DOCET_UNDEF_COLOR;
DocPrint(doc_out,"%s",body_footer);
DocPrint(doc_out,"%s",html_footer);
@@ -304,7 +359,7 @@ public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
public U0 ToHtml(U8 *_in_name,U8 *_out_name=NULL,U8 *html_header=NULL,
U8 *body_header=NULL,U8 *body_footer=NULL,U8 *html_footer=NULL,
I64 width=80,Bool line_anchors=TRUE,
U8 (*link_cvt)(U8 *link_st)=&TOSLinkCvt1)
U8 (*link_cvt)(U8 *link_st)=&TOSLinkCvt1,Bool line_nums=FALSE)
{//Convert $LK,"DolDoc",A="FI:::/Doc/DolDocOverview.DD"$file to HTML.
//Supply your own link_cvt routine.
U8 *in_name,*out_name;
@@ -321,7 +376,7 @@ public U0 ToHtml(U8 *_in_name,U8 *_out_name=NULL,U8 *html_header=NULL,
doc_in=DocRead(in_name);
doc_out=Doc2Html(doc_in,html_header,body_header,body_footer,html_footer,
line_anchors,link_cvt);
line_anchors,link_cvt,line_nums);
StrCpy(&doc_out->filename.name,out_name);
SettingsPop;