2012/11/21 Camillo Bruni <camillobruni@gmail.com>
To me text model should completly represent what user see at text view. Otherwise why you call it model? Otherwise it is just raw data like Text in current TextMorph
Model IS the raw base model, the view is what you see, that are definitely two different things. For instance where would you deal with hyphenation? dynamic layouts?
When I think about TextMorph model I think about object which can be used from tests or just workspace where no any view exists. And this is what you exactly implement with TxModel. You have TxModelTest where you move cursor, change selection, insert characters. And this is not depends on any possible text view. Great!. And without any thinking on text wrapping logic and others I can implement very SimpleTextMorph based on TxModel. You can imagine how simple can be implementation of multiline text view/editor based on such nice model. No crappy paragraphs and editors. Drawing morph can be just something like spans do: [:each | each drawOn: aCanvas] But now imagine that I want such morph with two options: autowrap by morph bounds and restrict lines by 10 characters. What should be changed for such behaviour? And maybe more clever question: what this options actually mean? In any case user just see list of text lines. And user can not know is this lines virtual (created by wrapping logic) or real (created by cr from source string). So logic of wrap lines is just splitting source string to visual lines by some restriction. (Same for hyphenation). But view just show list of lines (spans) and nothing more. And object which edit text (insert characters...) should know about "lines restrictions" and change span structure of text model appropriately. Now TxCharactersSpan implements full edit logic (#at:insert: method for example). To achive my suggestions new "restriction object" should be introduced and maybe special kind of spans. Maybe it should be called SpanBuilder (with WrappedTextSpanBuilder-like subclasses) Ok, this is my ideas. I try to implement it this weekend. What you mean by dynamic layouts? Best regards, Denis