mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-07 13:55:46 +01:00
Serialize map groups.
This commit is contained in:
@@ -532,27 +532,37 @@ var Mappings = Module("mappings", {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
serialize: function () {
|
serialize: function () {
|
||||||
return this.name == "map" ? [
|
return this.name != "map" ? [] :
|
||||||
{
|
array(mappings.userHives)
|
||||||
command: this.name,
|
.filter(function (h) !h.noPersist)
|
||||||
options: array([
|
.map(function (hive) [
|
||||||
["-modes", uniqueModes(map.modes)],
|
{
|
||||||
["-description", map.description],
|
command: "mapgroup",
|
||||||
map.silent && ["-silent"]])
|
bang: true,
|
||||||
.filter(util.identity)
|
arguments: [hive.name, String(hive.filter)].slice(0, hive.name == "user" ? 1 : 2)
|
||||||
.toObject(),
|
}
|
||||||
arguments: [map.names[0]],
|
].concat([
|
||||||
literalArg: map.rhs,
|
{
|
||||||
ignoreDefaults: true
|
command: "map",
|
||||||
}
|
options: array([
|
||||||
for (map in userMappings())
|
["-modes", uniqueModes(map.modes)],
|
||||||
if (map.persist)
|
["-description", map.description],
|
||||||
] : [];
|
map.silent && ["-silent"]])
|
||||||
|
.filter(util.identity)
|
||||||
|
.toObject(),
|
||||||
|
arguments: [map.names[0]],
|
||||||
|
literalArg: map.rhs,
|
||||||
|
ignoreDefaults: true
|
||||||
|
}
|
||||||
|
for (map in userMappings(hive))
|
||||||
|
if (map.persist)
|
||||||
|
]))
|
||||||
|
.flatten().array;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function userMappings() {
|
function userMappings(hive) {
|
||||||
let seen = {};
|
let seen = {};
|
||||||
for (let stack in values(mappings.userHive.stacks))
|
for (let stack in values(hive.stacks))
|
||||||
for (let map in array.iterValues(stack))
|
for (let map in array.iterValues(stack))
|
||||||
if (!set.add(seen, map.id))
|
if (!set.add(seen, map.id))
|
||||||
yield map;
|
yield map;
|
||||||
@@ -650,6 +660,8 @@ var Mappings = Module("mappings", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
hive = mappings.addHive(name, filter, args["-description"]);
|
hive = mappings.addHive(name, filter, args["-description"]);
|
||||||
|
if (args["-nopersist"])
|
||||||
|
hive.noPersist = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
dactyl.assert(hive, "No mapping group: " + name);
|
dactyl.assert(hive, "No mapping group: " + name);
|
||||||
@@ -680,6 +692,10 @@ var Mappings = Module("mappings", {
|
|||||||
names: ["-description", "-d"],
|
names: ["-description", "-d"],
|
||||||
description: "A description of this mapping group",
|
description: "A description of this mapping group",
|
||||||
type: CommandOption.STRING
|
type: CommandOption.STRING
|
||||||
|
},
|
||||||
|
{
|
||||||
|
names: ["-nopersist", "-n"],
|
||||||
|
description: "Do not save this mapping group to an auto-generated RC file"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user