1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-16 13:25:46 +01:00

Rename abbreviations.abbrevs to abbreviations._store.

This commit is contained in:
Doug Kearns
2011-02-01 16:58:41 +11:00
parent 8732940655
commit df4b9340eb

View File

@@ -41,7 +41,7 @@ var Abbreviation = Class("Abbreviation", {
var Abbreviations = Module("abbreviations", { var Abbreviations = Module("abbreviations", {
init: function () { init: function () {
this.abbrevs = {}; this._store = {};
// (summarized from Vim's ":help abbreviations") // (summarized from Vim's ":help abbreviations")
// //
@@ -99,9 +99,9 @@ var Abbreviations = Module("abbreviations", {
abbr = Abbreviation.apply(null, arguments); abbr = Abbreviation.apply(null, arguments);
for (let [, mode] in Iterator(abbr.modes)) { for (let [, mode] in Iterator(abbr.modes)) {
if (!this.abbrevs[mode]) if (!this._store[mode])
this.abbrevs[mode] = {}; this._store[mode] = {};
this.abbrevs[mode][abbr.lhs] = abbr; this._store[mode][abbr.lhs] = abbr;
} }
}, },
@@ -112,7 +112,7 @@ var Abbreviations = Module("abbreviations", {
* @param {string} lhs The LHS of the abbreviation. * @param {string} lhs The LHS of the abbreviation.
*/ */
get: function (mode, lhs) { get: function (mode, lhs) {
let abbrevs = this.abbrevs[mode]; let abbrevs = this._store[mode];
return abbrevs && abbrevs.hasOwnProperty(lhs) ? abbrevs[lhs] : null; return abbrevs && abbrevs.hasOwnProperty(lhs) ? abbrevs[lhs] : null;
}, },
@@ -139,17 +139,17 @@ var Abbreviations = Module("abbreviations", {
get merged() { get merged() {
let result = []; let result = [];
let lhses = []; let lhses = [];
let modes = [mode for (mode in this.abbrevs)]; let modes = [mode for (mode in this._store)];
for (let [, mabbrevs] in Iterator(this.abbrevs)) for (let [, abbrevs] in Iterator(this._store))
lhses = lhses.concat([key for (key in mabbrevs)]); lhses = lhses.concat([key for (key in abbrevs)]);
lhses.sort(); lhses.sort();
lhses = array.uniq(lhses); lhses = array.uniq(lhses);
for (let [, lhs] in Iterator(lhses)) { for (let [, lhs] in Iterator(lhses)) {
let exists = {}; let exists = {};
for (let [, mabbrevs] in Iterator(this.abbrevs)) { for (let [, abbrevs] in Iterator(this._store)) {
let abbr = mabbrevs[lhs]; let abbr = abbrevs[lhs];
if (abbr && !exists[abbr.rhs]) { if (abbr && !exists[abbr.rhs]) {
exists[abbr.rhs] = 1; exists[abbr.rhs] = 1;
result.push(abbr); result.push(abbr);
@@ -192,10 +192,10 @@ var Abbreviations = Module("abbreviations", {
remove: function (modes, lhs) { remove: function (modes, lhs) {
let result = false; let result = false;
for (let [, mode] in Iterator(modes)) { for (let [, mode] in Iterator(modes)) {
if ((mode in this.abbrevs) && (lhs in this.abbrevs[mode])) { if ((mode in this._store) && (lhs in this._store[mode])) {
result = true; result = true;
this.abbrevs[mode][lhs].removeMode(mode); this._store[mode][lhs].removeMode(mode);
delete this.abbrevs[mode][lhs]; delete this._store[mode][lhs];
} }
} }
return result; return result;
@@ -208,11 +208,11 @@ var Abbreviations = Module("abbreviations", {
*/ */
removeAll: function (modes) { removeAll: function (modes) {
for (let [, mode] in modes) { for (let [, mode] in modes) {
if (!(mode in this.abbrevs)) if (!(mode in this._store))
return; return;
for (let [, abbr] in this.abbrevs[mode]) for (let [, abbr] in this._store[mode])
abbr.removeMode(mode); abbr.removeMode(mode);
delete this.abbrevs[mode]; delete this._store[mode];
} }
} }
}, { }, {