Flávio Etrusco wrote: >> 1) Logic should be separated from the presentation, so first there should be >> 'TAbstractSynEdit' class, concerning itself purely with text manipulations, >> such as text insertion/deletion, cursor position changes, text >> attribute calculation, >> save/loading, codetools etc. >> TAbstractSynEdit should not depend on any visual code, in partucular it >> should >> descend from TObject/TPersistent, not TControl. >> > > My vision deviates a bit from this in the sense that TAbstractSynEdit > would just be an abstraction (or dedicated implementation) of a > cleaner text manipulation interface (as TStrings won't cut it), which > would also implement transparent/automatic/implicit 'undo' handling. > Then each command would be a class, probably inheriting from TAction. > Just read this, ....
I had the same idea, and am in progress with something like this. I needed it to abstract layers of functionality. for example trimming trailing spaces. If it should work as a transparent plugin it needs access to undo/redo. My current approach is: - I separated SynEdit.Lines from the internal textbuffer (so textbuffer has no longer a need to be TStrings based (it still is, because i didn't take the time to change it)) - I add a few basic methods such as InsertText(x,y, substring); DeleteText,(x,y, len) ; BreakLine, JoinLine (maybe InsertNewLine, DeleteEntireLine) [*] - they can deal with undo and redo - In SynEdit all operations can be reduced to the above (and don't care about undo/redo) Since TrailingSpaces is already a wrapper around the TextBuffer, it can simply intercept those methods, and deal with them. ---- The only flaw I still have with this is, that currently all the SynEditText* (wrappers around the actual textbuffer, doing, spaces, tabs, folding....) are combining Display and Edit functionality. It would be nice to be able to write a TSynDisplay class first, and inherit the editor from it.... Best Regards Martin [*] of course insertText could detect newlines, but it adds complexity. It will be simpler if SynEdit keeps control of this level, and InsertText, only operates on the current line _______________________________________________ Lazarus mailing list [email protected] http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
