remove UTF-8 code when compiling with --disable-unicode

This commit is contained in:
Christian Hesse 2015-07-17 14:33:34 +02:00
parent 9e67b6585e
commit d8e23bb084
5 changed files with 51 additions and 11 deletions

14
CRT.c
View File

@ -133,6 +133,8 @@ const char *CRT_treeStrAscii[TREE_STR_COUNT] = {
"-", // TREE_STR_SHUT "-", // TREE_STR_SHUT
}; };
#ifdef HAVE_LIBNCURSESW
const char *CRT_treeStrUtf8[TREE_STR_COUNT] = { const char *CRT_treeStrUtf8[TREE_STR_COUNT] = {
"\xe2\x94\x80", // TREE_STR_HORZ ─ "\xe2\x94\x80", // TREE_STR_HORZ ─
"\xe2\x94\x82", // TREE_STR_VERT │ "\xe2\x94\x82", // TREE_STR_VERT │
@ -143,14 +145,16 @@ const char *CRT_treeStrUtf8[TREE_STR_COUNT] = {
"\xe2\x94\x80", // TREE_STR_SHUT ─ "\xe2\x94\x80", // TREE_STR_SHUT ─
}; };
bool CRT_utf8 = false;
#endif
const char **CRT_treeStr = CRT_treeStrAscii; const char **CRT_treeStr = CRT_treeStrAscii;
static bool CRT_hasColors; static bool CRT_hasColors;
int CRT_delay = 0; int CRT_delay = 0;
bool CRT_utf8 = false;
int* CRT_colors; int* CRT_colors;
int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
@ -596,7 +600,11 @@ void CRT_init(int delay, int colorScheme) {
CRT_utf8 = false; CRT_utf8 = false;
#endif #endif
CRT_treeStr = CRT_utf8 ? CRT_treeStrUtf8 : CRT_treeStrAscii; CRT_treeStr =
#ifdef HAVE_LIBNCURSESW
CRT_utf8 ? CRT_treeStrUtf8 :
#endif
CRT_treeStrAscii;
mousemask(BUTTON1_CLICKED, NULL); mousemask(BUTTON1_CLICKED, NULL);
} }

8
CRT.h
View File

@ -114,14 +114,18 @@ void CRT_handleSIGSEGV(int sgn);
extern const char *CRT_treeStrAscii[TREE_STR_COUNT]; extern const char *CRT_treeStrAscii[TREE_STR_COUNT];
#ifdef HAVE_LIBNCURSESW
extern const char *CRT_treeStrUtf8[TREE_STR_COUNT]; extern const char *CRT_treeStrUtf8[TREE_STR_COUNT];
extern bool CRT_utf8;
#endif
extern const char **CRT_treeStr; extern const char **CRT_treeStr;
extern int CRT_delay; extern int CRT_delay;
extern bool CRT_utf8;
int* CRT_colors; int* CRT_colors;
extern int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT]; extern int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT];

View File

@ -42,7 +42,11 @@ static void ListItem_display(Object* cast, RichString* out) {
snprintf(buffer, len, "%s", this->value); snprintf(buffer, len, "%s", this->value);
*/ */
if (this->moving) { if (this->moving) {
RichString_write(out, CRT_colors[DEFAULT_COLOR], CRT_utf8 ? "" : "+ "); RichString_write(out, CRT_colors[DEFAULT_COLOR],
#ifdef HAVE_LIBNCURSESW
CRT_utf8 ? "" :
#endif
"+ ");
} else { } else {
RichString_prune(out); RichString_prune(out);
} }

26
Meter.c
View File

@ -308,6 +308,8 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
/* ---------- GraphMeterMode ---------- */ /* ---------- GraphMeterMode ---------- */
#ifdef HAVE_LIBNCURSESW
#define PIXPERROW_UTF8 4 #define PIXPERROW_UTF8 4
static const char* GraphMeterMode_dotsUtf8[] = { static const char* GraphMeterMode_dotsUtf8[] = {
/*00*/"", /*01*/"", /*02*/"", /*03*/"", /*04*/ "", /*00*/"", /*01*/"", /*02*/"", /*03*/"", /*04*/ "",
@ -317,6 +319,8 @@ static const char* GraphMeterMode_dotsUtf8[] = {
/*40*/"", /*41*/"", /*42*/"", /*43*/"", /*44*/ "" /*40*/"", /*41*/"", /*42*/"", /*43*/"", /*44*/ ""
}; };
#endif
#define PIXPERROW_ASCII 2 #define PIXPERROW_ASCII 2
static const char* GraphMeterMode_dotsAscii[] = { static const char* GraphMeterMode_dotsAscii[] = {
/*00*/" ", /*01*/".", /*02*/":", /*00*/" ", /*01*/".", /*02*/":",
@ -333,10 +337,13 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
GraphData* data = (GraphData*) this->drawData; GraphData* data = (GraphData*) this->drawData;
const int nValues = METER_BUFFER_LEN; const int nValues = METER_BUFFER_LEN;
#ifdef HAVE_LIBNCURSESW
if (CRT_utf8) { if (CRT_utf8) {
GraphMeterMode_dots = GraphMeterMode_dotsUtf8; GraphMeterMode_dots = GraphMeterMode_dotsUtf8;
pixperrow = PIXPERROW_UTF8; pixperrow = PIXPERROW_UTF8;
} else { } else
#endif
{
GraphMeterMode_dots = GraphMeterMode_dotsAscii; GraphMeterMode_dots = GraphMeterMode_dotsAscii;
pixperrow = PIXPERROW_ASCII; pixperrow = PIXPERROW_ASCII;
} }
@ -399,12 +406,16 @@ static const char* LEDMeterMode_digitsAscii[] = {
"|__|"," |","|__ "," __|"," |"," __|","|__|"," |","|__|"," __|" "|__|"," |","|__ "," __|"," |"," __|","|__|"," |","|__|"," __|"
}; };
#ifdef HAVE_LIBNCURSESW
static const char* LEDMeterMode_digitsUtf8[] = { static const char* LEDMeterMode_digitsUtf8[] = {
"┌──┐","","╶──┐","╶──┐","╷ ╷","┌──╴","┌──╴","╶──┐","┌──┐","┌──┐", "┌──┐","","╶──┐","╶──┐","╷ ╷","┌──╴","┌──╴","╶──┐","┌──┐","┌──┐",
"│ │","","┌──┘"," ──┤","└──┤","└──┐","├──┐","","├──┤","└──┤", "│ │","","┌──┘"," ──┤","└──┤","└──┐","├──┐","","├──┤","└──┤",
"└──┘","","└──╴","╶──┘","","╶──┘","└──┘","","└──┘"," ──┘" "└──┘","","└──╴","╶──┘","","╶──┘","└──┘","","└──┘"," ──┘"
}; };
#endif
static const char** LEDMeterMode_digits; static const char** LEDMeterMode_digits;
static void LEDMeterMode_drawDigit(int x, int y, int n) { static void LEDMeterMode_drawDigit(int x, int y, int n) {
@ -415,11 +426,12 @@ static void LEDMeterMode_drawDigit(int x, int y, int n) {
static void LEDMeterMode_draw(Meter* this, int x, int y, int w) { static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {
(void) w; (void) w;
if (CRT_utf8) { #ifdef HAVE_LIBNCURSESW
if (CRT_utf8)
LEDMeterMode_digits = LEDMeterMode_digitsUtf8; LEDMeterMode_digits = LEDMeterMode_digitsUtf8;
} else { else
#endif
LEDMeterMode_digits = LEDMeterMode_digitsAscii; LEDMeterMode_digits = LEDMeterMode_digitsAscii;
}
char buffer[METER_BUFFER_LEN]; char buffer[METER_BUFFER_LEN];
Meter_setValues(this, buffer, METER_BUFFER_LEN - 1); Meter_setValues(this, buffer, METER_BUFFER_LEN - 1);
@ -427,7 +439,11 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {
RichString_begin(out); RichString_begin(out);
Meter_displayBuffer(this, buffer, &out); Meter_displayBuffer(this, buffer, &out);
int yText = CRT_utf8 ? y+1 : y+2; int yText =
#ifdef HAVE_LIBNCURSESW
CRT_utf8 ? y+1 :
#endif
y+2;
attrset(CRT_colors[LED_COLOR]); attrset(CRT_colors[LED_COLOR]);
mvaddstr(yText, x, this->caption); mvaddstr(yText, x, this->caption);
int xx = x + strlen(this->caption); int xx = x + strlen(this->caption);

View File

@ -119,11 +119,19 @@ ListItem* Meter_toListItem(Meter* this, bool moving);
/* ---------- GraphMeterMode ---------- */ /* ---------- GraphMeterMode ---------- */
#ifdef HAVE_LIBNCURSESW
#define PIXPERROW_UTF8 4 #define PIXPERROW_UTF8 4
#endif
#define PIXPERROW_ASCII 2 #define PIXPERROW_ASCII 2
/* ---------- LEDMeterMode ---------- */ /* ---------- LEDMeterMode ---------- */
#ifdef HAVE_LIBNCURSESW
#endif
extern MeterMode* Meter_modes[]; extern MeterMode* Meter_modes[];
/* Blank meter */ /* Blank meter */