From: Andrew T. <an...@fu...> - 2011-05-17 22:41:46
|
Hi, I have an application that writes out the lcd data to a file (as opposed to writing a custom plugin) and I need to make some words bold. I have hacked this up locally to make the ascii BEL char as a bold toggle. This works quite well for me so I am sharing it. The BEL char may not be a good choice vs. the proper ANSI escape sequences but is easier to implement. --- drv_generic_graphic.c.orig 2011-05-12 10:11:40.000000000 +1200 +++ drv_generic_graphic.c 2011-05-18 10:13:51.000000000 +1200 @@ -233,6 +233,7 @@ const char *style, const char *txt) { int c, r, x, y, len; + int bold; /* sanity checks */ if (layer < 0 || layer >= LAYERS) { @@ -249,10 +250,17 @@ c = col; /* render text into layout FB */ + bold = 0; while (*txt != '\0') { unsigned char *chr; - if (strstr(style, "bold") != NULL) { + /* magic char to toggle bold */ + if (*txt == '\a') { + bold ^= 1; + txt++; + continue; + } + if (bold || strstr(style, "bold") != NULL) { chr = Font_6x8_bold[(int) *(unsigned char *) txt]; } else { chr = Font_6x8[(int) *(unsigned char *) txt]; The snippets from my lcd4linux.conf Layout picoLCDGraphic { Row1 { Col1 'status1' } Row2 { Col1 'status2' } ... } Widget status1 { class 'Text' expression file::readline(statfile, currline) width 42 update tick } Widget status2 { class 'Text' expression file::readline(statfile, currline+1) width 42 update tick } ... |