[ncman] print substituted macros

This commit is contained in:
nick black 2021-12-09 14:16:41 -05:00
parent 358a6306da
commit 32fd9a4478
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -593,6 +593,7 @@ putpara(struct ncplane* p, const char* text){
// cur indicates where the current text to be displayed starts.
const char* cur = text;
uint16_t style = 0;
const char* posttext = NULL;
while(*cur){
b = 0;
// find the next style marker
@ -644,7 +645,7 @@ putpara(struct ncplane* p, const char* text){
const char* macend = NULL;
for(typeof(&*macros) m = macros ; m->tr ; ++m){
if(strncmp(curend, m->macro, strlen(m->macro)) == 0){
// FIXME emit thus far, write tr
posttext = m->tr;
macend = curend + strlen(m->macro);
break;
}
@ -664,6 +665,12 @@ putpara(struct ncplane* p, const char* text){
if(puttext(p, cur, textend) < 0){
return -1;
}
if(posttext){
if(puttext(p, posttext, posttext + strlen(posttext)) < 0){
return -1;
}
posttext = NULL;
}
cur = curend;
ncplane_set_styles(p, style);
}