use LETextBox2 formatting to color {} text blue.

Eventually, they should hyperlink but that's a separate issue.
This commit is contained in:
Kelvin Sherlock 2019-07-07 21:54:49 -04:00
parent 366ce8ae54
commit 93491e673f
1 changed files with 37 additions and 12 deletions

49
nda.c
View File

@ -25,12 +25,10 @@
#include "nda.h" #include "nda.h"
/* #define TBBlack "\x01" "C" "\x00\x00"
* TODO: #define TBBlue "\x01" "C" "\x11\x11"
* [ ] store definition in handle, put into TE control when finished? #define TBRed "\x01" "C" "\x44\x44"
* [ ] {text} -> drop {}, use dark blue text color.
*
*/
unsigned NDAStartUpTools(Word memID, StartStopRecord *ssRef); unsigned NDAStartUpTools(Word memID, StartStopRecord *ssRef);
@ -124,19 +122,44 @@ void AppendText(word length, char *cp) {
TextHandleUsed += length; TextHandleUsed += length;
} }
void AppendText2(word length, char *cp) {
unsigned i;
unsigned char c;
unsigned start = 0;
for (i = 0; i < length; ++i) {
c = cp[i];
if (c == '{' || c == '}' || c == 0x01) {
/* flush any pending data */
if (start < i)
AppendText(i - start, cp + start);
if (c == '{') AppendText(4, TBBlue);
if (c == '}') AppendText(4, TBBlack);
start = i + 1;
}
}
if (start < length)
AppendText(length - start, cp + start);
}
void SetText(void) { void SetText(void) {
Handle handle; Handle handle;
TERecord *temp; //TERecord *temp;
longword oldStart, oldEnd; longword oldStart, oldEnd;
handle = (Handle)GetCtlHandleFromID(MyWindow, rCtrlTE); handle = (Handle)GetCtlHandleFromID(MyWindow, rCtrlTE);
temp = *(TERecord **)handle; //temp = *(TERecord **)handle;
temp->textFlags &= (~fReadOnly); //temp->textFlags &= (~fReadOnly);
TESetSelection((Pointer)-1, (Pointer)-1, handle); TESetSelection((Pointer)-1, (Pointer)-1, handle);
TESetText(teDataIsTextBlock, (Ref)*TextHandle, TextHandleUsed, NULL, NULL, handle); TESetText(teDataIsTextBox2|teTextIsPtr, (Ref)*TextHandle, TextHandleUsed, NULL, NULL, handle);
temp->textFlags |= fReadOnly; //temp->textFlags |= fReadOnly;
TextHandleUsed = 0; TextHandleUsed = 0;
@ -279,6 +302,7 @@ redo:
/* expect 550, 552, or 150 status */ /* expect 550, 552, or 150 status */
if (status == 150) { if (status == 150) {
++st; ++st;
AppendText(4, TBBlack);
break; break;
} }
@ -286,6 +310,7 @@ redo:
MarinettiCallback("\pNo match"); MarinettiCallback("\pNo match");
st = st_idle; st = st_idle;
} else { } else {
AppendText(4, TBRed);
AppendText(rlr.rlrBuffCount, buffer); AppendText(rlr.rlrBuffCount, buffer);
SetText(); SetText();
st = st_idle; st = st_idle;
@ -313,7 +338,7 @@ redo:
--st; --st;
} }
} else { } else {
AppendText(rlr.rlrBuffCount, buffer); AppendText2(rlr.rlrBuffCount, buffer);
} }
goto redo; goto redo;
break; break;