如何使用 Ace 突出显示多行? [英] How can I highlight multiple lines with Ace?

查看:48
本文介绍了如何使用 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

有什么建议吗?

推荐答案

addMarker 函数的签名似乎被改变了

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"
 );`

工作正常,请参阅http://jsbin.com/acotuv/3/edit

这篇关于如何使用 Ace 突出显示多行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆