Underscore uncomment bug in OSX

Peter M. Brigham pmbrig at gmail.com
Fri Jul 24 16:13:50 CEST 2015


Here's the workaround that I have been using, in case others find it useful. I put it into a controlkeydown handler in my LC frontscript. All my script shortcuts use control-shift-<key>. The command doUndoSpace types a space and then deletes it, to make sure LC knows that editing has been done and the script needs re-checking. This may not be necessary in later LC versions (I operate still in 5.5 -- I know, I'm a dinosaur). So control-shift-<underscore> comments out a line or lines, control-shift-= uncomments a line or lines.

on controlkeydown which
   put the long name of the target into tarName
   put the shiftkey is down into shK
   switch which
      case "-"
      case "_" -- comment out the line -- until Rev fixes the commandkey shortcut
         if not shK then pass controlkeydown
         if "field" is not in tarName then pass controlkeydown
         if "revNewScriptEditor" is not in tarName then pass controlkeydown
         put the selectedLine into tLineCh
         put "-" & "-" into cmntChars
         if " to " is in tLineCh then
            put word 2 of tLineCh into stLineNbr
            put word 4 of tLineCh into endLineNbr
            repeat with n = stLineNbr to endLineNbr
               put "put cmntChars & space before word 1 of line" && n && "of" && tarName \
                     into theDo
               do theDo
            end repeat
            -- put scriptLinesText into line stLineNbr to endLineNbr of the target
            put endLineNbr into selectHere
         else
            put word 2 of tLineCh into lineNbr
            put the long name of the target into tLongName
            put sr(line lineNbr of the target) into tLineText
            do "put cmntChars & space before word 1 of" && tLineCh
            put lineNbr into selectHere
         end if
         doUndoSpace
         send "tabkey" to tarname -- to fix indenting
         select after line selectHere of the target
         break
      case "="
      case "+" -- uncomment the line -- until Rev fixes the commandkey shortcut
         if not shK then pass controlkeydown
         if "field" is not in tarName then pass controlkeydown
         if "revNewScriptEditor" is not in tarName then pass controlkeydown
         put the selectedLine into tLineCh
         if " to " is in tLineCh then
            put word 2 of tLineCh into stLineNbr
            put word 4 of tLineCh into endLineNbr
            put line stLineNbr to endLineNbr of target into scriptLinesText
            repeat with n = 1 to the number of lines of scriptLinesText
               put sr(line n of scriptLinesText) into tLineText
               if char 1 to 2 of tLineText = "-" & "-"
               then delete char 1 to 2 of tLineText
               put tLineText into line n of scriptLinesText
            end repeat
            put scriptLinesText into line stLineNbr to endLineNbr of the target
         else
            put sr(value(tLineCh)) into tLineText
            if char 1 to 2 of tLineText = "-"&"-" then
               delete char 1 to 2 of tLineText
               do "put tLineText into" && tLineCh
            end if
         end if
         doUndoSpace
         send "tabkey" to tarname
         break
      default
         pass controlkeydown
   end switch
end controlkeydown

private command doUndoSpace
   -- this solves the problem that after the above scripted 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

function sr pText
   return word 1 to -1 of pText
end sr

On Jul 23, 2015, at 6:30 AM, Alan Stenhouse wrote:

> The uncomment keyboard shortcut has never worked for me either, would love if it did.
> 
> Interestingly, after someone posted about holding open the menu and then trying it, it does work. Haven’t investigated further though.
> 
> Wonder if it’s possibly related to having multiple keyboard languages available. 
> 
> Was surprised to hear from many that it works fine for them…!! Thought that it was again, one of those things…
> 
> cheers
> 
> Alan
> 
> On 23 Jul 2015, at 12:00 pm, use-livecode-request at lists.runrev.com wrote:
> 
>> I normally work on a 2009 iMac, but I?ve just installed LC 7.1.0(dp1) on my 2015 MacBook Pro and it?s doing exactly the same as the iMac, i.e. it doesn?t work correctly and adding the system shortcut is only a partial workaround. The MBP is also on OS X 10.10.4.
>> 
>> I?ll head over to the bug report now.
>> 
>> Paul
>> 
>> 
>>> On Jul 22, 2015, at 17:59, Jerry Jensen <jhj at jhj.com> wrote:
>>> 
>>> Oh thank you Paul! I am not crazy (well, not about that anyway!). What model computer are you using?
>>> Yes, please add this to the comments in the bug report. I do think it will help.
>>> .Jerry
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list