2. support the 8 basic highlighted colors, plus a couple of color_hash fixes
On 03/25/2011 10:25 PM, Ross Mohn wrote:
> I'm going to post a series of 6 patches for dvtm over the next several
> minutes. They all apply to the current HEAD of the dvtm git repository
> (committed 2011-01-07). I think I've teased them all apart pretty well
> so that each one is separate and complete.
>
> 1. support for compiling under AIX
> 2. support the 8 basic highlighted colors, plus a couple of color_hash fixes
> 3. fix a scrolling issue and add in "ESC #" to call interpret_esc_SCS()
> 4. support for "ESC 6 n", get cursor position, which calls a new
> function, send_curs()
> 5. support colorrules[] to match strings against window titles,
> applycolorrules(), and call madtty_set_dflt_colors()
> 6. support to backfill text from the buffer when a windows is resized
> with more rows
>
> Comments, testing, and bugfixes sincerely welcome!
>
> Cheers! -Ross
>
>
Index: madtty.c
===================================================================
--- madtty.c (.../vendor/current) (revision 47)
+++ madtty.c (.../trunk) (revision 47)
@@ -54,8 +54,8 @@
#define IS_CONTROL(ch) !((ch) & 0xffffff60UL)
static int has_default, is_utf8, use_palette;
-static const unsigned palette_start = 1;
-static const unsigned palette_end = 256;
+#define palette_start 1
+#define palette_end 512
static unsigned palette_cur;
static short *color2palette;
@@ -415,8 +419,14 @@
case 49:
t->curbg = -1;
break;
+ case 90 ... 97: /* hi fg */
+ t->curfg = param[i] - 82;
+ break;
+ case 100 ... 107: /*hi bg */
+ t->curbg = param[i] - 92;
+ break;
default:
break;
}
@@ -1439,7 +1492,7 @@
static unsigned color_hash(short f, short b)
{
- return ((f+1) * (COLORS+1)) + b + 1;
+ return ((f+1) * COLORS) + b + 1;
}
void madtty_color_set(WINDOW *win, short fg, short bg)
@@ -1488,8 +1541,8 @@
color2palette = calloc((COLORS+1)*(COLORS+1), sizeof(short));
int bg = 0, fg = 0;
for (int i = palette_start; i < palette_end; i++) {
- init_pair(i, bg, fg);
- color2palette[color_hash(bg, fg)] = i;
+ init_pair(i, fg, bg);
+ color2palette[color_hash(fg, bg)] = i;
if (++fg == COLORS) {
fg = 0;
bg++;