added tooltips back to errors; intermediate status

This commit is contained in:
Steven Hugg 2018-07-25 13:29:09 -04:00
parent 6e5005f613
commit 2759db6920
4 changed files with 38 additions and 24 deletions

View File

@ -2,7 +2,7 @@
import { FileData, Dependency, SourceLine, SourceFile, CodeListing, CodeListingMap, WorkerError, WorkerResult } from "./workertypes";
type BuildResultCallback = (result:WorkerResult) => void;
type BuildResultCallback = (result:WorkerResult, intermediate:boolean) => void;
type BuildStatusCallback = (busy:boolean) => void;
type LoadFilesCallback = (err:string, result?:Dependency[]) => void;
type IterateFilesCallback = (path:string, data:FileData) => void;
@ -30,7 +30,8 @@ export class CodeProject {
this.store = store;
worker.onmessage = (e) => {
if (this.pendingWorkerMessages > 1) {
var notfinal = this.pendingWorkerMessages > 1;
if (notfinal) {
this.sendBuild();
} else {
if (this.callbackBuildStatus) this.callbackBuildStatus(false);
@ -38,7 +39,8 @@ export class CodeProject {
this.pendingWorkerMessages = 0;
if (e.data && !e.data.unchanged) {
this.processBuildResult(e.data);
if (this.callbackBuildResult) this.callbackBuildResult(e.data); // call with data when changed
var intermediate = false; // TODO?
if (this.callbackBuildResult) this.callbackBuildResult(e.data, intermediate); // call with data when changed
}
};
}

View File

@ -86,17 +86,17 @@ function initProject() {
current_project = new CodeProject(newWorker(), platform_id, platform, store);
projectWindows = new ProjectWindows($("#workspace")[0], current_project);
current_project.callbackGetRemote = $.get;
current_project.callbackBuildResult = function(result) {
setCompileOutput(result);
current_project.callbackBuildResult = (result:WorkerResult, intermediate:boolean) => {
setCompileOutput(result, intermediate);
refreshWindowList();
};
current_project.callbackBuildStatus = function(busy) {
current_project.callbackBuildStatus = (busy:boolean) => {
if (busy) {
toolbar.addClass("is-busy");
} else {
toolbar.removeClass("is-busy");
toolbar.removeClass("has-errors"); // may be added in next callback
projectWindows.setErrors(null);
projectWindows.setErrors(null, false);
}
$('#compile_spinner').css('visibility', busy ? 'visible' : 'hidden');
};
@ -376,10 +376,10 @@ function updateSelector() {
});
}
function setCompileOutput(data: WorkerResult) {
function setCompileOutput(data: WorkerResult, intermediate:boolean) {
// errors? mark them in editor
if (data.errors && data.errors.length > 0) {
projectWindows.setErrors(data.errors);
projectWindows.setErrors(data.errors, intermediate);
toolbar.addClass("has-errors");
} else {
// process symbol map
@ -400,7 +400,7 @@ function setCompileOutput(data: WorkerResult) {
} catch (e) {
console.log(e);
toolbar.addClass("has-errors");
projectWindows.setErrors([{line:0,msg:e+""}]);
projectWindows.setErrors([{line:0,msg:e+""}], false);
current_output = null;
}
/* TODO?

View File

@ -14,7 +14,7 @@ export interface ProjectView {
getSourceFile?() : SourceFile;
setGutterBytes?(line:number, s:string) : void;
openBitmapEditorAtCursor?() : void;
markErrors?(errors:WorkerError[]) : void;
markErrors?(errors:WorkerError[], intermediate?:boolean) : void;
clearErrors?() : void;
};
@ -56,6 +56,7 @@ export class SourceEditor implements ProjectView {
sourcefile : SourceFile;
currentDebugLine : number;
errorwidgets = [];
lines2errmsg = [];
createDiv(parent:HTMLElement, text:string) {
var div = document.createElement('div');
@ -110,18 +111,29 @@ export class SourceEditor implements ProjectView {
getPath() : string { return this.path; }
addErrorMarker(line:number, msg:string) {
var tooltip = document.createElement("span");
tooltip.setAttribute("class", "tooltiperrorline");
addErrorMarker(line:number, msg:string, intermediate:boolean) {
// add line widget w/ error msg
if (!intermediate) {
var errspan = document.createElement("span");
errspan.setAttribute("class", "tooltiperrorline");
errspan.appendChild(document.createTextNode(msg));
this.errorwidgets.push(this.editor.addLineWidget(line, errspan));
}
// concatenate error msgs for tooltip text
var div = document.createElement("div");
div.setAttribute("class", "tooltipbox tooltiperror");
div.appendChild(document.createTextNode("\u24cd"));
this.editor.setGutterMarker(line, "gutter-info", div);
if (this.lines2errmsg[line])
msg = this.lines2errmsg[line] + "\n" + msg;
this.lines2errmsg[line] = msg;
var tooltip = document.createElement("span");
tooltip.setAttribute("class", "tooltiptext");
tooltip.appendChild(document.createTextNode(msg));
this.errorwidgets.push(this.editor.addLineWidget(line, tooltip));
div.appendChild(tooltip);
this.editor.setGutterMarker(line, "gutter-info", div);
}
markErrors(errors:WorkerError[]) {
markErrors(errors:WorkerError[], intermediate?:boolean) {
// TODO: move cursor to error line if offscreen?
this.clearErrors();
var numLines = this.editor.lineCount();
@ -130,7 +142,7 @@ export class SourceEditor implements ProjectView {
if (!info.path || this.path.endsWith(info.path)) {
var line = info.line-1;
if (line < 0 || line >= numLines) line = 0;
this.addErrorMarker(line, info.msg);
this.addErrorMarker(line, info.msg, intermediate);
}
}
}
@ -138,7 +150,7 @@ export class SourceEditor implements ProjectView {
clearErrors() {
this.editor.clearGutter("gutter-info");
this.refreshDebugState();
//this.lines2errmsg = [];
this.lines2errmsg = [];
this.dirtylisting = true;
// clear line widgets
while (this.errorwidgets.length)

View File

@ -46,7 +46,7 @@ export class ProjectWindows {
this.activewnd = wnd;
$(div).show();
this.refresh();
this.refreshErrors();
this.refreshErrors(false);
}
this.activeid = id;
return wnd;
@ -66,15 +66,15 @@ export class ProjectWindows {
this.activewnd.tick();
}
setErrors(errors:WorkerError[]) {
setErrors(errors:WorkerError[], intermediate:boolean) {
this.lasterrors = errors;
this.refreshErrors();
this.refreshErrors(intermediate);
}
refreshErrors() {
refreshErrors(intermediate:boolean) {
if (this.activewnd && this.activewnd.markErrors) {
if (this.lasterrors && this.lasterrors.length)
this.activewnd.markErrors(this.lasterrors);
this.activewnd.markErrors(this.lasterrors, intermediate);
else
this.activewnd.clearErrors();
}