about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--070display.cc10
-rw-r--r--077trace_browser.cc4
-rw-r--r--termbox/README4
-rw-r--r--termbox/termbox.c44
-rw-r--r--termbox/termbox.h17
5 files changed, 24 insertions, 55 deletions
diff --git a/070display.cc b/070display.cc
index a0c964c1..d8649695 100644
--- a/070display.cc
+++ b/070display.cc
@@ -54,7 +54,7 @@ Recipe_number["clear-line-on-display"] = CLEAR_LINE_ON_DISPLAY;
 case CLEAR_LINE_ON_DISPLAY: {
   long long int width = tb_width();
   for (long long int x = Display_column; x < width; ++x) {
-    tb_change_cell(x, Display_row, ' ', TB_WHITE, TB_DEFAULT);
+    tb_change_cell(x, Display_row, ' ', TB_WHITE, TB_BLACK);
   }
   tb_set_cursor(Display_column, Display_row);
   tb_present();
@@ -86,22 +86,22 @@ case PRINT_CHARACTER_TO_DISPLAY: {
   }
   if (c == '\b') {
     if (Display_column > 0) {
-      tb_change_cell(Display_column-1, Display_row, ' ', TB_WHITE, TB_DEFAULT);
+      tb_change_cell(Display_column-1, Display_row, ' ', TB_WHITE, TB_BLACK);
       --Display_column;
       tb_set_cursor(Display_column, Display_row);
       tb_present();
     }
     break;
   }
-  int color = TB_DEFAULT;
+  int color = TB_BLACK;
   if (SIZE(ingredients) > 1) {
     assert(scalar(ingredients.at(1)));
-    color = ingredients.at(1).at(0)+1/*skip default*/;
+    color = ingredients.at(1).at(0);
 //?     tb_shutdown(); //? 1
 //?     cerr << "AAA " << color << '\n'; //? 1
 //?     exit(1); //? 1
   }
-  tb_change_cell(Display_column, Display_row, c, color, TB_DEFAULT);
+  tb_change_cell(Display_column, Display_row, c, color, TB_BLACK);
   if (Display_column < width-1) {
     ++Display_column;
     tb_set_cursor(Display_column, Display_row);
diff --git a/077trace_browser.cc b/077trace_browser.cc
index 6819a473..501eaa8f 100644
--- a/077trace_browser.cc
+++ b/077trace_browser.cc
@@ -192,9 +192,9 @@ void render_line(int screen_row, const string& s) {
   for (col = 0; col < tb_width() && col < SIZE(s); ++col) {
     char c = s.at(col);
     if (c == '\n') c = ';';  // replace newlines with semi-colons
-    tb_change_cell(col, screen_row, c, TB_WHITE, TB_DEFAULT);
+    tb_change_cell(col, screen_row, c, TB_WHITE, TB_BLACK);
   }
   for (; col < tb_width(); ++col) {
-    tb_change_cell(col, screen_row, ' ', TB_WHITE, TB_DEFAULT);
+    tb_change_cell(col, screen_row, ' ', TB_WHITE, TB_BLACK);
   }
 }
diff --git a/termbox/README b/termbox/README
index bb97525c..d97cae4e 100644
--- a/termbox/README
+++ b/termbox/README
@@ -1,2 +1,2 @@
-Fork of https://github.com/nsf/termbox as of 2015-05-09
-git hash c5b8b598f17fe60477ba0bb57d24bf8dae11ef92
+Fork of https://github.com/nsf/termbox as of 2015-06-05
+git hash 252bef01264a2aeef22ebe5bae0b5893a58947f3
diff --git a/termbox/termbox.c b/termbox/termbox.c
index 0e4d5a9f..6bd14213 100644
--- a/termbox/termbox.c
+++ b/termbox/termbox.c
@@ -47,12 +47,10 @@ static int lasty = LAST_COORD_INIT;
 static int cursor_x = -1;
 static int cursor_y = -1;
 
-static uint16_t background = TB_DEFAULT;
-static uint16_t foreground = TB_DEFAULT;
+static uint16_t background = TB_BLACK;
+static uint16_t foreground = TB_WHITE;
 
 static void write_cursor(int x, int y);
-static void write_sgr_fg(uint16_t fg);
-static void write_sgr_bg(uint16_t bg);
 static void write_sgr(uint16_t fg, uint16_t bg);
 
 static void cellbuf_init(struct cellbuf *buf, int width, int height);
@@ -310,26 +308,13 @@ static void write_cursor(int x, int y) {
   WRITE_LITERAL("H");
 }
 
-static void write_sgr_fg(uint16_t fg) {
-  char buf[32];
-  WRITE_LITERAL("\033[3");
-  WRITE_INT(fg-1);
-  WRITE_LITERAL("m");
-}
-
-static void write_sgr_bg(uint16_t bg) {
-  char buf[32];
-  WRITE_LITERAL("\033[4");
-  WRITE_INT(bg-1);
-  WRITE_LITERAL("m");
-}
-
 static void write_sgr(uint16_t fg, uint16_t bg) {
   char buf[32];
-  WRITE_LITERAL("\033[3");
-  WRITE_INT(fg-1);
-  WRITE_LITERAL(";4");
-  WRITE_INT(bg-1);
+  WRITE_LITERAL("\033[38;5;");
+  WRITE_INT(fg);
+  WRITE_LITERAL("m");
+  WRITE_LITERAL("\033[48;5;");
+  WRITE_INT(bg);
   WRITE_LITERAL("m");
 }
 
@@ -412,8 +397,8 @@ static void send_attr(uint16_t fg, uint16_t bg)
   if (fg != lastfg || bg != lastbg) {
     bytebuffer_puts(&output_buffer, funcs[T_SGR0]);
 
-    uint16_t fgcol = fg & 0x0F;
-    uint16_t bgcol = bg & 0x0F;
+    uint16_t fgcol = fg & 0xFF;
+    uint16_t bgcol = bg & 0xFF;
 
     if (fg & TB_BOLD)
       bytebuffer_puts(&output_buffer, funcs[T_BOLD]);
@@ -423,16 +408,7 @@ static void send_attr(uint16_t fg, uint16_t bg)
       bytebuffer_puts(&output_buffer, funcs[T_UNDERLINE]);
     if ((fg & TB_REVERSE) || (bg & TB_REVERSE))
       bytebuffer_puts(&output_buffer, funcs[T_REVERSE]);
-
-    if (fgcol != TB_DEFAULT) {
-      if (bgcol != TB_DEFAULT)
-        write_sgr(fgcol, bgcol);
-      else
-        write_sgr_fg(fgcol);
-    } else if (bgcol != TB_DEFAULT) {
-      write_sgr_bg(bgcol);
-    }
-
+    write_sgr(fgcol, bgcol);
     lastfg = fg;
     lastbg = bg;
   }
diff --git a/termbox/termbox.h b/termbox/termbox.h
index ac31230a..9b7fd772 100644
--- a/termbox/termbox.h
+++ b/termbox/termbox.h
@@ -11,20 +11,13 @@ extern "C" {
 /* The screen is a 2D array of cells. */
 struct tb_cell {
   uint32_t ch;  /* unicode character */
-  uint16_t fg;  /* foreground color and attributes */
-  uint16_t bg;  /* background color and attributes */
+  uint16_t fg;  /* foreground color (0-255) and attributes */
+  uint16_t bg;  /* background color (0-255) and attributes */
 };
 
-/* Possible colors in tb_cell.fg and tb_cell.bg. */
-#define TB_DEFAULT 0x00
-#define TB_BLACK   0x01
-#define TB_RED     0x02
-#define TB_GREEN   0x03
-#define TB_YELLOW  0x04
-#define TB_BLUE    0x05
-#define TB_MAGENTA 0x06
-#define TB_CYAN    0x07
-#define TB_WHITE   0x08
+/* Names for some colors in tb_cell.fg and tb_cell.bg. */
+#define TB_BLACK 232
+#define TB_WHITE 255
 
 /* Colors in tb_cell can be combined using bitwise-OR with multiple
  * of the following attributes. */