Page 1 of 2
An option for line wrapping in the script editor, please
Posted: Wed Jul 27, 2011 7:17 pm
by Yann
I know this has been discussed already, but it puzzles me not to see at least an option in the preferences for automatic line wrapping. Coming from traditional text editors, I just can't get used to the way LiveCode's one behaves. And it is particularly annoying when you are working with an Apple Magic Mouse, make an accidental lateral swipe and lose the cursor for the 50th time in a day, OMG...
As for manual wrapping with the "\" character : sometimes it can be helpful, but I don't regard it as a general solution since it formats your code in a rigid manner. You should be able to resize your script window the way you like and see the lines wrap naturally, like in so many other script editors.
Pleaaaase RunRev !

Re: An option for line wrapping in the script editor, please
Posted: Wed Jul 27, 2011 11:41 pm
by BarrySumpter
Hey! Now that would be cool!
Are they smart enough to code wrap and not just word wrap?
if x = y or z = w
and zzz = wer
and uuu = ooo
Re: An option for line wrapping in the script editor, please
Posted: Fri Jul 29, 2011 3:32 am
by jacque
Yann wrote:
As for manual wrapping with the "\" character : sometimes it can be helpful, but I don't regard it as a general solution since it formats your code in a rigid manner. You should be able to resize your script window the way you like and see the lines wrap naturally, like in so many other script editors.
Pleaaaase RunRev !

It won't happen, I don't know any code editor that does that. In LiveCode, lines of script are delimited by return characters, and wrapping them without rigid returns would make them nearly impossible to read and parse. You'd triple your effort with little or no gain. It is easy currently to scan the first word of each line to see the intent and flow of the handler. In fact, that's one reason why continued lines are indented so much -- so the eye won't confuse them with new lines. In LiveCode, every line of script starts with a "verb" word, and it's easy to spot those with the current formatting.
A code editor is a different beast from a word processor. I'm betting if you give it a few weeks, you'll wonder why you wanted it to be.

Re: An option for line wrapping in the script editor, please
Posted: Fri Jul 29, 2011 3:50 am
by BarrySumpter
jacque wrote:... I don't know any code editor that does that. ...
Same here. In my limited experience of 30+ years in IT, that is.
Re: An option for line wrapping in the script editor, please
Posted: Tue Aug 02, 2011 8:45 pm
by Yann
Actually, I think we must be talking of different things - which can be due to the fact that English is not my native language... so, sorry for that.
By "automatic line wrapping", I mean the option you can find for example in TextWrangler (Display menu -> Soft Wrap Text) or which is activated by default in code editors like Xcode, Dashcode, AppleScript Editor, Coda, etc., just to name a few : reaching the end of a line when you type won't make the screen scroll horizontally, the extra words will rather be displayed on the following line(s). Just like in a LiveCode field with the "dontWrap" property set to false. Would such an option be hard to implement in the LiveCode editor - and ideally, in the message box too ?
Re: An option for line wrapping in the script editor, please
Posted: Wed Aug 03, 2011 5:49 pm
by jacque
You did fine, I understood what you meant. Your English is excellent, flawless enough that I didn't know you weren't a native.
Here's an example of what would happen if your idea was implemented. I'm hard-wrapping the lines here just because the forums field is so wide, but pretend the ends of each line have hit the maximum of the script editor for this example:
Code: Select all
if there is not a background "_DataGridTemplateInstructions_" of stack
tStackName then
copy group "_DataGridTemplateInstructions_" of stack kResourceStack to card
1 of stack tStackName
set the backgroundBehavior of group "_DataGridTemplateInstructions_" of card
1 of stack tStackName to true
end if
repeat with i = 1 to the number of cards of stack tStackName
if there is not a group "_DataGridTemplateInstructions_" of card i of stack
tStackName then
place group "_DataGridTemplateInstructions_" onto card i
set the bottomleft of group "_DataGridTemplateInstructions_" of card i to
0, the height of card i
end if
end repeat
Here is the same snippet as normally displayed:
Code: Select all
if there is not a background "_DataGridTemplateInstructions_" of stack tStackName then
copy group "_DataGridTemplateInstructions_" of stack kResourceStack to card 1 of stack tStackName
set the backgroundBehavior of group "_DataGridTemplateInstructions_" of card 1 of stack tStackName to true
end if
repeat with i = 1 to the number of cards of stack tStackName
if there is not a group "_DataGridTemplateInstructions_" of card i of stack tStackName then
place group "_DataGridTemplateInstructions_" onto card i
set the bottomleft of group "_DataGridTemplateInstructions_" of card i to 0, the height of card i
end if
end repeat
It is difficult to follow the logic in the first example because you can't skim the first word of each line to see what is happening. In the second example, I can see generally what is going on very quickly (except that this forum editor has wrapped one of the lines by itself):
if something
copy something
set something
end if
repeat for some condition
if something
place something
set something
end if
end repeat
The logic flow is immediately apparent. This is typical of all code editors. And even though not all languages use return characters to separate commands, coders almost always add the carriage returns anyway just to make it easier to read and follow.
Re: An option for line wrapping in the script editor, please
Posted: Wed Aug 03, 2011 10:53 pm
by BarrySumpter
Again, code wrap not word wrap.
Otherwise, word wrap is taking a step backwards.
In readability that is.
Re: An option for line wrapping in the script editor, please
Posted: Thu Aug 04, 2011 12:54 am
by jacque
I see. So the OP wants the same as what we have, only automatic without having to type the "\". And it would dynamically adjust.
Not a bad idea in that case. I don't know how possible it is.
Re: An option for line wrapping in the script editor, please
Posted: Thu Aug 04, 2011 1:37 am
by FourthWorld
jacque wrote:I see. So the OP wants the same as what we have, only automatic without having to type the "\". And it would dynamically adjust.
Not a bad idea in that case. I don't know how possible it is.
Apparently this has been requested for Eclipse too - request filed in March of 2003, updated yesterday; current status "Assigned":
https://bugs.eclipse.org/bugs/show_bug.cgi?id=35779
This could be done in LiveCode in less than the 8 years it's been outstanding in Eclipse.
Looking at it briefly in LC, it seems one could write a plugin that uses a frontScript to modify a couple properties of the field "script" of group "Editor" in the script stack.
The only downside would be the line numbers are off (well, the only technical downside; the productivity downside would be scrolling through text and never being able to know which line wraps are hard and which ones are soft, which may be why this has been a low priority for even something as popular as Eclipse).
Re: An option for line wrapping in the script editor, please
Posted: Fri Aug 05, 2011 11:56 am
by Yann
Thank you Jacqueline, Barry and Richard for your very informative answers. Needless to say, I'm enjoying LiveCode more and more every day. Already 2 commercial products released in less than one year, and 2 others almost ready : didn't even think this would be possible before starting to use LiveCode.
With a few adjustments in the IDE ergonomics and in text/graphic display performance (hardware acceleration some day ?) it will come even closer to perfection, from my point of view, for rapid development of powerful desktop/mobile apps. Kudos to the RunRev team and the helpful community.
Re: An option for line wrapping in the script editor, please
Posted: Fri Aug 05, 2011 6:29 pm
by mwieder
This could be done in LiveCode in less than the 8 years it's been outstanding in Eclipse.

Well, it took all of 30 seconds to implement in glx2 (plus a bit more to test it...) I set the dontWrap of the code storage field to false. Might work for LC's editor as well.
The reason this works is that what's displayed on the screen is the htmlText version of the script, and there carriage returns don't matter. The compiler works with the un-htmlized version of the script. Of couse, as Richard points out, some other things that rely on line numbers will probably fail, notably soft breakpoints and the "go to line" feature. But those are fixable as well.
Re: An option for line wrapping in the script editor, please
Posted: Fri Aug 05, 2011 6:51 pm
by FourthWorld
mwieder wrote:This could be done in LiveCode in less than the 8 years it's been outstanding in Eclipse.

Well, it took all of 30 seconds to implement in glx2 (plus a bit more to test it...) I set the dontWrap of the code storage field to false. Might work for LC's editor as well.
The reason this works is that what's displayed on the screen is the htmlText version of the script, and there carriage returns don't matter. The compiler works with the un-htmlized version of the script. Of couse, as Richard points out, some other things that rely on line numbers will probably fail, notably soft breakpoints and the "go to line" feature. But those are fixable as well.
Even if it took several days to finish it, you'd still be ahead of the Eclipse team by almost 8 years.

Re: An option for line wrapping in the script editor, please
Posted: Fri Aug 05, 2011 8:24 pm
by mwieder
Problem is, I'm still not convinced it's a good idea. The code just doesn't look right wrapped like that. It's quite a bit harder to see what's going on when you can't read a line of code all at once. My coding style is to break lines up with the "\" continuation character when they get too long, but I do it at logical breaks rather than at an arbitrary right border. And I try not to get long lines of code anyway because they get hard to read and maintain later on.
Re: An option for line wrapping in the script editor, please
Posted: Sat Aug 06, 2011 9:36 am
by Yann
In fact, this is why I was asking for a simple option in the script editor settings, like in TextWrangler : depending on your coding style - or on the type of project you are working on - you could choose one behavior or another.
Re: An option for line wrapping in the script editor, please
Posted: Sat Aug 06, 2011 4:23 pm
by BvG
- Check this checkmark: Properties (from edit menu) -> General -> livecode ui elements appear in list of stacks
- Open Application Browser from the Tools menu
- Go to revSETemplate (it's a substack of revNewScriptEditor) and open that stack ( if it does not show up, close and reopen the Application Browser)
- Activate "Select grouped" from the toolbar icons, or check "Select Grouped Controls" from the Edit menu
- Click on the script editor field (big blank area) to select it
- Open the Inspector by clicking on "Inspect" on the toolbar icons, or select "Object Inspector" from the Object menu.
- Uncheck "Don't Wrap" from the Inspector
- Save the stack (Ctrl-S)
Do this for every version of the IDE that you use (redo after future updates).
Note: Save may fail on newer Windows systems due to virtualization of the applications folder. Check online how to work around that.
I showed the long route above, so you can understand how I arrived at this two line solution:
Code: Select all
Set the dontWrap of field "script" of stack "revSETemplate" to false
Save stack "script" of stack "revSETemplate"