1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-26 22:31:14 +00:00

ui: memory map click updates nav bar, started on open relevant source file

This commit is contained in:
Steven Hugg 2019-09-29 08:36:20 -05:00
parent e88fb97a07
commit a9736e18cf
4 changed files with 47 additions and 23 deletions

View File

@ -188,6 +188,8 @@ TODO:
- TypeError: null is not an object (evaluating 'n.destination')
https://8bitworkshop.com/v3.4.1/javatari.js/release/javatari/javatari.js
(32:443651) Safari 12.1.2
- Safari: doesn't send good exception reasons ("undefined")
WEB WORKER FORMAT

View File

@ -6,7 +6,7 @@ import * as bootstrap from "bootstrap";
import { CodeProject } from "./project";
import { WorkerResult, WorkerOutput, VerilogOutput, SourceFile, WorkerError, FileData } from "./workertypes";
import { ProjectWindows } from "./windows";
import { Platform, Preset, DebugSymbols, DebugEvalCondition, isDebuggable } from "./baseplatform";
import { Platform, Preset, DebugSymbols, DebugEvalCondition, isDebuggable, EmuState } from "./baseplatform";
import { PLATFORMS, EmuHalt, Toolbar } from "./emu";
import * as Views from "./views";
import { createNewPersistentStore } from "./store";
@ -48,7 +48,7 @@ var current_preset : Preset; // current preset object (if selected)
var store; // persistent store
export var compparams; // received build params from worker
export var lastDebugState; // last debug state (object)
export var lastDebugState : EmuState; // last debug state (object)
var lastDebugInfo; // last debug info (CPU text)
var debugCategory; // current debug category
@ -194,11 +194,14 @@ function refreshWindowList() {
li.appendChild(a);
ul.append(li);
if (createfn) {
var onopen = (id, wnd) => {
ul.find('a').removeClass("dropdown-item-checked");
$(a).addClass("dropdown-item-checked");
};
projectWindows.setCreateFunc(id, createfn);
projectWindows.setShowFunc(id, onopen);
$(a).click( (e) => {
projectWindows.createOrShow(id);
ul.find('a').removeClass("dropdown-item-checked");
ul.find(e.target).addClass("dropdown-item-checked");
});
}
}
@ -994,7 +997,7 @@ function measureBuildTime() {
ga('send', 'timing', 'build', platform_id, (measureTimeBuild.getTime() - measureTimeLoad.getTime()));
measureTimeLoad = null; // only measure once
}
gaEvent('build', platform_id);
//gaEvent('build', platform_id);
}
function setCompileOutput(data: WorkerResult) {
@ -1091,15 +1094,34 @@ function checkRunReady() {
return true;
}
function uiDebugCallback(state) {
function openRelevantListing(state: EmuState) {
var listings = current_project.getListings();
if (listings) {
var pc = state.c ? (state.c.EPC || state.c.PC) : 0;
for (var lstfn in listings) {
var lst = listings[lstfn];
var file = lst.assemblyfile || lst.sourcefile;
var lineno = file && file.findLineForOffset(pc, 16); // TODO: const
console.log(pc,lstfn,lineno);
if (lineno !== null) {
projectWindows.createOrShow(lstfn, true);
return;
}
}
}
projectWindows.createOrShow("#disasm", true);
}
function uiDebugCallback(state: EmuState) {
lastDebugState = state;
showDebugInfo(state);
projectWindows.refresh(true);
//openRelevantListing(state);
projectWindows.refresh(true); // move cursor
debugTickPaused = true;
}
function setupDebugCallback(btnid? : string) {
if (platform.setupDebug) platform.setupDebug((state) => {
if (platform.setupDebug) platform.setupDebug((state:EmuState) => {
uiDebugCallback(state);
setDebugButtonState(btnid||"pause", "stopped");
});

View File

@ -495,12 +495,7 @@ export class ListingView extends DisassemblerView implements ProjectView {
// lookup corresponding assemblyfile for this file, using listing
var lst = current_project.getListingForFile(this.path);
// TODO?
if (lst && lst.assemblyfile) {
this.assemblyfile = lst.assemblyfile;
}
else if (lst && lst.sourcefile) {
this.assemblyfile = lst.sourcefile;
}
this.assemblyfile = lst && (lst.assemblyfile || lst.sourcefile);
}
refresh(moveCursor: boolean) {
@ -800,7 +795,6 @@ export class MemoryMapView implements ProjectView {
segdiv.click(() => {
var memview = projectWindows.createOrShow('#memory') as MemoryView;
memview.scrollToAddress(seg.start);
// TODO: this doesn't update nav bar
});
}

View File

@ -6,12 +6,14 @@ import { WorkerError, FileData } from "./workertypes";
import { ProjectView } from "./views";
type WindowCreateFunction = (id:string) => ProjectView;
type WindowShowFunction = (id:string, view:ProjectView) => void;
export class ProjectWindows {
containerdiv : HTMLElement;
project : CodeProject;
id2window : {[id:string]:ProjectView} = {};
id2createfn : {[id:string]:WindowCreateFunction} = {};
id2showfn : {[id:string]:WindowShowFunction} = {};
id2div : {[id:string]:HTMLElement} = {};
activeid : string;
activewnd : ProjectView;
@ -29,6 +31,10 @@ export class ProjectWindows {
setCreateFunc(id:string, createfn:WindowCreateFunction) : void {
this.id2createfn[id] = createfn;
}
setShowFunc(id:string, showfn:WindowShowFunction) : void {
this.id2showfn[id] = showfn;
}
create(id:string) : ProjectView {
var wnd = this.id2window[id];
@ -45,21 +51,21 @@ export class ProjectWindows {
return wnd;
}
createOrShow(id:string) : ProjectView {
createOrShow(id: string, moveCursor?: boolean) : ProjectView {
var wnd = this.create(id);
var div = this.id2div[id];
if (this.activewnd != wnd) {
if (this.activediv)
$(this.activediv).hide();
if (this.activewnd && this.activewnd.setVisible)
this.activewnd.setVisible(false);
this.activediv && $(this.activediv).hide();
this.activewnd && this.activewnd.setVisible && this.activewnd.setVisible(false);
this.activediv = div;
this.activewnd = wnd;
$(div).show();
this.refresh(true);
this.refresh(moveCursor);
this.refreshErrors();
if (wnd.setVisible)
wnd.setVisible(true);
wnd.setVisible && wnd.setVisible(true);
this.id2showfn[id] && this.id2showfn[id](id, wnd);
} else {
this.refresh(moveCursor);
}
this.activeid = id;
return wnd;