TempleOSCDV4.03.ISO
This commit is contained in:
1 parent
1541d7328d
commit
0f1a4a5d65
115 files changed
+5618
-4863
No files matched your search
+63
-72
@@ -27,8 +27,7 @@ public U0 DocLoad(CDoc *doc,U8 *src2,I64 size)
|
||||
}
|
||||
if (!(doc->flags & (DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_TABS)))
|
||||
DocBinsValidate(doc);
|
||||
DocTop(doc); //DOCT_CURSOR will set it in recalc
|
||||
DocRecalc(doc);
|
||||
DocTop(doc); //Calls $LK,"DocRecalc",A="MN:DocRecalc"$(). DOCT_CURSOR will be set.
|
||||
if (unlock)
|
||||
DocUnlock(doc);
|
||||
}
|
||||
@@ -53,24 +52,27 @@ public CDoc *DocRead(U8 *name=NULL,I64 flags=0)
|
||||
|
||||
public U8 *DocSave(CDoc *doc,I64 *_size=NULL)
|
||||
{//Store doc to raw mem buf.
|
||||
CDocEntry *doc_e;
|
||||
CDocEntry *doc_e,*doc_e1;
|
||||
CDocBin *b;
|
||||
Bool unlock=DocLock(doc);
|
||||
I64 ch,i,cnt;
|
||||
I64 ch,cnt=1;//terminator
|
||||
U8 *st,*result,*dst,*src;
|
||||
|
||||
if (!(doc->flags & (DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_TABS)))
|
||||
DocBinsValidate(doc);
|
||||
DocRecalc(doc);
|
||||
if (doc->flags&DOCF_NO_CURSOR || doc->root.next==doc)
|
||||
cnt=1; //terminator
|
||||
else
|
||||
cnt=2; //cursor + terminator
|
||||
if (doc->flags&DOCF_NO_CURSOR)
|
||||
DocRecalc(doc);
|
||||
else {
|
||||
DocRecalc(doc,RECALCF_ADD_CURSOR);
|
||||
if (doc->root.next->type_u8==DOCT_CURSOR)
|
||||
DocEntryDel(doc,doc->root.next); //If no cursor, $LK,"DocLoad",A="MN:DocLoad"$() puts at top.
|
||||
}
|
||||
for (doc_e=doc->root.next;doc_e!=doc;doc_e=doc_e->next) {
|
||||
if (!Bt(doldoc.type_flags_data,doc_e->type_u8)) {
|
||||
switch (doc_e->type_u8) {
|
||||
case DOCT_TAB:
|
||||
case DOCT_PAGE_BREAK:
|
||||
case DOCT_CURSOR:
|
||||
cnt++;
|
||||
break;
|
||||
case DOCT_NEW_LINE:
|
||||
@@ -81,12 +83,12 @@ public U8 *DocSave(CDoc *doc,I64 *_size=NULL)
|
||||
break;
|
||||
case DOCT_SOFT_NEW_LINE:
|
||||
break;
|
||||
case DOCT_TEXT://$BK,1$Update $LK,"DOCT_TEXT",A="FF:D:/Compiler/Lex.CPP,DOCT_TEXT"$$BK,0$
|
||||
case DOCT_TEXT:
|
||||
if (!(doc_e->de_flags & ~(DOCEF_TAG|DOCG_BL_IV_UL|DOCEF_WORD_WRAP|
|
||||
DOCEF_HIGHLIGHT|DOCEF_SKIP|DOCEF_FILTER_SKIP))&&
|
||||
!(doc_e->type&DOCG_BL_IV_UL)) {
|
||||
cnt+=StrLen(doc_e->tag);
|
||||
if (!(doc->flags & (DOCF_PLAIN_TEXT | DOCF_PLAIN_TEXT_TABS)) ||
|
||||
if (!(doc->flags & (DOCF_PLAIN_TEXT|DOCF_PLAIN_TEXT_TABS)) ||
|
||||
doc->flags&DOCF_DBL_DOLLARS)
|
||||
cnt+=StrOcc(doc_e->tag,'$$');
|
||||
break;
|
||||
@@ -98,72 +100,57 @@ public U8 *DocSave(CDoc *doc,I64 *_size=NULL)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (b=doc->bin_root.next;b!=&doc->bin_root;b=b->next) {
|
||||
for (b=doc->bin_root.next;b!=&doc->bin_root;b=b->next)
|
||||
if (b->use_cnt>b->temp_use_cnt)
|
||||
cnt+=offset(CDocBin.end)-
|
||||
offset(CDocBin.start)+b->size;
|
||||
}
|
||||
cnt+=offset(CDocBin.end)-offset(CDocBin.start)+b->size;
|
||||
result=MAlloc(cnt);
|
||||
dst=result;
|
||||
for (doc_e=doc->root.next;doc_e!=doc;doc_e=doc_e->next) {
|
||||
if (!Bt(doldoc.type_flags_data,doc_e->type_u8)) {
|
||||
if (doc_e->type_u8==DOCT_TEXT &&
|
||||
!(doc_e->de_flags & ~(DOCEF_TAG|DOCG_BL_IV_UL|DOCEF_WORD_WRAP|
|
||||
DOCEF_HIGHLIGHT|DOCEF_SKIP|DOCEF_FILTER_SKIP)) &&
|
||||
!(doc_e->type&DOCG_BL_IV_UL)) {
|
||||
src=doc_e->tag;
|
||||
i=0;
|
||||
while (ch=*src++) {
|
||||
if (doc_e==doc->cur_entry && i++==doc->cur_col &&
|
||||
!(doc->flags&DOCF_NO_CURSOR))
|
||||
*dst++=CH_CURSOR;
|
||||
*dst++=ch;
|
||||
if (ch=='$$') {
|
||||
if (!(doc->flags & (DOCF_PLAIN_TEXT | DOCF_PLAIN_TEXT_TABS)) ||
|
||||
doc->flags&DOCF_DBL_DOLLARS)
|
||||
doc_e=doc->root.next;
|
||||
while (doc_e!=doc) {
|
||||
doc_e1=doc_e->next;
|
||||
if (!Bt(doldoc.type_flags_data,doc_e->type_u8))
|
||||
switch (doc_e->type_u8) {
|
||||
case DOCT_CURSOR:
|
||||
DocEntryDel(doc,doc_e);
|
||||
*dst++=CH_CURSOR;
|
||||
break;
|
||||
case DOCT_TAB:
|
||||
*dst++='\t';
|
||||
break;
|
||||
case DOCT_PAGE_BREAK:
|
||||
*dst++=CH_FORM_FEED;
|
||||
break;
|
||||
case DOCT_NEW_LINE:
|
||||
if (doc->flags&DOCF_CARRIAGE_RETURN)
|
||||
*dst++='\r';
|
||||
*dst++='\n';
|
||||
break;
|
||||
case DOCT_SOFT_NEW_LINE:
|
||||
break;
|
||||
case DOCT_TEXT:
|
||||
if (!(doc_e->de_flags & ~(DOCEF_TAG|DOCG_BL_IV_UL|DOCEF_WORD_WRAP|
|
||||
DOCEF_HIGHLIGHT|DOCEF_SKIP|DOCEF_FILTER_SKIP)) &&
|
||||
!(doc_e->type&DOCG_BL_IV_UL)) {
|
||||
src=doc_e->tag;
|
||||
while (ch=*src++) {
|
||||
*dst++=ch;
|
||||
if (ch=='$$' && (!(doc->flags & (DOCF_PLAIN_TEXT|
|
||||
DOCF_PLAIN_TEXT_TABS)) || doc->flags&DOCF_DBL_DOLLARS))
|
||||
*dst++=ch;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (doc_e==doc->cur_entry && i++==doc->cur_col &&
|
||||
!(doc->flags&DOCF_NO_CURSOR))
|
||||
*dst++=CH_CURSOR;
|
||||
} else {
|
||||
if (doc_e==doc->cur_entry && !(doc->flags&DOCF_NO_CURSOR))
|
||||
*dst++=CH_CURSOR;
|
||||
switch (doc_e->type_u8) {
|
||||
case DOCT_TAB:
|
||||
*dst++='\t';
|
||||
break;
|
||||
case DOCT_PAGE_BREAK:
|
||||
*dst++=CH_FORM_FEED;
|
||||
break;
|
||||
case DOCT_NEW_LINE:
|
||||
if (doc->flags&DOCF_CARRIAGE_RETURN)
|
||||
*dst++='\r';
|
||||
*dst++='\n';
|
||||
break;
|
||||
case DOCT_SOFT_NEW_LINE:
|
||||
break;
|
||||
default:
|
||||
*dst++='$$';
|
||||
st=Doc2PlainText(doc,doc_e);
|
||||
StrCpy(dst,st);
|
||||
dst+=StrLen(st);
|
||||
*dst++='$$';
|
||||
Free(st);
|
||||
}
|
||||
default:
|
||||
*dst++='$$';
|
||||
st=Doc2PlainText(doc,doc_e);
|
||||
StrCpy(dst,st);
|
||||
dst+=StrLen(st);
|
||||
*dst++='$$';
|
||||
Free(st);
|
||||
}
|
||||
}
|
||||
doc_e=doc_e1;
|
||||
}
|
||||
if (doc->cur_entry==doc && doc->root.next!=doc &&
|
||||
!(doc->flags&DOCF_NO_CURSOR))
|
||||
*dst++=CH_CURSOR;
|
||||
*dst++=0;
|
||||
if (*result==CH_CURSOR) {
|
||||
MemCpy(result,result+1,dst-result-1);
|
||||
cnt--;
|
||||
dst--;
|
||||
}
|
||||
b=doc->bin_root.next;
|
||||
if (b!=&doc->bin_root) {
|
||||
do {
|
||||
@@ -210,7 +197,7 @@ public U0 DocInsDoc(CDoc *doc=NULL,CDoc *doc2)
|
||||
if (doc_ce->type_u8==DOCT_TEXT && doc->cur_col>doc_ce->min_col) {
|
||||
if (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));
|
||||
doc_ne=DocEntryNewTag(doc,doc_ce,dst);
|
||||
*dst=0;
|
||||
doc_ne->type=DOCT_TEXT | doc_ce->type & 0xFFFFFF00;
|
||||
doc_ce->max_col=doc->cur_col;
|
||||
@@ -258,7 +245,7 @@ public U0 StreamDoc(CDoc *doc)
|
||||
Bool DocCaptureUndo(CDoc *doc,Bool force=FALSE)
|
||||
{
|
||||
Bool result=FALSE,unlock;
|
||||
I64 time_stamp;
|
||||
I64 time_stamp,flags;
|
||||
CDocUndo *u;
|
||||
if (doc->flags&DOCF_ALLOW_UNDO) {
|
||||
unlock=DocLock(doc);
|
||||
@@ -268,7 +255,10 @@ Bool DocCaptureUndo(CDoc *doc,Bool force=FALSE)
|
||||
force) {
|
||||
u=CAlloc(sizeof(CDocUndo),doc->mem_task);
|
||||
u->time_stamp=time_stamp;
|
||||
flags=doc->flags;
|
||||
doc->flags&=~DOCF_NO_CURSOR;
|
||||
u->body=DocSave(doc,&u->size);
|
||||
doc->flags=flags;
|
||||
QueIns(u,doc->undo_root.last);
|
||||
doc->flags&=~DOCF_UNDO_DIRTY;
|
||||
doc->undo_cnt++;
|
||||
@@ -291,8 +281,9 @@ U0 DocUndoRestore(CDoc *doc)
|
||||
u_last=doc->undo_root.last;
|
||||
QueInit(&doc->undo_root);
|
||||
DocRst(doc,TRUE);
|
||||
doc->flags=u->doc_flags;
|
||||
doc->flags=u->doc_flags&~DOCF_NO_CURSOR;
|
||||
DocLoad(doc,u->body,u->size);
|
||||
doc->flags=u->doc_flags;
|
||||
DocUndoDel(doc,u);
|
||||
doc->undo_root.next=u_next;
|
||||
doc->undo_root.last=u_last;
|
||||
|
||||
Reference in new issue
Block a user