Re: [9fans] Plot(1) broken on p9p OSX?

2013-04-21 Thread erik quanstrom
also, /n/sources/patch/plotresize

- erik



Re: [9fans] Plot(1) broken on p9p OSX?

2013-04-21 Thread erik quanstrom
On Sat Apr 20 14:25:53 EDT 2013, j...@corpus-callosum.com wrote:
> Plot doesn't have any redraw in eresized().  It would need to redraw
> the screen and reprocess the data for the new size.  

yes.  this is a problem for plan 9.  you cannot move or hide the plot
window.  imho this is pretty antisocial.

i've attached a version that always uses the double-buffer buffer
to allow for resize events.  double-buffering now only prevents
the draw from going directly to the screen.  it is also possible to
select exit from the menu before the input is exhausted.  for
programs like mapdemo, this is important.

a better solution would be to additionally save all the draw commands
(between clears) and if the screen size has changed, recompute.  otherwise
if redrawing is necessary, the double-buffer buffer can be reused.

unfortunately, i'm too lazy for that.

> Fixing this
> would probably fix devdraw cocoa versions as well and enable the
> server option.
> 
> This could be why devdraw on Mountain Lion also ends up with a
> blank screen.

it would seem that mountain lion devdraw has a bug.  devdraw should not
send a resize event until there is a, er, resize event.  this spurious
event is an error.

- erikdiff -c /n/dump/2013/0421/sys/src/cmd/plot/plot.c plot.c
/n/dump/2013/0421/sys/src/cmd/plot/plot.c:3,9 - plot.c:3,11
  #include 
  #include "plot.h"
  #include 
- #include 
+ #include 
+ #include 
+ #include 
  
  void  define(char*);
  void  call(char*);
/n/dump/2013/0421/sys/src/cmd/plot/plot.c:106,111 - plot.c:108,114
  
  #define   NFSTACK 50
  struct fstack{
+   char name[128];
int peekc;
int lineno;
char *corebuf;
/n/dump/2013/0421/sys/src/cmd/plot/plot.c:124,146 - plot.c:127,228
  int cnt[NPTS];/* control-polygon vertex counts */
  double *pts[NPTS];/* control-polygon vertex pointers */
  
- extern void m_swapbuf(void);
+ extern void m_swapbuf(void);  /* reaching into implementation.  ick. */
+ extern Image *offscreen;
  
  void
- eresized(int new){
-   if(new && getwindow(display, Refnone) < 0){
-   fprint(2, "Can't reattach to window: %r\n");
-   exits("resize");
+ resize(Point p)
+ {
+   int fd;
+ 
+   fd = open("/dev/wctl", OWRITE);
+   if(fd >= 0){
+   fprint(fd, "resize -dx %d -dy %d", p.x+4*2, p.y+4*2);
+   close(fd);
}
+ }
+ 
+ void
+ resizeto(Point p)
+ {
+   Point s;
+ 
+   s = (Point){Dx(screen->r), Dy(screen->r)};
+   if(eqpt(p, s))
+   return;
+   resize(p);
+ }
+ 
+ void
+ eresized(int new)
+ {
+   if(new && getwindow(display, Refnone) < 0)
+   sysfatal("plot: can't reattach to window: %r\n");
+ //resizeto((Point){Dx(offscreen->r)+4, Dy(offscreen->r)+4});
m_swapbuf();
  }
+ 
  char *items[]={
"exit",
0
  };
  Menu menu={items};
+ 
  void
- main(int arc, char *arv[]){
+ mouseproc(void*)
+ {
+   void *v;
+   Rune r;
+   Alt alts[4];
+   Keyboardctl *k;
+   Mousectl *m;
+   Mouse mc;
+   enum{Amouse, Akbd, Aresize, Aend};
+ 
+   m = initmouse(nil, screen);
+   k = initkeyboard(nil);
+ 
+   memset(alts, 0, sizeof alts);
+   alts[Amouse].c = m->c;
+   alts[Amouse].v = &mc;
+   alts[Amouse].op = CHANRCV;
+ 
+   alts[Akbd].c = k->c;
+   alts[Akbd].v = &r;
+   alts[Akbd].op = CHANRCV;
+ 
+   alts[Aresize].c = m->resizec;
+   alts[Aresize].v = &v;
+   alts[Aresize].op = CHANRCV;
+ 
+   alts[Aend].op = CHANEND;
+ 
+   for(;;)
+   switch(alt(alts)){
+   default:
+   sysfatal("mouse!");
+   case Amouse:
+   if(mc.buttons & 4) {
+   if(menuhit(3, m, &menu, nil) == 0)
+   threadexitsall("");
+   }
+   break;
+   case Akbd:
+   switch(r){
+   case 'q':
+   case 0x7f:
+   case 0x04:
+   threadexitsall("");
+   }
+   break;
+   case Aresize:
+   eresized(1);
+   ;
+   }
+ }
+ 
+ void
+ threadmain(int arc, char *arv[]){
char *ap;
Biobuf *bp;
int fd;
/n/dump/2013/0421/sys/src/cmd/plot/plot.c:147,157 - plot.c:229,240
int i;
int dflag;
char *oflag;
-   Mouse m;
+ 
bp = 0;
fd = dup(0, -1);/* because openpl will close 0! */
dflag=0;
oflag="";
+   argv0 = arv[0];
for(i=1;i!=arc;i++) if(arv[i][0]=='-') switch(arv[i][1]){
case 'd': dflag=1; break;
case 'o': oflag=arv[i]+2; break;
/n/dump/2013/0421/sys/src/cmd/plot/plot.c:158,164 - plot.c:241,249
case 's': fd=server(); break;
}
openpl(ofl

Re: [9fans] Plot(1) broken on p9p OSX?

2013-04-20 Thread Jeff Sickel
Plot doesn't have any redraw in eresized().  It would need to redraw
the screen and reprocess the data for the new size.  Fixing this
would probably fix devdraw cocoa versions as well and enable the
server option.

This could be why devdraw on Mountain Lion also ends up with a
blank screen.

-jas

On Apr 20, 2013, at 3:00 AM, Nicolas Bercher  wrote:

> On 19/04/2013 23:23, marius a. eriksen wrote:
>> % @{echo 1; echo 2; echo 3} | graph -a | plot
>> 
>> Yields only a lonely, blank window.
> 
> Using drawterm connected to a native Plan 9, it's working
> but if I drag the window, the plot disappears (the window
> becomes blank).
> 
> Nicolas
> 




Re: [9fans] Plot(1) broken on p9p OSX?

2013-04-20 Thread Nicolas Bercher

On 19/04/2013 23:23, marius a. eriksen wrote:

% @{echo 1; echo 2; echo 3} | graph -a | plot

Yields only a lonely, blank window.


Using drawterm connected to a native Plan 9, it's working
but if I drag the window, the plot disappears (the window
becomes blank).

Nicolas



Re: [9fans] Plot(1) broken on p9p OSX?

2013-04-19 Thread Skip Tavakkolian
right... uname says, 10.7.5 -- which i can see now is a Lion, but not of
the Mountains


On Fri, Apr 19, 2013 at 5:20 PM, Jeff Sickel wrote:

> I'm on 10.8.3 and I see the grey screen w/ no plot.
>
> Skip's still on that "Blue" Quartz UI setting, the stop light colors on
> the window buttons give it away, so he may not have done a full rebuild of
> p9p in a while.  I can't get all of p9p to compile on 10.8, that mean's
> there are likely a few bits missing that never made it forward from my pre
> 10.7 builds.
>
> I've tried forcing a flush image in during the event loop and after
> resizing the window.  All that does is give a clean white background that
> didn't use to exist.  Still no real plot info.
>
> To get around the drawing problems I always went w/ grap | pic | troff |
> tr2post | psfonts > t.ps.
>
> -jas
>
>
>
> On Apr 19, 2013, at 6:33 PM, marius a. eriksen  wrote:
>
> > Interesting. Which version of OSX is this? I'm running Mountain Lion.
> >
> > -marius
> >
>
>
>


Re: [9fans] Plot(1) broken on p9p OSX?

2013-04-19 Thread Jeff Sickel
I'm on 10.8.3 and I see the grey screen w/ no plot.

Skip's still on that "Blue" Quartz UI setting, the stop light colors on the 
window buttons give it away, so he may not have done a full rebuild of p9p in a 
while.  I can't get all of p9p to compile on 10.8, that mean's there are likely 
a few bits missing that never made it forward from my pre 10.7 builds.

I've tried forcing a flush image in during the event loop and after resizing 
the window.  All that does is give a clean white background that didn't use to 
exist.  Still no real plot info.

To get around the drawing problems I always went w/ grap | pic | troff | 
tr2post | psfonts > t.ps.

-jas



On Apr 19, 2013, at 6:33 PM, marius a. eriksen  wrote:

> Interesting. Which version of OSX is this? I'm running Mountain Lion.
> 
> -marius
> 




Re: [9fans] Plot(1) broken on p9p OSX?

2013-04-19 Thread Skip Tavakkolian
Ditto.

On Apr 19, 2013, at 4:33 PM, "marius a. eriksen"  wrote:

> Interesting. Which version of OSX is this? I'm running Mountain Lion.
> 
> -marius
> 



Re: [9fans] Plot(1) broken on p9p OSX?

2013-04-19 Thread marius a. eriksen
Interesting. Which version of OSX is this? I'm running Mountain Lion.

-marius



[9fans] Plot(1) broken on p9p OSX?

2013-04-19 Thread marius a. eriksen
Graph(1) seems to work:

% @{echo 1; echo 2; echo 3} | graph -a
o
ra 0 0 4096 4096
e
li 200 200 4000 200
v 4000 4000
v 200 4000
v 200 200
li 1150 200 1150 4000
li 2100 200 2100 4000
li 3050 200 3050 4000
li 200 1150 4000 1150
li 200 2100 4000 2100
li 200 3050 4000 3050
m 200 140
t "0 <= x <= 2, 1 <= y <= 3"
pe solid
co kblack
m 200 200
v 2100 2100
v 4000 4000
pe solid
cl

But not plot(1):

% @{echo 1; echo 2; echo 3} | graph -a | plot

Yields only a lonely, blank window.

Has anyone gotten this to work?

-marius