Explicit Variables again

J. Landman Gay jacque at hyperactivesw.com
Fri Oct 26 00:01:25 EDT 2012


On 10/25/12 7:04 PM, Peter Haworth wrote:
> Ho Jacque,
> Just been playing around with this and there seems to be a problem using
> command-z to undo - leaves garbage in the script field?

Yes, it can do that. The insertions the script makes aren't known to the 
editor. Undo is tracked by character position and those have changed 
behind its back. I've become so used to it that I automatically save the 
script after I use any of the frontscript features. Since the script was 
always just for my personal use, I never bothered to harden it.

Last week I added a variation on Peter Brigham's "type space" fix, which 
I've been meaning to do for ages. I haven't tested it much but so far 
it's working. Forcing the editor to recognize the script changes may 
also fix the undo problem (but I haven't really paid attention to that 
yet.) Anyway, here's what I'm using now:

on commandKeyDown whichKey
   if ("editor field" is not in the name of the target and "script" is 
not in the name of the target) \
         or the shiftkey is not down
   then pass commandKeyDown
   switch whichKey
     case quote
     case "'"
       put quote & the selection & quote into the selection
       break
     case "v" -- paste only plain text
       put the clipboardData["text"] into the selection
       break
     case "9"
     case "0"
     case "("
     case ")"
       put "(" & the selection & ")" into the selection
       break
     case "["
     case "]"
     case "{"
     case "}"
       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
       break
     case " " -- scriptPaint
       put the mousetext into the selection
       break
     default
       pass commandKeyDown
   end switch
   setEditorDirty
end commandKeyDown

private command setEditorDirty
   type space
   delete char (word 4 of the selectedchunk) of the target
end setEditorDirty



-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the Use-livecode mailing list