How to use the ko/prefs.getStringPref function in ko

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
var schemeService = Cc['@activestate.com/' + serviceName + ';1'].getService();
                var scheme = schemeService.getScheme(pkg.name);
                // getScheme() returns the default scheme if the requested
                // scheme does not exist; ensure the correct scheme is to be
                // uninstalled.
                if (scheme.name == pkg.name)
                {
                    (pkg.kind == SCHEMES) ? scheme.remove() : keybindings.manager.deleteConfiguration(pkg.name, prefs);
                    // If the current scheme is the one being uninstalled,
                    // revert to the default scheme.
                    if (pkg.kind == SCHEMES && prefs.getStringPref('editor-scheme') == pkg.name)
                    {
                        schemeService.activateScheme(schemeService.getScheme('Default'));
                        log.debug("Reverted to Default scheme.");
                    }
                    else if (pkg.kind == KEYBINDS && prefs.getStringPref('keybinding-scheme') == pkg.name)
                    {
                        keybindings.manager.revertToPref('Default'); // probably not the intended use, but it works
                        log.debug("Reverted to Default scheme");
                    }
                }
                callback();
                break;
        }
    }
github Komodo / KomodoEdit / src / chrome / komodo / content / dialogs / colorscheme.js View on Github external
this.deleteScheme = () =>
    {
        var name = selectedScheme.name;
        if (ko.dialogs.yesNo("Are you sure you want to delete the scheme '" + name +"'?  This action cannot be undone.") == 'No') {
            return;
        }
        selectedScheme.remove();
        selectedScheme = schemeService.getScheme('Default');
        var oldScheme = prefs.getStringPref('editor-scheme');
        if (oldScheme == name) {
            // Delete the pref and inherit the global one again
            prefs.deletePref('editor-scheme');
            oldScheme = prefs.getStringPref('editor-scheme');
        }
        
        // need to remove it from the popup
        $(`#schemeslist menuitem[label="${name}"]`).remove();
        $("#schemeslist").element().selectedItem = $(`#schemeslist menuitem[label="${oldScheme}"]`).element();
        
        selectedScheme = schemeService.getScheme(oldScheme);
        this.onSelectScheme();
    };
github Komodo / KomodoEdit / src / chrome / komodo / content / dialogs / colorscheme.js View on Github external
this.pickColor = (button, callback) =>
    {
        var color = "#" + button.attr("color").replace(/^#/, "");
        
        var picker = null;
        var cid = prefs.getStringPref("colorpicker_cid");
        if (cid) {
            try {
                picker = Components.classes[cid]
                                   .getService(Components.interfaces.koIColorPickerAsync);
            } catch (ex) {
                log.exception(ex, "Unable to load the colorpicker with CID: " + cid);
                picker = null;
            }
        }
        if (!picker) {
            // Use the sysUtils color picker then:
            picker = Components.classes['@activestate.com/koSysUtils;1']
                               .getService(Components.interfaces.koIColorPickerAsync);
        }
        
        color = color == "#" ? "#000000" : color;
github Komodo / KomodoEdit / src / chrome / komodo / content / sdk / dialogs.js View on Github external
if ( ! _opts.no)
        {
            _opts.no = "Cancel";
        }

        // Break out early if "doNotAskPref" prefs so direct.
        if (_opts.doNotAskPref)
        {
            _opts.doNotAskUI = true;
            var bpref = "donotask_"+_opts.doNotAskPref;
            var spref = "donotask_action_"+_opts.doNotAskPref;
            if (prefs.getBoolean(bpref, false))
            {
                var actions = [_opts.yes, _opts.no];
                var action = prefs.getStringPref(spref);
                if (actions.indexOf(action) != -1)
                {
                    return action;
                } else {
                    log.error("illegal action for Yes/No/Cancel dialog in '" +
                                     spref + "' preference: '" + action + "'");
                    // Reset the boolean pref.
                    prefs.deletePref(bpref);
                    prefs.deletePref(spref);
                }
            }
        }

        w = opts.window || window;

        w.openDialog("chrome://komodo/content/dialogs/yesNo.xul",
github Komodo / KomodoEdit / src / chrome / komodo / content / sdk / dialogs.js View on Github external
this.open = (message, opts = {}) =>
    {
        var _opts = {};
        var props = ["response", "text", "title", "doNotAskPref", "helpTopic",
                     "buttons", "classNames","hidechrome", "pin"];
        _.each(props, (prop) => { _opts[prop] = opts[prop] || null; });
        _opts.prompt = message;
        _opts.style = opts.className || "question-icon spaced";

        // Break out early if "doNotAskPref" prefs so direct.
        var bpref = null, spref = null;
        if (_opts.doNotAskPref) {
            bpref = "donotask_"+_opts.doNotAskPref;
            spref = "donotask_action_"+_opts.doNotAskPref;
            if (prefs.getBooleanPref(bpref)) {
                return prefs.getStringPref(spref);
            }
        }

        window.openDialog("chrome://komodo/content/dialogs/customButtons.xul",
                          "_blank",
                          "chrome,modal,titlebar,centerscreen",
                          _opts);

        if (_opts.doNotAskPref && _opts.doNotAsk) {
            prefs.setBooleanPref(bpref, true);
            prefs.setStringPref(spref, _opts.response);
        }
        return _opts.response;
    };
github Komodo / KomodoEdit / src / chrome / komodo / content / dialogs / colorscheme.js View on Github external
this.deleteScheme = () =>
    {
        var name = selectedScheme.name;
        if (ko.dialogs.yesNo("Are you sure you want to delete the scheme '" + name +"'?  This action cannot be undone.") == 'No') {
            return;
        }
        selectedScheme.remove();
        selectedScheme = schemeService.getScheme('Default');
        var oldScheme = prefs.getStringPref('editor-scheme');
        if (oldScheme == name) {
            // Delete the pref and inherit the global one again
            prefs.deletePref('editor-scheme');
            oldScheme = prefs.getStringPref('editor-scheme');
        }
        
        // need to remove it from the popup
        $(`#schemeslist menuitem[label="${name}"]`).remove();
        $("#schemeslist").element().selectedItem = $(`#schemeslist menuitem[label="${oldScheme}"]`).element();
        
        selectedScheme = schemeService.getScheme(oldScheme);
        this.onSelectScheme();
    };
github Komodo / KomodoEdit / src / chrome / komodo / content / sdk / colorscheme.js View on Github external
this.get = (name) =>
    {
        if ( ! currentScheme[name])
            currentScheme[name] = schemeService.getScheme(prefs.getStringPref(name));
        
        return currentScheme[name];
    };
github Komodo / KomodoEdit / src / chrome / komodo / content / project / templateProperties.js View on Github external
}
        else
            elems.name().attr("value", tool.getStringAttribute('name'));
        this.updateTitle();
        
        elems.ejs().attr("checked", tool.getStringAttribute('treat_as_ejs'));
        elems.default().attr("checked", tool.getStringAttribute('lang_default'));
        elems.languages().element().selection = tool.getStringAttribute('language');
        
        var content = elems.value().element();
        content.scintilla.symbolMargin = false;
        content.scimoz.useTabs = prefs.getBooleanPref("useTabs");
        content.scimoz.indent = prefs.getLongPref('indentWidth');
        content.scimoz.tabWidth = prefs.getLongPref('indentWidth');
        content.initWithBuffer(tool.value, tool.getStringAttribute('language') || "Text");
        var foldStyle = prefs.getStringPref("editFoldStyle");
        if (foldStyle && foldStyle != "none")
            content.setFoldStyle(prefs.getStringPref("editFoldStyle"));
    };
github Komodo / KomodoEdit / src / chrome / komodo / content / project / templateProperties.js View on Github external
elems.name().attr("value", tool.getStringAttribute('name'));
        this.updateTitle();
        
        elems.ejs().attr("checked", tool.getStringAttribute('treat_as_ejs'));
        elems.default().attr("checked", tool.getStringAttribute('lang_default'));
        elems.languages().element().selection = tool.getStringAttribute('language');
        
        var content = elems.value().element();
        content.scintilla.symbolMargin = false;
        content.scimoz.useTabs = prefs.getBooleanPref("useTabs");
        content.scimoz.indent = prefs.getLongPref('indentWidth');
        content.scimoz.tabWidth = prefs.getLongPref('indentWidth');
        content.initWithBuffer(tool.value, tool.getStringAttribute('language') || "Text");
        var foldStyle = prefs.getStringPref("editFoldStyle");
        if (foldStyle && foldStyle != "none")
            content.setFoldStyle(prefs.getStringPref("editFoldStyle"));
    };
github Komodo / KomodoEdit / src / chrome / komodo / content / dialogs / colorscheme.js View on Github external
'Indicators': {
            fields: ['indicator-alpha', 'indicator-color', 'indicator-draw_underneath', 'indicator-style'],
            properties: [
                'collab_local_change','collab_remote_change','collab_remote_cursor_1',
                'collab_remote_cursor_2','collab_remote_cursor_3','collab_remote_cursor_4',
                'collab_remote_cursor_5','find_highlighting','linter_error',
                'linter_warning','soft_characters','tabstop_current','tabstop_pending',
                'tag_matching','spelling_error'
            ]
        }

    };
    
    var selectedLanguage = "Python";
    var selectedScheme = schemeService.getScheme(prefs.getStringPref('editor-scheme'));
    
    var sample;
    
    this.init = () =>
    {
        scintillaOverlayOnLoad();
        
        sample = $('#sample');
        sample.element().initWithBuffer("", "Text");
        
        var scimoz = sample.element().scimoz;
        for (var i=0; i <= scimoz.SC_MAX_MARGIN; i++) 
            scimoz.setMarginWidthN(i, 0);
        
        sample.on("blur", () => scimoz.caretPeriod = 0);
        sample.on("focus", () => scimoz.caretPeriod = 500);