[Pharo-project] TxTextMorph based on new text model

2013-02-15 Thread Stephan Eggermont
Sean wrote:
Denis Kudriashov wrote
 Do you think that presenting any letter with real object (not just
 character) is sufficient for modern computers? I think not. Of course such
 model significantly simplified all logic around text layout stuff. But I
 think it is too expensive.

In a case study on designing a document editor in  'Design Patterns (1995)' ,
there is a reference to  a thesis from 1993 showing that using Flyweight
or sharing commonality makes it fast enough. I assume that was c++, but
20 years of hardware improvements should be enough. 

Paul R Calder. Building User Interfaces with Lightweight Objects. 
PhD Thesis, Stanford University, 1993 

I don't know how efficient it would be, but how much text do we really
layout at once? If it makes the code simpler and more beautiful, then it
would be my starting point. Doing otherwise is premature optimization.

One book at a time. In multiple columns, with tables. But we don't need 
to show more than one screenful at a time. 

I noticed the current strategy seems to be to make a very simple model 
work, and add abstractions late. That means a lot of refactorings will be 
needed. Cocoa fundamental abstractions are TextStorage, LayoutManager,
TextContainer and TextView. LayoutManager uses TypeSetter(s) to layout
glyphs in lines according to the dimensions of one or more text container
objects in one or more text views, directs the GlyphGenerator to translate 
characters in the textstorage into glyphs... 

Stephan




Re: [Pharo-project] TxTextMorph based on new text model

2013-02-15 Thread p...@highoctane.be
I guess if we could have something that lays out basic text properly
(e.g. bold/italics do not mess everything) and a
ParagraphcomposeAll: that works, it would be a huge plus.

The main issue IMV is that we keep on recreating Paragraphs and that
whole logic should be revised.

Phil

2013/2/15 Stephan Eggermont step...@stack.nl:
 Sean wrote:
 Denis Kudriashov wrote
 Do you think that presenting any letter with real object (not just
 character) is sufficient for modern computers? I think not. Of course such
 model significantly simplified all logic around text layout stuff. But I
 think it is too expensive.

 In a case study on designing a document editor in  'Design Patterns (1995)' ,
 there is a reference to  a thesis from 1993 showing that using Flyweight
 or sharing commonality makes it fast enough. I assume that was c++, but
 20 years of hardware improvements should be enough.

 Paul R Calder. Building User Interfaces with Lightweight Objects.
 PhD Thesis, Stanford University, 1993

I don't know how efficient it would be, but how much text do we really
layout at once? If it makes the code simpler and more beautiful, then it
would be my starting point. Doing otherwise is premature optimization.

 One book at a time. In multiple columns, with tables. But we don't need
 to show more than one screenful at a time.

 I noticed the current strategy seems to be to make a very simple model
 work, and add abstractions late. That means a lot of refactorings will be
 needed. Cocoa fundamental abstractions are TextStorage, LayoutManager,
 TextContainer and TextView. LayoutManager uses TypeSetter(s) to layout
 glyphs in lines according to the dimensions of one or more text container
 objects in one or more text views, directs the GlyphGenerator to translate
 characters in the textstorage into glyphs...

 Stephan





Re: [Pharo-project] TxTextMorph based on new text model

2013-02-14 Thread Sean P. DeNigris
Thanks again for tackling this! I'm definitely available to collaborate :)


Denis Kudriashov wrote
 Do you think that presenting any letter with real object (not just
 character) is sufficient for modern computers? I think not. Of course such
 model significantly simplified all logic around text layout stuff. But I
 think it is too expensive.

I don't know how efficient it would be, but how much text do we really
layout at once? If it makes the code simpler and more beautiful, then it
would be my starting point. Doing otherwise is premature optimization.


Denis Kudriashov wrote
 Another thing which I always not agree is introduction scripting languages
 inside smalltalk... [but] I like what they do inside rules. It is
 really simple and understandable code.

Yes, I think a special scripting language would be way outside the bounds of
Pharo, but the rules idea simplicity of that style could be great for us :)

Cheers,
Sean



--
View this message in context: 
http://forum.world.st/TxTextMorph-based-on-new-text-model-tp4663219p4669991.html
Sent from the Pharo Smalltalk mailing list archive at Nabble.com.



Re: [Pharo-project] TxTextMorph based on new text model

2013-02-14 Thread Fernando Olivero
Hi, this is really interesting! To have a simpler text model and UI.


I recall Safara, in squeaksource. Lukas and a student worked on a nice text
model. Worth checking it out.

Fernando


On Fri, Feb 15, 2013 at 12:29 AM, Sean P. DeNigris s...@clipperadams.comwrote:

 Thanks again for tackling this! I'm definitely available to collaborate :)


 Denis Kudriashov wrote
  Do you think that presenting any letter with real object (not just
  character) is sufficient for modern computers? I think not. Of course
 such
  model significantly simplified all logic around text layout stuff. But I
  think it is too expensive.

 I don't know how efficient it would be, but how much text do we really
 layout at once? If it makes the code simpler and more beautiful, then it
 would be my starting point. Doing otherwise is premature optimization.


 Denis Kudriashov wrote
  Another thing which I always not agree is introduction scripting
 languages
  inside smalltalk... [but] I like what they do inside rules. It is
  really simple and understandable code.

 Yes, I think a special scripting language would be way outside the bounds
 of
 Pharo, but the rules idea simplicity of that style could be great for us :)

 Cheers,
 Sean



 --
 View this message in context:
 http://forum.world.st/TxTextMorph-based-on-new-text-model-tp4663219p4669991.html
 Sent from the Pharo Smalltalk mailing list archive at Nabble.com.




Re: [Pharo-project] TxTextMorph based on new text model

2013-01-29 Thread Igor Stasenko
On 28 January 2013 19:37, Stéphane Ducasse stephane.duca...@inria.fr wrote:
 This was experimental. Do not lose your time with it. Now you know that you 
 should continue :)
 This was to prove that kids could define even texteditor with simple rules.

that 'script' called DSL :)

so, yes.. you can write text editor with 10 lines of DSL code..
+ 100+ lines of code for DSL parser
+ numerous hours for developers to master your DSL before they can
understand/change the code :)

 Stef


 Here is the paper: http://www.vpri.org/pdf/m2010002_lobjects.pdf
 And you can download the image with the actual active essay from 
 http://tinlizzie.org/lesserphic2/Text%20Field%20for%20LObject.zip

 I read paper and play with image. And I have not good impression about this 
 work.

 First they present text with real objects for each letter. Each letter is 
 actually big object with x, y, predecessor, successor and other attributes. 
 How much memory such model required?
 Do you think that presenting any letter with real object (not just 
 character) is sufficient for modern computers? I think not. Of course such 
 model significantly simplified all logic around text layout stuff. But I 
 think it is too expensive.

 Another thing which I always not agree is introduction scripting languages 
 inside smalltalk. In paper all layout logic (and editing too) programmed by 
 system of rules in special scripting language (very similar to smalltalk). 
 If you look deeply you will see that rules call other rules with same way 
 methods call other methods in basic smalltalk code. So I don't see any value 
 of rules idea expressed with special scripts.
 In spite of my non positive opinion I like what they do inside rules. It is 
 really simple and understandable code. Maybe I will try reuse something.

 Best regards,
 Denis








-- 
Best regards,
Igor Stasenko.



Re: [Pharo-project] TxTextMorph based on new text model

2013-01-29 Thread Denis Kudriashov
Hi

2013/1/29 Igor Stasenko siguc...@gmail.com

 On 28 January 2013 19:37, Stéphane Ducasse stephane.duca...@inria.fr
 wrote:
  This was experimental. Do not lose your time with it. Now you know that
 you should continue :)
  This was to prove that kids could define even texteditor with simple
 rules.
 
 that 'script' called DSL :)

 so, yes.. you can write text editor with 10 lines of DSL code..
 + 100+ lines of code for DSL parser
 + numerous hours for developers to master your DSL before they can
 understand/change the code :)


I think you all agree that smalltalk is powerfull enough to be DSL for any
domain/problem. No needs for special syntax


   Stef
 
 
  Here is the paper: http://www.vpri.org/pdf/m2010002_lobjects.pdf
  And you can download the image with the actual active essay from
 http://tinlizzie.org/lesserphic2/Text%20Field%20for%20LObject.zip
 
  I read paper and play with image. And I have not good impression about
 this work.
 
  First they present text with real objects for each letter. Each letter
 is actually big object with x, y, predecessor, successor and other
 attributes. How much memory such model required?
  Do you think that presenting any letter with real object (not just
 character) is sufficient for modern computers? I think not. Of course such
 model significantly simplified all logic around text layout stuff. But I
 think it is too expensive.
 
  Another thing which I always not agree is introduction scripting
 languages inside smalltalk. In paper all layout logic (and editing too)
 programmed by system of rules in special scripting language (very similar
 to smalltalk). If you look deeply you will see that rules call other rules
 with same way methods call other methods in basic smalltalk code. So I
 don't see any value of rules idea expressed with special scripts.
  In spite of my non positive opinion I like what they do inside rules.
 It is really simple and understandable code. Maybe I will try reuse
 something.
 
  Best regards,
  Denis
 
 
 
 
 



 --
 Best regards,
 Igor Stasenko.




Re: [Pharo-project] TxTextMorph based on new text model

2013-01-28 Thread Denis Kudriashov
Hello

2013/1/24 DeNigris Sean s...@clipperadams.com

  I don't. Do you have link?

 Here is the paper: http://www.vpri.org/pdf/m2010002_lobjects.pdf
 And you can download the image with the actual active essay from
 http://tinlizzie.org/lesserphic2/Text%20Field%20for%20LObject.zip


I read paper and play with image. And I have not good impression about this
work.

First they present text with real objects for each letter. Each letter is
actually big object with x, y, predecessor, successor and other attributes.
How much memory such model required?
Do you think that presenting any letter with real object (not just
character) is sufficient for modern computers? I think not. Of course such
model significantly simplified all logic around text layout stuff. But I
think it is too expensive.

Another thing which I always not agree is introduction scripting languages
inside smalltalk. In paper all layout logic (and editing too) programmed by
system of rules in special scripting language (very similar to
smalltalk). If you look deeply you will see that rules call other rules
with same way methods call other methods in basic smalltalk code. So I
don't see any value of rules idea expressed with special scripts.
In spite of my non positive opinion I like what they do inside rules. It is
really simple and understandable code. Maybe I will try reuse something.

Best regards,
Denis


Re: [Pharo-project] TxTextMorph based on new text model

2013-01-28 Thread Stéphane Ducasse
This was experimental. Do not lose your time with it. Now you know that you 
should continue :)
This was to prove that kids could define even texteditor with simple rules.

Stef


 Here is the paper: http://www.vpri.org/pdf/m2010002_lobjects.pdf
 And you can download the image with the actual active essay from 
 http://tinlizzie.org/lesserphic2/Text%20Field%20for%20LObject.zip
 
 I read paper and play with image. And I have not good impression about this 
 work.
 
 First they present text with real objects for each letter. Each letter is 
 actually big object with x, y, predecessor, successor and other attributes. 
 How much memory such model required? 
 Do you think that presenting any letter with real object (not just character) 
 is sufficient for modern computers? I think not. Of course such model 
 significantly simplified all logic around text layout stuff. But I think it 
 is too expensive.
 
 Another thing which I always not agree is introduction scripting languages 
 inside smalltalk. In paper all layout logic (and editing too) programmed by 
 system of rules in special scripting language (very similar to smalltalk). 
 If you look deeply you will see that rules call other rules with same way 
 methods call other methods in basic smalltalk code. So I don't see any value 
 of rules idea expressed with special scripts.
 In spite of my non positive opinion I like what they do inside rules. It is 
 really simple and understandable code. Maybe I will try reuse something.
 
 Best regards,
 Denis







Re: [Pharo-project] TxTextMorph based on new text model

2013-01-28 Thread Sean P. DeNigris
Denis Kudriashov wrote
 I like what they do inside rules. It is
 really simple and understandable code. Maybe I will try reuse something.

Very good. I am not suggesting we copy the exact approach, just learn any
lessons so we don't have to repeat the mistakes of the past.

Sean



--
View this message in context: 
http://forum.world.st/TxTextMorph-based-on-new-text-model-tp4663219p4665942.html
Sent from the Pharo Smalltalk mailing list archive at Nabble.com.



Re: [Pharo-project] TxTextMorph based on new text model

2013-01-23 Thread Sean P. DeNigris
Denis Kudriashov wrote
 I upload new version of TxText with new TxTextMorph

Denis, thank you for taking this on! This is /so/ important. There are many
times in my experiments with reinventing the tools when I've gotten confused
and frustrated by the way text / editors work and chosen to revert to a more
standard way of doing things.

Two things:
1. Have you read about the experiments from VPRI? There is even an active
essay where you can see each rule being applied individually
2. Have you considered growth as text is typed in? The current hold the
width and grow down approach is very poor in certain applications. There
was a growable version that increased to a maximum length, but it was very
hacky due to the complexity of hooking into the existing objects. My point
is, it would be great to be able to plugin different strategies here.

Thanks for tackling this urgent and complicated topic!
Sean



--
View this message in context: 
http://forum.world.st/TxTextMorph-based-on-new-text-model-tp4663219p4664903.html
Sent from the Pharo Smalltalk mailing list archive at Nabble.com.



Re: [Pharo-project] TxTextMorph based on new text model

2013-01-23 Thread DeNigris Sean
 I don't. Do you have link?

Here is the paper: http://www.vpri.org/pdf/m2010002_lobjects.pdf
And you can download the image with the actual active essay from 
http://tinlizzie.org/lesserphic2/Text%20Field%20for%20LObject.zip

Re: [Pharo-project] TxTextMorph based on new text model

2013-01-23 Thread Stéphane Ducasse

On Jan 23, 2013, at 1:34 PM, Sean P. DeNigris wrote:

 Thanks for tackling this urgent and complicated topic!

+ 1000

Stef




Re: [Pharo-project] TxTextMorph based on new text model

2013-01-20 Thread Denis Kudriashov
I uploaded new version with refactored layout code and new tests.

TxText tests now uses Mocketry framework. I very hope you will enjoy it.
Mock objects to me is main tool to design and implement flexible object
systems. And Mocketry simplifies mock objects technique very much.
See announcement about new version of Mocketry.

Best regards
Denis

2013/1/19 Stéphane Ducasse stephane.duca...@inria.fr

 This is really nice.
 Tristan started to look at what you are doing because we proposed him to
 enhance textModel as part of an internship with us.

 Stef

 On Jan 18, 2013, at 9:30 PM, Denis Kudriashov wrote:

  Hello.
 
  I publish configuration at TxText repository based on proposed
 repackaging.
 
  2013/1/15 Camillo Bruni camillobr...@gmail.com
 
  On 2013-01-15, at 12:44, Denis Kudriashov dionisi...@gmail.com wrote:
 
   Yes.
   I want to do it. But today I busy. Tomorrow I hope I can make it.
 
  no hurry :) I set up the jenkins build, it will trigger as soon as you
 push the configuration :)
 
   I actually want to split package to TxText-Model, TxText-Layout,
 TxText-UI,
   TxTextTests-Model, TxTextTests-Layout
 
  nice!
 





Re: [Pharo-project] TxTextMorph based on new text model

2013-01-19 Thread Stéphane Ducasse
This is really nice.
Tristan started to look at what you are doing because we proposed him to 
enhance textModel as part of an internship with us.

Stef

On Jan 18, 2013, at 9:30 PM, Denis Kudriashov wrote:

 Hello.
 
 I publish configuration at TxText repository based on proposed repackaging.
 
 2013/1/15 Camillo Bruni camillobr...@gmail.com
 
 On 2013-01-15, at 12:44, Denis Kudriashov dionisi...@gmail.com wrote:
 
  Yes.
  I want to do it. But today I busy. Tomorrow I hope I can make it.
 
 no hurry :) I set up the jenkins build, it will trigger as soon as you push 
 the configuration :)
 
  I actually want to split package to TxText-Model, TxText-Layout, TxText-UI,
  TxTextTests-Model, TxTextTests-Layout
 
 nice!
 




Re: [Pharo-project] TxTextMorph based on new text model

2013-01-18 Thread Denis Kudriashov
Hello.

I publish configuration at TxText repository based on proposed repackaging.

2013/1/15 Camillo Bruni camillobr...@gmail.com


 On 2013-01-15, at 12:44, Denis Kudriashov dionisi...@gmail.com wrote:

  Yes.
  I want to do it. But today I busy. Tomorrow I hope I can make it.

 no hurry :) I set up the jenkins build, it will trigger as soon as you
 push the configuration :)

  I actually want to split package to TxText-Model, TxText-Layout,
 TxText-UI,
  TxTextTests-Model, TxTextTests-Layout

 nice!



Re: [Pharo-project] TxTextMorph based on new text model

2013-01-15 Thread Camillo Bruni
Denis, could you create a ConfigurationOfTxText?
That would greatly simplify the creation of a build job on jenkins!

On 2013-01-13, at 22:39, Camillo Bruni camillobr...@gmail.com wrote:

 I added a new jenkins job:
 
 https://ci.inria.fr/rmod/job/TxText/
 
 currently inactive/broken, we will dive into it tomorrow ;)
 
 
 On 2013-01-13, at 22:26, Stéphane Ducasse stephane.duca...@inria.fr wrote:
 
 thanks denis for pushing that
 
 Stef
 
 
 Hello.
 
 I upload new version of TxText with new TxTextMorph which can show 
 TxTextModel (http://www.smalltalkhub.com/#!/~sig/TxText ). See class side 
 examples.
 
 Implementation details:
 
 TxTextMorph has textLayout instance variable which contains full 
 precomputed information to draw text on screen. TxTextLayout contains 
 collection of TxTextLine. TxTextLine contains collection of span objects 
 (from text model) and offset with extent required for drawing lines (with 
 right align for example).
 There are TxTextLayoutStrategy hierarchy responsible for building specific 
 text layout objects:
 • TxSimpleTextLayoutStrategy build layout with actual text lines which 
 text model contains
 • TxWrapTextStrategy build layout with lines which satisfied 
 preferredExtent (given from text morph bounds)
 When text morph accepts new text model It asks layoutStrategy to build new 
 layout. Then align selector applyed to layout. So text can be placed left 
 to right, centered or right to left.
 
 Morph drawing method very simple:
 
 TxTextMorphdrawOn: aCanvas
   textLayout drawTextOn: aCanvas at: self position 
 
 TxTextLayoutdrawTextOn: aCanvas at: aPoint
   | topOffset linePosition |
   topOffset := 0.
   lines do: [:eachLine | 
   linePosition := aPoint x @ (aPoint y + topOffset).
   eachLine drawOn: aCanvas at: linePosition.
   topOffset := topOffset + eachLine height.
   ]
 
 TxTextLinedrawOn: aCanvas at: aPoint
 
   spans do: [:each | 
   each drawOn: aCanvas at: aPoint + offset 
   ]
 
 At the end TxCharactersSpan draw contents on canvas:
 
 TxCharactersSpan drawOn: aCanvas at: aPoint 
   aCanvas 
   drawString: characters 
   at: aPoint 
   font: (self getAttribute: TxFontAttribute) 
   color: (self getAttribute: TxColorAttribute)
 
 And with Athens api text attributes can be not hardcoded:
 
 TxCharactersSpan drawAthensOn: aCanvas at: aPoint 
   attributes applyOn: aCanvas.
   aCanvas pathTransform translateX: aPoint x Y: aPoint y.
   aCanvas drawString: characters 
 
 Questions:
 
 Now text alignment (like centering) is property of TxTextMorph. So it 
 global property of full text layout. 
 But how such attribute can be applied to specific line?
 
 TxModel is list of spans. And each span object contains characters with 
 same text attributes like font or color. Text alignment can be such 
 attribute too. Do you think it should be attribute of all spans from single 
 line? Or it should be only attribute of TxLineSeparator span? What your 
 idea?
 
 Future:
 
 Next plan: cursor navigation, text selection and editing features. And of 
 course tests, sorry I not start with tests now.
 
 I wait your comments , ideas and questions. Maybe you don't like my 
 approach. I want to know why. 
 I really want clean and object solution for text stuff in pharo.
 
 
 
 




Re: [Pharo-project] TxTextMorph based on new text model

2013-01-15 Thread Denis Kudriashov
Yes.
I want to do it. But today I busy. Tomorrow I hope I can make it.
I actually want to split package to TxText-Model, TxText-Layout, TxText-UI,
TxTextTests-Model, TxTextTests-Layout

2013/1/15 Camillo Bruni camillobr...@gmail.com

 Denis, could you create a ConfigurationOfTxText?
 That would greatly simplify the creation of a build job on jenkins!

 On 2013-01-13, at 22:39, Camillo Bruni camillobr...@gmail.com wrote:

  I added a new jenkins job:
 
  https://ci.inria.fr/rmod/job/TxText/
 
  currently inactive/broken, we will dive into it tomorrow ;)
 
 
  On 2013-01-13, at 22:26, Stéphane Ducasse stephane.duca...@inria.fr
 wrote:
 
  thanks denis for pushing that
 
  Stef
 
 
  Hello.
 
  I upload new version of TxText with new TxTextMorph which can show
 TxTextModel (http://www.smalltalkhub.com/#!/~sig/TxText ). See class side
 examples.
 
  Implementation details:
 
  TxTextMorph has textLayout instance variable which contains full
 precomputed information to draw text on screen. TxTextLayout contains
 collection of TxTextLine. TxTextLine contains collection of span objects
 (from text model) and offset with extent required for drawing lines (with
 right align for example).
  There are TxTextLayoutStrategy hierarchy responsible for building
 specific text layout objects:
  • TxSimpleTextLayoutStrategy build layout with actual text lines
 which text model contains
  • TxWrapTextStrategy build layout with lines which satisfied
 preferredExtent (given from text morph bounds)
  When text morph accepts new text model It asks layoutStrategy to build
 new layout. Then align selector applyed to layout. So text can be placed
 left to right, centered or right to left.
 
  Morph drawing method very simple:
 
  TxTextMorphdrawOn: aCanvas
textLayout drawTextOn: aCanvas at: self position
 
  TxTextLayoutdrawTextOn: aCanvas at: aPoint
| topOffset linePosition |
topOffset := 0.
lines do: [:eachLine |
linePosition := aPoint x @ (aPoint y + topOffset).
eachLine drawOn: aCanvas at: linePosition.
topOffset := topOffset + eachLine height.
]
 
  TxTextLinedrawOn: aCanvas at: aPoint
 
spans do: [:each |
each drawOn: aCanvas at: aPoint + offset
]
 
  At the end TxCharactersSpan draw contents on canvas:
 
  TxCharactersSpan drawOn: aCanvas at: aPoint
aCanvas
drawString: characters
at: aPoint
font: (self getAttribute: TxFontAttribute)
color: (self getAttribute: TxColorAttribute)
 
  And with Athens api text attributes can be not hardcoded:
 
  TxCharactersSpan drawAthensOn: aCanvas at: aPoint
attributes applyOn: aCanvas.
aCanvas pathTransform translateX: aPoint x Y: aPoint y.
aCanvas drawString: characters
 
  Questions:
 
  Now text alignment (like centering) is property of TxTextMorph. So it
 global property of full text layout.
  But how such attribute can be applied to specific line?
 
  TxModel is list of spans. And each span object contains characters
 with same text attributes like font or color. Text alignment can be such
 attribute too. Do you think it should be attribute of all spans from single
 line? Or it should be only attribute of TxLineSeparator span? What your
 idea?
 
  Future:
 
  Next plan: cursor navigation, text selection and editing features. And
 of course tests, sorry I not start with tests now.
 
  I wait your comments , ideas and questions. Maybe you don't like my
 approach. I want to know why.
  I really want clean and object solution for text stuff in pharo.
 
 
 
 





Re: [Pharo-project] TxTextMorph based on new text model

2013-01-15 Thread Camillo Bruni

On 2013-01-15, at 12:44, Denis Kudriashov dionisi...@gmail.com wrote:

 Yes.
 I want to do it. But today I busy. Tomorrow I hope I can make it.

no hurry :) I set up the jenkins build, it will trigger as soon as you push the 
configuration :)

 I actually want to split package to TxText-Model, TxText-Layout, TxText-UI,
 TxTextTests-Model, TxTextTests-Layout

nice!


Re: [Pharo-project] TxTextMorph based on new text model

2013-01-13 Thread Igor Stasenko
Wow..
this is a huge progress!
Sorry i was busy with other stuff and had no time to look at your code.


On 13 January 2013 20:54, Denis Kudriashov dionisi...@gmail.com wrote:
 Hello.

 I upload new version of TxText with new TxTextMorph which can show
 TxTextModel (http://www.smalltalkhub.com/#!/~sig/TxText ). See class side
 examples.

 Implementation details:

 TxTextMorph has textLayout instance variable which contains full precomputed
 information to draw text on screen. TxTextLayout contains collection of
 TxTextLine. TxTextLine contains collection of span objects (from text model)
 and offset with extent required for drawing lines (with right align for
 example).
 There are TxTextLayoutStrategy hierarchy responsible for building specific
 text layout objects:

 TxSimpleTextLayoutStrategy build layout with actual text lines which text
 model contains
 TxWrapTextStrategy build layout with lines which satisfied preferredExtent
 (given from text morph bounds)

 When text morph accepts new text model It asks layoutStrategy to build new
 layout. Then align selector applyed to layout. So text can be placed left to
 right, centered or right to left.

 Morph drawing method very simple:

 TxTextMorphdrawOn: aCanvas
 textLayout drawTextOn: aCanvas at: self position

 TxTextLayoutdrawTextOn: aCanvas at: aPoint
 | topOffset linePosition |
 topOffset := 0.
 lines do: [:eachLine |
 linePosition := aPoint x @ (aPoint y + topOffset).
 eachLine drawOn: aCanvas at: linePosition.
 topOffset := topOffset + eachLine height.
 ]

 TxTextLinedrawOn: aCanvas at: aPoint

 spans do: [:each |
 each drawOn: aCanvas at: aPoint + offset
 ]

 At the end TxCharactersSpan draw contents on canvas:

 TxCharactersSpan drawOn: aCanvas at: aPoint
 aCanvas
 drawString: characters
 at: aPoint
 font: (self getAttribute: TxFontAttribute)
 color: (self getAttribute: TxColorAttribute)

 And with Athens api text attributes can be not hardcoded:

 TxCharactersSpan drawAthensOn: aCanvas at: aPoint
 attributes applyOn: aCanvas.
 aCanvas pathTransform translateX: aPoint x Y: aPoint y.
 aCanvas drawString: characters

 Questions:

 Now text alignment (like centering) is property of TxTextMorph. So it global
 property of full text layout.
 But how such attribute can be applied to specific line?

 TxModel is list of spans. And each span object contains characters with same
 text attributes like font or color. Text alignment can be such attribute
 too. Do you think it should be attribute of all spans from single line? Or
 it should be only attribute of TxLineSeparator span? What your idea?


Well, there is two approaches: a per-line attribute can be a special
span at the beginning at
line, or it can be an attribute. Both has pros and cons, however.
In case of span, it needs to be dealt properly with text editing/navigation.
In case of attribute(s), this attribute is really per line (or better
to say, per paragraph)
and putting it into each span seems like superfluous.

IMO, i would go for a simplest model: the capability like text
alignment (left/center/right)
per line, is kind of overkill for our little world.
I mean, it would be nice to have, but look at our tools: where are
they used? Nowhere.
So i would not focus on it right now, and having a global attribute
seems like a good solution right now.

 Future:

 Next plan: cursor navigation, text selection and editing features. And of
 course tests, sorry I not start with tests now.

don't forget about tests.
We started writing a model by implementing tests first, because we
didn't wanted
an implementation to dictate how things should be used.

 I wait your comments , ideas and questions. Maybe you don't like my
 approach. I want to know why.
 I really want clean and object solution for text stuff in pharo.




-- 
Best regards,
Igor Stasenko.



Re: [Pharo-project] TxTextMorph based on new text model

2013-01-13 Thread Stéphane Ducasse
Igor 

do not think that because our tools do not use anything, we do not need good 
text support.
Moose is struggling with the limits of the current textmodel.

We should offer solutions to people not just to edit methods.

Stef

On Jan 13, 2013, at 9:51 PM, Igor Stasenko wrote:

 Wow..
 this is a huge progress!
 Sorry i was busy with other stuff and had no time to look at your code.
 
 
 On 13 January 2013 20:54, Denis Kudriashov dionisi...@gmail.com wrote:
 Hello.
 
 I upload new version of TxText with new TxTextMorph which can show
 TxTextModel (http://www.smalltalkhub.com/#!/~sig/TxText ). See class side
 examples.
 
 Implementation details:
 
 TxTextMorph has textLayout instance variable which contains full precomputed
 information to draw text on screen. TxTextLayout contains collection of
 TxTextLine. TxTextLine contains collection of span objects (from text model)
 and offset with extent required for drawing lines (with right align for
 example).
 There are TxTextLayoutStrategy hierarchy responsible for building specific
 text layout objects:
 
 TxSimpleTextLayoutStrategy build layout with actual text lines which text
 model contains
 TxWrapTextStrategy build layout with lines which satisfied preferredExtent
 (given from text morph bounds)
 
 When text morph accepts new text model It asks layoutStrategy to build new
 layout. Then align selector applyed to layout. So text can be placed left to
 right, centered or right to left.
 
 Morph drawing method very simple:
 
 TxTextMorphdrawOn: aCanvas
textLayout drawTextOn: aCanvas at: self position
 
 TxTextLayoutdrawTextOn: aCanvas at: aPoint
| topOffset linePosition |
topOffset := 0.
lines do: [:eachLine |
linePosition := aPoint x @ (aPoint y + topOffset).
eachLine drawOn: aCanvas at: linePosition.
topOffset := topOffset + eachLine height.
]
 
 TxTextLinedrawOn: aCanvas at: aPoint
 
spans do: [:each |
each drawOn: aCanvas at: aPoint + offset
]
 
 At the end TxCharactersSpan draw contents on canvas:
 
 TxCharactersSpan drawOn: aCanvas at: aPoint
aCanvas
drawString: characters
at: aPoint
font: (self getAttribute: TxFontAttribute)
color: (self getAttribute: TxColorAttribute)
 
 And with Athens api text attributes can be not hardcoded:
 
 TxCharactersSpan drawAthensOn: aCanvas at: aPoint
attributes applyOn: aCanvas.
aCanvas pathTransform translateX: aPoint x Y: aPoint y.
aCanvas drawString: characters
 
 Questions:
 
 Now text alignment (like centering) is property of TxTextMorph. So it global
 property of full text layout.
 But how such attribute can be applied to specific line?
 
 TxModel is list of spans. And each span object contains characters with same
 text attributes like font or color. Text alignment can be such attribute
 too. Do you think it should be attribute of all spans from single line? Or
 it should be only attribute of TxLineSeparator span? What your idea?
 
 
 Well, there is two approaches: a per-line attribute can be a special
 span at the beginning at
 line, or it can be an attribute. Both has pros and cons, however.
 In case of span, it needs to be dealt properly with text editing/navigation.
 In case of attribute(s), this attribute is really per line (or better
 to say, per paragraph)
 and putting it into each span seems like superfluous.
 
 IMO, i would go for a simplest model: the capability like text
 alignment (left/center/right)
 per line, is kind of overkill for our little world.
 I mean, it would be nice to have, but look at our tools: where are
 they used? Nowhere.
 So i would not focus on it right now, and having a global attribute
 seems like a good solution right now.
 
 Future:
 
 Next plan: cursor navigation, text selection and editing features. And of
 course tests, sorry I not start with tests now.
 
 don't forget about tests.
 We started writing a model by implementing tests first, because we
 didn't wanted
 an implementation to dictate how things should be used.
 
 I wait your comments , ideas and questions. Maybe you don't like my
 approach. I want to know why.
 I really want clean and object solution for text stuff in pharo.
 
 
 
 
 -- 
 Best regards,
 Igor Stasenko.
 




Re: [Pharo-project] TxTextMorph based on new text model

2013-01-13 Thread Stéphane Ducasse
thanks denis for pushing that

Stef


 Hello.
 
 I upload new version of TxText with new TxTextMorph which can show 
 TxTextModel (http://www.smalltalkhub.com/#!/~sig/TxText ). See class side 
 examples.
 
 Implementation details:
 
 TxTextMorph has textLayout instance variable which contains full precomputed 
 information to draw text on screen. TxTextLayout contains collection of 
 TxTextLine. TxTextLine contains collection of span objects (from text model) 
 and offset with extent required for drawing lines (with right align for 
 example).
 There are TxTextLayoutStrategy hierarchy responsible for building specific 
 text layout objects:
   • TxSimpleTextLayoutStrategy build layout with actual text lines which 
 text model contains
   • TxWrapTextStrategy build layout with lines which satisfied 
 preferredExtent (given from text morph bounds)
 When text morph accepts new text model It asks layoutStrategy to build new 
 layout. Then align selector applyed to layout. So text can be placed left to 
 right, centered or right to left.
 
 Morph drawing method very simple:
 
 TxTextMorphdrawOn: aCanvas
 textLayout drawTextOn: aCanvas at: self position 
 
 TxTextLayoutdrawTextOn: aCanvas at: aPoint
 | topOffset linePosition |
 topOffset := 0.
 lines do: [:eachLine | 
 linePosition := aPoint x @ (aPoint y + topOffset).
 eachLine drawOn: aCanvas at: linePosition.
 topOffset := topOffset + eachLine height.
 ]
 
 TxTextLinedrawOn: aCanvas at: aPoint
 
 spans do: [:each | 
 each drawOn: aCanvas at: aPoint + offset 
 ]
 
 At the end TxCharactersSpan draw contents on canvas:
 
 TxCharactersSpan drawOn: aCanvas at: aPoint 
 aCanvas 
 drawString: characters 
 at: aPoint 
 font: (self getAttribute: TxFontAttribute) 
 color: (self getAttribute: TxColorAttribute)
 
 And with Athens api text attributes can be not hardcoded:
 
 TxCharactersSpan drawAthensOn: aCanvas at: aPoint 
 attributes applyOn: aCanvas.
 aCanvas pathTransform translateX: aPoint x Y: aPoint y.
 aCanvas drawString: characters 
 
 Questions:
 
 Now text alignment (like centering) is property of TxTextMorph. So it global 
 property of full text layout. 
 But how such attribute can be applied to specific line?
 
 TxModel is list of spans. And each span object contains characters with same 
 text attributes like font or color. Text alignment can be such attribute too. 
 Do you think it should be attribute of all spans from single line? Or it 
 should be only attribute of TxLineSeparator span? What your idea?
 
 Future:
 
 Next plan: cursor navigation, text selection and editing features. And of 
 course tests, sorry I not start with tests now.
 
 I wait your comments , ideas and questions. Maybe you don't like my approach. 
 I want to know why. 
 I really want clean and object solution for text stuff in pharo.
 




Re: [Pharo-project] TxTextMorph based on new text model

2013-01-13 Thread Camillo Bruni
I added a new jenkins job:

https://ci.inria.fr/rmod/job/TxText/

currently inactive/broken, we will dive into it tomorrow ;)


On 2013-01-13, at 22:26, Stéphane Ducasse stephane.duca...@inria.fr wrote:

 thanks denis for pushing that
 
 Stef
 
 
 Hello.
 
 I upload new version of TxText with new TxTextMorph which can show 
 TxTextModel (http://www.smalltalkhub.com/#!/~sig/TxText ). See class side 
 examples.
 
 Implementation details:
 
 TxTextMorph has textLayout instance variable which contains full precomputed 
 information to draw text on screen. TxTextLayout contains collection of 
 TxTextLine. TxTextLine contains collection of span objects (from text model) 
 and offset with extent required for drawing lines (with right align for 
 example).
 There are TxTextLayoutStrategy hierarchy responsible for building specific 
 text layout objects:
  • TxSimpleTextLayoutStrategy build layout with actual text lines which 
 text model contains
  • TxWrapTextStrategy build layout with lines which satisfied 
 preferredExtent (given from text morph bounds)
 When text morph accepts new text model It asks layoutStrategy to build new 
 layout. Then align selector applyed to layout. So text can be placed left to 
 right, centered or right to left.
 
 Morph drawing method very simple:
 
 TxTextMorphdrawOn: aCanvas
textLayout drawTextOn: aCanvas at: self position 
 
 TxTextLayoutdrawTextOn: aCanvas at: aPoint
| topOffset linePosition |
topOffset := 0.
lines do: [:eachLine | 
linePosition := aPoint x @ (aPoint y + topOffset).
eachLine drawOn: aCanvas at: linePosition.
topOffset := topOffset + eachLine height.
]
 
 TxTextLinedrawOn: aCanvas at: aPoint
 
spans do: [:each | 
each drawOn: aCanvas at: aPoint + offset 
]
 
 At the end TxCharactersSpan draw contents on canvas:
 
 TxCharactersSpan drawOn: aCanvas at: aPoint 
aCanvas 
drawString: characters 
at: aPoint 
font: (self getAttribute: TxFontAttribute) 
color: (self getAttribute: TxColorAttribute)
 
 And with Athens api text attributes can be not hardcoded:
 
 TxCharactersSpan drawAthensOn: aCanvas at: aPoint 
attributes applyOn: aCanvas.
aCanvas pathTransform translateX: aPoint x Y: aPoint y.
aCanvas drawString: characters 
 
 Questions:
 
 Now text alignment (like centering) is property of TxTextMorph. So it global 
 property of full text layout. 
 But how such attribute can be applied to specific line?
 
 TxModel is list of spans. And each span object contains characters with same 
 text attributes like font or color. Text alignment can be such attribute 
 too. Do you think it should be attribute of all spans from single line? Or 
 it should be only attribute of TxLineSeparator span? What your idea?
 
 Future:
 
 Next plan: cursor navigation, text selection and editing features. And of 
 course tests, sorry I not start with tests now.
 
 I wait your comments , ideas and questions. Maybe you don't like my 
 approach. I want to know why. 
 I really want clean and object solution for text stuff in pharo.