9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] get the last write offset in p9p acme
@ 2011-08-24 16:45 Mathieu Lonjaret
  2011-08-24 17:03 ` Russ Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Lonjaret @ 2011-08-24 16:45 UTC (permalink / raw)
  To: golang-nuts, Fans of the OS Plan 9 from Bell Labs

Hi,

After I've written a bunch of lines in an acme win ( with (w *Win)
Write("body",...), I need to know (and save) the position of the last
char I've written.
I need that position because I want everything I write afterwards to
be written there, and not appended. (constantly overwriting the last
thing that was written).

So the silly trick I've used to get that position is to first select
the whole text and then get the address of the end of the selection,
as the following:

	err = w.Addr("%s", "#0,")
	if err != nil {
		return err
	}
	_, pos, err := w.ReadAddr()

Is there a more direct way?

Thanks,
Mathieu



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

* Re: [9fans] get the last write offset in p9p acme
  2011-08-24 16:45 [9fans] get the last write offset in p9p acme Mathieu Lonjaret
@ 2011-08-24 17:03 ` Russ Cox
  2011-08-25  8:35   ` Mathieu Lonjaret
  0 siblings, 1 reply; 3+ messages in thread
From: Russ Cox @ 2011-08-24 17:03 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs; +Cc: golang-nuts

Seems fine to me.
You can shorten to w.Addr(",")


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

* Re: [9fans] get the last write offset in p9p acme
  2011-08-24 17:03 ` Russ Cox
@ 2011-08-25  8:35   ` Mathieu Lonjaret
  0 siblings, 0 replies; 3+ messages in thread
From: Mathieu Lonjaret @ 2011-08-25  8:35 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs; +Cc: golang-nuts

Ah yes, thx for the tip.

On Wed, Aug 24, 2011 at 7:03 PM, Russ Cox <rsc@swtch.com> wrote:
> Seems fine to me.
> You can shorten to w.Addr(",")
>
>



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

end of thread, other threads:[~2011-08-25  8:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-24 16:45 [9fans] get the last write offset in p9p acme Mathieu Lonjaret
2011-08-24 17:03 ` Russ Cox
2011-08-25  8:35   ` Mathieu Lonjaret

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