Ace编辑器,如何打开块选择,而不必按Alt [英] Ace editor, how to turn on block selection without having to press alt
本文介绍了Ace编辑器,如何打开块选择,而不必按Alt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通常在ace编辑器中,如果你按住alt键,同时进行选择,它将以块形式选择它,我认为是块选择。
Normally in ace-editor, to if you hold down the alt key, while making a selection, it will select it in block form which i think is called block selection.
我如何做,使其在标准的块选择,按alt替换为正常选择。
How do i make it so that it is in block selection as standard, and pressing alt changes it to normal selection instead.
我认为它有事情与此
function onMouseDown(e) {
var ev = e.domEvent;
var alt = ev.altKey;
var shift = ev.shiftKey;
var ctrl = e.getAccelKey();
var button = e.getButton();
var editor = e.editor;
var selection = editor.selection;
var isMultiSelect = editor.inMultiSelectMode;
var pos = e.getDocumentPosition();
var cursor = selection.getCursor();
var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
var mouseX = e.x, mouseY = e.y;
var onMouseSelection = function(e) {
mouseX = e.clientX;
mouseY = e.clientY;
};
var blockSelect = function() {
var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
if (isSamePoint(screenCursor, newCursor)
&& isSamePoint(cursor, selection.selectionLead))
return;
screenCursor = newCursor;
editor.selection.moveCursorToPosition(cursor);
editor.selection.clearSelection();
editor.renderer.scrollCursorIntoView();
editor.removeSelectionMarkers(rectSel);
rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
rectSel.forEach(editor.addSelectionMarker, editor);
editor.updateSelectionMarkers();
};
这在我的第15479行和第15528行之间的ace.js中找到了,
which i found in ace.js between lines 15479 and 15528, and this;
else if (alt && button == 0) {
e.stop();
if (isMultiSelect && !ctrl)
selection.toSingleRange();
else if (!isMultiSelect && ctrl)
selection.addRange();
var rectSel = [];
if (shift) {
screenAnchor = session.documentToScreenPosition(selection.lead);
blockSelect();
} else {
selection.moveCursorToPosition(pos);
selection.clearSelection();
}
第15561行和第15567行
line 15561, and 15567
推荐答案
看起来很简单,只要更改此行...
It looks as simple as changing this line...
var alt = ev.altKey;
...
var alt = !ev.altKey;
这篇关于Ace编辑器,如何打开块选择,而不必按Alt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文