diff --git a/src/window_manager.cc b/src/window_manager.cc index e0f170a..ba460c0 100644 --- a/src/window_manager.cc +++ b/src/window_manager.cc @@ -549,9 +549,9 @@ void windowDrawText(int win, const char* str, int width, int x, int y, int color } } - if (color & 0xFF00) { - int t = (color & 0xFF00) >> 8; - textColor = (color & ~0xFFFF) | _colorTable[_GNW_wcolor[t]]; + if ((color & 0xFF00) != 0) { + int colorIndex = (color & 0xFF) - 1; + textColor = (color & ~0xFFFF) | _colorTable[_GNW_wcolor[colorIndex]]; } else { textColor = color; } @@ -582,9 +582,9 @@ void windowDrawLine(int win, int left, int top, int right, int bottom, int color return; } - if (color & 0xFF00) { - int t = (color & 0xFF00) >> 8; - color = (color & ~0xFFFF) | _colorTable[_GNW_wcolor[t]]; + if ((color & 0xFF00) != 0) { + int colorIndex = (color & 0xFF) - 1; + color = (color & ~0xFFFF) | _colorTable[_GNW_wcolor[colorIndex]]; } bufferDrawLine(window->buffer, window->width, left, top, right, bottom, color); @@ -604,8 +604,8 @@ void windowDrawRect(int win, int left, int top, int right, int bottom, int color } if ((color & 0xFF00) != 0) { - int v1 = (color & 0xFF00) >> 8; - color = (color & ~0xFFFF) | _colorTable[_GNW_wcolor[v1]]; + int colorIndex = (color & 0xFF) - 1; + color = (color & ~0xFFFF) | _colorTable[_GNW_wcolor[colorIndex]]; } if (right < left) { @@ -643,8 +643,8 @@ void windowFill(int win, int x, int y, int width, int height, int color) color = _colorTable[_GNW_wcolor[0]] & 0xFF; } } else if ((color & 0xFF00) != 0) { - int v1 = (color & 0xFF00) >> 8; - color = (color & ~0xFFFF) | _colorTable[_GNW_wcolor[v1]]; + int colorIndex = (color & 0xFF) - 1; + color = (color & ~0xFFFF) | _colorTable[_GNW_wcolor[colorIndex]]; } if (color < 256) { diff --git a/src/window_manager_private.cc b/src/window_manager_private.cc index af94de7..bd0b3ff 100644 --- a/src/window_manager_private.cc +++ b/src/window_manager_private.cc @@ -645,9 +645,8 @@ int _win_msg(const char* string, int x, int y, int color) int textColor; if ((color & 0xFF00) != 0) { - int index = (color & 0xFF) - 1; - textColor = _colorTable[_GNW_wcolor[index]]; - textColor |= color & ~0xFFFF; + int colorIndex = (color & 0xFF) - 1; + textColor = (color & ~0xFFFF) | _colorTable[_GNW_wcolor[colorIndex]]; } else { textColor = color; }