ACE code editor (cloud-9)

334 views
Skip to first unread message

Mariano Reingart

unread,
Mar 12, 2012, 5:55:19 PM3/12/12
to web2py-d...@googlegroups.com
I'm looking to the ACE code editor per suggestion of a pycon attendee,
it seems quite promising, supporting several languages and some
features we need (like line markers for syntax errorrs and debug
breakpoints), and also it says that support big files (+100K lines),
and It is LGPL btw.

The API is here:

https://github.com/ajaxorg/ace/wiki/Embedding---API

The demo:

http://ace.ajax.org/build/kitchen-sink.html

The only problem I'm facing is that it is HUGE (6MB, 10 times editarea).
I don't know if it can be compressed, I'm still figuring it out.

What do you think?

Best regards,

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com

Mariano Reingart

unread,
Mar 12, 2012, 7:53:57 PM3/12/12
to web2py-d...@googlegroups.com
First screenshot...

(look the code fold feature)

I could reduce the src folder to around 361KB, without workers (I
think the syntax checkers for css and javascript: 1MB) and with only
the used syntax modes (python, html, css, js, json, xml, text), but
including visual themes (54KB) and even keybindings for emacs and vim
;-)

Do I must continue? or do we look for other options?

web2py_ace_editor.png

Massimo DiPierro

unread,
Mar 12, 2012, 10:46:40 PM3/12/12
to web2py-d...@googlegroups.com
emacs bindings. I am sold.

Looks like we only need:
/build/src/ace.js
/build/src/keybinding-emacs.js
/build/src/mode-css.js
/build/src/mode-python.js
/build/src/mode-javascript.js
/build/src/mode-coffeescript.js
/build/src/theme-clouds.js

and perhaps

worker-coffee.js
worker-css.js
worker-javascript.js
worker-json.js

not sue what the latter files do.

> --
> mail from:GoogleGroups "web2py-developers" mailing list
> make speech: web2py-d...@googlegroups.com
> unsubscribe: web2py-develop...@googlegroups.com
> details : http://groups.google.com/group/web2py-developers
> the project: http://code.google.com/p/web2py/
> official : http://www.web2py.com/

Massimo DiPierro

unread,
Mar 12, 2012, 10:48:03 PM3/12/12
to web2py-d...@googlegroups.com
Love this. I would stick with black on white instead of white on black.

> --
> mail from:GoogleGroups "web2py-developers" mailing list
> make speech: web2py-d...@googlegroups.com
> unsubscribe: web2py-develop...@googlegroups.com
> details : http://groups.google.com/group/web2py-developers
> the project: http://code.google.com/p/web2py/
> official : http://www.web2py.com/

> <web2py_ace_editor.png>

Anthony

unread,
Mar 12, 2012, 11:11:28 PM3/12/12
to web2py-d...@googlegroups.com
Overall, I like it (agree with Massimo it should be dark text on white/light background). One benefit is that this works in IE9 (EditArea does not). On the downside, Ace does not have syntax highlighting in IE8, and it doesn't work at all in IE7 (EditArea works in IE8 and IE7, though with a minor display quirk). I only tested the online demo, though -- maybe we can get it to work in admin. Anyway, not a big deal given that older IE usage is falling off (particularly among folks who would be using web2py).

Anthony

Massimo DiPierro

unread,
Mar 12, 2012, 11:25:19 PM3/12/12
to web2py-d...@googlegroups.com
i think we can assume developers have a current browser. ;-)
If not, they better upgrade.

Anthony

unread,
Mar 12, 2012, 11:33:43 PM3/12/12
to web2py-d...@googlegroups.com
I agree. :-)

Ross Peoples

unread,
Mar 13, 2012, 11:38:08 AM3/13/12
to web2py-d...@googlegroups.com
The breakpoint feature would be really nice. Would it be possible to debug using the web interface? There have been several times where an app does something weird in production and I have to stop it, manually start it from a console, and edit the source file to add "import pdb; pdb.set_trace()", then play with it until it gets fixed. Then I have to remember to remove the breakpoint from production, and start it back up in Apache or Nginx. I usually have to do this through an SSH session, so being able to debug through the web interface would be HUGE.

I have also run into issues where an app runs fine in Rocket, but acts strangely when run in WSGI. Debugging through the web interface would allow me to debug these issues, since putting a breakpoint in code running in WSGI usually causes requests to fail with Bad Quit.

Mariano Reingart

unread,
Mar 13, 2012, 2:44:20 PM3/13/12
to web2py-d...@googlegroups.com
On Tue, Mar 13, 2012 at 8:38 AM, Ross Peoples <ross.p...@gmail.com> wrote:
> The breakpoint feature would be really nice. Would it be possible to debug
> using the web interface? There have been several times where an app does
> something weird in production and I have to stop it, manually start it from
> a console, and edit the source file to add "import pdb; pdb.set_trace()",
> then play with it until it gets fixed. Then I have to remember to remove the
> breakpoint from production, and start it back up in Apache or Nginx. I
> usually have to do this through an SSH session, so being able to debug
> through the web interface would be HUGE.

That is already possible since 1.99.5:

http://reingart.blogspot.com/2012/02/new-web2py-online-python-debugger.html

What this editor enables it to being able to mark the breakpoints in
the editing windows (i.e. with a red sign near the line number),
and/or highlight the currrent line.
It also open new possibilities like autocompletion, calltips,
hovering, syntax checking and error mark/highlight, etc.
It has better configuration and addons scheme as it is being used by
github to make a full web IDE (cloud-9, but I think only works for
js).

> I have also run into issues where an app runs fine in Rocket, but acts
> strangely when run in WSGI. Debugging through the web interface would allow
> me to debug these issues, since putting a breakpoint in code running in WSGI
> usually causes requests to fail with Bad Quit.

If you don't use multiples process (but use multiple threads), you can
use the online web2py debugger.
If you use a multiprocess setup, you can use my IDE (rad2py) to
remotelly attach to a production server (I'm working on the
webservices admin to ease all the steps as it is not trivial right
now)

> On Monday, March 12, 2012 10:46:40 PM UTC-4, Massimo Di Pierro wrote:
>>
>> emacs bindings. I am sold.

:-)

>> Looks like we only need:
>> /build/src/ace.js
>> /build/src/keybinding-emacs.js
>> /build/src/mode-css.js
>> /build/src/mode-python.js
>> /build/src/mode-javascript.js
>> /build/src/mode-coffeescript.js
>> /build/src/theme-clouds.js

exactly

>> and perhaps
>>
>> worker-coffee.js
>> worker-css.js
>> worker-javascript.js
>> worker-json.js
>>
>> not sue what the latter files do.

I think they do on-the-fly syntax checking.

Ross Peoples

unread,
Mar 13, 2012, 4:00:54 PM3/13/12
to web2py-d...@googlegroups.com
Mariano,

This sounds great. So the features mentioned in the post you linked are included in 1.99.5, right? So no need to download the customized web2py installation because it's included already? I haven't pulled from the trunk for a while, so I'll have to play with this. It sounds like the cloud9 / ACE editor would bring a lot of good things to web2py's built in IDE.

Anthony

unread,
Mar 13, 2012, 4:08:55 PM3/13/12
to web2py-d...@googlegroups.com

It has better configuration and addons scheme as it is being used by
github to make a full web IDE (cloud-9, but I think only works for
js).

There is an open-source version of the full-fledged Cloud9 IDE (which uses the Ace editor), and it can be used for Python coding, but it requires running Node.js  (though it does include the Node binary, so I guess you don't need a separate install for that).


They also offer a cloud hosted service (free for open source projects, paid otherwise): http://c9.io/

Anthony
 

Mariano Reingart

unread,
Mar 13, 2012, 9:11:25 PM3/13/12
to web2py-d...@googlegroups.com
Finally, web2py + ace in my clone:

http://reingart-web2py.googlecode.com/

hg clone https://rein...@code.google.com/r/reingart-web2py/

Pull against trunk:

hg pull https://code.google.com/r/reingart-web2py/

It is working like textarea, there are two new config variables in
admin/models/0.py:

## Default editor
TEXT_EDITOR = 'ace' or 'edit_area' or 'amy'
## Editor Color scheme (only for ace)
TEXT_EDITOR_THEME = "chrome" ...
## Editor Keyboard bindings (only for ace)
TEXT_EDITOR_KEYBINDING = '' #'emacs' or 'vi'

If this work well, I'll add nicer markers to breakpoints, and, maybe,
line highlight / autocomplete.

If anyone want to help, welcome!!!!!

Please, help me to test it!

Best regards

> --
> mail from:GoogleGroups "web2py-developers" mailing list

> make speech: web2py-d...@googlegroups.com
> unsubscribe: web2py-develop...@googlegroups.com

Massimo DiPierro

unread,
Mar 13, 2012, 9:21:29 PM3/13/12
to web2py-d...@googlegroups.com
If I pull this, do I get all of your recent changes?

Mariano Reingart

unread,
Mar 13, 2012, 9:27:37 PM3/13/12
to web2py-d...@googlegroups.com
Yes, my clone includes the webservices and app_pack fixes too
(7e9759bb4e96, e4a9d387b685)

Best regards,

Massimo DiPierro

unread,
Mar 13, 2012, 10:17:39 PM3/13/12
to web2py-d...@googlegroups.com
Pulled and merged. Well done. Did you include emacs bindings? How can they be added?

Massimo

On Mar 13, 2012, at 8:11 PM, Mariano Reingart wrote:

Mariano Reingart

unread,
Mar 14, 2012, 1:31:46 AM3/14/12
to web2py-d...@googlegroups.com
Great!

Yes, I've included the binding, look at applications/admin/models/0.py
configuration:

TEXT_EDITOR_KEYBINDING = 'emacs' or 'vi'

It should work (it was adapted from the example).
The problem is I don't know what the emacs keypresses are :P

BTW, we can add commands and binding as we want (see the Ctrl+S example).

Best regards,

Reply all
Reply to author
Forward
0 new messages