On 28 March 2013 22:26, Denis Kudriashov <dionisiydk@gmail.com> wrote:
Hello.
I implement positioning text for new TxTextMorph. You can now see blinking cursor, move it right, left, up and down, position it by mouse click. I make new version 0.4 which restore jenkins builds https://ci.inria.fr/rmod/job/TxText/, You can try TxTextMorph class side example methods.
Details:
Cursor position at "visual text" presented by TxTextLayoutPosition. TxTextLayoutPosition has state:
textLayout span - TxLayoutSpan (introduced by Igor suggestion) spanPosition - index inside TxLayoutSpan desiredOffset - desired x offset from start of "visual line". It can differ from actual (x,y) position xyValue - actual (x,y) position inside "visual text" box.
TxTextLayoutPosition implements moveRight. moveLeft, moveUp and moveDown methods. Desired offset allow moving up and down with remember of first offset. Example: 123456 123 123456 Cursor moves from up to bottom. Position of cursor at each line will be after red char. It is common behaviour of text editors. But our current text morph not works such way. And current text morph implements move up and move down in terms of index from start line. So it is visually incorrect up or down movement for no mono fonts. Try this to check it: WWWWWW - 6 W-characters, move from 6-th W-char down and try same at pharo. 1234567890
+1
TxLayoutSpan present part of text span which placed at some line and has offset, extent and font. It was created by layout builder to fit text layout restrictions. When text span wrapped by max line width restriction It "splitted" for two or more LayoutSpan's. TxLayoutSpan has span interval (TxInterval).
Igor was suggest removing explicit font attribute from text model and replace it with small font parts like family name, bold, underlined and others. He said it's should be responsibillity of "view system" to select appropriate font by this attributes. I don't know is it good idea. But I have some user cases where it is needed. So TxLayoutSpan allows such design decision. That's why it has font instance. TxLayoutSpan is created by layout builder which can select appropriate font for underlying spans. Now it just extracts font from span attributes like before.
No problem, we can think more of it later.
There is TxCursorMorph which presents blinking cursor (basic morph stepping logic). So visual text cursor is just submorph of TextMorph. I not yet implement any communication level between TxTextLayout, TxTextLayoutPosition and morphs. It is for future. Now morphs implemented to show what already works.
I needs help with namings. All ideas are welcome.
For example we have too much different position names: - TxPosition with vars linePosition, spanPosition - indexes - TxTextLayoutPosition with vars spanPosition (index of char), desiredOffset (x coordinate of offset inside line), xyValue (x@y coordinates inside text box) - TxCharactersSpan methods: #isLastPosition: , #lastInsertPosition - indexes - TxLayoutSpan methods: #charPositionAtOffset: (char index at offset). #computeXYPositionAt:, #containsXPosition:, #endPosition (TxPosition). I want easily understand what kind of position method means. In TxLayoutSpan I try to distinct it by "charPosition" and "xyPosition". I dont sure it is nice.
How about textPosition and visualPosition/layoutPosition? So you know that it speaking either about position in text or layout position (x/y).
And I don't like name of TxLayoutSpan. (too many spans).
well, it represents a portion of text, laid out in some view. so, layout span is logical name for it.
Small tasks which I have in mind: - more cursor movement actions - make settings for shortcuts at TxTextMorph - make cursor actions dynamically connected to shortcut settings. Each cursor action (method) should automatically creates shortcut setting for it.
There is strange problem with TxTextMorph when it is transparent. Try change #drawOn: method to see it (remove rectangle filling).
Next I will implement events logic to update TxLayoutPosition when layout changed. And text selection stuff.
What an impressive amount of progress! Too bad i had no time to work on it.. but during next couple month i will allocate time (in context of working with Athens), to spend on it, and adopt it for athens rendering.
Best regards, Denis
-- Best regards, Igor Stasenko.