Kay C Lan wrote:

Unfortunately, Rev and CopyPaste don't get on :-(

I have a frontscript that lives in a plugin and automatically gets put in use whenever I launch Rev. Adding scriptpaint to it was a one-liner, I just did it a couple of minutes ago since it seems like such a great idea.

In case anyone else might find this useful, here are some details. The handler does these things:

1. Uses the standard HC keystrokes to edit card and stack scripts (Cmd-Opt-C and Cmd-Opt-S.) After 20 years of xtalk work, these are hard-coded into my brain. They are also the keystrokes MC uses, so I don't have to remember to change my habits when I'm in Rev.

2. Uses the standard HC keystroke Cmd-Opt-B to edit the first background (group) script if there is one. I do a lot of HC conversions, and every HC stack has a background on every card. Most of the time, this gets me where I want to go.

3. Exits if the target is not the script editor. If it is, checks to see if the shift key is down as well as the Command key. If so, executes these shortcuts:

4. Cmd-Shift-quote: put quotes around the selected text. If there is no selection, a pair of quotes is inserted with nothing between. I use it mostly for fixing imported HC scripts containing unquoted literals.

5. Cmd-Shift-equals or Cmd-Shift-hyphen: inserts the special marker I use for comments I want to look at again later. Has two triggers because I sometimes miss when I reach to the top of the keyboard without looking.

6. Cmd-Shift-9 or Cmd-Shift-0: bracket the selection with parentheses. If no selection, inserts a pair of parentheses. Good for writing functions or visually enclosing segments of multiple "if"s. Doesn't backtrack (see next.)

7. Cmd-Shift-[ or Cmd-Shift-]: same as parentheses, but inserts square brackets for arrays. This one also backtracks the insertion point so you can start typing in between them. I didn't backtrack for parentheses because most of the time I add parentheses to existing text. You could change it.

8. Cmd-Shift-space: New addition, does scriptPaint. Inserts the word under the mouse into the selection.


Here is the handler (watch for wrap):

on commandKeyDown whichKey
  -- HyperActive Software: Revolution and MetaCard frontscript
  if the optionKey is down and "revLibrary.rev" is in the frontscripts then
    switch whichKey
    case "s"
      edit script of this stack
      break
    case "c"
      edit script of this cd
      break
    end switch
    exit commandKeyDown
  end if
  if whichKey = "b" and there is a grp 1 then edit script of grp 1
  if "editor field" is not in the name of the target \
      or the shiftkey is not down
  then pass commandKeyDown
  switch whichKey
  case "'"
    put quote & the selection & quote into the selection
    break
  case "="
  case "-"
    put " -" & "-" & "#"&"#"&"#" into the selection
    break
  case "9"
  case "0"
    put "(" & the selection & ")" into the selection
    break
  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
end commandKeyDown

To make this load when Rev launches, put the handler into a button script in a new stack. Put this handler into the stack script:

on revPreOpenStack
  if "myScripts" is not in the frontscripts
  then insert the script of btn "myScriptBtn" into front
end revPreOpenStack

Put the stack in your plugins folder. Relaunch Rev. Use the Plugins Setting (Development menu) to open the stack invisibly when Rev starts up. Select "revPreOpenStack" from the list of messages to send.



--
Jacqueline Landman Gay         |     [EMAIL PROTECTED]
HyperActive Software           |     http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to