9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] cursor editor
@ 1998-03-10 23:34 Kenji
  0 siblings, 0 replies; 2+ messages in thread
From: Kenji @ 1998-03-10 23:34 UTC (permalink / raw)


Hello 9fans!

forsyth@caldo.demon.co.uk send me a mail:
>plan9.aichi-u.ac.jp/cedit.l
>is unreadable!
>it is good to see a Plan 9 FTP server on the net!

Oh sorry!
I have fixed.

Kenji Arisawa
E-mail: arisawa@aichi-u.ac.jp




^ permalink raw reply	[flat|nested] 2+ messages in thread

* [9fans] cursor editor
@ 1998-03-10  8:36 Kenji
  0 siblings, 0 replies; 2+ messages in thread
From: Kenji @ 1998-03-10  8:36 UTC (permalink / raw)


Hello 9fans!

I have written a mouse cursor editor.
Please use if you need it.

If the following string "8^[$@B=^[(J" (eight half) is not recognized on your Plan9
terminal, you must amend winit() in this program or get correct
program from:
plan9.aichi-u.ac.jp/cedit.l

This is a subproduct for my another project:
I would like to have a grab program that enables to cut a screen.

Kenji Arisawa
E-mail: arisawa@aichi-u.ac.jp

------------------ cedit.l --------------------
/*
*   cedit: Cursor Editor forr map:
*       1-bit color: gwhite=0, gblack=1, ggray=0;
*       2-bit color: gwhite=0, gblack=3, ggray=1;
*       4-bit color: gwhite=0, gblack=15, ggray=3;
*       8-bit color: gwhite=0, gblack=255, ggray=85;
*   We can get screen.ldepth values 0, 1, 2, 3 corresponding
*   to these bits value respectively.
*/
int pblack[4,
     0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00}
};

Cursor boxcurs = {
    {-7, -7},
    {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
     0xFF, 0xFF, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F,
   , 0x00,}
};

Cursor whitearrow = {
    {0, 0},
    {0xFF, 0xE0, 0xFF, 0xE0, 0xFF, 0xC0, 0xFF, 0x00,
     0xFF, 0x00, 0xFF, 0x80, 0xFF, 0xC0, 0xFF, 0xE0,
     0xE7, 0xF0, 0xE3, 0xF8, 0xC1, 0xFC, 0x00, 0xFE,
     0x00, 0x7F, 0x00, 0x3E, 0x00, 0x1C, 0x00, 0x08,},
   Dr(r) get size of rectangle r.
*/

#define Rt(p,s) (Rectangle)(p, add(p, s))
#define Rs(p, s) raddp(Rt(p,s), screen.r.min)
#define Dr(r) sub(r.max,r.min)

#define gputs(p,size,strorS);
    else{
        Bitmap *b;
        b = balloc(Rt(p, size), screen.ldepth);
        string(b, p, font, s, S);
        bitblt(&screen, add(screen.r.min, p), b, Rt(p, size), DorS)ize){
    gfbox(p, size, ggray);
    gbox(p, size, gbabel, int mode){
    gbutton(p, size, mode);
    if(label) glabel(p, size, label, CC);
    return size;
}
/*  ---- end of g functions --------- */


/*
*   A general mousn; i++)
                if(ptinrect(e.Point, mc[i].r)){
                    mc[i].c <-= e;
                    break;
                }
        }
    }
}

adt TextField {
    Rectangle r;);
    self->n = n;
    self->num = malloc(n*sizeof(int));
    gtext(p, size, nil);
    return self;
}

void NumField.set(NumField *self, ...){
    /* see "The documents" p.99 for the usage ... */
    int i;
  reen. r.min);
    r = raddp(self->r,p);
    bitblt(&screen, p, &screen, r, F);
    if(op == 0) {
        p = add(p, Pt(2,2));
        bitblt(&screen, p, &screen, inset(r,2), Zero);
    }
}

adt Bmatrix {
    Rectangle r;
    Cell* e;
    Point csize; /* cell size */
    byte** cell;
min,(1,1)),
        add(sub(self->r.max, self->r.min),(2,2)), gwhite);
    bflush();
    return self;
}

void Bmatrix.draw(Bmatrix *self){
    int i,j;
    int mbx, mby;
    Cell *t;
    
    (mbx, mby) = sfor(i = 0; i < 16; i++){
        for(j = 0; j< 8; j++)
            if(t[i][j]) s[2*i] |= (a << (7 - j));
        for(j = 0; j< 8; j++)
            if(t[i][j + 8]) s[2*i + 1] |= (a << (7 - j));
    }
}


void Bmatr    }
        bflush();
    }
}

adt Button {
    Rectangle r;
    byte *label;
    int type;/* radio or not */
    int status;
    void (*action)(int);
    Button *init(*Button, Point, Point size, byte *label, int      (*(self->action))(self->status);
        if(!(self->type)){
            self->status = !(self->status);
            glbutton(self->r.min, 
            sub(self->r.max, self->r.min), self->label, self->status);
            bflush();
        }
    }
}


Bmatrix clrmat, setmat;

void try(int status){
    Cursor cur;
    int++) print(" 0x%.02X,", cur.clr[8*i + j]);
        if(i != 3) print("\n");
    }
    print("},\n");
    print("{");
    for(i = 0; i < 4; i++){
        for(j = 0; j <v=malloc(size+1);
    if(v==nil){
        fprint(2, "Can't malloc: %r\n");
        exits("no mem");
    }
    seek(fd, 0, 0);
    read(fd, v, size);
    v[size]=0;
    close(fd);
    r();
    srvfd=open(srv, ORDWR);
    free(srv);
    if(srvfd==-1){
        fprint(2, "Can't open %s: %r\n", srv);
        exits("no srv");
    }
    sprint(spec, "N%d,%d,%d,%d,%d\n",
        pid,  = font0;

    gputs((50, 20), (200, 20), "left button: draw");
    gputs((50, 40), (200, 20),"middle button: erase");
    gputs((50, 60), (300, 20),"right button: set cursor offset");
    glabel((try.rect();
    mc[3].r = bot_quit.rect();
    mc[4].r = bot_load[0].rect();
    mc[5].r = bot_load[1].rect();
    mc[6].r = bot_load[2].rect();
    mc[7].r = bot_load[3].rect();
    proc mouse(mc, 8);
    task clrmat.run(mc[0].c);
    task setmat.run(mc[1].c);
    task bot_try.run(mc[2].c);
    task bot_quit.run(mc[3].c);
    task bot_load[0].run(mc[4].c);
    task bot_load[1].run(mc[5].c);
    task bot_load[2].run(mc[6].c);
    task bot_load[3].run(mc[7].c);
    
    alloc term;
    <-term;
}




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-03-10 23:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-10 23:34 [9fans] cursor editor Kenji
  -- strict thread matches above, loose matches on Subject: below --
1998-03-10  8:36 Kenji

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).