From a9736e18cf4ccf6171f2cdc34fea263ea4f8b5c8 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Sun, 29 Sep 2019 08:36:20 -0500 Subject: [PATCH] ui: memory map click updates nav bar, started on open relevant source file --- doc/notes.txt | 2 ++ src/ui.ts | 38 ++++++++++++++++++++++++++++++-------- src/views.ts | 8 +------- src/windows.ts | 22 ++++++++++++++-------- 4 files changed, 47 insertions(+), 23 deletions(-) diff --git a/doc/notes.txt b/doc/notes.txt index d9d45905..f4e0d3b6 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -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 diff --git a/src/ui.ts b/src/ui.ts index 353cf9c2..b2c6e885 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -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"); }); diff --git a/src/views.ts b/src/views.ts index 6fa7f302..0421a10c 100644 --- a/src/views.ts +++ b/src/views.ts @@ -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 }); } diff --git a/src/windows.ts b/src/windows.ts index 4964bfc8..49c446bd 100644 --- a/src/windows.ts +++ b/src/windows.ts @@ -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;