Esempio n. 1
0
static void DisplayPrompt (char* s)
/* Display a prompt */
{
    unsigned char OldColor;

    /* Remember the current color */
    OldColor = textcolor (COLOR_TEXTHIGH);

    /* Clear the old prompt if there is one */
    if (ActivePrompt) {
        (void) textcolor (PromptColor);
        chlinexy ((MAX_X - PromptLength) / 2, MAX_Y-1, PromptLength);
    }

    /* Get the new prompt data */
    ActivePrompt = s;
    PromptColor  = OldColor;
    PromptLength = strlen (ActivePrompt);

    /* Display the new prompt */
    (void) textcolor (COLOR_TEXTHIGH);
    cputsxy ((MAX_X - PromptLength) / 2, MAX_Y-1, ActivePrompt);

    /* Restore the old color */
    (void) textcolor (PromptColor);
}
/*-----------------------------------------------------------------------------------*/
static void
s_ctk_draw_dialog(struct ctk_window *dialog)
{
  unsigned char x, y;
  unsigned char i;
  unsigned char x1, y1, x2, y2;
  
  (void)textcolor(DIALOGCOLOR);

  x = dialog->x;
  y = dialog->y + 1;

  x1 = x + 1;
  y1 = y + 1;
  x2 = x1 + dialog->w;
  y2 = y1 + dialog->h;

  /* Draw dialog frame. */
  cvlinexy(x, y1,
	   dialog->h);
  cvlinexy(x2, y1,
	   dialog->h);

  chlinexy(x1, y,
	   dialog->w);
  chlinexy(x1, y2,
	   dialog->w);

  cputcxy(x, y, CH_ULCORNER);
  cputcxy(x, y2, CH_LLCORNER);
  cputcxy(x2, y, CH_URCORNER);
  cputcxy(x2, y2, CH_LRCORNER);
  
  /* Clear dialog contents. */
  for(i = y1; i < y2; ++i) {
    cclearxy(x1, i, dialog->w);
  }

  draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey,
		       x1, x2, y1, y2);
}
Esempio n. 3
0
int showAddrsBar()
{
  int Len;

  cclearxy(0,0,screenW*2);
  chlinexy(0,1,screenW);
  cputsxy(0,0,"URL:");

  //fflush (stdout);
  fgets (url, sizeof (url), stdin);

  /* Remove trailing white space including the line terminator */
  Len = strlen (url);
  while (Len > 0 && isspace (url[Len-1])) {
      --Len;
  }
  url[Len] = '\0';

  if (Len>0) {
      getData();
  }

  return(Len);
}
Esempio n. 4
0
/*-----------------------------------------------------------------------------------*/
static void
draw_widget(struct ctk_widget *w,
	    unsigned char x, unsigned char y,
	    unsigned char clipx, unsigned char clipy,
	    unsigned char clipy1, unsigned char clipy2,
	    unsigned char focus)
{
  unsigned char xpos, ypos, xscroll;
  unsigned char i, j;
  char c, *text;
  unsigned char wfocus;
#if CTK_CONF_ICONS
  unsigned char len;
#endif /* CTK_CONF_ICONS */

  wfocus = 0;
  if(focus & CTK_FOCUS_WINDOW) {    
    (void)textcolor(WIDGETCOLOR_FWIN);
    if(focus & CTK_FOCUS_WIDGET) {
      (void)textcolor(WIDGETCOLOR_FOCUS);
      wfocus = 1;
    }
#if CTK_CONF_WINDOWS
  } else if(focus & CTK_FOCUS_DIALOG) {
    (void)textcolor(WIDGETCOLOR_DIALOG);
    if(focus & CTK_FOCUS_WIDGET) {
      (void)textcolor(WIDGETCOLOR_FOCUS);
      wfocus = 1;
    }
#endif /* CTK_CONF_WINDOWS */
  } else {
    (void)textcolor(WIDGETCOLOR);
  }
  
  xpos = x + w->x;
  ypos = y + w->y;
    
  switch(w->type) {
  case CTK_WIDGET_SEPARATOR:
    if(ypos >= clipy1 && ypos < clipy2) {
      chlinexy(xpos, ypos, w->w);
    }
    break;
  case CTK_WIDGET_LABEL:
    text = w->widget.label.text;
    for(i = 0; i < w->h; ++i) {
      if(ypos >= clipy1 && ypos < clipy2) {
	gotoxy(xpos, ypos);
	cputsn(text, w->w);
	if(w->w - (wherex() - xpos) > 0) {
	  cclear(w->w - (wherex() - xpos));
	}
      }
      ++ypos;
      text += w->w;
    }
    break;
  case CTK_WIDGET_BUTTON:
    if(ypos >= clipy1 && ypos < clipy2) {
      revers(wfocus != 0);
      cputcxy(xpos, ypos, '[');
      cputsn(w->widget.button.text, w->w);
      cputc(']');
      revers(0);
    }
    break;
  case CTK_WIDGET_HYPERLINK:
    if(ypos >= clipy1 && ypos < clipy2) {
      revers(wfocus == 0);
      gotoxy(xpos, ypos);
      (void)textcolor(WIDGETCOLOR_HLINK);
      cputsn(w->widget.button.text, w->w);
      revers(0);
    }
    break;
  case CTK_WIDGET_TEXTENTRY:
    text = w->widget.textentry.text;
    xscroll = 0;
    if(w->widget.textentry.xpos >= w->w - 1) {
      xscroll = w->widget.textentry.xpos - w->w + 1;
    }
    for(j = 0; j < w->h; ++j) {
      if(ypos >= clipy1 && ypos < clipy2) {
	if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
	   w->widget.textentry.ypos == j) {
	  revers(0);
	  cputcxy(xpos, ypos, '>');
	  c = 1;
	  for(i = 0; i < w->w; ++i) {
	    if(c != 0) {
	      c = text[i + xscroll];
	    }
	    revers(i == w->widget.textentry.xpos - xscroll);
	    if(c == 0) {
	      cputc(' ');
	    } else {
	      cputc(c);
	    }
	  }
	  revers(0);
	  cputc('<');
	} else {
	  revers(wfocus != 0 && j == w->widget.textentry.ypos);
	  cvlinexy(xpos, ypos, 1);
	  gotoxy(xpos + 1, ypos);          
	  cputsn(text, w->w);
	  i = wherex();
	  if(i - xpos - 1 < w->w) {
	    cclear(w->w - (i - xpos) + 1);
	  }
	  cvline(1);
	}
      }
      ++ypos;
      text += w->widget.textentry.len + 1;
    }
    revers(0);
    break;
#if CTK_CONF_ICONS
  case CTK_WIDGET_ICON:
    if(ypos >= clipy1 && ypos < clipy2) {
      revers(wfocus != 0);
#if CTK_CONF_ICON_TEXTMAPS
      if(w->widget.icon.textmap != NULL) {
	for(i = 0; i < 3; ++i) {
	  gotoxy(xpos, ypos);
	  if(ypos >= clipy1 && ypos < clipy2) {
	    cputc(w->widget.icon.textmap[0 + 3 * i]);
	    cputc(w->widget.icon.textmap[1 + 3 * i]);
	    cputc(w->widget.icon.textmap[2 + 3 * i]);
	  }
	  ++ypos;
	}
      }
#endif /* CTK_CONF_ICON_TEXTMAPS */
  
      len = (unsigned char)strlen(w->widget.icon.title);
      if(xpos + len >= sizex) {
	xpos = sizex - len;
      }

      gotoxy(xpos, ypos);
      if(ypos >= clipy1 && ypos < clipy2) {
	cputs(w->widget.icon.title);
      }
      revers(0);
    }
    break;
#endif /* CTK_CONF_ICONS */

  default:
    break;
  }
}
Esempio n. 5
0
/*-----------------------------------------------------------------------------------*/
void
ctk_draw_window(struct ctk_window *window, unsigned char focus,
		unsigned char clipy1, unsigned char clipy2,
		unsigned char draw_borders)
{
#if CTK_CONF_WINDOWS
  unsigned char x, y;
  unsigned char x1, y1, x2, y2;
  unsigned char h;

  if(window->y + CTK_CONF_MENUS >= clipy2) {
    return;
  }
    
  x = window->x;
  y = window->y + CTK_CONF_MENUS;
  x1 = x + 1;
  y1 = y + 1;
  x2 = x1 + window->w;
  y2 = y1 + window->h;

  if(draw_borders) {

    /* Draw window frame. */  
    if(focus & CTK_FOCUS_WINDOW) {
      (void)textcolor(WINDOWCOLOR_FOCUS);
    } else {
      (void)textcolor(WINDOWCOLOR);
    }

    if(y >= clipy1) {
      cputcxy(x, y, (char)CH_ULCORNER);
      gotoxy(wherex() + window->titlelen + CTK_CONF_WINDOWMOVE * 2, wherey());
      chline(window->w - (wherex() - x) - 2);
      cputcxy(x2, y, (char)CH_URCORNER);
    }

    h = window->h;
  
    if(clipy1 > y1) {
      if(clipy1 - y1 < h) {
	h = clipy1 - y1;
	y1 = clipy1;
      } else {
	h = 0;
      }
    }

    if(clipy2 < y1 + h) {
      if(y1 >= clipy2) {
	h = 0;
      } else {
	h = clipy2 - y1;
      }
    }

    cvlinexy(x, y1, h);
    cvlinexy(x2, y1, h);  

    if(y + window->h >= clipy1 && y + window->h < clipy2) {
      cputcxy(x, y2, (char)CH_LLCORNER);
      chlinexy(x1, y2, window->w);
      cputcxy(x2, y2, (char)CH_LRCORNER);
    }
  }

  draw_window_contents(window, focus, clipy1, clipy2, x1, x2, y + 1, y2);

#else /* CTK_CONF_WINDOWS */

  draw_window_contents(window, focus, clipy1, clipy2, 0, window->w, 0, window->h);

#endif /* CTK_CONF_WINDOWS */
}
Esempio n. 6
0
void main(void)
{
        int i, j, n;
        unsigned char xsize, ysize, tcol, bgcol, bcol, inpos = 0;

        clrscr();
        screensize(&xsize, &ysize);
        cputs("cc65 conio test\n\rInput: [        ]");

        cputsxy(0, 2, "Colors:" );
        tcol = textcolor(0); /* remember original textcolor */
        bgcol = bgcolor(0); /* remember original background color */
        bcol = bordercolor(0); /* remember original border color */
        bgcolor(bgcol);bordercolor(bcol);
        for (i = 0; i < 3; ++i) {
                gotoxy(i,3 + i);
                for (j = 0; j < 16; ++j) {
                        textcolor(j);
                        cputc('X');
                }
        }
        textcolor(tcol);

        cprintf("\n\n\r Screensize is: %dx%d", xsize, ysize );

        chlinexy(0,6,xsize);
        cvlinexy(0,6,3);
        chlinexy(0,8,xsize);
        cvlinexy(xsize-1,6,3);
        cputcxy(0,6,CH_ULCORNER);
        cputcxy(xsize-1,6,CH_URCORNER);
        cputcxy(0,8,CH_LLCORNER);
        cputcxy(xsize-1,8,CH_LRCORNER);

        for (i = 0; i < 5; ++i) {
                gotoxy(xsize - 5,i);
                for (j = 0; j < 5; ++j) {
                        cputc(grid[i][j]);
                }
        }

        gotoxy(0,ysize - 2 - ((256 + xsize) / xsize));
        revers(1);
        for (i = 0; i < xsize; ++i) {
                cputc('0' + i % 10);
        }
        revers(0);
        for (i = 0; i < 256; ++i) {
            if ((i != '\n') && (i != '\r')) {
                    cputc(i);
            } else {
                    cputc(' ');
            }
        }
        while(wherex() > 0) {
                cputc('#');
        }
        revers(1);
        for (i = 0; i < xsize; ++i) {
                cputc('0' + i % 10);
        }
        revers(0);

        cursor(1);
        for(;;) {

                gotoxy(8, 2);
                j = n & 1;
                revers(j);
                cputc(j ? 'R' : ' ');
                revers(j ^ 1);
                cputs(" revers");
                revers(0);

                gotoxy(8 + inpos,1);
                i = cgetc();
                if ((i >= '0') && (i<='9')) {
                    textcolor(i - '0');
                } else if (i == CH_CURS_LEFT) {
                    inpos = (inpos - 1) & 7;
                } else if (i == CH_CURS_RIGHT) {
                    inpos = (inpos + 1) & 7;
                } else if (i == CH_F5) {
                    bgcol = (bgcol + 1) & 0x0f;
                    bordercolor(bgcol);
                } else if (i == CH_F6) {
                    bgcol = (bgcol - 1) & 0x0f;
                    bordercolor(bgcol);
                } else if (i == CH_F7) {
                    bgcol = (bgcol + 1) & 0x0f;
                    bgcolor(bgcol);
                } else if (i == CH_F8) {
                    bgcol = (bgcol - 1) & 0x0f;
                    bgcolor(bgcol);
                } else {
                    cputc(i);
                    inpos = (inpos + 1) & 7;
                }

                ++n;
        }

        for(;;);
}