mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-23 03:29:39 +00:00
editor uses markText to show current pc line, show state when paused
This commit is contained in:
parent
d92cc5542d
commit
5269585fd0
@ -16,6 +16,12 @@
|
|||||||
.gutter-info {
|
.gutter-info {
|
||||||
width: 1em;
|
width: 1em;
|
||||||
}
|
}
|
||||||
|
.currentpc-span {
|
||||||
|
background-color: #7e2a70;
|
||||||
|
}
|
||||||
|
.currentpc-marker {
|
||||||
|
color: #ff66ee;
|
||||||
|
}
|
||||||
.tooltipbox {
|
.tooltipbox {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -814,8 +814,7 @@ export class BASICParser {
|
|||||||
|
|
||||||
///// BASIC DIALECTS
|
///// BASIC DIALECTS
|
||||||
|
|
||||||
// TODO
|
// TODO: require END statement, check FOR condition at start of loop
|
||||||
|
|
||||||
export const ECMA55_MINIMAL : BASICOptions = {
|
export const ECMA55_MINIMAL : BASICOptions = {
|
||||||
dialectName: "ECMA55",
|
dialectName: "ECMA55",
|
||||||
asciiOnly : true,
|
asciiOnly : true,
|
||||||
|
@ -515,11 +515,11 @@ export class BASICRuntime {
|
|||||||
${lexpr} = value;
|
${lexpr} = value;
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
return `this.running=false;
|
return `this.running=false; this.curpc--;
|
||||||
this.input(${prompt}, ${stmt.args.length}).then((vals) => {
|
this.input(${prompt}, ${stmt.args.length}).then((vals) => {
|
||||||
let valid = 1;
|
let valid = 1;
|
||||||
${setvals}
|
${setvals}
|
||||||
if (!valid) this.curpc--;
|
if (valid) this.curpc++;
|
||||||
this.running=true;
|
this.running=true;
|
||||||
this.resume();
|
this.resume();
|
||||||
})`;
|
})`;
|
||||||
@ -641,10 +641,10 @@ export class BASICRuntime {
|
|||||||
do__GET(stmt : basic.GET_Statement) {
|
do__GET(stmt : basic.GET_Statement) {
|
||||||
var lexpr = this.assign2js(stmt.lexpr);
|
var lexpr = this.assign2js(stmt.lexpr);
|
||||||
// TODO: single key input
|
// TODO: single key input
|
||||||
return `this.running=false;
|
return `this.running=false; this.curpc--;
|
||||||
this.input().then((vals) => {
|
this.input().then((vals) => {
|
||||||
${lexpr} = this.convert(${JSON.stringify(stmt.lexpr.name)}, vals[0]);
|
${lexpr} = this.convert(${JSON.stringify(stmt.lexpr.name)}, vals[0]);
|
||||||
this.running=true;
|
this.running=true; this.curpc++;
|
||||||
this.resume();
|
this.resume();
|
||||||
})`;
|
})`;
|
||||||
}
|
}
|
||||||
|
@ -1890,6 +1890,7 @@ function globalErrorHandler(msgevent) {
|
|||||||
werr = Object.create(err.$loc);
|
werr = Object.create(err.$loc);
|
||||||
werr.msg = msg;
|
werr.msg = msg;
|
||||||
console.log(werr);
|
console.log(werr);
|
||||||
|
projectWindows.refresh(false);
|
||||||
}
|
}
|
||||||
showErrorAlert([werr]);
|
showErrorAlert([werr]);
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,7 @@ export class SourceEditor implements ProjectView {
|
|||||||
dirtylisting = true;
|
dirtylisting = true;
|
||||||
sourcefile : SourceFile;
|
sourcefile : SourceFile;
|
||||||
currentDebugLine : SourceLocation;
|
currentDebugLine : SourceLocation;
|
||||||
|
markCurrentPC; // TextMarker
|
||||||
errormsgs = [];
|
errormsgs = [];
|
||||||
errorwidgets = [];
|
errorwidgets = [];
|
||||||
inspectWidget;
|
inspectWidget;
|
||||||
@ -331,20 +332,22 @@ export class SourceEditor implements ProjectView {
|
|||||||
|
|
||||||
var addCurrentMarker = (line:SourceLocation) => {
|
var addCurrentMarker = (line:SourceLocation) => {
|
||||||
var div = document.createElement("div");
|
var div = document.createElement("div");
|
||||||
div.style.color = '#66ffff';
|
div.classList.add('currentpc-marker');
|
||||||
div.appendChild(document.createTextNode("\u25b6"));
|
div.appendChild(document.createTextNode("\u25b6"));
|
||||||
this.editor.setGutterMarker(line, "gutter-info", div);
|
this.editor.setGutterMarker(line.line-1, "gutter-info", div);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clearCurrentLine(moveCursor);
|
this.clearCurrentLine(moveCursor);
|
||||||
if (line) {
|
if (line) {
|
||||||
addCurrentMarker(line);
|
addCurrentMarker(line);
|
||||||
if (moveCursor) {
|
if (moveCursor) {
|
||||||
if (line.start || line.end)
|
this.editor.setCursor({line:line.line-1,ch:line.start||0}, {scroll:true});
|
||||||
this.editor.setSelection({line:line.line-1,ch:line.start}, {line:line.line-1,ch:line.end||line.start+1}, {scroll:true});
|
|
||||||
else
|
|
||||||
this.editor.setSelection({line:line.line-1,ch:0}, {line:line.line,ch:0}, {scroll:true});
|
|
||||||
}
|
}
|
||||||
|
var markOpts = {className:'currentpc-span', inclusiveLeft:true};
|
||||||
|
if (line.start || line.end)
|
||||||
|
this.markCurrentPC = this.editor.markText({line:line.line-1,ch:line.start}, {line:line.line-1,ch:line.end||line.start+1}, markOpts);
|
||||||
|
else
|
||||||
|
this.markCurrentPC = this.editor.markText({line:line.line-1,ch:0}, {line:line.line,ch:0}, markOpts);
|
||||||
this.currentDebugLine = line;
|
this.currentDebugLine = line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -355,18 +358,27 @@ export class SourceEditor implements ProjectView {
|
|||||||
if (moveCursor) this.editor.setSelection(this.editor.getCursor());
|
if (moveCursor) this.editor.setSelection(this.editor.getCursor());
|
||||||
this.currentDebugLine = null;
|
this.currentDebugLine = null;
|
||||||
}
|
}
|
||||||
|
if (this.markCurrentPC) {
|
||||||
|
this.markCurrentPC.clear();
|
||||||
|
this.markCurrentPC = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getActiveLine() : SourceLocation {
|
getActiveLine() : SourceLocation {
|
||||||
var state = lastDebugState;
|
if (this.sourcefile) {
|
||||||
if (this.sourcefile && state) {
|
var cpustate = lastDebugState && lastDebugState.c;
|
||||||
var EPC = (state && state.c && (state.c.EPC || state.c.PC)); // || (platform.getPC && platform.getPC());
|
if (!cpustate && platform.getCPUState && !platform.isRunning())
|
||||||
var res = this.sourcefile.findLineForOffset(EPC, 15);
|
cpustate = platform.getCPUState();
|
||||||
return res;
|
if (cpustate) {
|
||||||
|
var EPC = (cpustate && (cpustate.EPC || cpustate.PC));
|
||||||
|
var res = this.sourcefile.findLineForOffset(EPC, 15);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshDebugState(moveCursor:boolean) {
|
refreshDebugState(moveCursor:boolean) {
|
||||||
|
// TODO: only if line changed
|
||||||
this.clearCurrentLine(moveCursor);
|
this.clearCurrentLine(moveCursor);
|
||||||
var line = this.getActiveLine();
|
var line = this.getActiveLine();
|
||||||
if (line) {
|
if (line) {
|
||||||
|
Loading…
Reference in New Issue
Block a user