mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-24 09:28:58 +00:00
can use binary file as main
This commit is contained in:
parent
c2eb32ce35
commit
fdb4117579
@ -32,22 +32,26 @@ export class CodeProject {
|
||||
this.store = store;
|
||||
|
||||
worker.onmessage = (e) => {
|
||||
var notfinal = this.pendingWorkerMessages > 1;
|
||||
if (notfinal) {
|
||||
this.sendBuild();
|
||||
this.pendingWorkerMessages = 1;
|
||||
} else {
|
||||
if (this.callbackBuildStatus) this.callbackBuildStatus(false);
|
||||
if (!this.isCompiling) { console.log(this.pendingWorkerMessages); console.trace(); } // debug compile problems
|
||||
this.isCompiling = false;
|
||||
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
|
||||
}
|
||||
this.receiveWorkerMessage(e.data);
|
||||
};
|
||||
}
|
||||
|
||||
receiveWorkerMessage(data : WorkerResult) {
|
||||
var notfinal = this.pendingWorkerMessages > 1;
|
||||
if (notfinal) {
|
||||
this.sendBuild();
|
||||
this.pendingWorkerMessages = 1;
|
||||
} else {
|
||||
if (this.callbackBuildStatus) this.callbackBuildStatus(false);
|
||||
if (!this.isCompiling) { console.log(this.pendingWorkerMessages); console.trace(); } // debug compile problems
|
||||
this.isCompiling = false;
|
||||
this.pendingWorkerMessages = 0;
|
||||
}
|
||||
if (data && !data.unchanged) {
|
||||
this.processBuildResult(data);
|
||||
if (this.callbackBuildResult) this.callbackBuildResult(data); // call with data when changed
|
||||
}
|
||||
}
|
||||
|
||||
preloadWorker(path:string) {
|
||||
var tool = this.platform.getToolForFilename(path);
|
||||
@ -235,6 +239,19 @@ export class CodeProject {
|
||||
sendBuild() {
|
||||
if (!this.mainpath) throw "need to call setMainFile first";
|
||||
var maindata = this.getFile(this.mainpath);
|
||||
// if binary blob, just return it as ROM
|
||||
if (maindata instanceof Uint8Array) {
|
||||
this.isCompiling = true;
|
||||
this.receiveWorkerMessage({
|
||||
output:maindata,
|
||||
errors:[],
|
||||
listings:null,
|
||||
symbolmap:null,
|
||||
params:{}
|
||||
});
|
||||
return;
|
||||
}
|
||||
// otherwise, make it a string
|
||||
var text = typeof maindata === "string" ? maindata : '';
|
||||
// TODO: load dependencies of non-main files
|
||||
this.loadFileDependencies(text, (err, depends) => {
|
||||
|
@ -206,7 +206,6 @@ function loadProject(preset_id:string) {
|
||||
alert(err);
|
||||
} else if (result && result.length) {
|
||||
// we need this to build create functions for the editor
|
||||
// TODO: can't use binary file as main
|
||||
refreshWindowList();
|
||||
// show main file
|
||||
projectWindows.createOrShow(preset_id);
|
||||
|
@ -25,7 +25,6 @@ export interface ProjectView {
|
||||
setTimingResult?(result:CodeAnalyzer) : void;
|
||||
};
|
||||
|
||||
// TODO: move to different namespace
|
||||
declare var CodeMirror;
|
||||
declare var VirtualList;
|
||||
|
||||
@ -36,8 +35,9 @@ function jumpToLine(ed, i:number) {
|
||||
ed.scrollTo(null, t - middleHeight - 5);
|
||||
}
|
||||
|
||||
// TODO: https://stackoverflow.com/questions/10463518/converting-em-to-px-in-javascript-and-getting-default-font-size
|
||||
function getVisibleEditorLineHeight() : number{
|
||||
return $(".CodeMirror-line:visible").first().height();
|
||||
return $("#booksMenuButton").first().height();
|
||||
}
|
||||
|
||||
/////
|
||||
|
@ -94,4 +94,6 @@ export interface WorkerResult {
|
||||
listings:CodeListingMap,
|
||||
symbolmap:{[sym:string]:number},
|
||||
params:{},
|
||||
unchanged?:boolean,
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user