mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2026-10-24 08:02:27 +00:00
ui: click hex offset in gutter to Run to Line
This commit is contained in:
1 parent
f54af9e19f
commit
309df400a2
1 file changed
+23
-2
+23
-2
@@ -146,7 +146,19 @@ const currentPcField = StateField.define<RangeSet<GutterMarker>>({
|
||||
|
||||
class OffsetMarker extends GutterMarker {
|
||||
constructor(readonly hex: string) { super(); }
|
||||
toDOM() { return document.createTextNode(this.hex); }
|
||||
toDOM() {
|
||||
const span = document.createElement("span");
|
||||
span.textContent = this.hex;
|
||||
span.style.cursor = "pointer";
|
||||
span.title = "Click to run to here";
|
||||
span.addEventListener("mouseenter", () => {
|
||||
span.style.textDecoration = "underline";
|
||||
});
|
||||
span.addEventListener("mouseleave", () => {
|
||||
span.style.textDecoration = "none";
|
||||
});
|
||||
return span;
|
||||
}
|
||||
eq(other: OffsetMarker) { return this.hex == other.hex; }
|
||||
}
|
||||
|
||||
@@ -234,7 +246,16 @@ const CURRENT_PC_MARKER = new class extends GutterMarker {
|
||||
const offsetGutter = gutter({
|
||||
class: "gutter-offset",
|
||||
markers: v => v.state.field(offsetField),
|
||||
initialSpacer: () => new OffsetMarker("0000")
|
||||
initialSpacer: () => new OffsetMarker("0000"),
|
||||
domEventHandlers: {
|
||||
click(view, line) {
|
||||
const lineNum = view.state.doc.lineAt(line.from).number;
|
||||
view.dispatch({
|
||||
effects: runToLineEffect.of(lineNum)
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const bytesGutter = gutter({
|
||||
|
||||
Reference in new issue
Block a user