Skip to content

Commit 40f9251

Browse files
authored
Merge pull request #223 from fredsa/fileexts2
Recommend default extensions #206
2 parents b85b2ff + f742812 commit 40f9251

35 files changed

Lines changed: 57 additions & 58 deletions

css/ui.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,4 +812,7 @@ div.scripting-cell button:hover {
812812
}
813813
div.scripting-cell button.scripting-enabled {
814814
background-color: #339999;
815+
}
816+
.dialog-help {
817+
color: #6666ff;
815818
}

doc/platforms.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Mandatory functions:
1515
These are for the compiler/editor:
1616
~~~
1717
getToolForFilename(s:string) : string;
18-
getDefaultExtension() : string;
18+
getDefaultExtensions() : string[];
1919
getPresets() : Preset[];
2020
~~~
2121

@@ -205,7 +205,7 @@ class ColecoVisionMAMEPlatform extends BaseMAMEPlatform implements Platform {
205205
206206
getPresets() { return ColecoVision_PRESETS; }
207207
getToolForFilename = getToolForFilename_z80;
208-
getDefaultExtension() { return ".c"; };
208+
getDefaultExtensions() { return [".c", ".ns", ".s", ".scc", ".sgb", ".z", ".wiz"]; }
209209
}
210210
~~~
211211

src/common/baseplatform.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export interface Platform {
8181
reset(): void;
8282
isRunning(): boolean;
8383
getToolForFilename(s: string): string;
84-
getDefaultExtension(): string;
84+
getDefaultExtensions(): string[];
8585
getPresets?(): Preset[];
8686
pause(): void;
8787
resume(): void;
@@ -480,7 +480,7 @@ export abstract class Base6502Platform extends BaseDebugPlatform {
480480
return disassemble6502(pc, read(pc), read(pc + 1), read(pc + 2));
481481
}
482482
getToolForFilename = getToolForFilename_6502;
483-
getDefaultExtension() { return ".a"; };
483+
getDefaultExtensions() { return [".c", ".cpp", ".acme", ".ca65", ".dasm", ".ecs", ".wiz"]; };
484484

485485
getDebugCategories() {
486486
return ['CPU', 'ZPRAM', 'Stack'];
@@ -600,7 +600,7 @@ export abstract class BaseZ80Platform extends BaseDebugPlatform {
600600
}
601601

602602
getToolForFilename = getToolForFilename_z80;
603-
getDefaultExtension() { return ".c"; };
603+
getDefaultExtensions() { return [".c", ".ns", ".s", ".scc", ".sgb", ".z", ".wiz"]; };
604604
// TODO: Z80 opcode metadata
605605
//this.getOpcodeMetadata = function() { }
606606

@@ -677,7 +677,7 @@ export abstract class Base6809Platform extends BaseZ80Platform {
677677
// TODO: don't create new CPU
678678
return Object.create(CPU6809()).disasm(read(pc), read(pc + 1), read(pc + 2), read(pc + 3), read(pc + 4), pc);
679679
}
680-
getDefaultExtension(): string { return ".asm"; };
680+
getDefaultExtensions() { return [".c", ".lwasm", ".xasm"]; };
681681
//this.getOpcodeMetadata = function() { }
682682
getToolForFilename = getToolForFilename_6809;
683683
getDebugCategories() {
@@ -789,7 +789,7 @@ export abstract class BaseMachinePlatform<T extends Machine> extends BaseDebugPl
789789

790790
abstract newMachine(): T;
791791
abstract getToolForFilename(s: string): string;
792-
abstract getDefaultExtension(): string;
792+
abstract getDefaultExtensions(): string[];
793793
abstract getPresets(): Preset[];
794794

795795
constructor(mainElement: HTMLElement) {
@@ -979,6 +979,7 @@ export abstract class Base6502MachinePlatform<T extends Machine> extends BaseMac
979979

980980
getOpcodeMetadata = getOpcodeMetadata_6502;
981981
getToolForFilename(fn) { return getToolForFilename_6502(fn); }
982+
getDefaultExtensions() { return [".c", ".cpp", ".acme", ".ca65", ".dasm", ".ecs", ".wiz"]; }
982983

983984
disassemble(pc: number, read: (addr: number) => number): DisasmLine {
984985
return disassemble6502(pc, read(pc), read(pc + 1), read(pc + 2));
@@ -1003,6 +1004,7 @@ export abstract class BaseZ80MachinePlatform<T extends Machine> extends BaseMach
10031004

10041005
//getOpcodeMetadata = getOpcodeMetadata_z80;
10051006
getToolForFilename = getToolForFilename_z80;
1007+
getDefaultExtensions() { return [".c", ".ns", ".s", ".scc", ".sgb", ".z", ".wiz"]; }
10061008

10071009
getDebugCategories() {
10081010
if (isDebuggable(this.machine))
@@ -1032,6 +1034,7 @@ export abstract class BaseZ80MachinePlatform<T extends Machine> extends BaseMach
10321034
export abstract class Base6809MachinePlatform<T extends Machine> extends BaseMachinePlatform<T> {
10331035

10341036
getToolForFilename = getToolForFilename_6809;
1037+
getDefaultExtensions() { return [".c", ".lwasm", ".xasm"]; }
10351038

10361039
getDebugCategories() {
10371040
if (isDebuggable(this.machine))

src/ide/ui.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,14 +502,18 @@ function checkEnteredFilename(fn: string): boolean {
502502

503503
function _createNewFile(e) {
504504
// TODO: support spaces
505+
var extensions = platform.getDefaultExtensions();
505506
bootbox.prompt({
506-
title: "Enter the name of your new main source file.",
507-
placeholder: "newfile" + platform.getDefaultExtension(),
507+
title: "Enter the name of your new main source file.<br><br>" +
508+
"<span class='dialog-help'>" +
509+
(extensions.length > 1 ? extensions.join(" ") : "") +
510+
"</span>",
511+
placeholder: "newfile" + extensions[0],
508512
callback: (filename) => {
509513
if (filename && filename.trim().length > 0) {
510514
if (!checkEnteredFilename(filename)) return;
511515
if (filename.indexOf(".") < 0) {
512-
filename += platform.getDefaultExtension();
516+
filename += extensions[0];
513517
}
514518
var path = filename;
515519
gaEvent('workspace', 'file', 'new');

src/platform/apple2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Apple2MAMEPlatform extends BaseMAME6502Platform implements Platform {
4747
}
4848

4949
getOpcodeMetadata = getOpcodeMetadata_6502;
50-
getDefaultExtension() { return ".c"; };
50+
getDefaultExtensions() { return [".c", ".cpp", ".acme", ".ca65", ".dasm", ".ecs", ".wiz"]; }
5151
getToolForFilename = getToolForFilename_6502;
5252

5353
getPresets() { return APPLE2_PRESETS; }
@@ -64,7 +64,7 @@ class NewApple2Platform extends Base6502MachinePlatform<AppleII> implements Plat
6464

6565
newMachine() { return new AppleII(); }
6666
getPresets() { return APPLE2_PRESETS; }
67-
getDefaultExtension() { return ".c"; };
67+
getDefaultExtensions() { return [...super.getDefaultExtensions(), ".lnk"]; }
6868
readAddress(a) { return this.machine.readConst(a); }
6969
// TODO loadBIOS(bios) { this.machine.loadBIOS(a); }
7070
getMemoryMap = function () {

src/platform/arm32.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export abstract class BaseARMMachinePlatform<T extends Machine> extends BaseMach
4343
return "armtcc";
4444
}
4545
getPresets() { return ARM32_PRESETS; }
46-
getDefaultExtension() { return ".c"; };
46+
getDefaultExtensions() { return [".c", ".armips", ".vasm"]; }
4747
}
4848

4949
class ARM32Platform extends BaseARMMachinePlatform<ARM32Machine> implements Platform {

src/platform/astrocade.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class BallyAstrocadePlatform extends BaseZ80MachinePlatform<BallyAstrocade> impl
3434

3535
newMachine() { return new BallyAstrocade(false); }
3636
getPresets() { return ASTROCADE_PRESETS; }
37-
getDefaultExtension() { return ".c"; };
3837
readAddress(a) { return this.machine.read(a); }
3938
getMemoryMap = function() { return { main:[
4039
{name:'BIOS',start:0x0,size:0x2000,type:'rom'},

src/platform/atari7800.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Atari7800Platform extends Base6502MachinePlatform<Atari7800> implements Pl
1919

2020
newMachine() { return new Atari7800(); }
2121
getPresets() { return Atari7800_PRESETS; }
22-
getDefaultExtension() { return ".c"; };
22+
getDefaultExtensions() { return [...super.getDefaultExtensions(), ".cc7800"]; }
2323
readAddress(a) { return this.machine.readConst(a); }
2424
// TODO loadBIOS(bios) { this.machine.loadBIOS(a); }
2525
getMemoryMap = function() { return { main:[

src/platform/atari8.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function getToolForFilename_Atari8(fn:string) {
4343
class Atari800Platform extends Base6502MachinePlatform<Atari800> {
4444
newMachine() { return new Atari800(); }
4545
getPresets() { return Atari800_PRESETS; }
46-
getDefaultExtension() { return ".c"; };
46+
getDefaultExtensions() { return [...super.getDefaultExtensions(), ".bas"]; }
4747
getToolForFilename = getToolForFilename_Atari8;
4848
readAddress(a) { return this.machine.readConst(a); }
4949
getMemoryMap() { return Atari800_MemoryMap; }
@@ -83,7 +83,7 @@ abstract class Atari8MAMEPlatform extends BaseMAME6502Platform {
8383
getPresets() { return Atari8_PRESETS; }
8484
getToolForFilename = getToolForFilename_Atari8;
8585
getOpcodeMetadata = getOpcodeMetadata_6502;
86-
getDefaultExtension() { return ".asm"; };
86+
getDefaultExtensions() { return [".c", ".bas", ".cpp", ".acme", ".ca65", ".dasm", ".ecs", ".wiz"]; }
8787
showHelp = atari8_showHelp;
8888
}
8989

src/platform/basic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class BASICPlatform implements Platform {
163163

164164
isBlocked() { return this.tty.waitingfor != null || this.runtime.exited; } // is blocked for input?
165165
isRunning() { return this.timer.isRunning(); }
166-
getDefaultExtension() { return ".bas"; }
166+
getDefaultExtensions() { return [".bas"]; }
167167
getToolForFilename() { return "basic"; }
168168
getPresets() { return BASIC_PRESETS; }
169169

0 commit comments

Comments
 (0)