Editor Frustration!

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
kcorey
Posts: 62
Joined: Fri Nov 25, 2011 6:06 pm

Editor Frustration!

Post by kcorey » Fri Dec 16, 2011 10:17 am

Hi All,

Can anyone help a Livecode newbie fix the editor key configuration (and maybe make the script editor more usable)?

I'm from a Linux/Windows background...there are a set of little niggles with the editor that combine to make using it incredibly frustrating. Most mac programs respect the requested key bindings modified according to this page:
http://lifehacker.com/225873/mac-switch ... d-end-keys
...but not Livecode.

1) Cmd-arrow to go to the beginning/end of line, doesn't. There's some sort of smart indenting going on with the caret so that if I cmd-left-arrow, the caret is advanced to the beginning of text, not the beginning of line.
2) "home" and "end" keys don't. They take me to the top/bottom of the script.

Why is this frustrating?

Take the code:

on stopGame
put false into sGameRunning
stopUpdatingTheScreen
end StopGame

Let's assume I want to delete the line "stopUpdatingTheScreen".

My muscle memory says to:
arrow up until I'm on the line
press the "home" key
hold the shift key down while pressing the down arrow to select the line
backspace/cmd-x the line

Of course, follow those keystrokes in Livecode, and you're looking at the remains of the top of the document...growling. cmd-z, cmd-z.

Okay, let's try again:
scroll around to find the place I was working.
arrow onto the line
use cmd-left arrow to go to the "beginning"
shift-down to select a "line"
The selected area now includes the 'en' at the beginning of the 'end stopGame' line. Anything I do now breaks that line as well. Argh!

Finally, I end up using the mouse to select the line, remind myself to use cmd-x/cmd-c/cmd-v instead of ctrl, and I'm (finally) editting again, trying to pick up the train of thought again.

After an enthusiastic Army/college experience, I cannot deny I've probably only got 3-4 brain cells working now and two of them are keeping the heart and lungs going. I enjoy using what's left to learn new things (like Livecode), but that means there's none to fight with muscle memory in my fingers. Every time this happens I forget what I was working on, and practice my Bad Words.

Anyone have any suggestions? (I want to keep using this on the Mac, as I plan on targetting iOS devices eventually.)

-Ken

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Editor Frustration!

Post by dunbarx » Fri Dec 16, 2011 3:22 pm

Not sure I feel your pain.

I just triple click a line to select it. If you want to delete, press "delete". Double clicking, of course, selects only the underlying word.

Craig newman

kcorey
Posts: 62
Joined: Fri Nov 25, 2011 6:06 pm

Re: Editor Frustration!

Post by kcorey » Fri Dec 16, 2011 6:15 pm

Ah, but I have to triple click. The mouse. To the right of the keyboard. Which means I need to move my arm.

Since that's not the motion my muscle memory is expecting (and seems significantly slower to me than hitting the keys under my fingers), I keep getting caught out. I'm thinking about the code, about the capabilities of LiveCode, about what I'm trying to accomplish. Not about exactly what effect each keystroke is going to have on my code.

I just start getting into the programming zone, and I get the effect of someone walking up behind me and striking me on the back of the head, and then laughing while I pick up the pieces. Not a brilliant sensation.

If I were shifting totally over to the Mac world, maybe that'd be okay. I'd just "get used to it". However, I'm not. I have a Windows PC, a Mac, and a Terminal shell open with a Linux box. Heck, even on the Mac, in OS X, I can use vi from the command line (just to be more sacreligious, I'd prefer it, truth be told).

All I really need is for the editor to respect the change I've made to the keymapping (like all other programs I've tried seem to do), and to be able to turn off the smart indents for beginning-of-line keystroke.

-Ken

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Editor Frustration!

Post by mwieder » Fri Dec 16, 2011 6:41 pm

Ken-
1) Cmd-arrow to go to the beginning/end of line, doesn't. There's some sort of smart indenting going on with the caret so that if I cmd-left-arrow, the caret is advanced to the beginning of text, not the beginning of line.
2) "home" and "end" keys don't. They take me to the top/bottom of the script.
I'm doing this on linux at work right now, so I can't duplicate your mac experience until I get home later, but...

the "home" and "end" keys take me to the start and end of the current text line

since I'm not at a mac right now I don't have a command key to experiment with, but control-arrow moves a word at a time, more or less as I would expect.

I guess I've used the editor for enough years that the auto-indenting thing seems natural. After time I'm sure it will feel that way to you, too. The indenting is as important in LiveCode as it is in python. It's an indicator of the validity of nesting level, it ensures that you can match your if/end if repeat/end repeat structures, etc. If you really feel the need to disable it, go to Preferences | Script Editor and uncheck Auto Format. But I think you'll find life easier if you leave it on.

kcorey
Posts: 62
Joined: Fri Nov 25, 2011 6:06 pm

Re: Editor Frustration!

Post by kcorey » Fri Dec 16, 2011 7:39 pm

Hiya,

Just to clarify: I don't want to turn off all smart-indenting. The last couple of years I've been programming Python, and I *love* well indented code, especially when that's automatically maintained. Good stuff!

What I'm saying is that if I use a key stroke sequence to go to the beginning of the line, that should be respected. I didn't want to go to the first character, because then highlighting the rest of the line (and only this line) is a bother, breaks my rhythm, and forces me to modify my typing habits to suit the editor.

-Ken

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Editor Frustration!

Post by mwieder » Fri Dec 16, 2011 7:58 pm

Ah, ok - got it.

Philosophically I hate the fact that Python *forces* me to do what I want to do anyway... I'd like to think that I have control over the formatting, but whatever. <g>

Anyway, the editor is a bit quirky for some historical reasons and isn't likely to change too much. I don't use it myself. We've got glx2 available as an open-source tool https://bitbucket.org/mwieder/glx2/downloads, but we've kept most of the script editor keyboard equivalents, and there is a thread on the listserv about using external text editors on the mac.

You might want to check out Ken Ray's resource at:
http://www.sonsothunder.com/devres/revo ... Editor.htm

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Editor Frustration!

Post by jacque » Sun Dec 18, 2011 8:31 pm

You can use the script editor of your choice and link it into LiveCode. Assign the app in preferences.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Editor Frustration!

Post by mwieder » Sun Dec 18, 2011 10:03 pm

? On my planet we don't have a preference like that.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Editor Frustration!

Post by jacque » Sun Dec 18, 2011 10:22 pm

Hm, I had to go look. It isn't there now for me either. Maybe I'm mis-remembering or I hallucinated it. The interface is still there, I still sometimes get a spurious error message about how the script was edited in an external editor.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Editor Frustration!

Post by mwieder » Sun Dec 18, 2011 10:37 pm

Well, we do that with glx2, but it has to be explicitly shoehorned in. The external script editor has to be able to handle stdin and stdout piping in order to hand the modified script back to LC. I don't see how this could be done in a generic way with the current IDE coding.

kcorey
Posts: 62
Joined: Fri Nov 25, 2011 6:06 pm

Re: Editor Frustration!

Post by kcorey » Tue Dec 20, 2011 5:26 pm

Great answers, and I love the editting available in GLX2 or an external like textmate (which behaves more or less like my fingers expect)...

...but I think I'm still going to stick with the built-in editor. *sigh* As a rank beginner, I spend at least as much time in the debugger as I do in the editor, and if I turn /on/ the external editor, in effect I turn /off/ using the built-in editor, it seems.

Thanks all,

-Ken

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Editor Frustration!

Post by jacque » Tue Dec 20, 2011 6:06 pm

The editor behavior is all scripted, so as a last resort you could script your own behaviors. I actually do this to add some functionality to the editor that it doesn't already have. The basic idea is to insert a frontscript when the IDE starts up, which you can do by creating a custom plugin. The script would have a rawkeydown handler, check the target to make sure it's the editor field, and if so, catch the keys you want to cusomize and change how they work.

The basic idea:

Code: Select all

on rawKeyDown pKey
  if ("editor field" is not in the name of the target and "script" is not in the name of the target)
  then pass rawKeyDown
  switch pKey
    case <whatever the keycode is for "home">
      -- select beginning of line
      break
    case <keycode for "end">
      -- select end of line
      break
    case -- etc
  end switch
end rawKeyDown
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Editor Frustration!

Post by mwieder » Tue Dec 20, 2011 6:27 pm

Ken-

Yes, the IDE's built-in debugger is hopelessly entangled with the built-in script editor. I should point out, however, (ahem...) that PowerDebug works with both glx2 and the IDE's editor, so you're free to use either one as desired. You can check out the trial version of PowerDebug on revOnline (http://revonline2.runrev.com/stack/507/PowerDebug). Or try the interactive demo in a revlet at http://www.ahsoftware.net/PowerTools/Po ... DDemo.html.

http://www.ahsoftware.net/PowerTools/BuyPowerDebug.irev

Post Reply