On 06/13/2010 11:13 AM, Sidharth Kshatriya wrote:
I want to understand
* What is the use of the inset_ member in the DocIterator class? Each
CursorSlice has a link to its corresponding inset so what is the use
of inset_ in the DocIterator class?
I don't know this code terribly well, but I think that inset_ here
essentially acts as a pointer to the top of the stack, i.e., in the
normal case, to the Buffer's top InsetText. Note also that the
DocIterator's lists of CursorSlices might be empty. In any event, each
CursorSlice only knows about the *one* inset that it represents.
* What happens if there are multiple cells?
A DocIterator is a stack of CursorSlice's. If there is more than one
cell, then the CursorSlice itself knows which cell it is in; this is
kept in idx_.
In effect, a CursorSlice represents a position in an inset, where this
is marked by (i) the inset, (ii) the cell in the inset, (iii) the
paragraph in that cell, and (iv) the position in that paragraph.
* In the example described in the diagram in the link above there is
an Inset for each letter. What happens if there are sentences... does
the whole sentence appear in an InsetText?
>
More or less. Though it is really in a Paragraph.
As the comment in Text.h says, that class is mostly just a pimpl for
InsetText. So InsetText kind of has the "inset" parts and the "text"
parts are in Text. The actual text in a Text is broken into Paragraphs
(Text::pars_), and the actual text strings are in the Paragraphs, more
precisely, in Paragraph::Private::text_, which is a Docstring. So the
InsetText contains, in the end, a list of Paragraphs, and the text lives
in those.
* When is a DocIterator used? When is a CursorIterator used?
Do you mean a Cursor? In any event, DocIterator is used for general
iterations through a document, whereas a Cursor is a more specialized
beast and is generally used to represent the insertion point, i.e., the
cursor. And, as the comment says in Cursor.h, it probably isn't true
that a Cursor IS-A DocIterator, so public inheritance, though easy to
implement, may not be conceptually correct.
Is there a way I can rapidly learn LyX source code somehow? Are there
simple test cases perhaps? Doxygen documentation is very useful of
course but nothing like a short writeup what explains the internal
workings.
The best way is to find a bug that bothers you and fix it. I.e., learn
by doing. Ask questions if you get lost or get stuck.
Richard