int main (int argc, char** argv) { if (! vapi_initialize ()) { vapi_full_screen (); vapi_clear (); color black = color_def ("on bright black"); color white = color_def ("on bright white"); int origin_x = (vapi_width () - 8 * 3 * 2) / 2; int origin_y = (vapi_height () - 8 * 3) / 2; for (int row = 0; row < 8; row++) for (int col = 0; col < 8; col++) vapi_rectangle (origin_x + (col * 3 * 2), origin_y + (row * 3), 3 * 2, 3, ((row + col) % 2 == 0 ? black : white)); vapi_moveto (1, 1); vapi_refresh (); sleep (4); vapi_deinitialize (); } else std::cout << "Your $TERM (" << getenv ("TERM") << ") is not supported." << std::endl; return 0; }
void instructions (int w, int h) { vapi_rectangle (1, h - 1, w, 2, color_def ("on red")); vapi_pos_color_text ((w - 36) / 2, h - 1, color_def ("bold white on red"), "Press 'q' to quit, Ctrl-L to redraw."); }
void mouse_pos (int w, int h, int mx, int my) { char msg[48]; sprintf (msg, "Mouse (%d,%d)", mx, my); color c = color_def ("white on blue"); vapi_rectangle (w - 16, 10, 17, 3, c); vapi_pos_color_text (w - 15, 11, c, msg); }
void term_size (int w, int h) { char msg[48]; sprintf (msg, "Term %dx%d", w, h); color c = color_def ("black on green"); vapi_rectangle (w - 16, 6, 17, 3, c); vapi_pos_color_text (w - 15, 7, c, msg); }
void rulers (int w, int h) { color red = color_def ("red"); std::stringstream line1; std::stringstream line2; std::stringstream line3; std::stringstream line4; for (int i = 1; i <= w; i++) { if ((i % 10 == 0) && i > 90) { line1 << (i / 100); line2 << (i % 100) / 10; line4 << '|'; } else if (i % 10 == 0) { line1 << ' '; line2 << (i / 10); line4 << '|'; } else if (i % 5 == 0) { line1 << ' '; line2 << ' '; line4 << ':'; } else { line1 << ' '; line2 << ' '; line4 << '.'; } line3 << (i % 10); } vapi_pos_color_text (1, 1, red, line1.str ().c_str ()); vapi_pos_color_text (1, 2, red, line2.str ().c_str ()); vapi_pos_color_text (1, 3, red, line3.str ().c_str ()); vapi_pos_color_text (1, 4, red, line4.str ().c_str ()); }
static void plcmap0_def(int imin, int imax) { int i; color_def(0, 0, 0, 0, "black" ); /* black */ color_def(1, 255, 0, 0, "red"); /* red */ color_def(2, 255, 255, 0, "yellow" ); /* yellow */ color_def(3, 0, 255, 0, "green" ); /* green */ color_def(4, 127, 255, 212, "aquamarine" ); /* aquamarine */ color_def(5, 255, 192, 203, "pink" ); /* pink */ color_def(6, 245, 222, 179, "wheat" ); /* wheat */ color_def(7, 190, 190, 190, "grey" ); /* grey */ color_def(8, 165, 42, 42, "brown" ); /* brown */ color_def(9, 0, 0, 255, "blue" ); /* blue */ color_def(10, 138, 43, 226, "BlueViolet" ); /* Blue Violet */ color_def(11, 0, 255, 255, "cyan" ); /* cyan */ color_def(12, 64, 224, 208, "turquoise" ); /* turquoise */ color_def(13, 255, 0, 255, "magenta" ); /* magenta */ color_def(14, 250, 128, 114, "salmon" ); /* salmon */ color_def(15, 255, 255, 255, "white" ); /* white */ /* color_def(0, 255, 255, 255, "white" ); /\* white *\/ */ /* color_def(1, 0, 0, 0, "black" ); /\* black *\/ */ /* color_def(2, 0, 0, 255, "blue" ); /\* blue *\/ */ /* color_def(3, 255, 0, 0, "red"); /\* red *\/ */ /* color_def(4, 165, 42, 42, "brown" ); /\* brown *\/ */ /* color_def(5, 250, 128, 114, "salmon" ); /\* salmon *\/ */ /* color_def(6, 255, 192, 203, "pink" ); /\* pink *\/ */ /* color_def(7, 127, 255, 212, "aquamarine" ); /\* aquamarine *\/ */ /* color_def(8, 245, 222, 179, "wheat" ); /\* wheat *\/ */ /* color_def(9, 64, 224, 208, "turquoise" ); /\* turquoise *\/ */ /* color_def(10, 190, 190, 190, "grey" ); /\* grey *\/ */ /* color_def(11, 0, 255, 255, "cyan" ); /\* cyan *\/ */ /* color_def(12, 0, 255, 0, "green" ); /\* green *\/ */ /* color_def(13, 255, 255, 0, "yellow" ); /\* yellow *\/ */ /* color_def(14, 255, 0, 255, "magenta" ); /\* magenta *\/ */ /* color_def(15, 138, 43, 226, "BlueViolet" ); /\* Blue Violet *\/ */ /* Any others are just arbitrarily set */ for (i = 16; i <= imax; i++) color_def(i, 255, 0, 0, "red"); /* red */ }