[tfman] pass through escaped characters

This commit is contained in:
nick black 2021-12-12 09:01:54 -05:00
parent 7107c9015c
commit c81adef86f
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 22 additions and 12 deletions

View File

@ -619,26 +619,30 @@ putpara(struct ncplane* p, const char* text){
}else if(inescape){
if(*curend == 'f'){ // set font
textend = curend - 1; // account for backslash
if(*++curend != '['){
fprintf(stderr, "illegal font macro %s\n", curend);
return -1;
bool bracketed = false;
if(*++curend == '['){
bracketed = true;
++curend;
}
while(isalpha(*++curend)){
while(isalpha(*curend)){
switch(toupper(*curend)){
case 'R': style = 0; break; // roman, default
case 'I': style |= NCSTYLE_ITALIC; break;
case 'B': style |= NCSTYLE_BOLD; break;
case 'C': break; // unsure! seems to be used with .nf/.fi
default:
fprintf(stderr, "illegal font macro %s\n", curend);
fprintf(stderr, "unknown font macro %s\n", curend);
return -1;
}
++curend;
}
if(*curend != ']'){
fprintf(stderr, "illegal font macro %s\n", curend);
return -1;
if(bracketed){
if(*curend != ']'){
fprintf(stderr, "missing ']': %s\n", curend);
return -1;
}
++curend;
}
++curend;
break;
}else if(*curend == '['){ // escaped sequence
textend = curend - 1; // account for backslash
@ -672,6 +676,10 @@ putpara(struct ncplane* p, const char* text){
}
curend = macend;
break;
}else{
inescape = false;
cur = curend++;
break;
}
inescape = false;
}
@ -737,6 +745,7 @@ draw_domnode(struct ncplane* p, const pagedom* dom, const pagenode* n,
break;
case LINE_PP: // paragraph
case LINE_TP: // tagged paragraph
case LINE_IP: // indented paragraph
if(*wrotetext){
if(n->text){
ncplane_puttext(p, -1, NCALIGN_LEFT, "\n\n", &b);

View File

@ -18,8 +18,9 @@ typedef struct docstructure {
static int
docstruct_callback(struct ncplane* n, void* curry, int i){
(void)n; // FIXME
(void)curry;
docnode* dn = curry;
ncplane_printf(n, "%p", dn);
ncplane_resize_simple(n, 1, ncplane_dim_x(n));
(void)i;
return 0;
}
@ -42,7 +43,7 @@ docstructure* docstructure_create(struct ncplane* n){
if(p == NULL){
return NULL;
}
uint64_t channels = NCCHANNELS_INITIALIZER(0, 0, 0, 0x80, 0x80, 0x80);
uint64_t channels = NCCHANNELS_INITIALIZER(0, 0, 0, 0x99, 0xed, 0xc3);
ncplane_set_base(p, "", 0, channels);
nctree_options topts = {
.nctreecb = docstruct_callback,