icewolfz / jiMUD

MUD client for ShadowMUD.com using electron
http://www.shadowmud.com
7 stars 0 forks source link

Code editor: project/workspace system #267

Open icewolfz opened 3 months ago

icewolfz commented 3 months ago

A side bar treeview that allows both folders and virtual folders to allow grouping or exploring folders

virtual folder feature be a folder contained in the work space that links to files/folders and users can add any files/folders with out creating new ones a folder would be a real folder that when expanded would reveal all folders/files under it

const Path = require('path');
enum WorkSpaceItemType { Container, Item } //maybe split up item into file/folder?
class WorkSpaceItem {
    let name:string; // the displayed name
    let type:WorkSpaceItemType = WorkSpaceItemType .Container; //the type of item
    let icon:string; //a custom icon
    let path; //the path
    let _items; //subitems? maybe workspacecollction type
    function contructor(type, path) {
        this.type = type;
        this.path = path;
        if(this.type === WorkSpaceItemType .Container)
            this._items = new WorkSpaceCollection();
    }
    function getIcon():string {
        if(this.icon&& this.icon.length) return this.icon;
        if(this.type === WorkSpaceItemType .Container) return "fa-folder-o";
        return "fa-file-o"; 
    }
    function getDisplayName():string {
        if(this.name && this.name.length) return this.name;
        if(this.path && this.path.length) return Path.basename(this.path);
        if(this.type === WorkSpaceItemType .Container) return "(Unnamed Folder)";
        return "(Unnamed File)";
    }
    function items() {
        if(this.type === WorkSpaceItemType .Container)
            return this._items;   
        if(isDir(this.path)) return [];//return array of file data
        return [];//a file or unknown type so just return empty array as they should not have items
    }
}
class WorkSpaceCollection{
    let Items[]:WorkSpaceItemType = [];
    function add(item) { /*TODO add safty checks */this.Items.push(item); }
    function remove(item) { int idx = this.Items.indexOf(item); this.Items.splice(idx, 0); }
    get length():int { return this.Items.length; }
}
icewolfz commented 3 months ago

A basic session system has been added but it is just for saving a group of opened tabs, a workspace/project is a management system to allow grouping of folders and files with out needing to have them open