* Re: [9fans] people who write little useless graphical programs should be shot
@ 2002-01-17 17:28 Russ Cox
0 siblings, 0 replies; 2+ messages in thread
From: Russ Cox @ 2002-01-17 17:28 UTC (permalink / raw)
To: 9fans
Did you find a good way to reproduce your problem?
> ps: could someone please explain how to use '|fmt' in acme mail? i have to press
> enter every line in order to make the mail somewhat readable :)
Highlight the text you want to format, and then middle-click |fmt.
Same way you use |anything in acme.
Russ
^ permalink raw reply [flat|nested] 2+ messages in thread
* [9fans] people who write little useless graphical programs should be shot
@ 2002-01-17 16:09 andrey mirtchovski
0 siblings, 0 replies; 2+ messages in thread
From: andrey mirtchovski @ 2002-01-17 16:09 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 1096 bytes --]
i have a laptop here running plan9.. i'm quite happy with it most of the time and
i'm not happy with it when it hangs during window resize (when running p9 locally)..
i suspected the vga driver so i wrote a small graphical program to see if it will force
it to hang by displaying lines on the screen over and over again. i indeed succeeded
in crashing it.
then, last night, i decided to 'beautify' the program and foo.c was born..
it displays moving lines in a window.. it provides the user with the wonderful
options to do 'more', 'less' and 'exit'.. it was hacked rather quickly to accomodate
more than one line at a time, and this shows in the code quality...
the performance is satisfactory even when running on a pure terminal (8bpp)...
of course higher bpp means more visually pleasing lines, but the performance
tradeoff is something you should decide for yourselves :)
enjoy (if you enjoy such things :)
andrey
ps: could someone please explain how to use '|fmt' in acme mail? i have to press
enter every line in order to make the mail somewhat readable :)
[-- Attachment #2: foo.c --]
[-- Type: text/plain, Size: 2791 bytes --]
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <event.h>
Rectangle r;
Image *img[256];
typedef struct {
Point p1;
Point p2;
int b;
int db;
int p1dx;
int p1dy;
int p2dx;
int p2dy;
} mline;
typedef struct mq mq;
struct mq {
mline *node;
mq *next;
};
void
eresized(int new)
{
if(new && getwindow(display, Refnone) < 0) {
fprint(2, "bez: can't reattach to window: %r\n");
exits("resized");
}
draw(screen, screen->r, display->black, nil, ZP);
r = screen->r;
}
char *buttons[] =
{
"more",
"less",
"exit",
0
};
Menu menu =
{
buttons
};
void
init(mline *m) {
m->p1.x = r.min.x + nrand(r.max.x - r.min.x);
m->p2.x = r.min.x + nrand(r.max.x - r.min.x);
m->p1.y = r.min.y + nrand(r.max.y - r.min.y);
m->p2.y = r.min.y + nrand(r.max.y - r.min.y);
m->p1dx = (int)((frand() - 0.5)*5);
m->p1dy = (int)((frand() - 0.5)*5);
m->p2dx = (int)((frand() - 0.5)*5);
m->p2dy = (int)((frand() - 0.5)*5);
m->b = 1;
m->db = 1;
}
void main(int argc, char **argv) {
int i, b = 1, db = 1;
Mouse ms;
Point p1, p2;
mq q;
mq *p;
mline *m;
srand(time(0));
if(initdraw(nil, nil, "bez") < 0)
sysfatal("initdraw failed: %r");
/* allocate colors */
for(i = 0; i < 256; i++) {
img[i] = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, (i<<24)|(i<<16)|(i<<8)|0xFF);
}
r = screen->r;
q.node = (mline *)malloc(sizeof (mline));
q.next = nil;
init(q.node);
einit(Emouse);
eresized(0);
for(;;) {
if(ecanmouse()) {
ms = emouse();
if(ms.buttons&4)
switch(emenuhit(3, &ms, &menu)) {
case 0: /* more */
p=&q;
while(p->next != nil)
p = p->next;
p->next = (mq *)malloc(sizeof (mq));
p->next->node = (mline *)malloc(sizeof(mline));
init(p->next->node);
p->next->next = nil;
break;
case 1:
if(q.next == nil)
break;
p = &q;
while(p->next->next != nil)
p = p->next;
free(p->next->node);
free(p->next);
p->next = nil;
break;
case 2:
exits(0);
}
}
p = &q;
while(p != nil) {
m = p->node;
m->p1.x += m->p1dx;
if(m->p1.x < r.min.x || m->p1.x > r.max.x)
m->p1dx = -m->p1dx;
m->p1.y += m->p1dy;
if(m->p1.y < r.min.y || m->p1.y > r.max.y)
m->p1dy = -m->p1dy;
m->p2.x += m->p2dx;
if(m->p2.x < r.min.x || m->p2.x > r.max.x)
m->p2dx = -m->p2dx;
m->p2.y += m->p2dy;
if(m->p2.y < r.min.y || m->p2.y > r.max.y)
m->p2dy = -m->p2dy;
line(screen, m->p1, m->p2, Endsquare, Endsquare,2, img[m->b], ZP);
if(m->b <= 0 || m->b >= 255)
m->db *= -1;
m->b+= m->db;
p = p->next;
}
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-01-17 17:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-17 17:28 [9fans] people who write little useless graphical programs should be shot Russ Cox
-- strict thread matches above, loose matches on Subject: below --
2002-01-17 16:09 andrey mirtchovski
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).