Transcript textedit, replace vs append

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Transcript textedit, replace vs append

ar-4
I want to create a view exactly like the transcript, with a running log.
However for my particular requirements (size, frequency of update
responsiviness etc) I am concerned about performance since I note that the
Transcript replaces the window text for every nextPutAll, rather than
appending to it. I am curious why the Transcript was done this way. Is it
just not worth worrying about? Or is it problematic to append text lines
to a textedit (I dont see any protocol for doing that).


Reply | Threaded
Open this post in threaded view
|

Re: Transcript textedit, replace vs append

Bill Schwab
> I want to create a view exactly like the transcript, with a running log.
> However for my particular requirements (size, frequency of update
> responsiviness etc) I am concerned about performance since I note that the
> Transcript replaces the window text for every nextPutAll, rather than
> appending to it.

Assuming you are correct (and I have no reason to doubt that), I
congratulate you on catching it.  However, it can't be too big of a deal,
because it would seem likely to have been that way for years, right?  Still,
it's inefficient and probably should be fixed.


>  I am curious why the Transcript was done this way. Is it
> just not worth worrying about? Or is it problematic to append text lines
> to a textedit (I dont see any protocol for doing that).

It might be possible to use #replaceSelection: to create an append behavior.
That assumes that you can select a range that is just beyond the existing
text, which could be problematic, and might very well be smoething that
would not work across all versions of Windows.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Transcript textedit, replace vs append

Blair McGlashan-2
In reply to this post by ar-4
Alan

You wrote in message news:[hidden email]...
> I want to create a view exactly like the transcript, with a running log.
> However for my particular requirements (size, frequency of update
> responsiviness etc) I am concerned about performance since I note that the
> Transcript replaces the window text for every nextPutAll, rather than
> appending to it. I am curious why the Transcript was done this way. Is it
> just not worth worrying about? Or is it problematic to append text lines
> to a textedit (I dont see any protocol for doing that).

I think you are misunderstanding the implementation. The relevant bit is in
the #flush method:

...
outputWindow
      caretPosition: 0;
      replaceSelection: buffer contents.
...

This moves the insertion point to the end, and then "replaces" the empty
selection with new lines of output. The net effect is to append the current
buffer contents.

One thing to consider if building a TTY-style text output window where
performance is an issue would be to only flush output from the buffer when
explicitly requested. The Transcript flushes on every #cr for convenience
and because immediate display of output can be important for debugging. One
possible approach would be to introduce a short delay between the last
output to the buffer and flushing the output. Arrival of new output would
reset the timer, so that bursts of output would only be displayed when the
output stops for a short while.

Regards

Blair