The way my thoughts seem to be going at the moment, where are three general styles of windows which I shall call Navigation windows, Content windows, and Display windows. Their contents are displayed quite differently.
Navigation Windows
A navigation window displays some key navigation points within a document with particular attention to points close to the current cursor.
By displaying these navigation points, it serves both to provide easy navigation around the document, and to provide overall contextual view of the document so the place of the current cursor can be easily seen.
A nav window will usually have it's cursor locked to some other content window so that cursor changes in one are reflected in the other.
A nav window is not scrollable. It will always show the whole document from start to end, though much of the internals will be elided to make room for the navigation points, which will typically be chapter/section/subsection headings.
No attempt is made to keep the display in a Nav window stable. It will always display the "best" display for the current document and cursor position.
The only other input into the display generation process (apart from the window geometry) is a simple number called "depth". This number is the number of levels down the path from the root of the document to the cursor where the display process starts. A large number means that substructure near the cursor will have precedence over high level structure further from the cursor. A small number means that the immediate context of the cursor is not so important and proportionally more weight will be given to general high-level structure.
This display algorithm involves starting at a point on the path from the root to the cursor, as determined by the depth, and generating a display using the smallest option for all components that displays that point.
The display choice at each unit is then enlarged if possible start with units closest to the beginning. This continues until no larger display choice is possible.
Content Windows
A content window is a scrollable window onto an arbitrarily large rendering of the document. The window can scroll both vertically and horizontally. However if the rendering of the document is defined to fit in the width of the window (i.e. line-wrap is enabled) then horizontal scrolling will not come into effect.
The display in a content window is kept stable where possible. Small changes are preferred over large changes.
The view of the document can contain some 'frozen' regions which will always be displayed if possible, preferentially over content that is simply near the cursor, though the content at the cursor will always be displayed. Frozen regions are easy to create and destroy and are highlighted with a different background colour.
To aid with stability, a content window records the location in the document of the start of the first and last displayed lines, the amount of horizontal scroll as a distance, and the amount of vertical scroll of the first text line as a distance (in case that first line uses an enormous font...). These values are only changed when there is need, and changing the start of the last line is preferred over changing the start of the first line.
When line wrapping is performed as a function of the window width, it is performed lazily in order to help stability. We keep the start of each screen-line and render backwards from the cursor until we find a screen-line start or a true start-of-line. As we go we look for possible errors that don't involve the word under the cursor and if we find one, we re-adjust the start line starts and try again (I probably need code to explain what I mean here).
Display Windows
A Display window is used for displaying a document in WYSIWYG mode, or displaying a fully rendered HTML page (which is much the same thing).
The display is a scrollable window on the document with scroll position given in terms of simple lengths. The content can contains a number of independent panes that each contain different parts of the document. The whole display is rendered top-down and if the cursor doesn't appear on the page, the scroll amounts are adjusted and the display process is retried.
Little effort is put into stability beyond the scroll lengths. The display is potentially regenerated after any change, though caching may help constant parts get rendered quickly.
Panes with in a Display Window can be Navigation or Content windows in which case changes that only affect them will be suitably localised.
All top-level windows of the editor are Display Windows
