Sign in Join
Wiki copytemporary

Redesign of the SynEdit component: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11For more info on SynEdit go to: [[SynEdit]]
22
33------------------------------------------------------------------------
44
55# Introduction
66
77This is an attempt to restructure the monolithic TCustomSynEdit class into more general base classes, which can be shared amongst various editor or viewer components. Such an approach will allow to encapsulate the basic functionality, so that derived classes cannot break that vital functionality.
88
99The goal of the redesign is a set of classes, useful in creating [[source code editor|source code editors]] and other browsers or editors.
1010
1111# Class Tree
1212
13-- <b>CustomSynViewer</b> (TODO)
13+- CustomSynViewer (TODO)
1414
15-:*<b>TextBuffer</b> (Partly done, currently TSynEditStringList)
15+:*TextBuffer (Partly done, currently TSynEditStringList)
1616
1717
1818
1919Holds the entire text. Eventually it should be possible that more than one SynEdit/SynViewer share the same TextBuffer. The TextBufffer provides the necessary callback hooks so all SynEdits can follow any changes
2020
2121SynEdit does not allow direct access to the TextBuffer. For the public SynEdit.Lines property a special wrapper is in place controlling access.
2222
2323The TextBuffer supports methods for Editing and viewing.
2424
2525Act as a wrapper to the TextBuffer. They allow SynEdit/SynView to see the content of the Textbuffer in certain ways (such as Folded, with expanded Tabs information or with trailing spaces).
2626
2727:* some of them are:
2828
2929
3030
3131TSynEditStringTrimmingList
3232
3333SynEditStringDoubleWidthChars
3434
3535TSynEditStringTabExpander
3636
3737TSynEditFoldedView
3838
3939
4040Not yet fully integrated
4141
4242TODO: Integrate Highlighter Access into the TextViews
4343
44-- <b>Highlighter</b>
44+- Highlighter
4545
4646Provides Highlight information, such as pascal or html specific highlighting. ([[SynEdit Highlighter|more]])
4747
48-- <b>Markup</b>
48+- Markup
4949
5050Provides additional highlight info, such as current selection, matching brackets...
5151
52-- <b>ViewPort</b> (TODO)
52+- ViewPort (TODO)
5353
5454
5555Defines the visible rectangle of the Text. (Screen content). This is given through TopLine, LeftChar, CharsInWindow, LinesInWindow.
5656
5757Translation of Screen to TextBuffer can be handled here. All Scrolling can be handled here. In a way this represents the ScreenGrid.
5858
59-- <b>TextGrid</b> (TODO)
60-- <b>Gutter</b>
59+- TextGrid (TODO)
60+- Gutter
6161
62-:*<b>GutterPart</b>
62+:*GutterPart
6363
64-- <b>HighlightTokenPrinter</b> (TODO)
64+- HighlightTokenPrinter (TODO)
6565
6666
6767Combines Text, Highlight, Markup, ... and sends it to the ViewPort/TextGrid
6868
69-- <b>CustomSynEdit</b>
69+- CustomSynEdit
7070
7171
7272Implements edit actions
7373
74-- <b>IDESynEdit</b> (TODO)
74+- IDESynEdit (TODO)
7575
7676
7777Instantiates a SynEdit, with a specific set of Views and Markup modules
7878
7979# Work in Process
8080
8181Plugins
8282The structure and integration of plug-ins needs some review, and is entirely subject to review. Applies to Syncron/TemplateEdit and/or to older SynPlugins (Code-Completion, ...)
8383
8484# Older Content
8585
8686Below is some older content. It may no longer reflect the actual process.
8787
8888I just came across the RichView control, that already is based on a general scrolling window component RVScroll. This component will become the root of my redesign.
8989
9090Once the scrollbar details are encapsulated, we can derive a basic grid component. According to our goal, of an [[source code editor]], the cells in this grid later shall contain characters, of an monospaced font. Unlike the TCustomGrid component, our grid is only a logical organization of the drawing surface. Instead of fixed rows or columns, a gutter can be shown to the left of the grid.
9191
9292The next level will implement the character grid class, with a demo implementation of an simple text file viewer. The handling of fonts (determination of the cell size), a caret, and lines of arbitrary length will be implemented in this class.
9393
9494In the next higher levels changes to the text are implemented, and finally the additional Lazarus specific functionality.
9595
9696## Related Classes
9797
9898Much specific functionality can be implemented in helper classes, so that the editor component can be customized by replacing the SynEdit helpers with other objects. One obvious helper is dedicated to the gutter display, another one to the display of the lines in the character grid, and the text lines are provided and managed by a third helper.
9999
100100### Gutter
101101
102102A gutter pane to the left of the grid can be used to display additional information. Where SynEdit displays line numbers and markers, some other application may display e.g. a table of contents in the gutter.
103103
104104### Grid Painters
105105
106106The basic grid delegates painting to the gutter object and a virtual PaintGrid method. In the case of a character grid, the PaintGrid method organizes the display of entire grid rows, calling another virtual PaintRow method for the actual painting. The PaintRow method again can call a PaintCell method, or it delegates the display of the text in the line to an text painter object.
107107
108108### Grid Contents
109109
110110The contents of a character grid typically are stored in some TStrings object, accessible as strings by line/row numbers. For proper display, all tabs must be expanded into spaces, what suggests an alternative method to retrieve the display strings from the string list. This method also can provide Unicode strings, in order to simplify the column index calculations. Syntax highlighting requires a synchronization between the parser, the highlighting painter, and the list of strings. When wordwrap or block folding can affect the number of visible lines, a translation between display rows and line numbers (string indices) has to be implemented in a dedicated content class. Such specialized content classes should be used only together with appropriate control classes.
111111
112112When multiple source files shall be presented in a tabbed editor window (notebook?), the contents of the control should be easily exchangable. When also the same file can be shown in multiple edit controls, at the same time, the actual caret position and further context information must be stored in the content objects, apart from the common text and file information. Changes to an shared text must be reported to all active edit/content objects. Such features require a proper separation of the configuration and context information, into control settings, display content state, and physical text source state.
113113
114114# See also
115115
116116- [[SynEdit]]
117117- [[SynEdit Highlighter]]
118118
119119---
120120*From the Free Pascal wiki, page "Redesign of the SynEdit component", as it stood on 2013-09-30 after a change by Jwdietrich, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
121121Category: Components
122122Category: SynEdit

Back to history