+ int i;
+
+ upd_color();
+ attron(COLOR_PAIR(cur_pair));
+
+ for(i=0; i<ysz; i++) {
+ move(y + i, x);
+ hline(bgchar, xsz);
+ }
+
+ if(flags & TGFX_FRAME) {
+ move(y, x + 1);
+ hline(ACS_HLINE, xsz - 2);
+ move(y + ysz - 1, x + 1);
+ hline(ACS_HLINE, xsz - 2);
+ move(y + 1, x);
+ vline(ACS_VLINE, ysz - 2);
+ move(y + 1, x + xsz - 1);
+ vline(ACS_VLINE, ysz - 2);
+
+ mvaddch(y, x, ACS_ULCORNER);
+ mvaddch(y, x + xsz - 1, ACS_URCORNER);
+ mvaddch(y + ysz - 1, x, ACS_LLCORNER);
+ mvaddch(y + ysz - 1, x + xsz - 1, ACS_LRCORNER);
+ }
+
+ if(label) {
+ tg_text(x + 2, y, "%s", label);
+ }
+
+ attroff(COLOR_PAIR(cur_pair));
+ refresh();
+}
+
+int tg_gchar(int gchar)
+{
+ switch(gchar) {
+ case TGFX_LARROW:
+ return ACS_LARROW;
+ case TGFX_RARROW:
+ return ACS_RARROW;
+ default:
+ break;
+ }
+ return '@';
+}
+
+static int curses_color(int col)
+{
+ switch(col) {
+ case TGFX_RED:
+ return COLOR_RED;
+ case TGFX_BLUE:
+ return COLOR_BLUE;
+ case TGFX_CYAN:
+ return COLOR_CYAN;
+ case TGFX_YELLOW:
+ return COLOR_YELLOW;
+ default:
+ break;
+ }
+ return col;
+}
+
+static void upd_color(void)
+{
+ int i;
+
+ for(i=0; i<num_colors; i++) {
+ if(fgcol == colors[i].fg && bgcol == colors[i].bg) {
+ cur_pair = colors[i].pair;
+ return;
+ }
+ }
+
+ /* not found, allocate a new color pair */
+ if(num_colors >= COLORS) {
+ return;
+ }
+ i = num_colors++;
+ cur_pair = num_colors;
+
+ colors[i].fg = fgcol;
+ colors[i].bg = bgcol;
+ colors[i].pair = cur_pair;
+ init_pair(cur_pair, fgcol, bgcol);