Я хочу всегда выбирать текущую строку при изменении положения курсора. А затем удалите эту строку нажатием клавиши и добавьте ее в тег div. Я знаю, как добавлять команды клавиатуры. Но я не понимаю, как сделать что-то onCursorChange()
, оно вроде отличается от Editor.on("change", function(Object e))
. а также я не нахожу, как удалить выбранную строку. onCursorChange()
упоминается здесь, но не описывается, как его использовать: http://ace.c9.io/#nav=api&api=editor
// 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");
// editor.on('onCursorChange', function() { editor.selection.selectLine(); }); // does not work
// editor.onCursorChange(editor.selection.selectLine()); // or this - does also not work
editor.commands.addCommand({
name: 'myCommand',
bindKey: {win: 'Ctrl-J', mac: 'Command-J'},
exec: function(editor) {
--- DO REMOVE THE SELECTED CONTENT ---
}
});
ОБНОВЛЕНИЕ 14.06.2015: теперь я решил эту проблему без события onCursorChange(). Только путем определения этого действия клавиатуры:
editor.commands.addCommand({
name: 'myCommand',
bindKey: {win: 'Ctrl-Y', mac: 'Command-Y'},
exec: function(editor) {
editor.selection.selectLine();
myElem = editor.session.getTextRange(editor.getSelectionRange());
$('#my_output_area').append(myElem);
editor.removeLines();
}
});