Re: Missing function selectedWords/selectedTrueWords

2018-08-31 Thread Tore Nilsen via use-livecode


We certainly are. I can already think of several sarcastic phrases to use, 
should the situation call for it! :) And since my students all know me well 
enough from earlier years, they will expect as much.

Tore




> 31. aug. 2018 kl. 22:13 skrev Mark Waddingham via use-livecode 
> :
> 
> P.S. Of course, at least one 'smart-ass' will ask 'why do those have brackety 
> things when the others don't' - but aren't teachers well versed in dealing 
> with such inquisitive minds? ;)

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Missing function selectedWords/selectedTrueWords

2018-08-31 Thread Mark Waddingham via use-livecode

On 2018-08-31 20:57, Tore Nilsen via use-livecode wrote:

The array form may well be what I need. I do think I still will have
to wait some time before I introduce it to my students.


Perhaps - certainly 'textFont' and 'textSize' have less syntactic 
baggage. However, the actual underlying form/pattern/functionality is 
identical:


  the  of the selectedChunk

Returns "mixed" if  is not the same across all chars, otherwise 
the value of  (or empty if unset across all of them - i.e. 
inherited).


You could introduce the text style ones as 'prepackaged' units though:

  the textStyle["bold"] of the selectedChunk
  the textStyle["italic"] of the selectedChunk

This isn't really a 'lie' either - as these aren't really array 
properties in the same way as when you use that syntactic form as a 
custom property. In an ideal world they would have been done as 'the 
bold of' etc. We didn't do that for the simple reason that the number of 
times I have seen 'bold', 'italic' and other textStyle keywords as 
variable names and custom property names might be most surprising - i.e. 
had we, an unknown number of stacks would have broken, quite severely! 
[Although with hindsight perhaps we should have considered textBold / 
textItalic ... ].


Warmest Regards,

Mark.

P.S. Of course, at least one 'smart-ass' will ask 'why do those have 
brackety things when the others don't' - but aren't teachers well versed 
in dealing with such inquisitive minds? ;)


--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Missing function selectedWords/selectedTrueWords

2018-08-31 Thread Tore Nilsen via use-livecode
It worked as advertised, provided I also check for the instance of the given 
textStyle to be false, this works a charm. The code I need to show to my 
students is easy enough for them to understand, without the need to actually 
understand arrays. Thank you!

Best regards,
Tore

> 31. aug. 2018 kl. 22:00 skrev Mark Waddingham via use-livecode 
> :
> 
> On 2018-08-31 20:51, Tore Nilsen via use-livecode wrote:
>> I got a bit confused there. Pages behaves as you say, Microsoft Word
>> would turn off bold on the initial push of the button, then adding
>> bold to the styles the next time.
>> This is why I thought I needed to find the style of each word in a
>> group of words when the the textStyles is mixed. And I still think
>> that is what I need in order to mimic the behaviour of either Word or
>> Pages.
> 
> Okay - so - create a stack, create a field, type some text in it and then see 
> if you find that the Text > Bold/Italic/... items work as you find in 
> Pages/Word (you should, they seem to for me)...
> 
> If you find they work the same then:
> 
>  set the textStyle["bold"] of the selectedChunk to true -- "bold" can be 
> "italic" or any of the others, setting to false does the inverse
> 
> Is definitely what you need.
> 
> If the textStyle["bold"] of the selectedChunk is "mixed" it means some chars 
> are bold, some aren't - so you can make the appropriate decision as to what 
> to do based on your preference for either the Pages or Word behavior :)
> 
> Warmest Regards,
> 
> Mark.
> 
> P.S. The above feature was implemented a few versions ago precisely to allow 
> the functionality you describe to be implemented very easily... Prior to it, 
> the IDE menu items still did the right thing - but the code was, well, 
> nowhere near a single line...
> 
> -- 
> Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
> LiveCode: Everyone can create apps
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Missing function selectedWords/selectedTrueWords

2018-08-31 Thread Mark Waddingham via use-livecode

On 2018-08-31 20:51, Tore Nilsen via use-livecode wrote:

I got a bit confused there. Pages behaves as you say, Microsoft Word
would turn off bold on the initial push of the button, then adding
bold to the styles the next time.

This is why I thought I needed to find the style of each word in a
group of words when the the textStyles is mixed. And I still think
that is what I need in order to mimic the behaviour of either Word or
Pages.


Okay - so - create a stack, create a field, type some text in it and 
then see if you find that the Text > Bold/Italic/... items work as you 
find in Pages/Word (you should, they seem to for me)...


If you find they work the same then:

  set the textStyle["bold"] of the selectedChunk to true -- "bold" can 
be "italic" or any of the others, setting to false does the inverse


Is definitely what you need.

If the textStyle["bold"] of the selectedChunk is "mixed" it means some 
chars are bold, some aren't - so you can make the appropriate decision 
as to what to do based on your preference for either the Pages or Word 
behavior :)


Warmest Regards,

Mark.

P.S. The above feature was implemented a few versions ago precisely to 
allow the functionality you describe to be implemented very easily... 
Prior to it, the IDE menu items still did the right thing - but the code 
was, well, nowhere near a single line...


--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Missing function selectedWords/selectedTrueWords

2018-08-31 Thread Tore Nilsen via use-livecode
The array form may well be what I need. I do think I still will have to wait 
some time before I introduce it to my students. 

Best regards
Tore

> 31. aug. 2018 kl. 21:39 skrev Mark Waddingham via use-livecode 
> :
> 
> The key thing here is that using the array form of textStyle treats each 
> individual text style completely separately.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Missing function selectedWords/selectedTrueWords

2018-08-31 Thread Tore Nilsen via use-livecode
I got a bit confused there. Pages behaves as you say, Microsoft Word would turn 
off bold on the initial push of the button, then adding bold to the styles the 
next time.

This is why I thought I needed to find the style of each word in a group of 
words when the the textStyles is mixed. And I still think that is what I need 
in order to mimic the behaviour of either Word or Pages.

Best Regards
Tore



> 31. aug. 2018 kl. 21:39 skrev Mark Waddingham via use-livecode 
> :
> 
> I'm not sure I follow... In pages if I have
> 
> Hello World Foo Bar
> 
> If I select the whole lot - then 'textStyle["bold"]' (in LC speak) will be 
> 'mixed' - this is indicated by the 'Bold' button in pages not being 
> highlighted. If I click the 'Bold' button then it does the equivalent of 'set 
> the textStyle["bold"] of the selectedChunk to true', if I click again it does 
> the same as setting the same property to false. In both cases 'Bar' remains 
> italic.
> 
> The key thing here is that using the array form of textStyle treats each 
> individual text style completely separately.
> 
> Perhaps I misunderstand what you meant?
> 
> Warmest Regards,
> 
> Mark.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Missing function selectedWords/selectedTrueWords

2018-08-31 Thread Tore Nilsen via use-livecode
Beats "looping around» all the text any day! I think I can use this with my 
students in a couple of months time. For now, I think I have to stick to the 
more basic tasks of just altering fonts, text size, text color and text styles 
for single word selections.


Best Regards
Tore Nilsen







> 31. aug. 2018 kl. 21:31 skrev hh via use-livecode 
> :
> 
> You could try:
> 
> on mouseUp
>  put the selectedChunk into sc
>  put word 2 of sc into strt
>  put word 4 of sc into stp
>  put fld word 7 of sc into txt
>  put selectedWords(strt,stp,txt) into fld "out"
> end mouseUp
> 
> function selectedWords strt,stp,txt
>  put the num of words in char 1 to strt of txt into w1
>  put the num of words in char 1 to stp of txt into w2
>  return w1,w2 -- start and stop
> end selectedWords
> 
> Of course you have an uncertainty if your selection
> starts or stops within words.
> 
> Similar for truewords ...
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Missing function selectedWords/selectedTrueWords

2018-08-31 Thread Mark Waddingham via use-livecode

On 2018-08-31 20:33, Tore Nilsen via use-livecode wrote:

Microsoft Word seems to behave the way you suggest, in the sense that
if any given text style is present among the words in the selection
then it is removed. Pages behaves differently. If a given text style
is true for some of the words in the selection, Pages will initially
keep this style for these words and add it to the styles of the rest
of the chunk. If a given text style is true/false for all words in the
selection, Pages will set the text style to false/true accordingly. To
mimic these behaviours it would be useful to be able to do so on a
word by word basis.


I'm not sure I follow... In pages if I have

Hello World Foo Bar

If I select the whole lot - then 'textStyle["bold"]' (in LC speak) will 
be 'mixed' - this is indicated by the 'Bold' button in pages not being 
highlighted. If I click the 'Bold' button then it does the equivalent of 
'set the textStyle["bold"] of the selectedChunk to true', if I click 
again it does the same as setting the same property to false. In both 
cases 'Bar' remains italic.


The key thing here is that using the array form of textStyle treats each 
individual text style completely separately.


Perhaps I misunderstand what you meant?

Warmest Regards,

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Missing function selectedWords/selectedTrueWords

2018-08-31 Thread Tore Nilsen via use-livecode
Microsoft Word seems to behave the way you suggest, in the sense that if any 
given text style is present among the words in the selection then it is 
removed. Pages behaves differently. If a given text style is true for some of 
the words in the selection, Pages will initially keep this style for these 
words and add it to the styles of the rest of the chunk. If a given text style 
is true/false for all words in the selection, Pages will set the text style to 
false/true accordingly. To mimic these behaviours it would be useful to be able 
to do so on a word by word basis. 

An alternative way to handle this could be that the textStyles function 
returned an numeric array with the number of the words as key and the text 
styles for the words as value.

Best Regards,
Tore
> 31. aug. 2018 kl. 21:22 skrev Mark Waddingham via use-livecode 
> :
> 
> You can actually manipulate individual textStyles for just this purposes:
> 
>  set the textStyle["bold"] of  to true -- or false
> 
> All styled text editors I know of work on the complete selected range 
> (including whitespace), rather than just on the words...
> 
> Warmest Regards,
> 
> Mark.


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Missing function selectedWords/selectedTrueWords

2018-08-31 Thread hh via use-livecode
You could try:

on mouseUp
  put the selectedChunk into sc
  put word 2 of sc into strt
  put word 4 of sc into stp
  put fld word 7 of sc into txt
  put selectedWords(strt,stp,txt) into fld "out"
end mouseUp

function selectedWords strt,stp,txt
  put the num of words in char 1 to strt of txt into w1
  put the num of words in char 1 to stp of txt into w2
  return w1,w2 -- start and stop
end selectedWords

Of course you have an uncertainty if your selection
starts or stops within words.

Similar for truewords ...

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Missing function selectedWords/selectedTrueWords

2018-08-31 Thread Mark Waddingham via use-livecode

On 2018-08-31 19:47, Tore Nilsen via use-livecode wrote:

This information is useful if you want to implement changes to the
styles of the selected text, where textStyles report mixed. In a
selection with mixed styles, setting the textStyle has to be done on a
word by word basis (or char by char basis if different styles are used
within a word).


You can actually manipulate individual textStyles for just this 
purposes:


  set the textStyle["bold"] of  to true -- or false

All styled text editors I know of work on the complete selected range 
(including whitespace), rather than just on the words...


Warmest Regards,

Mark.

P.S. I'm not saying that 'the wordIndex of ' might not be useful, 
but I do wonder if the above actually solves your problem in an easier / 
more consistent with the rest-of-the-world way ;)


--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode