Re: Line numbers for soft-wrapped styled text?

2017-04-03 Thread Mark Waddingham via use-livecode
On 2017-03-29 12:48, hh via use-livecode wrote: Alex, before you waste valuable time: The formattedRect can NOT be used in LC 7/8/9, because of the (2^15 div 2)-limit for coordinates is active for that. I couldn't find a bug report for that so I filed one:

Re: Line numbers for soft-wrapped styled text?

2017-04-02 Thread hh via use-livecode
Alex, a brilliant technique. It is certainly usable for other "searching" tasks. And it simply needs for this use case a faster measurement-method as input. We could try the selectedLoc: The script below gets for me the exakt topLefts of the visible ones of 2 "worse case"-lines in < 1

Re: Line numbers for soft-wrapped styled text?

2017-04-02 Thread Alex Tweedly via use-livecode
Sure, here it is. I couldn't resist doing some simple benchmarks, just to verify my intuition. Very glad I did. OK - here's the theory : we're using variations of binary search to find the lowest numbered line that is visible, and then again to find the highest numbered line. So at each

Re: Line numbers for soft-wrapped styled text?

2017-04-01 Thread Mark Wieder via use-livecode
On 04/01/2017 09:42 AM, hh via use-livecode wrote: Alex, please think about posting this. It is certainly valuable for other use cases. Agreed, even though I can't use it for my particular case. (I implemented the brilliant idea of listStyle line numbering in a test version of the glx2

Re: Line numbers for soft-wrapped styled text?

2017-04-01 Thread hh via use-livecode
> Alex T. wrote: > I set out to optimise the 'visibleLineNumber' function, and succeeded > in getting it down to approx 20% of the original version, by: > - reduce from 2 to 1 height calculations per iteration > - convert from recursive to iterative > - use Newton-Raphson style linear

Re: Line numbers for soft-wrapped styled text?

2017-04-01 Thread Alex Tweedly via use-livecode
Conclusion : I give up :-) We have three 'completed' approaches to the line numbering problem: 1. Jim Lambert's use of decimal-numbered-list style within the field (has the limitation of not allowing the user's text to include list styles, and some aesthetic constraints - but if you can live

Re: Line numbers for soft-wrapped styled text?

2017-03-30 Thread Alex Tweedly via use-livecode
On 29/03/2017 19:20, Jim Lambert via use-livecode wrote: Now that I think about it, I’ve overcomplicated things. You don’t need two fields at all. Just set the liststyle of the field that contains your editable text to ‘decimal’. Then the lines will be automatically numbered and outdented.

Re: Line numbers for soft-wrapped styled text?

2017-03-29 Thread Jim Lambert via use-livecode
Hermann wrote: > In sum I learned very important things in this thread: > Using a styledText array (by Alex Tweedly). > Using liststyles for _any_ field (by Jim Lambert). > You could now think about making a "Sample stack" for that (livecodeshare). > > One thing to remark: > One has to adjust

Re: Line numbers for soft-wrapped styled text?

2017-03-29 Thread hh via use-livecode
> Jim L. wrote: > Just set the liststyle of the field that contains your editable text to > ‘decimal’. Then the lines will be automatically numbered and outdented. > Yet conveniently, the ’text’ and the ‘styledtext’ runs will not ‘contain' > the numbering since it is a styling. Now I finally

Re: Line numbers for soft-wrapped styled text?

2017-03-29 Thread Jim Lambert via use-livecode
Richard wrote: > This morning Jim Lambert emailed me a very different solution that I > thought would be worth sharing here. > > Here he uses the engine's own metrics for calculating vertical line > spacings, by having the number field placed below the editable text > field, setting its width

Re: Line numbers for soft-wrapped styled text?

2017-03-29 Thread hh via use-livecode
Alex, before you waste valuable time: The formattedRect can NOT be used in LC 7/8/9, because of the (2^15 div 2)-limit for coordinates is active for that. So the algorithm works in LC 6.7.11, but the results are sadly 'extremely' wrong in LC 7/8/9: Crossing the 'limit' with a vertical coordinate

Re: Line numbers for soft-wrapped styled text?

2017-03-28 Thread hh via use-livecode
I see, you are optimizing this. Will become perfect. The current search is part of a script that has to work also for non-wrapped text (with possibly horizontal scrollbar) and is a first step for calculating the visible "chars" (incl. whitespace). In sum: you are right, the search for the lines

Re: Line numbers for soft-wrapped styled text?

2017-03-28 Thread Alex Tweedly via use-livecode
On 28/03/2017 22:11, hh via use-livecode wrote: Hi Alex, below you will find a tested binary search for the visible lines which uses item 4 of the formattedRect for the topLine and item 2 of the formattedRect for the bottomLine. That's great - thank you. However, I do have a couple of

Re: Line numbers for soft-wrapped styled text?

2017-03-28 Thread Alex Tweedly via use-livecode
- From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf Of Alex Tweedly via use-livecode Sent: Tuesday, March 28, 2017 4:13 PM To: use-livecode@lists.runrev.com Cc: Alex Tweedly Subject: Re: Line numbers for soft-wrapped styled text? There is a bit of a problem I encountered tr

RE: Line numbers for soft-wrapped styled text?

2017-03-28 Thread Ralph DiMola via use-livecode
] On Behalf Of Alex Tweedly via use-livecode Sent: Tuesday, March 28, 2017 4:13 PM To: use-livecode@lists.runrev.com Cc: Alex Tweedly Subject: Re: Line numbers for soft-wrapped styled text? There is a bit of a problem I encountered trying to code this up. I'm not 100% sure yet if it's a bug, though I think

Re: Line numbers for soft-wrapped styled text?

2017-03-28 Thread hh via use-livecode
Hi Alex, below you will find a tested binary search for the visible lines which uses item 4 of the formattedRect for the topLine and item 2 of the formattedRect for the bottomLine. TMHO your method is so fast for visible lines of a field on usual screensizes only that you could do that for each

Re: Line numbers for soft-wrapped styled text?

2017-03-28 Thread Alex Tweedly via use-livecode
There is a bit of a problem I encountered trying to code this up. I'm not 100% sure yet if it's a bug, though I think it must be. Comments anyone ? If I set the 'spacebelow' of the last (Nth) line of a field, and get the formattedheight of the field, that includes the spacebelow value just

Re: Line numbers for soft-wrapped styled text?

2017-03-27 Thread hh via use-livecode
The solution of Alex T. was the first example I saw of a useful usage of the styledText array. TMHO this is the way to go for the future of more and more complicated styled text. As was said elsewhere, there could be a considerable speed up if first the visible range of lines, say numbers L1 to

Re: Line numbers for soft-wrapped styled text?

2017-03-27 Thread Alex Tweedly via use-livecode
What a cool idea ! In fact, could you not simply do set the liststyle of line 1 to -1 of fld "mytextfield" to "decimal" and then unset the liststyle whenever needed (e.g. when the field is subject to copy, save, etc.) -- Alex. On 27/03/2017 20:32, Richard Gaskin via use-livecode wrote:

Re: Line numbers for soft-wrapped styled text?

2017-03-27 Thread Richard Gaskin via use-livecode
When I first started down this road I went for getting max values from the styledText array, similar (though far less efficiently) to how Alex Tweedly solved this so well in his post the other day: http://lists.runrev.com/pipermail/use-livecode/2017-March/235688.html Great work as usual from

Re: Line numbers for soft-wrapped styled text?

2017-03-27 Thread Richard Gaskin via use-livecode
Bob Sneidar wrote: > Yeah I was thinking the same thing. textChanged triggers a handler > that reformats the text every time. In essence, you are doing what > a word processor would do. The textChanged message is only sent when changes are made to the text of a field. Changes to styling

Re: Line numbers for soft-wrapped styled text?

2017-03-27 Thread Bob Sneidar via use-livecode
Yeah I was thinking the same thing. textChanged triggers a handler that reformats the text every time. In essence, you are doing what a word processor would do. Bob S > On Mar 25, 2017, at 09:07 , Mark Wieder via use-livecode > wrote: > > I looked into that

Re: Line numbers for soft-wrapped styled text?

2017-03-26 Thread Alex Tweedly via use-livecode
On 26/03/2017 02:25, Mark Wieder via use-livecode wrote: On 03/25/2017 04:00 PM, Alex Tweedly via use-livecode wrote: Never done it, but I had a quick play Hmmm... nice approach. And clever use of spacebelow. If you have a way of determining which line(s) are being changed, then you

Re: Line numbers for soft-wrapped styled text?

2017-03-25 Thread Mark Wieder via use-livecode
On 03/25/2017 04:00 PM, Alex Tweedly via use-livecode wrote: Never done it, but I had a quick play Hmmm... nice approach. And clever use of spacebelow. If you have a way of determining which line(s) are being changed, then you could run this only from that line onward to save some time

Re: Line numbers for soft-wrapped styled text?

2017-03-25 Thread dunbarx via use-livecode
aps.. So, just lock the text and move on... Craig -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Line-numbers-for-soft-wrapped-styled-text-tp4713343p4713362.html Sent from the Revolution - User mailing list archive at Nabble.com. ___

Re: Line numbers for soft-wrapped styled text?

2017-03-25 Thread Alex Tweedly via use-livecode
ed to pollute the source field in order to use the formattedText and identify the hard returns. -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Line-numbers-for-soft-wrapped-styled-text-tp4713343p4713356.html Sent from the Revolution - User mailing li

Re: Line numbers for soft-wrapped styled text?

2017-03-25 Thread dunbarx via use-livecode
m/Line-numbers-for-soft-wrapped-styled-text-tp4713343p4713356.html Sent from the Revolution - User mailing list archive at Nabble.com. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage you

Re: Line numbers for soft-wrapped styled text?

2017-03-25 Thread Richard Gaskin via use-livecode
Nicely done, Alex - thanks! -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.comhttp://www.FourthWorld.com

Re: Line numbers for soft-wrapped styled text?

2017-03-25 Thread Alex Tweedly via use-livecode
Never done it, but I had a quick play and found a way to do it - but whether it would count as "efficiently" or not is debatable :-( It does about 4 lines of text per millisecond on my elderly MacBook Pro (with LC 9.0.0 DP6) If you have a way of determining which line(s) are being

Re: Line numbers for soft-wrapped styled text?

2017-03-25 Thread Mark Wieder via use-livecode
On 03/25/2017 08:36 AM, Richard Gaskin via use-livecode wrote: I have an app that allows the user to write styled text, in which any portion of that text may have a variety of styles and sizes, and may be long enough to soft-wrap. I'd like to add a line-number field next to it, but I haven't

Line numbers for soft-wrapped styled text?

2017-03-25 Thread Richard Gaskin via use-livecode
I have an app that allows the user to write styled text, in which any portion of that text may have a variety of styles and sizes, and may be long enough to soft-wrap. I'd like to add a line-number field next to it, but I haven't come up with an efficient way of setting up those line numbers