1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-26 10:49:17 +00:00

don't replace existing gutter markers for performance (avoid forced layout reflow)

This commit is contained in:
Steven Hugg 2018-08-02 15:49:30 -04:00
parent 2e4178ffb2
commit 108dedd909

View File

@ -174,29 +174,35 @@ export class SourceEditor implements ProjectView {
var lstlines = this.sourcefile.lines || []; var lstlines = this.sourcefile.lines || [];
for (var info of lstlines) { for (var info of lstlines) {
if (info.offset >= 0) { if (info.offset >= 0) {
var textel = document.createTextNode(hex(info.offset,4)); this.setGutter("gutter-offset", info.line-1, hex(info.offset&0xffff,4));
this.editor.setGutterMarker(info.line-1, "gutter-offset", textel);
} }
if (info.insns) { if (info.insns) {
var insnstr = info.insns.length > 9 ? ("...") : info.insns; var insnstr = info.insns.length > 9 ? ("...") : info.insns;
var textel = document.createTextNode(insnstr); this.setGutter("gutter-bytes", info.line-1, insnstr);
this.editor.setGutterMarker(info.line-1, "gutter-bytes", textel);
if (info.iscode) { if (info.iscode) {
var opcode = parseInt(info.insns.split(" ")[0], 16); var opcode = parseInt(info.insns.split(" ")[0], 16);
if (platform.getOpcodeMetadata) { if (platform.getOpcodeMetadata) {
var meta = platform.getOpcodeMetadata(opcode, info.offset); var meta = platform.getOpcodeMetadata(opcode, info.offset);
var clockstr = meta.minCycles+""; var clockstr = meta.minCycles+"";
var textel = document.createTextNode(clockstr); this.setGutter("gutter-clock", info.line-1, clockstr);
this.editor.setGutterMarker(info.line-1, "gutter-clock", textel);
} }
} }
} }
} }
} }
setGutter(type:string, line:number, text:string) {
var lineinfo = this.editor.lineInfo(line);
if (lineinfo.gutterMarkers && lineinfo.gutterMarkers[type]) {
// do not replace existing marker
} else {
var textel = document.createTextNode(text);
this.editor.setGutterMarker(line, type, textel);
}
}
setGutterBytes(line:number, s:string) { setGutterBytes(line:number, s:string) {
var textel = document.createTextNode(s); this.setGutter("gutter-bytes", line-1, s);
this.editor.setGutterMarker(line-1, "gutter-bytes", textel);
} }
setCurrentLine(line:number, moveCursor:boolean) { setCurrentLine(line:number, moveCursor:boolean) {