Example #1
0
    function doPaste()
    {
        var item = commando.getSubscope();
        var path = (local.cut || local.copy).data.path;
        var ioFile = require("ko/file");
        var newPath = ioFile.join(item.data.path, ioFile.basename(path));

        if (local.cut)
            ioFile.move(path, newPath);
        else
            ioFile.copy(path, newPath);

        item.isExpanded = false;
        commando.clear();

        if (local.cut)
        {
            commando.tip('Moved "'+local.cut.name+'" here');
            local.cut = null;
        }
        else
        {
            commando.tip('Copied "'+local.copy.name+'" here');
            local.copy = null;
        }
    }
Example #2
0
    function doCopy()
    {
        local.cut = null;
        local.copy = commando.getSubscope();

        commando.tip('Copying: "'+local.copy.name+'", expand a folder to paste it');
        commando.navBack();
    }
Example #3
0
    function doMove()
    {
        local.copy = null;
        local.cut = commando.getSubscope();

        commando.tip('Moving: "'+local.cut.name+'", expand a folder to paste it');
        commando.navBack();
    }
Example #4
0
    function addShortcut()
    {
        var item = commando.getSubscope();
        var shortcut = commando.prompt(null, "Enter shortcut: ");

        if (shortcut.search(/^[A-Za-z0-9]+$/) == -1)
        {
            return commando.tip("Shortcuts need to be alphanumeric and can not contain whitespace", "error");
        }

        var _shortcut = shortcut + ":" + item.data.path;
        spref.appendString(_shortcut);
        
        resultCacheVersion = -1;
        handler.clearShortcutCache();

        commando.tip("Shortcut added, you can use it by typing '"+shortcut+"/'");
        commando.navBack();
    }
Example #5
0
    function doCreate()
    {
        var ioFile = require("sdk/io/file");
        var item = commando.getSubscope();

        var filename = commando.prompt("Filename: ");

        if ( ! filename) return;

        try
        {
            require("ko/file").create(item.data.path, filename);
        }
        catch (e)
        {
            commando.tip("Error: " + e.message, "error");
            return false;
        }
        
        commando.tip("File \""+filename+"\" has been created");
    }
Example #6
0
    function removeShortcut()
    {
        var item = commando.getSubscope();

        for (let x=0;x<spref.length;x++)
        {
            let [shortcut, path] = spref.getString(x).split(":");
            if (path == item.data.path)
            {
                spref.deletePref(x);
                break;
            }
        }

        resultCacheVersion = -1;
        handler.clearShortcutCache();

        commando.reSearch();
        commando.tip();
    }