Esempio n. 1
0
static void xorcursor()
{
    _ozvline(x, y, height, XOR);
    if (x > x0)
        _ozvline(x - 1, y, height, XOR);
    else
        _ozvline(x + 1, y, height, XOR);
}
Esempio n. 2
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;
}
Esempio n. 3
0
void ozline(int _x1,int _y1,int _x2,int _y2,byte color)
{
static int temp;
static int dx,dy;
static int x1,y1,x2,y2;
x1=_x1;
y1=_y1;
x2=_x2;
y2=_y2;

if(x1==x2)
{
    if(y2<y1)
    {
       temp=y1; y1=y2; y2=temp;
    }
    if(x1<0 || x1>238 || y2<0 || y1>79) return;
    if(y1<0) y1=0;
    if(y2>79) y2=79;
    _ozvline(x1,y1,y2-y1+1,color);
    return;
}
else
if (x1>x2)
    {
    temp=x1;
    x1=x2;
    x2=temp;
    temp=y1;
    y1=y2;
    y2=temp;
}

if(y1==y2)
{
    if(y1<0 || y1>79 || x2<0 || x1>238) return;
    if(x1<0) x1=0;
    if(x2>238) x2=238;
    for(;x1<=x2;x1++) _ozpoint(x1,y1,color);
    return;
}
else
{
dx=x2-x1;
ozpoint(x1,y1,color);

if (y1>y2)
    {
    dy=y1-y2;
    if (dx>=dy)
     {
        temp=(dx>>1) - dx;
     for (x1++;x1<=x2;x1++)
         {
         temp+=dy;
         if (0<temp)
         {
          y1--;
          temp-=dx;
         }
         ozpoint(x1,y1,color);
         }
     }
    else
     {