diff --git a/css/ui.css b/css/ui.css index 4bf0d917..c49443ec 100644 --- a/css/ui.css +++ b/css/ui.css @@ -16,6 +16,12 @@ .gutter-info { width: 1em; } +.currentpc-span { + background-color: #7e2a70; +} +.currentpc-marker { + color: #ff66ee; +} .tooltipbox { position: relative; display: inline-block; diff --git a/src/common/basic/compiler.ts b/src/common/basic/compiler.ts index c69f168e..3699e435 100644 --- a/src/common/basic/compiler.ts +++ b/src/common/basic/compiler.ts @@ -814,8 +814,7 @@ export class BASICParser { ///// BASIC DIALECTS -// TODO - +// TODO: require END statement, check FOR condition at start of loop export const ECMA55_MINIMAL : BASICOptions = { dialectName: "ECMA55", asciiOnly : true, diff --git a/src/common/basic/runtime.ts b/src/common/basic/runtime.ts index c2e7cae7..e01bbb4f 100644 --- a/src/common/basic/runtime.ts +++ b/src/common/basic/runtime.ts @@ -515,11 +515,11 @@ export class BASICRuntime { ${lexpr} = value; ` }); - return `this.running=false; + return `this.running=false; this.curpc--; this.input(${prompt}, ${stmt.args.length}).then((vals) => { let valid = 1; ${setvals} - if (!valid) this.curpc--; + if (valid) this.curpc++; this.running=true; this.resume(); })`; @@ -641,10 +641,10 @@ export class BASICRuntime { do__GET(stmt : basic.GET_Statement) { var lexpr = this.assign2js(stmt.lexpr); // TODO: single key input - return `this.running=false; + return `this.running=false; this.curpc--; this.input().then((vals) => { ${lexpr} = this.convert(${JSON.stringify(stmt.lexpr.name)}, vals[0]); - this.running=true; + this.running=true; this.curpc++; this.resume(); })`; } diff --git a/src/ide/ui.ts b/src/ide/ui.ts index e8bd13ce..84149b97 100644 --- a/src/ide/ui.ts +++ b/src/ide/ui.ts @@ -1890,6 +1890,7 @@ function globalErrorHandler(msgevent) { werr = Object.create(err.$loc); werr.msg = msg; console.log(werr); + projectWindows.refresh(false); } showErrorAlert([werr]); } diff --git a/src/ide/views.ts b/src/ide/views.ts index de8c29c9..28917f8d 100644 --- a/src/ide/views.ts +++ b/src/ide/views.ts @@ -89,6 +89,7 @@ export class SourceEditor implements ProjectView { dirtylisting = true; sourcefile : SourceFile; currentDebugLine : SourceLocation; + markCurrentPC; // TextMarker errormsgs = []; errorwidgets = []; inspectWidget; @@ -331,20 +332,22 @@ export class SourceEditor implements ProjectView { var addCurrentMarker = (line:SourceLocation) => { var div = document.createElement("div"); - div.style.color = '#66ffff'; + div.classList.add('currentpc-marker'); div.appendChild(document.createTextNode("\u25b6")); - this.editor.setGutterMarker(line, "gutter-info", div); + this.editor.setGutterMarker(line.line-1, "gutter-info", div); } this.clearCurrentLine(moveCursor); if (line) { addCurrentMarker(line); if (moveCursor) { - if (line.start || line.end) - 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}); + this.editor.setCursor({line:line.line-1,ch:line.start||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; } } @@ -355,18 +358,27 @@ export class SourceEditor implements ProjectView { if (moveCursor) this.editor.setSelection(this.editor.getCursor()); this.currentDebugLine = null; } + if (this.markCurrentPC) { + this.markCurrentPC.clear(); + this.markCurrentPC = null; + } } getActiveLine() : SourceLocation { - var state = lastDebugState; - if (this.sourcefile && state) { - var EPC = (state && state.c && (state.c.EPC || state.c.PC)); // || (platform.getPC && platform.getPC()); - var res = this.sourcefile.findLineForOffset(EPC, 15); - return res; + if (this.sourcefile) { + var cpustate = lastDebugState && lastDebugState.c; + if (!cpustate && platform.getCPUState && !platform.isRunning()) + cpustate = platform.getCPUState(); + if (cpustate) { + var EPC = (cpustate && (cpustate.EPC || cpustate.PC)); + var res = this.sourcefile.findLineForOffset(EPC, 15); + return res; + } } } refreshDebugState(moveCursor:boolean) { + // TODO: only if line changed this.clearCurrentLine(moveCursor); var line = this.getActiveLine(); if (line) {