revert files, not presets

This commit is contained in:
Steven Hugg 2018-08-21 10:16:47 -04:00
parent 0b67f94187
commit 75ea169720
5 changed files with 26 additions and 18 deletions

View File

@ -43,17 +43,17 @@ TODO:
- compile stuck when errors unchanged
- sound mute?
- $error updates source editor
- Revert loads cached files?
- Verilog compile spins forever?
- how to revert included files?
- go to error in include files
- BOM in upload/download?
- stack view for Z80 platforms using memory map
- online tools for music etc
- tools (memory, disasm) use debugging state
- loadROM needs to stop debugging before loading
- text log debugging script
- update listing when recompiling
- NES crt should mark raster pos when debugging
- make sure we don't store files in local storage unnecc.
- state buffer/replay
- intro/help text for each platform
FYI: Image links for the books on http://8bitworkshop.com/ are broken
On the website the additional grey spacing next to the program line numbers is not dynamically resized when the web browser window size is changed. Intentional?

View File

@ -72,11 +72,17 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<a tabindex="-1" href="#">Platform</a>
<ul class="dropdown-menu">
<li class="dropdown dropdown-submenu">
<a tabindex="-1" href="#">Consoles</a>
<a tabindex="-1" href="#">Game Consoles</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="?platform=vcs" id="item_platform_vcs">Atari 2600/VCS</a></li>
</ul>
</li>
<li class="dropdown dropdown-submenu">
<a tabindex="-1" href="#">Computers</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="?platform=apple2" id="item_platform_apple2">Apple ][+</a></li>
</ul>
</li>
<li class="dropdown dropdown-submenu">
<a tabindex="-1" href="#">Arcade Systems</a>
<ul class="dropdown-menu">

View File

@ -110,7 +110,6 @@ export class CodeProject {
updateFileInStore(path:string, text:FileData) {
// protect against accidential whole-file deletion
if ((<string>text).trim && (<string>text).trim().length) {
// TODO? (originalFileID != path || text != originalText)) {
this.store.setItem(path, text);
}
}
@ -170,7 +169,7 @@ export class CodeProject {
if (err) { // err fetching from store
callback(err, result);
} else if (value) { // found in store?
this.filedata[path] = value;
this.filedata[path] = value; // do not update store, just cache
addResult(path, value);
loadNext();
} else if (!path.startsWith("local/")) {
@ -183,7 +182,7 @@ export class CodeProject {
webpath += ".a"; // legacy stuff
this.callbackGetRemote( webpath, (text:string) => {
console.log("GET",webpath,text.length,'bytes');
this.filedata[path] = text;
this.filedata[path] = text; // do not update store, just cache
addResult(path, text);
loadNext();
}, 'text')
@ -191,7 +190,7 @@ export class CodeProject {
console.log("Could not load preset", path, err.status);
// only cache result if status is 404 (not found)
if (err.status && err.status == 404)
this.filedata[path] = null;
this.filedata[path] = null; // mark cache entry as invalid
loadNext();
});
} else {

View File

@ -310,14 +310,16 @@ function _shareFile(e) {
return true;
}
// TODO: reset file, not project
function _resetPreset(e) {
if (!current_preset_entry) {
alert("Can only reset built-in file examples.")
} else if (confirm("Reset '" + current_preset_entry.name + "' to default?")) {
qs['reset'] = '1';
gotoNewLocation();
}
function _revertFile(e) {
var fn = getCurrentEditorFilename();
$.get( "presets/"+platform_id+"/"+fn, function(text) {
if (confirm("Reset '" + fn + "' to default?")) {
projectWindows.getActive().setText(text);
}
}, 'text')
.fail(function() {
alert("Can only revert built-in files.");
});
return true;
}
@ -712,7 +714,7 @@ function setupDebugControls(){
$("#item_new_file").click(_createNewFile);
$("#item_upload_file").click(_uploadNewFile);
$("#item_share_file").click(_shareFile);
$("#item_reset_file").click(_resetPreset);
$("#item_reset_file").click(_revertFile);
if (platform.runEval)
$("#item_debug_expr").click(_breakExpression).show();
else

View File

@ -12,6 +12,7 @@ export interface ProjectView {
refresh(moveCursor:boolean) : void;
tick?() : void;
getValue?() : string;
setText?(text : string) : void;
getCursorPC?() : number;
getSourceFile?() : SourceFile;
setGutterBytes?(line:number, s:string) : void;