CLIM mail archive
[Prev][Next][Index][Thread]
Output-recording for fast word wrap
Date: Wed, 2 Sep 1992 12:18 EDT
From: Susan Gauch <sgauch@damon.ccs.northeastern.edu>
I am displaying text in a CLIM window on the Macintosh. When I use
indenting-output and filling-output to position the text in the window,
complete with wordwrap, the performance is unacceptable (4 seconds
versus < 1 second without filling-output/indenting-output for 20
lines of text).
So, I'm thinking of a 2 phase operation.
Phase 1. Read text from file. Calculate the required linefeeds.
Store result of this computation, including explicitly
indicated linefeeds. This is essentially a pre-processing phase.
Phase 2. Read formatted text from file. Write to screen. This will
be done "live" when the user asks to see the text.
I can think of 3 ways to get the formatted information I want
1) Use with-output-to-postscript to create a postscript representation
of the text. Can this be read into CLIM later? If so, how?
CLIM doesn't understand PostScript, it just knows how to generate it.
2) Use with-output-to-output-record to get the formatted version.
Is there a way to store the resulting output record in a file for
reading/replaying in a later session?
No, not really. Output records are somewhat device dependent. It is
possible that this will work by sheer good luck.
As an aside, a mini-test I tried didn't work:
(defmethod display ((abstract abstract) stream)
(with-slots (lmargin) *application-frame*
(let ((line-length (- (window-inside-width stream) (* 2 lmargin))))
(with-output-to-output-record
(stream 'clim::linear-output-record new-record)
(indenting-output (stream lmargin)
(filling-output (stream :fill-width line-length)
;; do a bunch of writing
(mapc #'(lambda (obj)
(display obj stream)) (seq abstract))))
(replay new-record stream)
)
Nothing was ever displayed in the pane. Without the (with-output-to-output-
record.....(replay...)) code, this works. Why doesn't this work?
I think you mean to use LET to bind NEW-RECORD to the result of the call
to WITH-OUTPUT-TO-OUTPUT-RECORD, and then replay that. Inside of
WITH-OUTPUT-TO-OUTPUT-RECORD, drawing is turned off, so REPLAY will have
no effect.
3) Use my own wrapping code. I've done this in the past, but would like to
use CLIM's output records, if possible, since they capture change in
fonts as well as just wrapping information.
I'm open to any other suggestions to improve speed.
FILLING-OUTPUT is slow because it's completely incremental in nature.
It can't assume anything in advance, and so has to be prepared to deal
with single characters, whole lines, etc. I just hacked it a bit and
got a speed improvement of about 35%. If CLIM took 2.5 seconds to do
the output, would that be fast enough? (If the answer is no, then
even the improved FILLING-OUTPUT isn't going to meet your speed
requirements.)
0,,
References:
Main Index |
Thread Index