[squeak-dev] String/TextMorph/Editor --why so complex?
K. K. Subramaniam
subbukk at gmail.com
Mon Nov 30 07:45:19 UTC 2009
On Monday 30 November 2009 03:57:48 am Ross Boylan wrote:
> So, are there reasons for this division of labor, or did they simply
> evolve trying to build new functionality on top of old functionality?
> My understanding of the morphic spirit led me to expect that the basic
> objects, StringMorph and TextMorph, would be handling the user
> interaction much more directly. What I see has more of an MVC flavor,
> though it's more complicated than that.
I poked into this framework sometime back to see how it affects multilingual
text. Let me share my understanding and let others step in with corrections:
String - sequence of 8-bit character codes (implied ASCII)
WideString - sequence of 32-bit character codes (implied Unicode 32)
Text - sequence of decorated Strings where decorations could be color, shape,
size.
Paragraph - Text laid out in boxes (alignment, justification, line spacing)
These are string encoding models with no dependencies on renderers/editors. In
practice, it is hard to keep encodings separated from rendering/editing
operations ;-). Refactoring is complicated by the fact editing is tightly
coupled with rendering and layout for text objects, esp. in the case of
multilingual texts.
Pre-morphic Squeak used ParagraphEditor for editing strings
(StringHolderController) and Text/Paragraphs. Editors (controllers) were hard-
bound to these objects.
Morphic uses StringMorph, TextMorph and NewParagraph to render these abstract
collections. Editing operations (like selection, undo) were moved into Editor
class and then extended for handling types of text. So you have
StringMorphEditor for short strings, TextEditor for runs of strings and
SmalltalkEditor for source code. The ability to switch editors is important
for text with complex layouts (e.g. right-to-left, math formula). Eventually,
one should be able to click on the 'pencil' halo icon to bring up a suitable
editor.
I hope Squeak evolves to support a simple and standard protocol (like
"inspect") for editing ("edit"?) which would pull up the appropriate editor
depending on its content, class and context (i.e. command line/MVC/Morphic).
Subbu
More information about the Squeak-dev
mailing list
|