mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-23 03:29:39 +00:00
rename/delete files
This commit is contained in:
parent
4b8d7406b0
commit
c20c5a466b
@ -84,7 +84,8 @@ TODO:
|
||||
- resize memory browser when split resize (any div resize)
|
||||
- preroll the emulator so optimizer does its thing before loading rom
|
||||
- wasm dynamic linking of emulators (https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md)
|
||||
- upload text/binary detection
|
||||
- use alternate confirm/prompt dialogs
|
||||
- https://github.com/jvilk/BrowserFS
|
||||
|
||||
|
||||
WEB WORKER FORMAT
|
||||
|
10
index.html
10
index.html
@ -48,11 +48,15 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<li><a class="dropdown-item" href="#" id="item_new_file">New Project...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_upload_file">Upload File...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_reset_file">Revert to Original...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_upload_file">Upload...</a></li>
|
||||
<hr>
|
||||
<li class="dropdown dropdown-submenu">
|
||||
<a tabindex="-1" href="#">Add Files to Project</a>
|
||||
<a tabindex="-1" href="#">File</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#" id="item_reset_file">Revert to Original...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_rename_file">Rename File...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_delete_file">Delete File...</a></li>
|
||||
<hr>
|
||||
<li><a class="dropdown-item" href="#" id="item_addfile_include">Add Include File...</a></li>
|
||||
<li><a class="dropdown-item" href="#" id="item_addfile_link">Add Linked File...</a></li>
|
||||
</ul>
|
||||
|
46
src/ui.ts
46
src/ui.ts
@ -143,7 +143,7 @@ function refreshWindowList() {
|
||||
if (typeof data === 'string')
|
||||
addWindowItem(id, getFilenameForPath(id), loadEditor);
|
||||
else if (data instanceof Uint8Array)
|
||||
addWindowItem(id, getFilenameForPath(id), () => { return new Views.BinaryFileView(data as Uint8Array); });
|
||||
addWindowItem(id, getFilenameForPath(id), () => { return new Views.BinaryFileView(id, data as Uint8Array); });
|
||||
}
|
||||
|
||||
// add main file editor
|
||||
@ -441,6 +441,48 @@ function _revertFile(e) {
|
||||
}
|
||||
}
|
||||
|
||||
function _deleteFile(e) {
|
||||
var wnd = projectWindows.getActive();
|
||||
if (wnd && wnd.getPath) {
|
||||
var fn = projectWindows.getActiveID();
|
||||
if (fn.startsWith("local/")) {
|
||||
if (confirm("Delete '" + fn + "'?")) {
|
||||
store.removeItem(fn, () => {
|
||||
alert("Deleted " + fn);
|
||||
updateSelector();
|
||||
// TODO: rebuild?
|
||||
//gotoNewLocation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
alert("Can only delete local files.");
|
||||
}
|
||||
} else {
|
||||
alert("Cannot delete the active window.");
|
||||
}
|
||||
}
|
||||
|
||||
function _renameFile(e) {
|
||||
var wnd = projectWindows.getActive();
|
||||
if (wnd && wnd.getPath && current_project.getFile(wnd.getPath())) {
|
||||
var fn = projectWindows.getActiveID();
|
||||
var newfn = prompt("Rename '" + fn + "' to?", fn);
|
||||
var data = current_project.getFile(wnd.getPath());
|
||||
if (newfn && data && newfn.startsWith("local/")) {
|
||||
store.removeItem(fn, () => {
|
||||
store.setItem(newfn, data, () => {
|
||||
alert("Renamed " + fn + " to " + newfn);
|
||||
updateSelector();
|
||||
// TODO: rebuild?
|
||||
//gotoNewLocation();
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
alert("Cannot rename the active window.");
|
||||
}
|
||||
}
|
||||
|
||||
function _downloadROMImage(e) {
|
||||
if (current_output == null) {
|
||||
alert("Please finish compiling with no errors before downloading ROM.");
|
||||
@ -1016,6 +1058,8 @@ function setupDebugControls(){
|
||||
$("#item_upload_file").click(_uploadNewFile);
|
||||
$("#item_share_file").click(_shareEmbedLink);
|
||||
$("#item_reset_file").click(_revertFile);
|
||||
$("#item_rename_file").click(_renameFile);
|
||||
$("#item_delete_file").click(_deleteFile);
|
||||
if (platform.runEval)
|
||||
$("#item_debug_expr").click(_breakExpression).show();
|
||||
else
|
||||
|
@ -13,6 +13,7 @@ export interface ProjectView {
|
||||
createDiv(parent:HTMLElement, text:string) : HTMLElement;
|
||||
refresh(moveCursor:boolean) : void;
|
||||
tick?() : void;
|
||||
getPath?() : string;
|
||||
getValue?() : string;
|
||||
setText?(text : string) : void;
|
||||
insertText?(text : string) : void;
|
||||
@ -716,9 +717,11 @@ export class MemoryView implements ProjectView {
|
||||
export class BinaryFileView implements ProjectView {
|
||||
memorylist;
|
||||
maindiv : HTMLElement;
|
||||
data;
|
||||
path:string;
|
||||
data:Uint8Array;
|
||||
|
||||
constructor(data:Uint8Array) {
|
||||
constructor(path:string, data:Uint8Array) {
|
||||
this.path = path;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@ -763,4 +766,6 @@ export class BinaryFileView implements ProjectView {
|
||||
|
||||
refresh() {
|
||||
}
|
||||
|
||||
getPath() { return this.path; }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user