How to use ko - 10 common examples

To help you get started, we’ve selected a few ko examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Komodo / KomodoEdit / src / modules / scope_packages / content / packages.js View on Github external
this._downloadFile(asset.browser_download_url, function(file)
                {
                    log.debug("Importing " + file + " as scheme " + pkg.name);
                    var schemeName = asset.browser_download_url.split(/\/|\./).slice(-2)[0];
                    var schemeService = Cc['@activestate.com/koKeybindingSchemeService;1'].getService();
                    // Refresh the list of known schemes.
                    schemeService.reloadAvailableSchemes();
                    keybindings.manager.reloadConfigurations(true); // refresh
                    callback(); // indicate success before potentially restarting
                    // Prompt the user to apply the new scheme.
                    if (dialog.confirm(l.get("applyKeybinds.prompt")))
                    {
                        log.debug("Applying scheme " + schemeName);
                        keybindings.manager.revertToPref(schemeName); // probably not the intended use, but it works
                        require("notify/notify").interact(l.get("keybindingsApplied", pkg.name), "packages", {id: "packageInstall"});
                    }
                    commando.focus();
                }, errorCallback, OS.Path.join(dirService.userDataDir, 'schemes'));
                break;
github Komodo / KomodoEdit / src / modules / scope_files / content / files.js View on Github external
}
                }
            }
        }

        // Set includes/excludes.
        var opts_prefs = ((curProject && subscope.path.indexOf(curProject.liveDirectory) === 0) ?
                          curProject.prefset :
                          prefs);
        opts["excludes"] = opts_prefs.getString("import_exclude_matches");
        opts["includes"] = opts_prefs.getString("import_include_matches");

        opts["excludes"] = opts["excludes"] == "" ? [] : opts["excludes"].split(";");
        opts["includes"] = opts["includes"] == "" ? [] : opts["includes"].split(";");

        opts["weightMatch"] = prefs.getBoolean('commando_files_weight_multiplier_match', 30);
        opts["weightHits"] = prefs.getBoolean('commando_files_weight_multiplier_hits', 20);
        opts["weightDepth"] = prefs.getBoolean('commando_files_weight_multiplier_depth', 10);
        
        paths.unshift(subscope.path);

        var _opts = JSON.stringify(opts);
        log.debug(uuid + " - Query: "+ query +", Paths: "+ paths.join(" : ") + ", Opts: " + _opts);

        scope.search(query, uuid, paths.join(","), _opts, function(status, results)
        {
            if (activeUuid != uuid)
            {
                if ( ! (uuid in local.warned))
                {
                    log.debug(uuid + " - No longer the active search, don't pass result");
                    local.warned[uuid] = true;
github Komodo / KomodoEdit / src / chrome / komodo / content / sdk / shell.js View on Github external
(function() {

    const {Cc, Ci, Cu}  = require("chrome");
    const prefs         = ko.prefs;

    const log           = require("ko/logging").getLogger("ko-shell");
    const platform      = require("sdk/system").platform;
    const pathSplitter  = platform == "winnt" ? /;/g : /:/g;
    const w             = require("ko/windows").getMain();
    const $             = require("ko/dom");
    //log.setLevel(require("ko/logging").LOG_DEBUG);

    /**
     * Get the current working directory, based on the places pane
     *
     * @returns {String}
     */
    this.getCwd = function()
    {
        // Detect current working directory
        var partSvc = Cc["@activestate.com/koPartService;1"].getService(Ci.koIPartService);
        var cwd = "";
github Komodo / KomodoEdit / src / chrome / komodo / content / project / customMenuProperties.js View on Github external
* decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 * 
 * ***** END LICENSE BLOCK ***** */


//Arguments to window.arguments[0] are:
//    Required:
//        item: the item being edited
//        task: 'new' or 'edit'
//        type: the type of the part ('URL', 'template', etc...)
//        src:  the chrome of the image to be used in the dialog

var ko = require("ko/windows").getMain().ko;
var gPriority, gPriorityLabel, gOKButton, gPart, gItem;
var gAccessKey = null;
var tabs, gApplyButton;
var gPartType;
var gObserverSvc;
var partname;

function onLoad() {
    try {
        var dialog = document.getElementById("dialog-custommenuproperties");
        gOKButton = dialog.getButton("accept");
        gApplyButton = dialog.getButton("extra1");
        gApplyButton.setAttribute('label', 'Apply');
        gApplyButton.setAttribute('accesskey', 'a');
        gItem = window.arguments[0].item;
        gPartType = window.arguments[0].type;
github Komodo / KomodoEdit / src / chrome / komodo / content / sdk / editor.js View on Github external
this.setBookmark = function(lineNum, type = ko.markers.MARKNUM_BOOKMARK)
    {
        if ( ! lineNum )
        {
            lineNum = scimoz().lineFromPosition(scimoz().currentPos);
        }
        else
        {
            --lineNum;
        }

        var markerId=0;
        let mainWindow = require("ko/windows").getMain();
        let bookMarknum = type
        let data = {
                      'line': lineNum,
                   }
        // Clean the line of old markers and re-set it
        this.unsetBookmarkByLine();
        markerId = scimoz().markerAdd(lineNum, bookMarknum);
        return markerId;
    };
github Komodo / KomodoEdit / src / chrome / komodo / content / about / about.js View on Github external
* either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 * 
 * ***** END LICENSE BLOCK ***** */

/* Komodo's About dialog */

const w = require("ko/windows").getMain();
var ko = w.ko;
var log = ko.logging.getLogger("about");
var _bundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
        .getService(Components.interfaces.nsIStringBundleService)
        .createBundle("chrome://komodo/locale/about.properties");
var infoSvc = Components.classes["@activestate.com/koInfoService;1"].
              getService(Components.interfaces.koIInfoService);


//---- interface routines for XUL

function onLoad()
{
    var iframe = window.frames[0];

    // Fill in Komodo build information.
github Komodo / KomodoEdit / src / modules / breadcrumbs / content / sdk / breadcrumbs.js View on Github external
var breadcrumbs = function(view) {

    /* Dependant interfaces */
    const {Cc, Ci} = require("chrome");
    const { NetUtil } =   window.Cu.import("resource://gre/modules/NetUtil.jsm", {});
    const w = require("ko/windows").getMain();
    const document = w.document;
    const legacy = w.ko;

    var RCService   = Cc["@activestate.com/koRemoteConnectionService;1"]
                        .getService(Ci.koIRemoteConnectionService);
    var koViews     = require("ko/views");
    var os          = Cc["@activestate.com/koOs;1"].getService(Ci.koIOs);
    var osPath      = Cc["@activestate.com/koOsPath;1"].getService(Ci.koIOsPath);
    var xtk         = window.xtk;
    var Iterator    = window.Iterator;

    /* Logging */
    var log = legacy.logging.getLogger('koBreadcrumbs');
    //log.setLevel(legacy.logging.LOG_DEBUG);

    /* Element References */
github Komodo / KomodoEdit / src / modules / scope_packages / content / packages.js View on Github external
this._downloadFile(asset.browser_download_url, function(file)
                {
                    log.debug("Importing " + file + " as scheme " + pkg.name);
                    var schemeService = Cc['@activestate.com/koScintillaSchemeService;1'].getService();
                    var scheme = schemeService.loadSchemeFromURI(file, pkg.name);
                    // Ask the user if the scheme should be applied immediately.
                    if (dialog.confirm(l.get("applyScheme.prompt"),
                        {
                            yes: l.get("applySchemeNow.label"),
                            no: l.get("applySchemeLater.label"),
                            response: l.get("applySchemeNow.label")
                        }))
                    {
                        schemeService.activateScheme(scheme);
                        require("notify/notify").interact(l.get("schemeApplied", pkg.name), "packages", {id: "packageInstall"});
                    }
                    commando.focus();
                    // TODO: delete temporary file.
                    callback();
                }, errorCallback);
                break;
github Komodo / KomodoEdit / src / modules / scope_packages / content / packages.js View on Github external
addon.uninstall();
                    }
                    catch (e)
                    {
                        log.exception(e, "addon uninstall failed for " + pkg.name);
                        errorCallback();
                        return;
                    }
                    // Prompt for restart if necessary.
                    log.debug("Package pending operations: " + addon.pendingOperations);
                    callback(); // indicate success before potentially restarting
                    if ((addon.pendingOperations & AddonManager.PENDING_DISABLE) ||
                        (addon.pendingOperations & AddonManager.PENDING_UNINSTALL))
                    {
                        log.debug("Package requires Komodo restart.");
                        if (dialog.confirm(l.get("restartKomodoAfterUninstall.prompt"),
                            {
                                yes: l.get("restartNow.label"),
                                no: l.get("restartLater.label"),
                                response: l.get("restartLater.label")
                            }))
                        {
                            utils.restart(true);
                        }
                        commando.focus();
                    }
                }
                break;
            case TOOLBOX:
            case MACROS:
                // TODO: differentiate between the two.
                // Uninstall the tool via Komodo's toolbox manager.
github Komodo / KomodoEdit / src / modules / scope_packages / content / packages.js View on Github external
this._downloadFile(asset.browser_download_url, function(file)
                {
                    log.debug("Importing " + file + " as scheme " + pkg.name);
                    var schemeService = Cc['@activestate.com/koScintillaSchemeService;1'].getService();
                    var scheme = schemeService.loadSchemeFromURI(file, pkg.name);
                    // Ask the user if the scheme should be applied immediately.
                    if (dialog.confirm(l.get("applyScheme.prompt"),
                        {
                            yes: l.get("applySchemeNow.label"),
                            no: l.get("applySchemeLater.label"),
                            response: l.get("applySchemeNow.label")
                        }))
                    {
                        schemeService.activateScheme(scheme);
                        require("notify/notify").interact(l.get("schemeApplied", pkg.name), "packages", {id: "packageInstall"});
                    }
                    commando.focus();
                    // TODO: delete temporary file.
                    callback();
                }, errorCallback);
                break;