clipboard issue in Windows?

Peter M. Brigham, MD pmbrig at gmail.com
Wed Nov 30 18:47:31 EST 2011


I have the following in my frontscript, loaded at LC startup:

private command doUndoSpace
  -- this solves the problem that after the certain operations
  -- the script editor remains unaware that the script has changed,
  -- so an <enterkey> will close but not save the changed script
  -- thus we have to *type* at least one character
  lock screen
  put the selectedText into selTxt
  type numToChar(32) -- the important step
  put word 4 of the selectedChunk into charNbr
  put selTxt into char charNbr of the target
  unlock screen
end doUndoSpace

I call this when I use the scriptPaint routine (also in my frontscript -- I think this comes from Jacque). In the script editor, a control-shift-space pops the mousetext (the word the cursor is hovering over) into the selection, great for copying longAndComplexAndEasilyMisspelledVariableNames. The problem with the routine as I poached it some time ago was that if one opens a script and the only change one makes is a scriptPaint move, the script editor won't see the script as having changed and won't save the change. (Purely scripted changes don't mark the field as dirty.) So I call doUndoSpace in the handler, and it works nicely.

It sounds like the same problem is occurring with the paste operation as described in this thread. Maybe the above routine, or something like it, will be useful. You would have to catch the paste in a frontscript and test to see if the window you are pasting into is a script editor window, call doUndoSpace at some point if it is, and pass the paste if it isn't.

BTW, Jacque's shortcuts for the script editor (I'm pretty sure it was you, Jacque -- if not, then someone take credit!) include not just scriptPaint but a several other nifty tricks, ie, putting quotes or parens or brackets around a selection. I've used them long enough now that I've gotten addicted to having them at my fingertips. Below is the controlkeydown handler from my frontscript, which incorporates them all. You can see that I use doUndoSpace in each one.

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig

---------
on controlkeydown whichKey
  -- I use control-shift for all the scripteditor shortcuts
  if the shiftKey is not down then pass controlkeydown
  put the long name of the target into tarName
  if "revNewScriptEditor" is not in tarName then
     pass controlkeydown
  end if
  switch whichKey
     case "'" -- put quotes around the selection
        get the selection
        put q(it) into the selection
        if it = "" then
           put the selectedChunk into tSel
           put word 4 of tSel into word 2 of tSel
           put (word 4 of tSel) - 1 into word 4 of tSel
           select tSel
        end if
        doUndoSpace
        break
     case "9"
     case "0" -- put parens around the selection
        get the selection
        put "(" & it & ")" into the selection
        if it = "" then
           put the selectedChunk into tSel
           put word 4 of tSel into word 2 of tSel
           put (word 4 of tSel) - 1 into word 4 of tSel
           select tSel
        end if
        doUndoSpace
        break
     case "["
     case "]" -- put brackets around the selection
        get the selection
        put "[" & it & "]" into the selection
        if it = "" then
           put the selectedChunk into tSel
           put word 4 of tSel into word 2 of tSel
           put (word 4 of tSel) - 1 into word 4 of tSel
           select tSel
        end if
        doUndoSpace
        break
     case " " -- scriptPaint, control-shift-space
        put the mouseText into the selection
        doUndoSpace
        break
     default
        pass controlkeydown
  end switch
end controlkeydown
---------


On Nov 30, 2011, at 3:33 PM, Ralph DiMola wrote:

> poof editor closes, no compile and changes lost
> 
> Been there done that. I have a couple lost my edits tee shirts. A have
> abandoned the "Ctrl Insert"/"Shift Insert" but old habits are hard to break
> 
> 
> Mike Bonner wrote:
> 
> This is why I only use ctrl-c ctrl-v. It seems that shift-insert doesn't
> necessarily set the dirty bit in the script editor so I have caught myself
> pasting, hit enter to compile, since it doesn't think theres a change..
> poof editor closes, no compile and changes lost. ctrl-v works fine though
> so i've just forced myself out of the shift-insert habit.
> 
> On Wed, Nov 30, 2011 at 12:15 PM, Ralph DiMola
> <rdimola at evergreeninfo.net>wrote:
> 
>> Don't know if this is a related issue. On Windows at the clipboard in the
>> IDE GUI acts odd at times. Running XP SP3. Sometimes "Ctrl Insert"/"Shift
>> Insert" works sometimes not. "Ctrl C"/"Ctrl V" work reliably most of the
>> time. Sometimes pasting things from the clipboard to the LC IDE from
>> another
>> windows app works, sometimes not. I put some code on the clipboard in VB6.
>> It would not paste into LC, BUT I pasted to Windows notepad then again put
>> the select text on the clipboard from notepad and was able to paste into
>> the
>> LC IDE??? "Control C" will put selected text onto the clipboard from both
>> the IDE and the LC Dictionary. "Control Insert" works only from the IDE
>> but
>> not in the LC Dictionary. Other oddities exist. I think if you're at a
>> debugging breakpoint the rules of the clipboard change but I don't
>> remember
>> what happens. I also just the other day used the LC copy to attempt to put
>> something on the clipboard but it did not work. Thought it was my inner LC
>> newbie coming out and was going to look at the docs, now maybe not.
>> 
>> Ralph DiMola





More information about the Use-livecode mailing list