我想选择第2行以复制并粘贴到ACE中。有一种方法selectLine()
,在这里记录:http : //ace.c9.io/#nav=api&api=selection但我不知道如何使用它。不幸的是,在stackoverflow.com上也没有关于选择的任何信息,仅关于突出显示,这是不一样的。
// ACE Editor Setup
var editor = ace.edit("editor");
editor.setTheme("ace/theme/crimson_editor");
editor.getSession().setMode("ace/mode/html");
editor.setValue("textline1\n textline2\n textline3");
var select = new Selection(editor.getSession()); // Uncaught TypeError: Illegal constructor
select.selectLine(2);
ace初始化后,它将创建一个Selection
对象实例,因此您无需重新创建它。要访问,Selection
只需使用editor.selection
。
另一个要点是selectLine
选择当前行(不接受任何参数)。因此,要移动光标并选择必须首先使用的行moveCursorToPosition
。
这是一个例子:
editor.selection.moveCursorToPosition({row: 1, column: 0});
editor.selection.selectLine();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句