diff --git a/src/common/workertypes.ts b/src/common/workertypes.ts index a7c5b78e..ebe4c6b5 100644 --- a/src/common/workertypes.ts +++ b/src/common/workertypes.ts @@ -138,6 +138,7 @@ export interface WorkerUnchangedResult { export interface WorkerErrorResult { errors: WorkerError[] listings?: CodeListingMap + uppercaseOnly?: boolean } export interface WorkerOutputResult { @@ -147,6 +148,7 @@ export interface WorkerOutputResult { params?: {} segments?: Segment[] debuginfo?: {} // optional info + uppercaseOnly?: boolean origin?: number } diff --git a/src/ide/ui.ts b/src/ide/ui.ts index 87d48429..ebe16df2 100644 --- a/src/ide/ui.ts +++ b/src/ide/ui.ts @@ -21,7 +21,7 @@ import { Toolbar } from "./toolbar"; import { AssetEditorView } from "./views/asseteditor"; import { isMobileDevice } from "./views/baseviews"; import { AddressHeatMapView, BinaryFileView, MemoryMapView, MemoryView, ProbeLogView, ProbeSymbolView, RasterStackMapView, ScanlineIOView, VRAMMemoryView } from "./views/debugviews"; -import { DisassemblerView, ListingView, PC_LINE_LOOKAHEAD, SourceEditor } from "./views/editors"; +import { DisassemblerView, ListingView, PC_LINE_LOOKAHEAD, SourceEditor, setUppercaseOnly } from "./views/editors"; import { CallStackView, DebugBrowserView } from "./views/treeviews"; import { ProjectWindows } from "./windows"; import Split = require('split.js'); @@ -908,6 +908,9 @@ function showExceptionAsError(err, msg: string) { } async function setCompileOutput(data: WorkerResult) { + if ('uppercaseOnly' in data) { + setUppercaseOnly(data.uppercaseOnly); + } // errors? mark them in editor if ('errors' in data && data.errors.length > 0) { toolbar.addClass("has-errors"); diff --git a/src/ide/views/editors.ts b/src/ide/views/editors.ts index 01fb8c1b..fbbf39ca 100644 --- a/src/ide/views/editors.ts +++ b/src/ide/views/editors.ts @@ -60,6 +60,10 @@ export var textMapFunctions = { input: null as ((text: string) => string) | null }; +export function setUppercaseOnly(uppercaseOnly: boolean) { + textMapFunctions.input = uppercaseOnly ? (s) => s.toUpperCase() : null; +} + export class SourceEditor implements ProjectView { constructor(path: string, mode: string) { this.path = path; diff --git a/src/platform/basic.ts b/src/platform/basic.ts index c2180af3..476704d9 100644 --- a/src/platform/basic.ts +++ b/src/platform/basic.ts @@ -1,7 +1,6 @@ import { Platform, BreakpointCallback, DebugCondition, DebugEvalCondition } from "../common/baseplatform"; import { PLATFORMS, AnimationTimer, EmuHalt } from "../common/emu"; -import * as editors from "../ide/views/editors"; import { BASICRuntime } from "../common/basic/runtime"; import { BASICProgram } from "../common/basic/compiler"; import { TeleTypeWithKeyboard } from "../common/teletype"; @@ -133,8 +132,6 @@ class BASICPlatform implements Platform { this.program = data; var resumePC = this.runtime.load(data); this.tty.uppercaseOnly = true; // this.program.opts.uppercaseOnly; //TODO? - // map editor to uppercase-only if need be - editors.textMapFunctions.input = this.program.opts.uppercaseOnly ? (s) => s.toUpperCase() : null; // only reset if we exited, or couldn't restart at label (PC reset to 0) if (!this.hotReload || didExit || !resumePC) this.reset(); diff --git a/src/worker/tools/misc.ts b/src/worker/tools/misc.ts index 55fe3bba..c8e495bb 100644 --- a/src/worker/tools/misc.ts +++ b/src/worker/tools/misc.ts @@ -128,7 +128,7 @@ export function compileBASIC(step: BuildStep): WorkerResult { if (parser.errors.length == 0) throw e; } if (parser.errors.length) { - return { errors: parser.errors }; + return { errors: parser.errors, uppercaseOnly: parser.opts.uppercaseOnly }; } // put AST into JSON (sans source locations) to see if it has changed var json = JSON.stringify(ast, (key, value) => { return (key == '$loc' ? undefined : value) }); @@ -136,6 +136,7 @@ export function compileBASIC(step: BuildStep): WorkerResult { if (anyTargetChanged(step, [jsonpath])) return { output: ast, listings: parser.getListings(), + uppercaseOnly: parser.opts.uppercaseOnly, }; } }