about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-04 20:46:50 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-04 20:47:17 -0700
commit57bcdaeefa83bdccc5ea15dd273747b0b50e836a (patch)
tree6e9001a7c764e0585dc5787865e4997d9e2cc9c2
parent8a965c60280a566f3f82cc5f52d47479aeb6d30d (diff)
downloadmu-57bcdaeefa83bdccc5ea15dd273747b0b50e836a.tar.gz
1705 - change background color
-rw-r--r--070display.cc26
-rw-r--r--071print.mu24
-rw-r--r--display.mu2
-rw-r--r--edit.mu2
4 files changed, 39 insertions, 15 deletions
diff --git a/070display.cc b/070display.cc
index a926c1ae..b6e4b9ca 100644
--- a/070display.cc
+++ b/070display.cc
@@ -76,6 +76,21 @@ case PRINT_CHARACTER_TO_DISPLAY: {
 //?   tb_shutdown(); //? 1
 //?   cerr << "AAA " << c << ' ' << (int)'\n' << ' ' << (int)'\r' << '\n'; //? 1
 //?   exit(1); //? 1
+  int color = TB_BLACK;
+  if (SIZE(ingredients) > 1) {
+    assert(scalar(ingredients.at(1)));
+    color = ingredients.at(1).at(0);
+//?     tb_shutdown(); //? 1
+//?     cerr << "AAA " << color << '\n'; //? 1
+//?     exit(1); //? 1
+  }
+  int bg_color = TB_BLACK;
+  if (SIZE(ingredients) > 2) {
+    assert(scalar(ingredients.at(2)));
+    bg_color = ingredients.at(2).at(0);
+    if (bg_color == 0) bg_color = TB_BLACK;
+  }
+  tb_change_cell(Display_column, Display_row, c, color, bg_color);
   if (c == '\n' || c == '\r') {
     if (Display_row < height-1) {
       Display_column = 0;
@@ -87,22 +102,13 @@ case PRINT_CHARACTER_TO_DISPLAY: {
   }
   if (c == '\b') {
     if (Display_column > 0) {
-      tb_change_cell(Display_column-1, Display_row, ' ', TB_WHITE, TB_BLACK);
+      tb_change_cell(Display_column-1, Display_row, ' ', color, bg_color);
       --Display_column;
       tb_set_cursor(Display_column, Display_row);
       if (Autodisplay) tb_present();
     }
     break;
   }
-  int color = TB_BLACK;
-  if (SIZE(ingredients) > 1) {
-    assert(scalar(ingredients.at(1)));
-    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_BLACK);
   if (Display_column < width-1) {
     ++Display_column;
     tb_set_cursor(Display_column, Display_row);
diff --git a/071print.mu b/071print.mu
index c7ed5a2b..b3875364 100644
--- a/071print.mu
+++ b/071print.mu
@@ -79,6 +79,12 @@ recipe print-character [
     break-if color-found?:boolean
     color:number <- copy 7:literal/white
   }
+  bg-color:number, bg-color-found?:boolean <- next-ingredient
+  {
+    # default color to white
+    break-if bg-color-found?:boolean
+    bg-color:number <- copy 0:literal/black
+  }
   {
     # if x exists
     # (handle special cases exactly like in the real screen)
@@ -146,7 +152,7 @@ recipe print-character [
     reply x:address:screen/same-as-ingredient:0
   }
   # otherwise, real screen
-  print-character-to-display c:character, color:number
+  print-character-to-display c:character, color:number, bg-color:number
   reply x:address:screen/same-as-ingredient:0
 ]
 
@@ -597,13 +603,19 @@ recipe print-string [
     break-if color-found?:boolean
     color:number <- copy 7:literal/white
   }
+  bg-color:number, bg-color-found?:boolean <- next-ingredient
+  {
+    # default color to white
+    break-if bg-color-found?:boolean
+    bg-color:number <- copy 0:literal/black
+  }
   len:number <- length s:address:array:character/deref
   i:number <- copy 0:literal
   {
     done?:boolean <- greater-or-equal i:number, len:number
     break-if done?:boolean
     c:character <- index s:address:array:character/deref, i:number
-    print-character x:address:screen, c:character, color:number
+    print-character x:address:screen, c:character, color:number, bg-color:number
     i:number <- add i:number, 1:literal
     loop
   }
@@ -640,8 +652,14 @@ recipe print-integer [
     break-if color-found?:boolean
     color:number <- copy 7:literal/white
   }
+  bg-color:number, bg-color-found?:boolean <- next-ingredient
+  {
+    # default color to white
+    break-if bg-color-found?:boolean
+    bg-color:number <- copy 0:literal/black
+  }
   # todo: other bases besides decimal
   s:address:array:character <- integer-to-decimal-string n:number
-  print-string x:address:screen, s:address:array:character, color:number
+  print-string x:address:screen, s:address:array:character, color:number, bg-color:number
   reply x:address:screen/same-as-ingredient:0
 ]
diff --git a/display.mu b/display.mu
index e2397382..f01c1b43 100644
--- a/display.mu
+++ b/display.mu
@@ -2,7 +2,7 @@
 
 recipe main [
   open-console
-  print-character-to-display 97:literal, 1:literal/red
+  print-character-to-display 97:literal, 1:literal/red, 2:literal/green
   1:number/raw, 2:number/raw <- cursor-position-on-display
   wait-for-some-interaction
   clear-display
diff --git a/edit.mu b/edit.mu
index ddcda895..fc592b92 100644
--- a/edit.mu
+++ b/edit.mu
@@ -20,7 +20,7 @@ recipe main [
   button-start:number <- subtract width:number, 20:literal
   move-cursor 0:literal/screen, 0:literal/row, button-start:number/column
   run-button:address:array:character <- new [run (F9)   ]
-  print-string 0:literal/screen, run-button:address:array:character, 1:literal/red
+  print-string 0:literal/screen, run-button:address:array:character, 7:literal/white, 1:literal/red
   # editor on the left
   left:address:array:character <- new [abcde]
   left-editor:address:editor-data <- new-editor left:address:array:character, 0:literal/screen, 1:literal/top, 0:literal/left, divider:number/right