简体   繁体   中英

How can I highlight multiple lines with Ace?

The old method mentioned in similar questions here is the following:

var editor = ace.edit("editor");
var Range = ace.require('ace/range').Range;
editor.setReadOnly(true);
editor.setTheme("ace/theme/github");
editor.getSession().setMode("ace/mode/javascript");
editor.getSession().addMarker(new Range(1, 0, 15, 0), "ace_active_line", "background");

Unfortunately it doesn't work, as you can see here:

http://jsbin.com/acotuv/1/edit

Any suggestions?

seems like signature of the addMarker function was changed

var Range = ace.require('ace/range').Range // get reference to ace/range
...
editor.session.addMarker(
    new Range(1, 0, 15, 0), "ace_active-line", "fullLine"
 );`

works fine, see http://jsbin.com/acotuv/3/edit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM