Status: Accepted
Owner: reiner.p...@gmail.com
Labels: Type-Defect Priority-Medium
New issue 360 by reiner.p...@gmail.com: Implement an incremental pango
renderer
http://code.google.com/p/yi-editor/issues/detail?id=360
The pango frontend currently uses the PangoLayout API for rendering. This
API provides functions (with nearly these types)
-- | Construct the layout from a string
layoutText :: String -> IO PangoLayout
-- | Lookup a point (given as x-y coordinates) as an index into the string
layoutXYToIndex :: PangoLayout -> Double -> Double -> IO Int
-- | Draw the layout
drawLayout :: PangoLayout -> DrawPanel -> IO ()
Although this API is simple, we run into problems because we pass in the
input string all in one go, rather than incrementally. Two problems are:
* to find out how much of the buffer's text is visible on the screen, we
need to use layoutXYToIndex. But in order to do this, we need to build a
PangoLayout with layoutText -- so we need to pass in a String of text to
display! It is not acceptable to pass in the entire buffer, because
layoutText lays out the entire string. It seems we have a chicken-and-egg
problem: we only want to lay out as much of the buffer's contents as will
be displayed, but we can only find out how much to display after running
layout.
The current solution uses an approximation to choose how much text to lay
out in the first place: calculate how many lines we can display (using the
font metrics and assuming a constant font), and pass in that many lines.
While this works for now, our assumption that the font is constant for the
entire buffer is rather limiting, and we would like to work around this.
* When the user enters a character, we have to layout (and render) the
entire screen again. We would like to avoid this: only the current line
actually needs to be laid out again
In both of these cases, we really want an *incremental* API: firstly, so
that layoutText only consumes enough of the String to fill a given
rectangle; and secondly, so that we only lay out the parts of the text that
have changed, rather than the entire screen.
--
Yi development mailing list
yi-devel@googlegroups.com
http://groups.google.com/group/yi-devel