SelectedChunk
Mike Bonner
bonnmike at gmail.com
Mon Sep 27 11:10:23 EDT 2010
http://forums.runrev.com/phpBB2/viewtopic.php?f=7&t=3199
Not the post I was thinking of, but some really useful stuff in that forum
thread about whole word selections.
On Mon, Sep 27, 2010 at 9:05 AM, Warren Kuhl <warrenkuhl at gmail.com> wrote:
> Mike,
>
> Thank you very much. You have been most helpful!
>
> All the best!
> Warren
>
> On Mon, Sep 27, 2010 at 10:03 AM, Mike Bonner <bonnmike at gmail.com> wrote:
>
> > Would have to program it, and now that i'm more awake, not sure you need
> to
> > go through all the convoluted stuff I did.
> >
> > This is probably closer to what you can end up with.
> > on mouseUp
> > put word 2 of the selectedchunk into tChar
> > put char 1 to tChar of field 1 into tTmp
> > put the number of words in tTmp
> > end mouseUp
> >
> > This will work with the exception that if your selection includes a space
> > at
> > the left the wordcount will be off by 1, so you'd have to test and decide
> > how you want it to behave in that situation. Will also have to test for
> a
> > simple insertion point rather than a selection also and adjust
> accordingly.
> >
> >
> > To force full word selections, I believe one of the Marks posted
> something
> > a
> > not too long ago that would do this... The gist of the script (If I
> recall
> > correctly) was that when a selection is made, you check for word
> boundaries
> > to the right and left and adjust the selection accordingly.
> > Once you have your char positions you can set the selection.
> >
> > select char 5 to 12 of field "yourfield"
> >
> > I haven't actually tried the forced selection part.
> >
> > G'luck with all this. If I can locate the script I'm trying to remember,
> > i'll post a link.
> >
> >
> >
> > On Mon, Sep 27, 2010 at 8:40 AM, Warren Kuhl <warrenkuhl at gmail.com>
> wrote:
> >
> > > Mike,
> > >
> > > Thank you very much for this. I really appreciate it. Looks exactly
> > like
> > > what I was looking for.
> > >
> > > You mentioned forcing only whole words. Is this a command? Or
> something
> > I
> > > would need to program?
> > >
> > > Thanks again!
> > > Warren
> > >
> > >
> > >
> > >
> > > On Mon, Sep 27, 2010 at 9:21 AM, Mike Bonner <bonnmike at gmail.com>
> wrote:
> > >
> > > > I'm positive this can be shortened, but as is should do what you
> want.
> > It
> > > > could be simplified greatly of course if you are forcing only whole
> > word
> > > > selections, but this will account for partial word selects, and also
> > just
> > > > an
> > > > insertion point.
> > > > *
> > > > on mouseUp
> > > > -- Determine if there is actually a selection of more than 1 char
> > > > if word 2 of the selectedchunk - word 4 of the selectedchunk < 0
> then
> > > > put word 2 of the selectedchunk into tChar
> > > > else
> > > > put word 4 of the selectedchunk into tChar
> > > > end if
> > > >
> > > > -- Determine if the selection is already on a word boundary.
> > > > --if so determine which word the break is at.
> > > > if char tChar of field 1 is space then
> > > > put true into tCharMatch
> > > > put char 1 to tChar of field 1 into tTmp
> > > > put"Word: " & the number of words in tTmp + 1 into tWord
> > > > end if
> > > >
> > > > -- if a match hasn't been found yet, and we're not at the field
> start
> > > > -- nudge 1 char left and check for word break. Repeat until top of
> > > field
> > > > or match
> > > > repeat while tChar > 1 and tCharMatch is empty
> > > > subtract 1 from tChar
> > > > if char tChar of field 1 is space then
> > > > put true into tCharMatch
> > > > put char 1 to tChar of field 1 into tTmp
> > > > put "Word: " & the number of words in tTmp + 1 into tWord
> > > > else if tChar = 0 then
> > > > --if we reach the start of the field, must be the first word
> > > > put "Word: 1" into tWord
> > > > end if
> > > > end repeat
> > > >
> > > > answer information tWord
> > > > end mouseUp*
> > > >
> > > > On Mon, Sep 27, 2010 at 7:17 AM, Warren Kuhl <warrenkuhl at gmail.com>
> > > wrote:
> > > >
> > > > > Is there an easy way to retrieve the word # of a field based on the
> > > > > SelectedChunk? The SelectedChunk contains the start/end position
> of
> > a
> > > > word
> > > > > of a field. Just am trying to determine which word without to much
> > > > > coding...if possible.
> > > > >
> > > > > Thanks for any help!
> > > > > Warren
> > > > > _______________________________________________
> > > > > use-revolution mailing list
> > > > > use-revolution at lists.runrev.com
> > > > > Please visit this url to subscribe, unsubscribe and manage your
> > > > > subscription preferences:
> > > > > http://lists.runrev.com/mailman/listinfo/use-revolution
> > > > >
> > > > _______________________________________________
> > > > use-revolution mailing list
> > > > use-revolution at lists.runrev.com
> > > > Please visit this url to subscribe, unsubscribe and manage your
> > > > subscription preferences:
> > > > http://lists.runrev.com/mailman/listinfo/use-revolution
> > > >
> > > _______________________________________________
> > > use-revolution mailing list
> > > use-revolution at lists.runrev.com
> > > Please visit this url to subscribe, unsubscribe and manage your
> > > subscription preferences:
> > > http://lists.runrev.com/mailman/listinfo/use-revolution
> > >
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-revolution
> >
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list