/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
export * from "./source-documents";
export * from "./source-search";
export * from "../ui";
export * from "./tokens";
import { createEditor } from "./create-editor"; import { isWasm, lineToWasmOffset, wasmOffsetToLine } from "../wasm"; import { createLocation } from "../location"; import { features } from "../prefs";
let editor;
export function getEditor(useCm6) { if (editor) { return editor;
}
/** * Update line wrapping for the codemirror editor.
*/
export function updateEditorLineWrapping(value) { if (!editor) { return;
}
editor.setLineWrapping(value);
}
export function fromEditorLine(source, line) { if (features.codemirrorNext) { // Also ignore the original source related to the .wasm file. if (editor.isWasm && !source.isOriginal) { // Content lines is 1-based in CM6 and 0-based in WASM return editor.lineToWasmOffset(line - 1);
} return line;
} // CM5 if (isWasm(source.id)) { return lineToWasmOffset(source.id, line);
} return line + 1;
}
export function toEditorPosition(location) { // Note that Spidermonkey, Debugger frontend and CodeMirror are all consistent regarding column // and are 0-based. But only CodeMirror consider the line to be 0-based while the two others // consider lines to be 1-based. const isSourceWasm = features.codemirrorNext
? editor.isWasm
: isWasm(location.source.id); return {
line: toEditorLine(location.source, location.line),
column: isSourceWasm || !location.column ? 0 : location.column,
};
}
export function toSourceLine(source, line) { if (features.codemirrorNext) { if (editor.isWasm && !source.isOriginal) { return editor.lineToWasmOffset(line - 1);
} return line;
} // CM5 // CodeMirror 5 cursor location is 0 based and Codemirror 6 position is 1 based. // Whereas in DevTools frontend and backend only column is 0-based, the line is 1 based. if (isWasm(source.id)) { return lineToWasmOffset(source.id, line);
} return line + 1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.