Exemplo n.º 1
0
Arquivo: TOSS.C Projeto: arpruss/ozdev
main()
{
    static byte sides;
    srand(oztime());
    ozfont(FONT_OZ_LARGE);
    ozputs(0,10,"Sides? (1-9)");
    sides=ozgetch()-'0';
    ozputch(115,30,'0'+(rand()%sides));
    ozgetch();
}
Exemplo n.º 2
0
void printheader(int y, long startdate)
{
    static byte x;
    reverse=1;
#ifndef OLDSTYLE
    if(propfont) x=ozputch(0,y,' ');
      else termputch(' ');
#else
    x=0;
#endif
    x=dumpdate(x,y,startdate,0,0);
    if(propfont) x=ozputs(x,y," - ");
     else termputs(" - ");
    x=dumpdate(x,y,startdate,NUMDAYS-1,0);
    if(!propfont) while(curcol<WIDTH) termputch(' ');
     else reverselines(y,PROP_FONT_HEIGHT);
    reverse=0;
}
Exemplo n.º 3
0
int dumpdate(int x, int y, long startdate, int index, int longform)
{
   if(!propfont)
   {
      termputs(longform?days[(startdate+index) % 7]:
               shortdays[(startdate+index) % 7]);
      termputs(", ");
#ifdef ITALIAN
      termputs(itoa(theday[index]));
      ttyprint(' ');
#endif /* ITALIAN */
      termputs(months[themonth[index]-1]);
      ttyprint(' ');
#ifndef ITALIAN
      termputs(itoa(theday[index]));
      termputs(", ");
#endif /* not ITALIAN */
      termputs(itoa(theyear[index]));
      return 0;
   }
   else
   {
      x=ozputs(x,y,longform?days[(startdate+index) % 7]:
               shortdays[(startdate+index) % 7]);
      x=ozputs(x,y,", ");
#ifdef ITALIAN
      x=ozputs(x,y,itoa(theday[index]));
      x=ozputs(x,y," ");
#endif /* ITALIAN */
      x=ozputs(x,y,months[themonth[index]-1]);
      x=ozputch(x,y,' ');
#ifndef ITALIAN
      x=ozputs(x,y,itoa(theday[index]));
      x=ozputs(x,y,", ");
#endif /* not ITALIAN */
      x=ozputs(x,y,itoa(theyear[index]));
      return x;
   }
}
Exemplo n.º 4
0
//extern int __LIB__ ozeditline(byte _x0,byte y0,char *s0,byte slen,byte xlen)
//int ozeditline(byte _x0,byte y0,char *s0,byte slen,byte xlen)
int ozeditline(int _x0, int y0, char* s0, int slen, int xlen)
{
    static char c;
    static byte l1, l2;
    static unsigned k;
    static byte i;
    register char* p;
    switch (ozgetfont()) {
    case FONT_PC_NORMAL:
    case FONT_OZ_NORMAL:
        height = 8;
        break;
    default:
        height = 13;
        break;
    }
    x = x0 = _x0;
    y = y0;
    if ((int)x0 + (int)xlen > 239 || (int)y + (int)height > 79)
        return OZEDITLINE_ERROR;
    xlen--;
    s = s0;
    pos = strlen(s0);
    if (pos >= slen)
        return OZEDITLINE_ERROR;
    ozputs(x0, y, s);
    setcursor();
    xorcursor();
    while (1) {
        switch (k = getch()) {
        case KEY_MAIN:
        case KEY_SCHEDULE:
        case KEY_MEMO:
        case KEY_TELEPHONE:
        case KEY_POWER:
        case KEY_MYPROGRAMS:
            ozexitto(k);
        case KEY_BACKLIGHT:
            oztogglelight();
            break;
        case KEY_LEFT:
            if (pos > 0) {
                pos--;
                movecursor();
            }
            break;
        case KEY_RIGHT:
            if (s[pos]) {
                pos++;
                movecursor();
            }
            break;
        case KEY_LOWER_ESC:
        case KEY_UPPER_ESC:
        case 27:
            xorcursor();
            return OZEDITLINE_CANCEL;
        case KEY_LOWER_ENTER:
        case KEY_UPPER_ENTER:
        case '\r':
        case '\n':
            xorcursor();
            return strlen(s);
        case KEY_BACKSPACE:
        case KEY_BACKSPACE_16K:
            if (pos > 0) {
                pos--;
                p = s + pos;
                c = *p;
                while (*p) {
                    *p = p[1];
                    p++;
                }
                xorcursor();
                l1 = ozputs(x0, y, s);
                l2 = ozputch(l1, -1, c);
                for (i = l1; i < l2; i++) {
                    _ozvline(i, y, height, WHITE);
                }
                ozputs(x0, y, s);
                setcursor();
                xorcursor();
            }
            break;
        default:
            if (k < 127 && ozputch(0, -1, k) + ozputs(0, -1, s) < xlen
                && (l1 = 1 + strlen(s)) < slen) {
                xorcursor();
                for (i = l1; i > pos; i--)
                    s[i] = s[i - 1];
                if (s[pos] == 0)
                    s[pos + 1] = 0;
                s[pos] = k;
                pos++;
                ozputs(x0, y, s);
                setcursor();
                xorcursor();
            }
            break;
        }
    }
    return OZEDITLINE_ERROR;
}
Exemplo n.º 5
0
byte ozputch0(byte x,byte y,byte c)
{
    if(c==' ') return x+5;
      else return ozputch(x,y,c);
}
Exemplo n.º 6
0
int dumpday(int _y, long start, int index, int from, int maxn)
{
    static int i;
    static char *b;
    static byte x0;
    register char *b2;
    if((!viewempty || !viewheaders || repeatchooser) && !num_appts[index]) return 0;
    if(index>=NUMDAYS || maxn==0) return 0;
    x=0; y=_y;
    if(from==-1)
    {
      reverse=1;
#ifndef OLDSTYLE
      if(propfont) x=ozputch(x,y,' '); else termputch(' ');
#endif
      x=dumpdate(x,y,start,index,1);
      if(propfont)
      {
        PROPPUTS(": ");
#ifndef ITALIAN
        PROPPUTS(num_appts[index]?itoa(num_appts[index]):"no");
        ozputs(x,y,num_appts[index]==1?" entry.":" entries.");
#else /* ITALIAN */
        PROPPUTS(num_appts[index]?itoa(num_appts[index]):"nessun");
        ozputs(x,y,num_appts[index]==1?" campo.":" campi.");
#endif /* ITALIAN */
        reverselines(y,PROP_FONT_HEIGHT);
        x=0; y+=PROP_FONT_HEIGHT;
      }
      else
      {
          termputs(": ");
          termputs(num_appts[index]?itoa(num_appts[index]):"no");
#ifndef ITALIAN
          termputs(num_appts[index]==1?" entry.":" entries.");
#else /* ITALIAN */
          termputs(num_appts[index]==1?" campo.":" campi.");
#endif /* ITALIAN */
          while(curcol<WIDTH) ttyprint(' ');
      }
      reverse=0;
    }
    if(num_appts[index]-from>maxn) maxn=from+maxn; else maxn=num_appts[index];
    for(i=from<0?0:from; i<maxn; i++)
    {
        if(repeatchooser)
        {
            dumpdate(x,y,start,index,1);
            if(propfont)
            {
                y+=PROP_FONT_HEIGHT;
                x=0;
            }
            else
            {
                currow++;
                curcol=0;
            }
        }
        else
        if(!viewheaders) minihead(start,index,i);
        b=ozloadcluster(appts[index][i].loc);
        switch(appts[index][i].type)
        {
            case TYPE_SCHEDULE:
                x0=x;
                x=puthour(x,b+24);
                if(propfont)
                {
                    PROPPUTCH(':');
                    PROPPUTCH0(b[26]);
                    PROPPUTCH0(b[27]);
                    x=putampm(x,b+24);
                    PROPPUTCH('-');
                    x=puthour(x,b+28);
                    PROPPUTCH(':');
                    PROPPUTCH0(b[30]);
                    PROPPUTCH0(b[31]);
                    x=putampm(x,b+28);
                    x=x0+time_indent;
                }
                else
                {
                    ttyprint(':');
                    ttyprint(b[26]);
                    ttyprint(b[27]);
                    putampm(0,b+24);
                    ttyprint('-');
                    puthour(0,b+28);
                    ttyprint(':');
                    termputs(b+30);
                    putampm(0,b+28);
                    ttyprint(' ');
                }
                b2=b+38;
                break;
            case TYPE_ANNIVERSARY:
                if(propfont)
                {
                    ozputs(x,y,"Anniv.");
                    x+=time_indent;
                }
                else
                {
                    underline=1;
#ifndef ITALIAN
                    termputs("Anniversary");
#else /* ITALIAN */
                    termputs("Anniversario");
#endif /* ITALIAN */
                    underline=0;
                    if(!_24hr)
                        termputs("  ");
                    ttyprint(' ');
                }
                b2=b+2+13+5;
                break;
            case TYPE_TODO:
                if(propfont)
                {
                    int x0=x;
#ifndef ITALIAN
                    PROPPUTS("TO DO [");
#else /* ITALIAN */
                    PROPPUTS("DAFARE[");
#endif /* ITALIAN */
                    PROPPUTCH(b[2+13+2+9]);
                    ozputch(x,y,']');
                    x=x0+time_indent;
                }
                else
                {
                    underline=1;
#ifndef ITALIAN
                    termputs("TO DO [");
#else /* ITALIAN */
                    termputs("DAFARE[");
#endif /* ITALIAN */
                    ttyprint(b[2+13+2+9]);
                    termputs("]");
                    underline=0;
                    termputs("   ");
                    if(!_24hr) termputs("  ");
                }
                b2=b+2+13+2+9+4;
                break;
        }
        if(propfont)
            PROPPUTS(b2);
        else
            while(*b2 && b2<b+64 && curcol<WIDTH)
              ttyprint(*b2++);
        if(b[1]!='\xFF' || b[0]!='\xFF')
        {
            unsigned loc2;
            b2=2+ozloadcluster(loc2=ozinclocation(appts[index][i].loc));
            if(propfont)
            {
                if(x<SCREEN_WIDTH && !*(ozputsgetend())) PROPPUTS(b2);
                if(x<SCREEN_WIDTH && (b2[-2]!='\xFF' || b2[-1]!='\xFF')
                  && !*(ozputsgetend()))
                  ozputs(x,y,2+ozloadcluster(ozinclocation(loc2)));
            }
            else
              while(*b2 && curcol<WIDTH)
                ttyprint(*b2++);
        }
        if(propfont)
        {
            x=0;
            y+=PROP_FONT_HEIGHT;
        }
        else curcol=WIDTH;
    }
    return i-from;
}