Deuce gadgets and streams 
Author Message
 Deuce gadgets and streams

Is it possible to treat a deuce gadget as a stream in some manner? For
example, if I have a deuce gadget:

  pane my-pane (frame)
    make(<deuce-gadget>);

And somewhere else in the application I want to stream text to that
gadget in an easy manner:

  define method log-message(frame :: <my-frame>, msg :: <string>)
    frame.deuce-gadget.somehow-stream-text(msg);
  end;

I can do:

  frame.deuce-gadget.gadget-value :=
    concatenate(frame.deuce-gadget.gadget-value, msg);

But was looking for something not involving so much copying. Anyone
able to provide hints towards a better way?

Chris.
--
http://www.*-*-*.com/



Sun, 04 Jan 2004 14:18:13 GMT  
 Deuce gadgets and streams
Take a look at dylan/sources/deuce/streams.dylan, and you'll
see that you can create a stream over buffers or regions within
a buffer.

The following will make an interval stream pointing to the location
BP within BP's buffer.  You can get the buffer by calling 'window-buffer'
on the Deuce gadget.

  make(<interval-stream>, direction: #"output", interval: make(<interval>,
start-bp: BP, end-bp: BP))

You can then call operations such as 'write' or 'write-line' on the
resulting stream.

Quote:

>Is it possible to treat a deuce gadget as a stream in some manner? For
>example, if I have a deuce gadget:

>  pane my-pane (frame)
>    make(<deuce-gadget>);

>And somewhere else in the application I want to stream text to that
>gadget in an easy manner:

>  define method log-message(frame :: <my-frame>, msg :: <string>)
>    frame.deuce-gadget.somehow-stream-text(msg);
>  end;

>I can do:

>  frame.deuce-gadget.gadget-value :=
>    concatenate(frame.deuce-gadget.gadget-value, msg);

>But was looking for something not involving so much copying. Anyone
>able to provide hints towards a better way?

>Chris.
>--
>http://www.double.co.nz/dylan



Mon, 05 Jan 2004 21:49:51 GMT  
 Deuce gadgets and streams

Quote:

> Take a look at dylan/sources/deuce/streams.dylan, and you'll see
> that you can create a stream over buffers or regions within a
> buffer.

Thanks Scott, that was a big help! I wanted the streamed text to
appear at the top of the gadget, moving the rest down and the
following example code is how I got it working (based on the code
snippet you showed):

  // deuce module imported with prefix "deuce/" to prevent
  // name clashes.
  //
  let gadget :: <deuce-gadget> = ...; // obtained from frame
  let buffer = deuce/window-buffer(gadget);
  let stream =
    make(deuce/<interval-stream>,
         direction: #"output",
         interval: make(deuce/<interval>,
                        start-bp: deuce/interval-start-bp(buffer),
                        end-bp:  deuce/interval-start-bp(buffer)));

  write-line(stream, "test line");
  close(stream);

  deuce/queue-redisplay(gadget, deuce/$display-all);
  deuce/redisplay-window(gadget);

I was a bit overwhelmed by the size of Duece at first, but the more I
dig into it, the more I like it.

Chris.
--
http://www.double.co.nz/dylan



Tue, 06 Jan 2004 06:39:59 GMT  
 Deuce gadgets and streams

Quote:


>> Take a look at dylan/sources/deuce/streams.dylan, and you'll see
>> that you can create a stream over buffers or regions within a
>> buffer.

>Thanks Scott, that was a big help! I wanted the streamed text to
>appear at the top of the gadget, moving the rest down and the
>following example code is how I got it working (based on the code
>snippet you showed):

>  // deuce module imported with prefix "deuce/" to prevent
>  // name clashes.
>  //
>  let gadget :: <deuce-gadget> = ...; // obtained from frame
>  let buffer = deuce/window-buffer(gadget);
>  let stream =
>    make(deuce/<interval-stream>,
>         direction: #"output",
>         interval: make(deuce/<interval>,
>                        start-bp: deuce/interval-start-bp(buffer),
>                        end-bp:  deuce/interval-start-bp(buffer)));

>  write-line(stream, "test line");
>  close(stream);

>  deuce/queue-redisplay(gadget, deuce/$display-all);
>  deuce/redisplay-window(gadget);

Hmm, I forgot that you needed to tell it to redisplay the window
after doing stream output, but I can see why I didn't make that
happen automagically -- it would slow down stream operations
to be asking for redisplay all the time.

I'm glad it worked!

Quote:
>I was a bit overwhelmed by the size of Duece at first, but the more I
>dig into it, the more I like it.

Yeah, Deuce started out pretty small, but the more we started
using it as the primary editor for the environment, the more I
had to make it a real editor.  I'll certainly take any compliment
from you, though!


Tue, 06 Jan 2004 21:08:45 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. come changes to the deuce editor gadget

2. Deuce display problem and possible fix

3. Question on implementing a Deuce command

4. Adding/Removing Streams from a Broadcast Stream

5. Distinguishing a binary Stream from a text Stream ?

6. adobe-svg-gadget available

7. Custom gadgets in a frame

8. Browser gadget sugguestions for a DUIM app

9. DUIM date gadgets for Harlequin Dylan

10. Stuck with displaying a gadget

11. Gadget images & tutorials

12. Gadget images & tutorials

 

 
Powered by phpBB® Forum Software