1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-07 01:44:13 +01:00

Remove some config.name checks. Add configbase module.

This commit is contained in:
Kris Maglione
2009-05-23 21:08:50 -04:00
parent 16b8af74d1
commit b8aab050e9
8 changed files with 39 additions and 42 deletions

View File

@@ -27,26 +27,29 @@ the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/
const configbase = { //{{{
features: [],
autocommands: [],
get browserModes() [modes.NORMAL],
defaults: { guioptions: "rb" },
guioptions: {},
autocommands: [],
dialogs: [],
features: [],
guioptions: {},
hasTabbrowser: false,
// they are sorted by relevance, not alphabetically
helpFiles: [],
init: function () {},
ignoreKeys: {},
optionDefaults: {},
scripts: [],
init: function () {},
}; //}}}
// vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -1014,10 +1014,8 @@ function Events() //{{{
if (this.duringFeed != "")
{
//Create a scalar constant for closure.
let duringFeed = this.duringFeed;
this.duringFeed = "";
setTimeout(function () events.feedkeys(duringFeed, false, false, true), 0);
}
}
@@ -1458,13 +1456,8 @@ function Events() //{{{
// XXX: ugly hack for now pass certain keys to Firefox as they are without beeping
// also fixes key navigation in combo boxes, submitting forms, etc.
// FIXME: breaks iabbr for now --mst
if (((config.name == "Xulmus" || config.name == "Vimperator") && liberator.mode == modes.NORMAL || liberator.mode == modes.INSERT))
{
if (key == "<Return>")
return false;
else if (key == "<Space>" || key == "<Up>" || key == "<Down>")
return false;
}
if (key in config.ignoreKeys && (config.ignoreKeys[key] & liberator.mode))
return false;
// TODO: handle middle click in content area
@@ -1601,8 +1594,8 @@ function Events() //{{{
else // if the key is neither a mapping nor the start of one
{
// the mode checking is necessary so that things like g<esc> do not beep
if (input.buffer != "" && !skipMap && (liberator.mode == modes.INSERT ||
liberator.mode == modes.COMMAND_LINE || liberator.mode == modes.TEXTAREA))
if (input.buffer != "" && !skipMap &&
(liberator.mode & (modes.INSERT | modes.COMMAND_LINE | modes.TEXTAREA)))
{
// no map found -> refeed stuff in input.buffer (only while in INSERT, CO... modes)
skipMap = true; // ignore maps while doing so

View File

@@ -33,6 +33,7 @@
["services.js",
"liberator.js",
"configbase.js",
"config.js",
"util.js",
"style.js",
@@ -50,9 +51,9 @@
"template.js",
"ui.js"].forEach(load);
modules.config.__proto__ = modules.configbase;
prefix.unshift("chrome://" + modules.config.name.toLowerCase() + "/content/");
if (modules.config.scripts)
modules.config.scripts.forEach(load);
modules.config.scripts.forEach(load);
})()

View File

@@ -1232,25 +1232,7 @@ const liberator = (function () //{{{
let start = Date.now();
liberator.log("Initializing liberator object...", 0);
config.features = config.features || [];
config.features.push(getPlatformFeature());
config.defaults = config.defaults || {};
config.guioptions = config.guioptions || {};
// -> we can't use this, since config.browserModes might already be defined as a getter-only
// TODO: also change the other config.* defaults?
// config.browserModes = config.browserModes || [modes.NORMAL];
if (!config.browserModes)
config.browserModes = [modes.NORMAL];
config.mailModes = config.mailModes || [modes.NORMAL];
// TODO: suitable defaults?
//config.mainWidget
//config.mainWindowID
//config.visualbellWindow
//config.styleableChrome
config.autocommands = config.autocommands || [];
config.dialogs = config.dialogs || [];
config.helpFiles = config.helpFiles || [];
try
{

View File

@@ -28,8 +28,6 @@ the terms of any one of the MPL, the GPL or the LGPL.
/** @scope modules */
// Do NOT create instances of this class yourself, use the helper method
// mappings.add() instead
/**
* A class representing key mappings. Instances are created by the
* {@link Mappings} class.

View File

@@ -110,7 +110,7 @@ function Tabs() //{{{
}
// hide tabs initially
if (config.name == "Vimperator")
if (config.hasTabbrowser)
getBrowser().mStrip.getElementsByClassName("tabbrowser-tabs")[0].collapsed = true;
/////////////////////////////////////////////////////////////////////////////}}}

View File

@@ -122,6 +122,16 @@ const config = { //{{{
"various.html", "index.html", "version.html"
],
get ignoreKeys() {
delete this.ignoreKeys;
return this.ignoreKeys = {
"<Return>": modes.NORMAL | modes.INSERT,
"<Space>": modes.NORMAL | modes.INSERT,
"<Up>": modes.NORMAL | modes.INSERT,
"<Down>": modes.NORMAL | modes.INSERT,
}
},
optionDefaults: {
showtabline: 2,
},

View File

@@ -165,6 +165,16 @@ const config = { //{{{
modes: [["PLAYER", { char: "p" }]],
get ignoreKeys() {
delete this.ignoreKeys;
return this.ignoreKeys = {
"<Return>": modes.NORMAL | modes.INSERT,
"<Space>": modes.NORMAL | modes.INSERT,
"<Up>": modes.NORMAL | modes.INSERT,
"<Down>": modes.NORMAL | modes.INSERT,
}
},
optionDefaults: {
showtabline: 2,
},