General.Web/wwwroot/lib/codemirror-5.31.0/test/multi_test.js
(开头部分) 9KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
(function() {
namespace = "multi_";
function hasSelections(cm) {
var sels = cm.listSelections();
var given = (arguments.length - 1) / 4;
if (sels.length != given)
throw new Failure("expected " + given + " selections, found " + sels.length);
for (var i = 0, p = 1; i < given; i++, p += 4) {
var anchor = Pos(arguments[p], arguments[p + 1]);
var head = Pos(arguments[p + 2], arguments[p + 3]);
eqCharPos(sels[i].anchor, anchor, "anchor of selection " + i);
eqCharPos(sels[i].head, head, "head of selection " + i);
}
}
function hasCursors(cm) {
var sels = cm.listSelections();
var given = (arguments.length - 1) / 2;
if (sels.length != given)
throw new Failure("expected " + given + " selections, found " + sels.length);
for (var i = 0, p = 1; i < given; i++, p += 2) {
eqCursorPos(sels[i].anchor, sels[i].head, "something selected for " + i);
var head = Pos(arguments[p], arguments[p + 1]);
eqCharPos(sels[i].head, head, "selection " + i);
}
}
testCM("getSelection", function(cm) {
select(cm, {anchor: Pos(0, 0), head: Pos(1, 2)}, {anchor: Pos(2, 2), head: Pos(2, 0)});
eq(cm.getSelection(), "1234\n56\n90");
eq(cm.getSelection(false).join("|"), "1234|56|90");
eq(cm.getSelections().join("|"), "1234\n56|90");
}, {value: "1234\n5678\n90"});
testCM("setSelection", function(cm) {
select(cm, Pos(3, 0), Pos(0, 0), {anchor: Pos(2, 5), head: Pos(1, 0)});
hasSelections(cm, 0, 0, 0, 0,
2, 5, 1, 0,
3, 0, 3, 0);
cm.setSelection(Pos(1, 2), Pos(1, 1));
hasSelections(cm, 1, 2, 1, 1);
select(cm, {anchor: Pos(1, 1), head: Pos(2, 4)},
{anchor: Pos(0, 0), head: Pos(1, 3)},
Pos(3, 0), Pos(2, 2));
hasSelections(cm, 0, 0, 2, 4,
3, 0, 3, 0);
cm.setSelections([{anchor: Pos(0, 1), head: Pos(0, 2)},
{anchor: Pos(1, 1), head: Pos(1, 2)},
{anchor: Pos(2, 1), head: Pos(2, 2)}], 1);
eqCharPos(cm.getCursor("head"), Pos(1, 2));
eqCharPos(cm.getCursor("anchor"), Pos(1, 1));
eqCharPos(cm.getCursor("from"), Pos(1, 1));
eqCharPos(cm.getCursor("to"), Pos(1, 2));
cm.setCursor(Pos(1, 1));
hasCursors(cm, 1, 1);
}, {value: "abcde\nabcde\nabcde\n"});
testCM("somethingSelected", function(cm) {
select(cm, Pos(0, 1), {anchor: Pos(0, 3), head: Pos(0, 5)});
eq(cm.somethingSelected(), true);
后面还有 225 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
