9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* a simple graphical application in Go?
@ 2020-04-04 13:54 Kim Lassila
  2020-04-04 20:32 ` [9fans] " Jeremy Jackins
  2020-04-04 21:37 ` Chris McGee
  0 siblings, 2 replies; 9+ messages in thread
From: Kim Lassila @ 2020-04-04 13:54 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 579 bytes --]

Has anyone written a graphical application in Go on Plan 9? How would the Go equivalent of black.c (thank you fgb) look like?  

- - - clip - - -

#include <u.h>
#include <libc.h>
#include <draw.h>

void
main(int, char *argv[])
{
	Rectangle	rect;
	Image *black;

	fmtinstall('R', Rfmt);
	if(initdraw(nil, nil, argv[0]) < 0)
		sysfatal("initdraw: %r");
	rect = screen->r;
	black = display->black;
	draw(screen, rect, black, nil, ZP);
	flushimage(display, 1);
	sleep(5 * 1000);
	closedisplay(display);
	print("rectangle was %R\n", rect);
	exits(nil);
}


[-- Attachment #2: Type: text/html, Size: 7029 bytes --]

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

* Re: [9fans] a simple graphical application in Go?
  2020-04-04 13:54 a simple graphical application in Go? Kim Lassila
@ 2020-04-04 20:32 ` Jeremy Jackins
  2020-04-04 21:50   ` Skip Tavakkolian
  2020-04-05  4:15   ` Fazlul Shahriar
  2020-04-04 21:37 ` Chris McGee
  1 sibling, 2 replies; 9+ messages in thread
From: Jeremy Jackins @ 2020-04-04 20:32 UTC (permalink / raw)
  To: 9fans

Well, you need a Go draw package in place of the C library. There is a
draw package in github.com/9fans/go/ but unfortunately I think it only
supports plan9port devdraw, rather than the native Plan 9 draw device.
So there is some library work to be done first. Since the Go standard
library also contains the most important drawing primitives
implemented by the Plan 9 draw device (with the exception of font
rendering, but there is golang.org/x/image/font), you may be able to
ignore a lot of functionality provided by the Plan 9 draw library and
focus on a few things like loading pixel data directly to the draw
device.

See: http://man.cat-v.org/plan_9/3/draw

Jeremy

On Sat, 4 Apr 2020 at 06:55, Kim Lassila <kim.lassila@gmail.com> wrote:
>
> Has anyone written a graphical application in Go on Plan 9? How would the Go equivalent of black.c (thank you fgb) look like?
>
> - - - clip - - -
>
> #include <u.h>
> #include <libc.h>
> #include <draw.h>
>
> void
> main(int, char *argv[])
> {
> Rectangle rect;
> Image *black;
>
> fmtinstall('R', Rfmt);
> if(initdraw(nil, nil, argv[0]) < 0)
> sysfatal("initdraw: %r");
> rect = screen->r;
> black = display->black;
> draw(screen, rect, black, nil, ZP);
> flushimage(display, 1);
> sleep(5 * 1000);
> closedisplay(display);
> print("rectangle was %R\n", rect);
> exits(nil);
> }
>
> 9fans / 9fans / see discussions + participants + delivery options Permalink

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

* Re: [9fans] a simple graphical application in Go?
  2020-04-04 13:54 a simple graphical application in Go? Kim Lassila
  2020-04-04 20:32 ` [9fans] " Jeremy Jackins
@ 2020-04-04 21:37 ` Chris McGee
  2020-04-05  0:40   ` ori
  2020-04-05  4:11   ` Kim Lassila
  1 sibling, 2 replies; 9+ messages in thread
From: Chris McGee @ 2020-04-04 21:37 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 1292 bytes --]

You can try this Go library by mischief and some examples in the cmd
package:
https://bitbucket.org/mischief/draw9/src/default/

Last I recall, it worked fine on 9front. I'm not sure about the other
variants.

Cheers,
Chris

On Sat, Apr 4, 2020 at 9:54 AM Kim Lassila <kim.lassila@gmail.com> wrote:

> Has anyone written a graphical application in Go on Plan 9? How would the
> Go equivalent of black.c (thank you fgb) look like?
>
> - - - clip - - -
>
> #include <u.h>
> #include <libc.h>
> #include <draw.h>
>
> void
> main(int, char *argv[])
> {
> Rectangle rect;
> Image *black;
>
> fmtinstall('R', Rfmt);
> if(initdraw(nil, nil, argv[0]) < 0)
> sysfatal("initdraw: %r");
> rect = screen->r;
> black = display->black;
> draw(screen, rect, black, nil, ZP);
> flushimage(display, 1);
> sleep(5 * 1000);
> closedisplay(display);
> print("rectangle was %R\n", rect);
> exits(nil);
> }
>
> *9fans <https://9fans.topicbox.com/latest>* / 9fans / see discussions
> <https://9fans.topicbox.com/groups/9fans> + participants
> <https://9fans.topicbox.com/groups/9fans/members> + delivery options
> <https://9fans.topicbox.com/groups/9fans/subscription> Permalink
> <https://9fans.topicbox.com/groups/9fans/T0d490c91935dc74b-M9cbad5709834cc595acc4061>
>

[-- Attachment #2: Type: text/html, Size: 7290 bytes --]

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

* Re: [9fans] a simple graphical application in Go?
  2020-04-04 20:32 ` [9fans] " Jeremy Jackins
@ 2020-04-04 21:50   ` Skip Tavakkolian
  2020-04-05  4:15   ` Fazlul Shahriar
  1 sibling, 0 replies; 9+ messages in thread
From: Skip Tavakkolian @ 2020-04-04 21:50 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 2096 bytes --]

I think that's the right place to start.  I've not looked closely, but it
looks like the only thing that you'd need to do for a client library is to
change drawfcall/mux.go:New to use the draw service posted on /srv.

On Sat, Apr 4, 2020 at 1:34 PM Jeremy Jackins <jeremyjackins@gmail.com>
wrote:

> Well, you need a Go draw package in place of the C library. There is a
> draw package in github.com/9fans/go/ but unfortunately I think it only
> supports plan9port devdraw, rather than the native Plan 9 draw device.
> So there is some library work to be done first. Since the Go standard
> library also contains the most important drawing primitives
> implemented by the Plan 9 draw device (with the exception of font
> rendering, but there is golang.org/x/image/font), you may be able to
> ignore a lot of functionality provided by the Plan 9 draw library and
> focus on a few things like loading pixel data directly to the draw
> device.
>
> See: http://man.cat-v.org/plan_9/3/draw
>
> Jeremy
>
> On Sat, 4 Apr 2020 at 06:55, Kim Lassila <kim.lassila@gmail.com> wrote:
> >
> > Has anyone written a graphical application in Go on Plan 9? How would
> the Go equivalent of black.c (thank you fgb) look like?
> >
> > - - - clip - - -
> >
> > #include <u.h>
> > #include <libc.h>
> > #include <draw.h>
> >
> > void
> > main(int, char *argv[])
> > {
> > Rectangle rect;
> > Image *black;
> >
> > fmtinstall('R', Rfmt);
> > if(initdraw(nil, nil, argv[0]) < 0)
> > sysfatal("initdraw: %r");
> > rect = screen->r;
> > black = display->black;
> > draw(screen, rect, black, nil, ZP);
> > flushimage(display, 1);
> > sleep(5 * 1000);
> > closedisplay(display);
> > print("rectangle was %R\n", rect);
> > exits(nil);
> > }
> >
> > 9fans / 9fans / see discussions + participants + delivery options
> Permalink
>
> ------------------------------------------
> 9fans: 9fans
> Permalink:
> https://9fans.topicbox.com/groups/9fans/T0d490c91935dc74b-M08178595d1453fd46812690c
> Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
>

[-- Attachment #2: Type: text/html, Size: 3160 bytes --]

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

* Re: [9fans] a simple graphical application in Go?
  2020-04-04 21:37 ` Chris McGee
@ 2020-04-05  0:40   ` ori
  2020-04-05  4:11   ` Kim Lassila
  1 sibling, 0 replies; 9+ messages in thread
From: ori @ 2020-04-05  0:40 UTC (permalink / raw)
  To: newton688, 9fans

> You can try this Go library by mischief and some examples in the cmd
> package:
> https://bitbucket.org/mischief/draw9/src/default/
> 
> Last I recall, it worked fine on 9front. I'm not sure about the other
> variants.
> 

It should work elsewhere -- There have been no incompatible changes
to devdraw on 9front.


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

* Re: [9fans] a simple graphical application in Go?
  2020-04-04 21:37 ` Chris McGee
  2020-04-05  0:40   ` ori
@ 2020-04-05  4:11   ` Kim Lassila
  1 sibling, 0 replies; 9+ messages in thread
From: Kim Lassila @ 2020-04-05  4:11 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 865 bytes --]

On Apr 5, 2020, at 12:37 AM, Chris McGee <newton688@gmail.com> wrote:
> 
> You can try this Go library by mischief and some examples in the cmd package:
> https://bitbucket.org/mischief/draw9/src/default/ <https://bitbucket.org/mischief/draw9/src/default/>
Thank you, thank you! Here is the Go version of black.c:

package main

import (
	"bitbucket.org/mischief/draw9"
	"fmt"
	"image"
	"log"
	"time"
)

func main() {
	disp, err := draw9.InitDraw(nil, "", "black")
	if err != nil {
		log.Fatal(err)
	}
	screen := disp.ScreenImage
	rect := screen.R
	black := disp.Black
	screen.Draw(rect, black, nil, image.ZP)
	disp.Flush()
	time.Sleep(5 * time.Second)
	disp.Close()
	fmt.Println("rectangle was", rect)
}

One minor issue: the window is white after the program exits. Text doesn’t show until I hit the up and down arrow keys.

Kim

[-- Attachment #2: Type: text/html, Size: 9038 bytes --]

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

* Re: [9fans] a simple graphical application in Go?
  2020-04-04 20:32 ` [9fans] " Jeremy Jackins
  2020-04-04 21:50   ` Skip Tavakkolian
@ 2020-04-05  4:15   ` Fazlul Shahriar
  2020-04-05  4:37     ` Skip Tavakkolian
  2020-04-06  9:58     ` Lucio De Re
  1 sibling, 2 replies; 9+ messages in thread
From: Fazlul Shahriar @ 2020-04-05  4:15 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 2046 bytes --]

There is a PR open with Plan 9 devdraw support to 9fans.net/go/draw:
https://github.com/9fans/go/pull/28
It at least works with the Go acme port Edwood last I tested.

On Sat, Apr 4, 2020 at 4:33 PM Jeremy Jackins <jeremyjackins@gmail.com>
wrote:

> Well, you need a Go draw package in place of the C library. There is a
> draw package in github.com/9fans/go/ but unfortunately I think it only
> supports plan9port devdraw, rather than the native Plan 9 draw device.
> So there is some library work to be done first. Since the Go standard
> library also contains the most important drawing primitives
> implemented by the Plan 9 draw device (with the exception of font
> rendering, but there is golang.org/x/image/font), you may be able to
> ignore a lot of functionality provided by the Plan 9 draw library and
> focus on a few things like loading pixel data directly to the draw
> device.
>
> See: http://man.cat-v.org/plan_9/3/draw
>
> Jeremy
>
> On Sat, 4 Apr 2020 at 06:55, Kim Lassila <kim.lassila@gmail.com> wrote:
> >
> > Has anyone written a graphical application in Go on Plan 9? How would
> the Go equivalent of black.c (thank you fgb) look like?
> >
> > - - - clip - - -
> >
> > #include <u.h>
> > #include <libc.h>
> > #include <draw.h>
> >
> > void
> > main(int, char *argv[])
> > {
> > Rectangle rect;
> > Image *black;
> >
> > fmtinstall('R', Rfmt);
> > if(initdraw(nil, nil, argv[0]) < 0)
> > sysfatal("initdraw: %r");
> > rect = screen->r;
> > black = display->black;
> > draw(screen, rect, black, nil, ZP);
> > flushimage(display, 1);
> > sleep(5 * 1000);
> > closedisplay(display);
> > print("rectangle was %R\n", rect);
> > exits(nil);
> > }
> >
> > 9fans / 9fans / see discussions + participants + delivery options
> Permalink
>
> ------------------------------------------
> 9fans: 9fans
> Permalink:
> https://9fans.topicbox.com/groups/9fans/T0d490c91935dc74b-M08178595d1453fd46812690c
> Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
>

[-- Attachment #2: Type: text/html, Size: 3188 bytes --]

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

* Re: [9fans] a simple graphical application in Go?
  2020-04-05  4:15   ` Fazlul Shahriar
@ 2020-04-05  4:37     ` Skip Tavakkolian
  2020-04-06  9:58     ` Lucio De Re
  1 sibling, 0 replies; 9+ messages in thread
From: Skip Tavakkolian @ 2020-04-05  4:37 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 2574 bytes --]

Cool! Thank you.

On Sat, Apr 4, 2020, 9:17 PM Fazlul Shahriar <fshahriar@gmail.com> wrote:

> There is a PR open with Plan 9 devdraw support to 9fans.net/go/draw:
> https://github.com/9fans/go/pull/28
> It at least works with the Go acme port Edwood last I tested.
>
> On Sat, Apr 4, 2020 at 4:33 PM Jeremy Jackins <jeremyjackins@gmail.com>
> wrote:
>
>> Well, you need a Go draw package in place of the C library. There is a
>> draw package in github.com/9fans/go/ but unfortunately I think it only
>> supports plan9port devdraw, rather than the native Plan 9 draw device.
>> So there is some library work to be done first. Since the Go standard
>> library also contains the most important drawing primitives
>> implemented by the Plan 9 draw device (with the exception of font
>> rendering, but there is golang.org/x/image/font), you may be able to
>> ignore a lot of functionality provided by the Plan 9 draw library and
>> focus on a few things like loading pixel data directly to the draw
>> device.
>>
>> See: http://man.cat-v.org/plan_9/3/draw
>>
>> Jeremy
>>
>> On Sat, 4 Apr 2020 at 06:55, Kim Lassila <kim.lassila@gmail.com> wrote:
>> >
>> > Has anyone written a graphical application in Go on Plan 9? How would
>> the Go equivalent of black.c (thank you fgb) look like?
>> >
>> > - - - clip - - -
>> >
>> > #include <u.h>
>> > #include <libc.h>
>> > #include <draw.h>
>> >
>> > void
>> > main(int, char *argv[])
>> > {
>> > Rectangle rect;
>> > Image *black;
>> >
>> > fmtinstall('R', Rfmt);
>> > if(initdraw(nil, nil, argv[0]) < 0)
>> > sysfatal("initdraw: %r");
>> > rect = screen->r;
>> > black = display->black;
>> > draw(screen, rect, black, nil, ZP);
>> > flushimage(display, 1);
>> > sleep(5 * 1000);
>> > closedisplay(display);
>> > print("rectangle was %R\n", rect);
>> > exits(nil);
>> > }
>> >
>> > 9fans / 9fans / see discussions + participants + delivery options
>> Permalink
>>
>> ------------------------------------------
>> 9fans: 9fans
>> Permalink:
>> https://9fans.topicbox.com/groups/9fans/T0d490c91935dc74b-M08178595d1453fd46812690c
>> Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
>>
> *9fans <https://9fans.topicbox.com/latest>* / 9fans / see discussions
> <https://9fans.topicbox.com/groups/9fans> + participants
> <https://9fans.topicbox.com/groups/9fans/members> + delivery options
> <https://9fans.topicbox.com/groups/9fans/subscription> Permalink
> <https://9fans.topicbox.com/groups/9fans/T0d490c91935dc74b-Mfd4090e269de1d17fc3df91d>
>

[-- Attachment #2: Type: text/html, Size: 4532 bytes --]

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

* Re: [9fans] a simple graphical application in Go?
  2020-04-05  4:15   ` Fazlul Shahriar
  2020-04-05  4:37     ` Skip Tavakkolian
@ 2020-04-06  9:58     ` Lucio De Re
  1 sibling, 0 replies; 9+ messages in thread
From: Lucio De Re @ 2020-04-06  9:58 UTC (permalink / raw)
  To: 9fans

On 4/5/20, Fazlul Shahriar <fshahriar@gmail.com> wrote:
> There is a PR open with Plan 9 devdraw support to 9fans.net/go/draw:
> https://github.com/9fans/go/pull/28
> It at least works with the Go acme port Edwood last I tested.
>
There are fourteen open PRs and #28 needs #26 first. That would still
leave 12 for 9frontiersmen to beat us over the head with (I have been
alerted that  go/plan 9 isn't being supported adequately - of course
in our field time is a very scarce resource).

It seems we 9fans need to provide some support for David Du Colombier
and help him clear these issues. I trust Richard Miller would be a
good judge of the outstanding PRs, I'm just too unsure of my own
understanding to offer that level of assistance. I can do some slog
work, of course.

David, Richard, what can I contribute?

Lucio.

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

end of thread, other threads:[~2020-04-06  9:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-04 13:54 a simple graphical application in Go? Kim Lassila
2020-04-04 20:32 ` [9fans] " Jeremy Jackins
2020-04-04 21:50   ` Skip Tavakkolian
2020-04-05  4:15   ` Fazlul Shahriar
2020-04-05  4:37     ` Skip Tavakkolian
2020-04-06  9:58     ` Lucio De Re
2020-04-04 21:37 ` Chris McGee
2020-04-05  0:40   ` ori
2020-04-05  4:11   ` Kim Lassila

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).