Re: use-livecode Digest, Vol 172, Issue 22

2018-01-16 Thread Mark Waddingham via use-livecode

On 2018-01-11 20:50, Richard Gaskin via use-livecode wrote:

Richard Burkett wrote:
Nice, but not as nice as:

  copy

I appreciate that we have the flexibility to do arcane things with the
Clipboard when needed, but shouldn't the copy command handle the most
common cases without requiring new users to research and experiment in
the hope of arriving at the above block of code?


Indeed - the copy command should.

The fact the above can now be written in LiveCode Script means it is 
much easier to work out how to make the copy command 'do the right 
thing'.


Indeed, it wouldn't be too much of a stretch to seriously consider 
implementing most clipboard functionality in script - based around the 
raw clipboard support we have (the clipboardData / fullClipboardData are 
both implemented in terms of the raw clipboard in the engine).


The main missing piece at the moment is the ability to bind the syntax 
to said script handlers, rather than internal C++ engine methods.


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: use-livecode Digest, Vol 172, Issue 22

2018-01-16 Thread Mark Waddingham via use-livecode

On 2018-01-16 05:13, Brian Milby via use-livecode wrote:
The code for MacOS is simpler (the 2 put's following the itemdel are 
not
needed, the format name is "public.html", not sure about Linux).  I 
copied
the above code in LC and then clicked the button to fix it before 
pasting

here.

Changing the tags is probably a good thing to do in the engine code.  
I'm

not so sure about the spaces though.


We can't change the tags for 'htmlText' - i.e. LiveCode's html-like 
styled text representation as many people process it by looking for 'p' 
tags. However, we could add a 'real' HTML converter for the clipboard 
which could use 'div'.


I wonder if the space issue is solved by using an xml:space="preserve" 
attribute?


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: use-livecode Digest, Vol 172, Issue 22

2018-01-15 Thread Brian Milby via use-livecode
Here is a function for Windows that will replace  with  and include
"" for multiple spaces.  It retains the other formatting.  (It won't
catch paragraph level formatting as is though.)  So if you are copying
code, this could be used to clean it for paste as rich text:

*on* mouseUp
   *local* tFormat, tClipboard
   *lock* clipboard
   *put* "HTML Format" into tFormat
   *put* the rawClipboardData[tFormat] into tClipboard
   *replace* "" with "" in tClipboard
   *replace* "" with "" in tClipboard
   *replace* "  " with "" in tClipboard
   *replace* " " with "" in tClipboard
   *set* the itemdel to ":"
   *put* format("%10d", offset(">   Richard Gaskin
>>   Fourth World Systems
>>   Software Design and Development for the Desktop, Mobile, and the Web
>>   
>>   ambassa...@fourthworld.comhttp://www.FourthWorld.com
>>
>> ___
>> 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: use-livecode Digest, Vol 172, Issue 22

2018-01-11 Thread Brian Milby via use-livecode
The problem in this case is the HTML format data (and possibly RTF) on the
clipboard. Testing in Windows, if I just put the LC styled text and plain
text on the clipboard, it works to get plain text outside of LC but retain
formatting inside. If I try to paste the RTF or LC data into Excel, I just
get a beep. HTML gives the double space text. The plain text formats work
as expected. So if the destination application accepts HTML, that is what
it takes.

This does not mean that the clipboard data is necessarily correct right
now. I’m not sure wrapping single spaced text in  tags is correct. I’m
not an expert there, so this may be an area that could be improved.
On Thu, Jan 11, 2018 at 1:51 PM Richard Gaskin via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Richard Burkett wrote:
>
>  > on mouseUp
>  >put fld "myField" into tClip
>  >lock the clipBoard
>  >set the ClipboardData to empty
>  >set the ClipboardData to tClip
>  >put the clipboardData["text"] into tClip
>  >set the rawclipBoardData to empty
>  >if the platform is "MacOS" then
>  >   set the rawClipboardData["public.utf8-plain-text"] \
>  > to textEncode(tClip, "UTF-8" )   -- OSX
>  >else if the platform is "Linux" then
>  >   set the rawClipboardData["text/plain;charset=utf-8"] \
>  > to textEncode(tClip, "UTF-8" ) -- Linux
>  >else if the platform contains "Win" then
>  >   set the rawClipboardData["CF_UNICODE"] \
>  > to textEncode(tClip, "UTF-16" ) -- Windows
>  >end if
>  >unlock the clipBoard
>  > end mouseUp
>
> Nice, but not as nice as:
>
>copy
>
> I appreciate that we have the flexibility to do arcane things with the
> Clipboard when needed, but shouldn't the copy command handle the most
> common cases without requiring new users to research and experiment in
> the hope of arriving at the above block of code?
>
> --
>   Richard Gaskin
>   Fourth World Systems
>   Software Design and Development for the Desktop, Mobile, and the Web
>   
>   ambassa...@fourthworld.comhttp://www.FourthWorld.com
>
> ___
> 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: use-livecode Digest, Vol 172, Issue 22

2018-01-11 Thread Richard Gaskin via use-livecode

Richard Burkett wrote:

> on mouseUp
>put fld "myField" into tClip
>lock the clipBoard
>set the ClipboardData to empty
>set the ClipboardData to tClip
>put the clipboardData["text"] into tClip
>set the rawclipBoardData to empty
>if the platform is "MacOS" then
>   set the rawClipboardData["public.utf8-plain-text"] \
> to textEncode(tClip, "UTF-8" )   -- OSX
>else if the platform is "Linux" then
>   set the rawClipboardData["text/plain;charset=utf-8"] \
> to textEncode(tClip, "UTF-8" ) -- Linux
>else if the platform contains "Win" then
>   set the rawClipboardData["CF_UNICODE"] \
> to textEncode(tClip, "UTF-16" ) -- Windows
>end if
>unlock the clipBoard
> end mouseUp

Nice, but not as nice as:

  copy

I appreciate that we have the flexibility to do arcane things with the 
Clipboard when needed, but shouldn't the copy command handle the most 
common cases without requiring new users to research and experiment in 
the hope of arriving at the above block of code?


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
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: use-livecode Digest, Vol 172, Issue 22

2018-01-10 Thread Brian Milby via use-livecode
You may be able to simplify it to this:

*on* stripClipboard

*local* tData

*lock* the clipboard

*put* the rawClipboardData["public.utf8-plain-text"] into tData

*set* the rawClipboardData to empty

*set* the rawClipboardData["public.utf8-plain-text"] to tData

*unlock* the clipboard

*end* stripClipboard


Here is the same thing pasted after calling that handler:

on stripClipboard
   local tData
   lock the clipboard
   put the rawClipboardData["public.utf8-plain-text"] into tData
   set the rawClipboardData to empty
   set the rawClipboardData["public.utf8-plain-text"] to tData
   unlock the clipboard
end stripClipboard


I'm not sure how much will come through the list server, but the first
version had colors and looks double spaced (but it is actually paragraph
html tags causing the extra space).  The indents were missing.  The second
one is plain text without any extra space and indents were preserved.  I
selected the script from the LC SE and used cmd-C to copy.  I then used
cmd-V to paste it at the top.  I then went to LC and called the handler.
Next I used cmd-V to paste it the second time.  I'm using Gmail in Chrome
to draft the email.  The code is from LC 9 DP 11 running on Sierra.

I think that the problem is that the clipboard is getting filled with many
different versions of the same text.  Some applications are better about
selecting the best version to paste than others.  The original solution and
mine above essentially force the clipboard to only contain a single version
of the data in our chosen format.

Here's your function modified to use the same principle.  To test, I pasted
the code into the field (so it shows formatted with coloring).  I then
clicked the button and pasted into this email.  I only tested on Mac though.

on mouseUp
   local tClip, tRawType

   if the platform is "MacOS" then
  put "public.utf8-plain-text" into tRawType   -- OSX
   else if the platform is "Linux" then
  put "text/plain;charset=utf-8" into tRawType -- Linux
   else if the platform contains "Win" then
  put "CF_UNICODE" into tRawType -- Windows
   end if

   put fld "myField" into tClip
   lock the clipBoard
   set the ClipboardData to tClip
   put the rawClipboardData[tRawType] into tClip
   set the rawClipboardData to empty
   set the rawClipboardData[tRawType] to tClip
   unlock the clipBoard
end mouseUp

Cheers,
Brian
___
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: use-livecode Digest, Vol 172, Issue 22

2018-01-10 Thread Richard Burkett via use-livecode
Thank you, Paul!
I finally got this to work in my test stack using the script below. Note that 
it has the change to “set the rawClipBoardData to empty” instead of just “set 
the ClipBoardData to empty” - that seemed to be necessary at least in LC 8.1.3 
with Mac OS X 10.12.8 Sierra which I have to use as my scripts of my main app 
don’t compile or run correctly at this point with more recent versions of 
LiveCode (but that’s another issue).

on mouseUp
   put fld "myField" into tClip
   lock the clipBoard
   set the ClipboardData to empty
   set the ClipboardData to tClip
   put the clipboardData["text"] into tClip
   set the rawclipBoardData to empty
   if the platform is "MacOS" then
  set the rawClipboardData["public.utf8-plain-text"] \
to textEncode(tClip, "UTF-8" )   -- OSX
   else if the platform is "Linux" then
  set the rawClipboardData["text/plain;charset=utf-8"] \
to textEncode(tClip, "UTF-8" ) -- Linux
   else if the platform contains "Win" then
  set the rawClipboardData["CF_UNICODE"] \
to textEncode(tClip, "UTF-16" ) -- Windows
   end if
   unlock the clipBoard
end mouseUp

Quietly laughing here as I had to copy the script from LC script editor to text 
edit to avoid having double spacing!

Richard

Richard Burkett
richard.burk...@sbcglobal.net

> On Jan 10, 2018, at 11:20 AM, Paul Hibbert wrote:
> 
> This works for me with LC9.0.0(dp11) on MacOS High Sierra 10.13.2:
> 
>   lock the clipBoard
>   put the clipboardData["text"] into tClip
>   set the clipBoardData to empty
>-- OSX
>   set the rawClipboardData["public.utf8-plain-text"] \
> to textEncode(tClip, "UTF-8" )
>   unlock the clipBoard
>   -- Now Go Paste in Apple Mail
> 
> For an in-depth explanation check the ?rawClipboardData" in the dictionary.
> 
> Hope this helps.
> 
> Paul
> 
> 
>> On Jan 10, 2018, at 7:20 AM, Richard Burkett via use-livecode 
>> > wrote:
>> 
>> Thanks for the suggestion, Jacqueline, but it didn?t change anything. Anyone 
>> else have a script-based solution to make sure LiveCode pastes only plain 
>> text? ASCII, Native, MacRoman - none of those text encodings work. 
>> Even putting only this line in my script results in the same thing:
>> set the clipboarddata to ( "blah" & lf & "blah" & lf & "blah" & cr & "blah" 
>> & cr & "blah" & return & "blah" )
>> 
>> What?s different about text set in the clipboard in LiveCode from other text 
>> copied from other Mac apps?
>> 
>> Richard Burkett
>> richard.burk...@sbcglobal.net 
>> 
>>> On 1/9/18 12:09 PM, Richard Burkett via use-livecode wrote:
 Does anyone have a solution to this problem: I set the clipboard in 
 LiveCode to the text of a field or variable that has returns after each 
 line. When I paste that into Mac Mail, the text appears double-spaced as 
 if it has two returns, but clearly there is just one (or a combination of 
 CR and LF?). I?ve tried all the keys for setting the clipboard and also 
 writing a script to delete line feeds, or CR characters, but nothing 
 works. It?s either no returns, or what appears to be double-spaced returns.
 
 If I paste the text first into Text Edit, then copy it, and paste into Mac 
 Mail it?s fine - single line spacing. What?s LiveCode adding to each line 
 that causes Mac Mail to show the pasted text as double spaced? Is there a 
 way to filter/remove that?
>>> 
>>> I don't have a good way to test this, but try:
>>> 
>>> set the clipboardData to textEncode(the clipboardData,"native")
>>> 
>>> 
>>> -- 
>>> Jacqueline Landman Gay | jac...@hyperactivesw.com 
>>>  >> >
>>> HyperActive Software   | http://www.hyperactivesw.com 
>>>  >> >

___
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