> cf the question below from a skywriter user - We'd also be interested
> in highlighting single lines in the editor (to show errors we've
> detected in user-submitted code).
>
> We know the line number, and we'd like to be able to specify a CSS
> class and some mouse-over help text.
>
> Is there any way of doing this, eg editor.highlightline(lineNo,
> message)?
There is a fairly new API to add line annotations, which I use to
display syntax errors and lint warnings:
editor.getSession().setAnnotations([{
row: 1,
column: 10,
text: "Strange error"
type: "error" // also warning and information
}]);
Right now it will only set a class in the gutter and by default it
will display an error or warning icon. I plan to also highlight the
line in the editor. Maybe this is already enough for you.
> We've looked into editor.renderer.addMarker(range, klass, type) but
This should also work and we use it e.g. in the Cloud9 debugger to
highlight the active line.
var markerId = editor.renderer.addMarker(new Range(1, 10, 1, 15),
"warning", "text");
This would highlight line 2 (all zero based) column 9-14 by putting a
div with the CSS class "warning" below the text. If you want to
highlight the full line you have to do:
var markerId = editor.renderer.addMarker(new Range(1, 0, 2, 0),
"warning", "line");
When using this approach you have to be aware that the marker is not
stored in the edit session so when you change the edit session you
have to remove or reset the markers manually. You have to keep track
of the markers yourself.
Hope this helps,
Fabian
> --
> You received this message because you are subscribed to the Google Groups "Ajax.org Cloud9 Editor (Ace)" group.
> To post to this group, send email to ace-d...@googlegroups.com.
> To unsubscribe from this group, send email to ace-discuss...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ace-discuss?hl=en.
>
>