On 07/18/2017 06:46 AM, Bob Hall via use-livecode wrote:
I’ve had the completion capability on my local dev environment for a couple of 
years via a plugin that I wrote. I wrestled with these same problems years ago. 
I actually find that it is benefitial to have BOTH completion and no 
completion. Having a setting to change this is combersome. It is an on-the-fly 
desire.

Here's my take on that... with a simple addition you can bracket existing text as well as inserting a pair in one place.

on rawKeyDown pKey
   local tBookmarks
   local tChunk

   if optionkey() = "down" then
      switch pKey
         case 34 # ok
            put quote&quote into tBookmarks
            break
         case 39 # ok
            put "''" into tBookmarks
            break
         case 57 #?
         case 40
            put "()" into tBookmarks
            break
         case 91 # ok
            put "[]" into tBookmarks
            break
         case 123 # ok
            put "{}" into tBookmarks
            break
         default
      end switch
   end if

   # see if we want to insert a pairing
   if tBookmarks is not empty then
      # this allows bracketing existing text
      put the selectedChunk into tChunk
      put char 2 of tBookmarks after the selectedChunk
      select tChunk
      put char 1 of tBookmarks before the selectedChunk
   else
      pass rawKeyDown
   end if
end rawKeyDown


Also, if the script editor is already in memory you don't need to insert a frontscript - just

set the behavior of stack "revSEEditorBehavior" to the long id of <button with this script>

but if the script editor hasn't already been loaded into memory I don't think you can do this without monkeypatching the SE startup script.

--
 Mark Wieder
 ahsoftw...@gmail.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

Reply via email to