<Glazblog/>

Search

Your search for Diavolo returned 26 results.

Thursday 19 February 2009

Bespin, canvas, SVG, DOM and other thoughts

A person named "LaC" left a rather strong comment on Ben Galbraith's blog. Since Ben's original article partly explains why canvas was chosen for Bespin, let me give you my personal view of the thing...

Diavolo, my source view editor, uses the editor in Gecko. So I had to deal with DOM nodes. Colorizing a word needs an element. Placing the caret in the middle of an element and typing a char needs expensive DOM operations to split the node in two if the grammar says the parsing was modified by the char. And if you're unlucky and it affects drastically the parsing of the rest of the document, well, you're doomed... All in all, dealing with a DOM here is so expensive that the performance is still poor on large files. The original parsing/rendering of a large file is too long. Ok, it's much better than it used to be, and my first attempt at a JS-based source editor in 2001 ended up nowhere because of Gecko itself.

So dealing with canvas - part of the HTML 5 standard - with good performance because there's no need to act on a DOM instead of contenteditable - part of the HTML 5 standard - with poor performance because you must deal with a DOM seems to me a natural choice, and a good choice. A markup-based editor for source is a workable solution if you don't want to implement complex features like rich syntax highlight, auto-completion, folding, exceptions allowing to put an instance conforming to one grammar inside another instance conforming to a different grammar (think for instance CSS embedded in HTML) and so on.

Last but not least, last time I checked Mozilla Labs' name contained the word "Labs". In general, labs are here to make experiments, things that don't seem ordinary or even reasonable, labs are here to pave the future, not do what all others are doing too.

Friday 8 August 2008

Diavolo 0.61

Diavolo I improved a lot code completion in this 0.61, it's almost ready...

  • completion popup not shown any more when the user moves the caret from one token to another using arrow keys or the mouse pointer
  • control-space key combination opens the completion popup if it can
  • fixed two bugs when the token value the completion popup depends on is unrecognized
  • changed the completion grammar to allow values that are available for all suggestion groups
  • started optimizing the code

Tuesday 5 August 2008

Diavolo 0.6

DiavoloYou can now test autocompletion in Diavolo, my source code editor, through my extension DiavoloTest for Firefox 3. Warning, it's not perfect yet, there are a few minor bugs, I know... Autocompletion is included for element types, properties and property values only. Not added yet for pseudos, functional notations and other CSS tokens.

  • as usual, DiavoloTest adds a new menu entry in the Tools menu
  • to hide the autocompletion popup, use the Escape key
  • to select the current autocompletion suggestion, use the Tab key or click on it
  • you can use the arrow and page keys to navigate between suggestions in the autocompletion popup
Click here to download and install DiavoloTest 0.6.

Friday 1 August 2008

Diavolo progress

Autocompletion in Diavolo, my source code editor, is almost done. It's as usual defined in an XML grammar, and it's smart enough so it can depend on the value of a previous token. Arrow and page keys allow to navigate in the popup, tab key or click selects the current option, escape closes the popup. See by yourself:

autocompletion

Tuesday 29 July 2008

Diavolo progress

I made a lot of progress on code completion, as you can see from the screenshot below:

code completion in Diavolo

Thursday 3 July 2008

ParisWeb 2008

L'édition 2008 de la superbe conférence ParisWeb se tiendra du 13 au 15 novembre. J'y serai, évidemment. Je vous proposerai, si les organisateurs l'acceptent, une présentation des nouveautés en chantier dans CSS ainsi qu'un rapport sur le fonctionnement du CSS WG. Si on me pousse un peu, je mettrai même mes bouts de code dans Diavolo ;-)

PS: quelqu'un a déjà réservé la grève des transports pour cette date ?-)

Wednesday 2 July 2008

Diavolo, documentation

DiavoloI have written a doc presenting Diavolo, how to embed it in your piece of code and use it. It's available from here and I hope you'll find it useful...

Update: sources available here.

Diavolo progress

All the styles in my source editor Diavolo are now modifiable by the client. That will allow a UI to specify, modify, delete styles for a given grammar in the source editor. Yay :-)

YAY !!!!!

I have successfully turned Diavolo into a new XUL element !!!!!

source code using new Diavolo XUL tag

Tuesday 1 July 2008

Diavolo progress

DiavoloThe v0.4 of my source code editor Diavolo is available from here, as always. I think you'll like this new version:

  • line numbering can be hidden
  • click on a line number selects the line, and it's possible to extend the selection to other lines
  • much better copy/paste, drag and drop with whitespace preservation; still some issues with refresh though
  • much harder to freeze :-)
  • improvements in the CSS grammar

diavolo 20080701

Monday 30 June 2008

nsIPlaintextEditor and copy/paste of whitespace

Diavolo is better and better every day. But I had a big issue with copy/paste of whitespace, my source indentations were lost on paste, and I really could not figure out why. After a short investigation, I found why : it's a little uglyness left in nsCopySupport.cpp by our friend and former Editor Team member Kin Blas :

if (atom == nsGkAtoms::body)
{
  // check for moz prewrap style on body.  If it's there we are
  // in a plaintext editor.  This is pretty cheezy but I haven't
  // found a good way to tell if we are in a plaintext editor.
  nsCOMPtr<nsIDOMElement> bodyElem = do_QueryInterface(selContent);
  nsAutoString wsVal;
  rv = bodyElem->GetAttribute(NS_LITERAL_STRING("style"), wsVal);
  if (NS_SUCCEEDED(rv) && (kNotFound != wsVal.Find(NS_LITERAL_STRING("pre-wrap"))))
  {
    *aIsPlainTextContext = PR_TRUE;
    break;
  }
}

Urrrgh, to say the least :-) I have filed bug 442686 for that and attached a first patch. In the meantime, make sure to add style="white-space: pre-wrap" on the body of your edited documents if you're using a plaintext editor in Mozilla and need white-space preservation during copy/paste...

Thursday 26 June 2008

Diavolo progress

Diavolo, my source code editor, is _almost_ done. Many thanks to Paul Rouget for his torture tests. You can test Diavolo using the last version of the DiavoloTest extension available here (FF3 required). It adds a new menu entry to the Tools menu.

Monday 23 June 2008

Diavolo, line numbering

YAY ! I made it. I found a very easy way to do it and implemented it in less than two hours :-) Magic !

line numbering in Diavolo

Diavolo, test it !!! #2

DiavoloI have a made a second XPI so you can test Diavolo, the source code editor for Mozilla, if you want. It's available from here, and adds a new menu entry "Diavolo Test" under the Tools menu. The test includes a CSS grammar. The Undo/Redo works much better (ctrl-Z/ctrl-Y) but is not entirely finalized. I also started encapsulating the whole thing into bindings for a <sourceeditor> xul tag but it's not ready yet.

Diavolo progress, lesson taken

If you try to insert into a document a node that is already in the document through the DOM insertBefore() method, the node is first removed... It's explicitely said in the spec. But the nsIEditor method insertNode() doesn't do that. So if you use it to move a node, never forget to delete the node through deleteNode() before calling insertNode(). Your Undo stack will be horked if you don't do it...

Thursday 19 June 2008

Diavolo progress

I started writing my own transaction manager for Diavolo because of the problem I outlined in my previous article. For those of you who did not understand the problem let me explain :

  • in the normal plaintext editor, if you type "foo > bar", the whole thing is aggregated into two transactions only : first create a text node, then insert the whole text inside that text node. The last transaction is in fact updated each time you add a character at the end of the text node. And both transactions are batched into a single container transaction so one Undo only removes the whole text
  • in the source editor, when you type the first "f", the editor calls the tokeniser and then tries to resolve the token in the current grammar context. So the source editor creates a span with attributes specifying the token, the context, the role, and the expected context ; the original text node is moved as first child of that span. Then "oo" are added to that text node. The first whitespace is another token so the editor splits the text node in two and the right result is inserted inside a new span for the whitespace token. And so on for the new tokens ">" " " and "bar".

So aggregating "insert text" transactions is much harder in the latter case than in the former one, and that's why I started my own transaction manager. The way the existing nsTransactionManager works did not seem to me enough for the quality of Undo/Redo I want for Diavolo.

Even if I had written a new editor on top of nsEditor dealing only with text insertion and deletion based on start and end offsets in the text, I would still have to deal with coalescing text transactions in the transaction manager...

So I wrote a large part of my own transaction manager and six editor transactions until I tried something I did not think of with the existing txrmgr. And it worked. Sort of. Undo and Redo almost work correctly now BUT if you type "foo", Undo does not delete the whole token yet ; it undoes the last char only. Of course, when you paste/cut/delete/move text, it works fine. I'll try to improve the code but it'll be difficult. Let me call it a good compromise for the time being.

When that's done, I'll add auto-indent and I'll prepare everything needed to add the <sourceeditor> tag to the XUL toolkit. Line numbering is out of scope for the first release but I keep it in mind.

In terms of speed and performance, I am super glad ! It's really fast. It's also reasonably light since the whole thing is only 1286 lines of JS, excluding the grammar and the associated stylesheet but with comments, empty lines for readability, braces standing alone on a line and so on. I'll run the source through a JS optimizer, just to have an idea of what could be the target size of v1.0. Stay tuned :-)

Sunday 15 June 2008

Diavolo progress

After a long day of investigation, I have finally understood why Undo/Redo is horked in Diavolo's editor... The hard thing to do in Diavolo is coalesce InsertText transactions so for instance Undo deletes the last word you typed and not only the last char. Working on it now, I need to optimize my refresh method for that.

Update: I wonder if I won't have to write my own transaction manager for diavolo...

Friday 13 June 2008

Diavolo, test it !!!

DiavoloI have a made a first XPI so you can test Diavolo, the source code editor for Mozilla, if you want. It's available from here, and adds a new menu entry "Diavolo Test" under the Tools menu. A few warnings:

  1. it's still very experimental ; can freeze on copy/paste and such things, that's absolutely normal, it's still a work in progress...
  2. the css grammar is not perfect yet and you'll notice a few errors that should not be reported.
  3. the associated stylesheet is not perfect yet so don't scream if some tokens remain black ; they _are_ detected, but they remain unstyled.
It's 100% JavaScript-based, as I said earlier in this blog. The comments on this article are allowed so feel free to drop a word if you have a comment, suggestion, report, ... /* Enjoy */

(Just for the record, I am myself using a FF3.0pre to test it)

Thursday 12 June 2008

Diavolo progress

The bug I was chasing yesterday afternoon beingDiavolo now fixed, I made dramatic progress on Diavolo, the refresh speed becoming - as it should be - almost independent of the caret's position in the document. I'm saying almost at this time because it should be totally independent of it only tomorrow, when my code for partial re-serialization on refresh is in. The speed is impressive. Honestly, it's so fast you would not say it's based entirely on JavaScript. And it's not optimized yet ! My goal with Diavolo is the following : a new XUL toolkit element :

<srceditor grammar="..." stylesheet="..."
src="..." />

with helper properties and methods to allow embedders to tune it according to their wishes. Things we're going to add in the near future : autocompletion, folding, auto-indent, and line numbering. Stay tuned...

Wednesday 11 June 2008

Diavolo progress

I reached the state where copy/paste and drag'n'drop now work beautifully. See by yourself (AVI, 7.5 megs)...

- page 1 of 2