1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-01 05:35:45 +01:00

Adjust some API names to make things more consistent and less confusing.

--HG--
branch : groups
This commit is contained in:
Kris Maglione
2011-02-06 20:18:12 -05:00
parent 83738de163
commit 2a99de96a0
4 changed files with 26 additions and 26 deletions

View File

@@ -73,10 +73,10 @@ var AutoCmdHive = Class("AutoCmdHive", {
*/ */
var AutoCommands = Module("autocommands", { var AutoCommands = Module("autocommands", {
init: function () { init: function () {
this.user = contexts.subGroup.autocmd.user; this.user = contexts.hives.autocmd.user;
}, },
hives: Group.SubGroup("autocmd", AutoCmdHive), hives: Group.Hive("autocmd", AutoCmdHive),
get activeHives() contexts.activeGroups("autocmd").map(function (h) h.autocmd).filter(function (h) h._store.length), get activeHives() contexts.activeGroups("autocmd").map(function (h) h.autocmd).filter(function (h) h._store.length),

View File

@@ -11,13 +11,13 @@ var Group = Class("Group", {
this.description = description; this.description = description;
this.filter = filter || Group.defaultFilter; this.filter = filter || Group.defaultFilter;
this.persist = persist || false; this.persist = persist || false;
this.subGroups = []; this.hives = [];
}, },
cleanup: function cleanup() { cleanup: function cleanup() {
for (let subGroup in values(this.subGroups)) for (let hive in values(this.hives))
if (subGroup.cleanup) if (hive.cleanup)
subGroup.cleanup(); hive.cleanup();
}, },
argsExtra: function argsExtra() ({}), argsExtra: function argsExtra() ({}),
@@ -26,7 +26,7 @@ var Group = Class("Group", {
get builtin() contexts.builtinGroups.indexOf(this) >= 0, get builtin() contexts.builtinGroups.indexOf(this) >= 0,
subGroups: {} hives: {}
}, { }, {
compileFilter: function (patterns) { compileFilter: function (patterns) {
@@ -56,9 +56,9 @@ var Group = Class("Group", {
defaultFilter: Class.memoize(function () this.compileFilter(["*"])), defaultFilter: Class.memoize(function () this.compileFilter(["*"])),
subGroupMap: {}, hiveMap: {},
SubGroup: Class("SubGroup", Class.Property, { Hive: Class("Hive", Class.Property, {
init: function init(name, constructor) { init: function init(name, constructor) {
const self = this; const self = this;
if (this.Group) if (this.Group)
@@ -73,13 +73,13 @@ var Group = Class("Group", {
this.name = name; this.name = name;
memoize(Group.prototype, name, function () { memoize(Group.prototype, name, function () {
let group = constructor(this); let group = constructor(this);
this.subGroups.push(group); this.hives.push(group);
return group; return group;
}); });
memoize(Group.subGroupMap, name, memoize(Group.hiveMap, name,
function () Object.create(Object.create(contexts.subGroupProto, function () Object.create(Object.create(contexts.hiveProto,
{ _subGroup: { value: name } }))); { _hive: { value: name } })));
memoize(Group.groupsProto, name, memoize(Group.groupsProto, name,
function () [group[name] for (group in values(this.groups)) if (set.has(group, name))]); function () [group[name] for (group in values(this.groups)) if (set.has(group, name))]);
@@ -93,7 +93,7 @@ var Contexts = Module("contexts", {
init: function () { init: function () {
this.groupList = []; this.groupList = [];
this.groupMap = {}; this.groupMap = {};
this.subGroupProto = {}; this.hiveProto = {};
this.builtin = this.addGroup("builtin", "Builtin items"); this.builtin = this.addGroup("builtin", "Builtin items");
this.user = this.addGroup("user", "User-defined items", null, true); this.user = this.addGroup("user", "User-defined items", null, true);
@@ -110,11 +110,11 @@ var Contexts = Module("contexts", {
groups: { value: this.activeGroups() } groups: { value: this.activeGroups() }
})), })),
activeGroups: function (subgroup) activeGroups: function (hive)
let (need = subgroup ? [subgroup] : Object.keys(this.subGroup)) let (need = hive ? [hive] : Object.keys(this.hives))
this.groupList.filter(function (group) need.some(function (name) set.has(group, name))), this.groupList.filter(function (group) need.some(function (name) set.has(group, name))),
get subGroup() Group.subGroupMap, get hives() Group.hiveMap,
addGroup: function addGroup(name, description, filter, persist) { addGroup: function addGroup(name, description, filter, persist) {
this.removeGroup(name); this.removeGroup(name);
@@ -122,7 +122,7 @@ var Contexts = Module("contexts", {
let group = Group(name, description, filter, persist); let group = Group(name, description, filter, persist);
this.groupList.unshift(group); this.groupList.unshift(group);
this.groupMap[name] = group; this.groupMap[name] = group;
this.subGroupProto.__defineGetter__(name, function () group[this._subGroup]); this.hiveProto.__defineGetter__(name, function () group[this._hive]);
return group; return group;
}, },
@@ -146,19 +146,19 @@ var Contexts = Module("contexts", {
this.context.group = null; this.context.group = null;
delete this.groupMap[name]; delete this.groupMap[name];
delete this.subGroupProto[name]; delete this.hiveProto[name];
delete this.groups; delete this.groups;
return group; return group;
}, },
getGroup: function getGroup(name, subGroup) { getGroup: function getGroup(name, hive) {
if (name === "default") if (name === "default")
var group = this.context && this.context.context && this.context.context.GROUP; var group = this.context && this.context.context && this.context.context.GROUP;
else else
group = array.nth(this.groupList, function (h) h.name == name, 0) || null; group = array.nth(this.groupList, function (h) h.name == name, 0) || null;
if (group && subGroup) if (group && hive)
return group[subGroup]; return group[hive];
return group; return group;
}, },

View File

@@ -301,13 +301,13 @@ var MapHive = Class("MapHive", {
*/ */
var Mappings = Module("mappings", { var Mappings = Module("mappings", {
init: function () { init: function () {
this.user = contexts.subGroup.mappings.user; this.user = contexts.hives.mappings.user;
this.builtin = contexts.subGroup.mappings.builtin; this.builtin = contexts.hives.mappings.builtin;
}, },
repeat: Modes.boundProperty(), repeat: Modes.boundProperty(),
hives: Group.SubGroup("mappings", MapHive), hives: Group.Hive("mappings", MapHive),
get allHives() contexts.allGroups.mappings, get allHives() contexts.allGroups.mappings,

View File

@@ -600,7 +600,7 @@ var Styles = Module("Styles", {
}); });
}, },
contexts: function (dactyl, modules, window) { contexts: function (dactyl, modules, window) {
modules.Group.SubGroup("styles", function (group) styles.addHive(group.name)); modules.Group.Hive("styles", function (group) styles.addHive(group.name));
}, },
completion: function (dactyl, modules, window) { completion: function (dactyl, modules, window) {
const names = Array.slice(util.computedStyle(window.document.createElement("div"))); const names = Array.slice(util.computedStyle(window.document.createElement("div")));