9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Kenji Arisawa arisawa@ar.aichi-u.ac.jp
Subject: [9fans] cursor editor
Date: Tue, 10 Mar 1998 17:36:41 +0900	[thread overview]
Message-ID: <19980310083641.-4ND3NF5I-hLExWARRakv4ldt0AFhZFqZmlAu--Imi4@z> (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;
}




             reply	other threads:[~1998-03-10  8:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-03-10  8:36 Kenji [this message]
1998-03-10 23:34 Kenji

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19980310083641.-4ND3NF5I-hLExWARRakv4ldt0AFhZFqZmlAu--Imi4@z \
    --to=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).