CodeMirror 2 has entered beta!

Showing 1-30 of 30 messages
CodeMirror 2 has entered beta! Marijn Haverbeke 2/8/11 8:22 AM
Please see the manual at http://codemirror.net/2/manual.html to find
out more about it. The demo is still at http://codemirror.net/2 , with
the ported CSS and XML modes at http://codemirror.net/2/mode/css and
http://codemirror.net/2/mode/xml .

Bug reports are very welcome. Please create github issues (
https://github.com/marijnh/codemirror2/issues ) so that I can properly
keep track of them.

If somebody wants to port a CodeMirror 1 parser to version 2, poke me
and I'll hurry up and add the 'writing a parser' section to the
manual. I will probably also build a 'wrapper' for old parsers, and
supply the CM1 parsers wrapped that way, but this will necessarily be
somewhat clunky and slow, since the interface changed racially (it got
a lot less weird).

Re: CodeMirror 2 has entered beta! Marijn Haverbeke 2/8/11 8:29 AM
Okay, reading that over, I feel I should actually market this more.

So:

* CodeMirror 2 deals with huge documents without trouble, because it
only puts the visible content in the DOM tree.

* Highlighting is now much, much faster because it doesn't directly
manipulate the DOM, and because the parser API is much less indirect.

* There is now an API for highlighting arbitrary pieces of text. The
highlighted text will deal well with being edited.

* There is also support for marking lines by putting stuff in the
line-number gutter.

* CodeMirror 2 support tabs. Supports them pretty well.

* The new API is much cleaner than the old one.

* The code is only 30k when put through UglifyJS. Take that, ACE.

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Tom Gleason 2/8/11 8:31 AM
That sounds great! I'll definitely be taking a look at this if I get a chance.
Thanks for all your work on CodeMirror. It has been a real help for
several of my projects.

> --
> You are receiving this because you are currently a member of the CodeMirror Google group. To send something to list, use codem...@googlegroups.com, to unsubscribe, send a message to codemirror-...@googlegroups.com.

--
Tom Gleason, PHP Developer

Exploring ResourceSpace at:
http://resourcespace.blogspot.com

ResourceSpace Support Services
https://www.buildadam.com/muse2

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Benoit Chesneau 2/8/11 8:33 AM
> --
 Thar's awesome news, thanks for the release :) Time to test.

- benoît

Re: CodeMirror 2 has entered beta! Marijn Haverbeke 2/8/11 8:33 AM
Ugg, typo. The parser interface changed *radically*, not racially. I
don't think APIs have races.
Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Jacob Lee 2/8/11 8:34 AM
Exciting to hear! I'll try to spend time this week trying the new
version and filing bugs.

On Tue, Feb 8, 2011 at 11:29 AM, Marijn Haverbeke <mar...@gmail.com> wrote:
> --
> You are receiving this because you are currently a member of the CodeMirror Google group. To send something to list, use codem...@googlegroups.com, to unsubscribe, send a message to codemirror-...@googlegroups.com.
>

--
Jacob Lee <jac...@google.com>

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! zalun 2/8/11 8:40 AM
Will it support wrapping lines?

--
blog http://piotr.zalewa.info
jobs http://webdev.zalewa.info
twit http://twitter.com/zalun
face http://www.facebook.com/zaloon

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Marijn Haverbeke 2/8/11 8:44 AM
> Will it support wrapping lines?

No. And that's a final, solemn "no". I spent two days trying to find a
way to do this, but line wrapping is just completely at odds with the
techniques used in CodeMirror 2 -- there is no way to ensure you get
the same wrapping in the hidden textarea, and showing only the visible
lines becomes much more awkward and slow when you have to take
line-wrapping into account.

I rather like line-wrapping myself, but it's just not going to work.

Re: CodeMirror 2 has entered beta! fabian...@googlemail.com 2/8/11 8:46 AM
Hi Martijn,

nice to see some of the Ace concepts coming to CodeMirror. The changes
look awesome.
:-D With Ace we are currently at about 180k - quite a bit bigger but
not totally out of proportion. I guess CodeMirror2 will also gain some
weight as it comes along.

Best,
Fabian
Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Marijn Haverbeke 2/8/11 8:51 AM
> Hi Martijn,

Heh, you're not Dutch are you? Looks like you've already adjusted to
the Netherlands long enough to misspell my name. It's Marijn --
Martijn is indeed more common.

> :-D With Ace we are currently at about 180k

I know, hence the jab ;)

I don't expect to grow all that much beyond this -- the API is pretty
much equivalent to CM1 at this point, and CodeMirror has always aimed
at minimalism.

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Mihai Călin Bazon 2/8/11 8:59 AM
It's irritatingly fast! :-)

One thing, it would be nice to have the TAB key always indent the
current line instead of inserting tab characters. ;-)  (or was that
intentional?)

Cheers,
-Mihai

> --
> You are receiving this because you are currently a member of the CodeMirror Google group. To send something to list, use codem...@googlegroups.com, to unsubscribe, send a message to codemirror-...@googlegroups.com.

--
Mihai Bazon,
http://mihai.bazon.net/blog

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Marijn Haverbeke 2/8/11 9:01 AM
> One thing, it would be nice to have the TAB key always indent the
> current line instead of inserting tab characters. ;-)  (or was that
> intentional?)

In the old version, the emacs way was the default. These days, I've
come to realize that most people aren't emacs heads. You can set the
tabMode option to "indent" to get the behaviour you want (RTFM, and
all that ;).

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Fabian Jakobs 2/8/11 9:06 AM
> Heh, you're not Dutch are you? Looks like you've already adjusted to
> the Netherlands long enough to misspell my name. It's Marijn --
> Martijn is indeed more common.

Oh, I'm sorry. I'm German but work now in the Netherlands and yes I
think I have heard the name Martijn already a couple of times.

>> :-D With Ace we are currently at about 180k
>
> I know, hence the jab ;)

We can take it :)

> I don't expect to grow all that much beyond this -- the API is pretty
> much equivalent to CM1 at this point, and CodeMirror has always aimed
> at minimalism.

With Ace we go in the direction of a full featured editor but I hope
we don't get too fat.

Met vriendelijke groeten,
Fabian

Re: CodeMirror 2 has entered beta! MtnViewMark 2/8/11 11:35 AM
Oh, this rocks!

I'm going to convert my project, Barley ( a web based development environment and tutorial for Haskell ) to use it as soon as possible. Alas, first live use by students will be this weekend (!) and I don't think I'll have time to convert it before then.

I do have a Haskell parser that will need to be ported. So, as soon as you have docs up on the new API, I'll start converting.

I also currently put things in the line number gutter (for in-line error messages). If I can port that to use the new API great, if not, I'll let you know why I needed to continue to roll-my-own.

Thanks again!
Re: CodeMirror 2 has entered beta! Marijn Haverbeke 2/10/11 4:31 AM
There is now a section on writing new modes in the manual (
http://codemirror.net/2/manual.html#modeapi ), and I've written a
mixed-mode HTML parser (in 64 lines) and a diff parser (in 14 lines)
to convince myself that the current API is workable for all kinds of
modes.

If anyone wants to try their hand a porting a CodeMirror 1 mode (or
rewriting one -- some of them are quite a mess), I would very much
welcome the help, and I'll happily answer any questions you have.

Cheers,
Marijn

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Erik Muttersbach 2/8/11 11:04 PM
That sounds quite promising, I am excited to check it out! How about
the new modes? Are they compatible with the languages of CodeMirror 1?
Is the process of integrating a new language the same/similar?

Sincerely,
Erik

> --
> You are receiving this because you are currently a member of the CodeMirror Google group. To send something to list, use codem...@googlegroups.com, to unsubscribe, send a message to codemirror-...@googlegroups.com.
>

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Marijn Haverbeke 2/11/11 11:51 AM
> How about
> the new modes? Are they compatible with the languages of CodeMirror 1?
> Is the process of integrating a new language the same/similar?

Not compatible. The mode API is similar, but quite a bit simpler. I
intend to write code that wraps CM1 modes to work with CM2 at some
point.

Re: CodeMirror 2 has entered beta! Superskunk 2/14/11 5:19 PM
Hello,

I'm very excited by this beta!
I was wondering if the PHP parser was on on todo list ?

Thanks in advance!
Re: CodeMirror 2 has entered beta! MtnViewMark 2/14/11 7:09 PM
I got most of the way integrating CM2 into my project where CM1 had been before. Converting the mode seemed straightforward --- and made my parser smaller -- though I've not yet gotten it to work.

Other than that, everything seems relatively the same for me with two exceptions:
1) saveFunction seems to be missing. Is this because CM2 no longer traps control-S? If so, fine, I'll do it myself (probably better that way) - but if it is grabbing control-S, then I'll need the hook, no?

2) height dynamic is missing. again, I can do this myself -- if I know what to resize in CM2. Perhaps, it would be best if CM2 had a resize API so that all the parts can move correctly?

 - Mark
Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Marijn Haverbeke 2/14/11 10:55 PM
> 1) saveFunction seems to be missing. Is this because CM2 no longer traps
> control-S? If so, fine, I'll do it myself (probably better that way) - but
> if it is grabbing control-S, then I'll need the hook, no?

It no longer grabs ctrl-s. Call getInputField and register your own
key handler. Should be a more flexible solution anyway.

> 2) height dynamic is missing. again, I can do this myself -- if I know what
> to resize in CM2. Perhaps, it would be best if CM2 had a resize API so that
> all the parts can move correctly?

This can be done with styling. Modify the CodeMirror class to remove
the fixed height and the "overflow: auto". Should be much less flaky
(as it will use the native DOM sizing, rather than a scripted hack
that resizes a frame).

Re: CodeMirror 2 has entered beta! Michael Heilemann 2/18/11 9:46 AM
The lack of line wrapping is a major show stopper, certainly for me,
but I'm sure also for a lot of others. Just wanted to throw that out
there.
Re: [CodeMirror] Re: CodeMirror 2 has entered beta! zalun 2/18/11 9:51 AM
On 02/18/11 17:46, Michael Heilemann wrote:
> The lack of line wrapping is a major show stopper, certainly for me,
> but I'm sure also for a lot of others. Just wanted to throw that out
> there.

++


--
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Peter Kroon 2/18/11 11:03 AM
Hello Marijn,

I'm very pleased to see that codeMirror 2 has gone to beta!
I have been testing a little and I can only use 1 mode on one page
with multiple editor instances at the same time? Is this correct?
Can you provide an example with 2 modes on one page? So 1 editor for
css and the second editor for javascript.

Best,
Peter

2011/2/18 Piotr Zalewa <zal...@gmail.com>:

> --
> You are receiving this because you are currently a member of the CodeMirror Google group. To send something to list, use codem...@googlegroups.com, to unsubscribe, send a message to codemirror-...@googlegroups.com.

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Peter Kroon 2/18/11 11:08 AM
Hello Marijn,

When I load http://codemirror.net/2/mode/javascript/ in IE
9.0.8080.16413 it will not function properly.
This is what I recieve from console:

SCRIPT1002: Syntaxisfout
codemirror.js, regel 1460 teken 45
SCRIPT5009: CodeMirror is niet gedefinieerd
javascript.js, regel 1 teken 1
SCRIPT5009: CodeMirror is niet gedefinieerd
javascript, regel 65 teken 7

Hope this helps.

Best,
Peter

2011/2/18 Peter Kroon <plak...@gmail.com>:

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Marijn Haverbeke 2/18/11 11:09 AM
> I'm very pleased to see that codeMirror 2 has gone to beta!
> I have been testing a little and I can only use 1 mode on one page
> with multiple editor instances at the same time? Is this correct?

No. It will default to the first mode that was loaded, but if you
specify a mode: option, you can select a different mode for each
instance. (Or, if you can't that's a bug.)

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Marijn Haverbeke 2/18/11 11:11 AM
> SCRIPT1002: Syntaxisfout
> codemirror.js, regel 1460 teken 45
> SCRIPT5009: CodeMirror is niet gedefinieerd

Interesting. That line looked like

    else if (option == "mode" || option = "indentUnit") setMode(value);

Note the single = in the second compare. So that was a bug, but it was
also valid JavaScript. So uhh, I don't understand why IE chokes on it,
but I'm glad it pointed it out to me.

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Marijn Haverbeke 2/18/11 11:12 AM
Hi Michael,

> The lack of line wrapping is a major show stopper, certainly for me,
> but I'm sure also for a lot of others. Just wanted to throw that out
> there.

Right, I mentioned before that I am also partial to line-wrapping, and
tried hard to get it integrated in a decent way, but concluded the
extra complexity and degraded performance wasn't worth it. Everybody
is, of course, free to hack on this.

Best,
Marijn

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Matt Passell 2/18/11 11:30 AM
Hi Marijn,

Just so you know, I never turn on line-wrapping, so I'm happy that you didn't try to jump through hoops to support it in CM2. :)

Thanks,
Matt
Re: [CodeMirror] Re: CodeMirror 2 has entered beta! zalun 2/18/11 11:57 AM
Is it hard to implement due to line numbers? Or any other reason?

--
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

Re: [CodeMirror] Re: CodeMirror 2 has entered beta! Marijn Haverbeke 2/18/11 12:35 PM
> Is it hard to implement due to line numbers? Or any other reason?

Not line numbers. There are two problems. Firstly, CodeMirror only
'renders' the visible lines, and figuring out which lines are scrolled
into view when lines can be wrapped becomes more difficult (same for
detemining the cursor location, or figuring out which character a
mouse click hit). This can be done though, if a bit slower than the
current set-up. The main problem, though, is that CodeMirror uses a
hidden textarea both for input and for 'local' cursor-movement -- the
textarea will contain the selected text plus a few lines around that,
and will be used to handle, for example, pressing the up or left arrow
('non-local' movement like page up is handled through key events).
Line wrapping not only makes cursor placement much more complicated
(ever notice that a cursor can show up in two different places for a
single character position on a wrapped line?), but requires us to
somehow synchronize the wrapping between the dom and the textarea. I
figured this could be done by ensuring both had the same font and the
same weight, but it turns out that browsers use (for some reason)
different wrapping algorithms in text controls (probably handled by
the native OS widget) and the DOM (handled by the browsers itself).
Thus, if the wrapping in the textarea does not match the wrapping that
you're seeing, pressing up or down will result in the wrong behaviour
-- you won't go straight up or down.

Hope that clarifies things a bit. The reason I'm using the textarea
like this is that I want to sidestep super-hairy things like
generalized re-binding of keys. Both because it'd make the editor more
heavyweight, and because it'd be an endless source of bugs and
complexity. Also, you can't detect default key bindings, so you'd be
forcing your own bindings on people rather than using their system's
default. (For example, I have emacs bindings configured in GTK. There
is no way for JS to know this.)

Best,
Marijn

More topics »