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

Fix charset bustage.

This commit is contained in:
Kris Maglione
2014-08-18 19:42:30 -07:00
parent 4ff0e3bc4c
commit e3abdd7559
3 changed files with 31 additions and 12 deletions

View File

@@ -216,6 +216,28 @@ var IO = Module("io", {
}
}),
charsets: Class.Memoize(function () {
const BASE = "@mozilla.org/intl/unicode/decoder;1?charset=";
return [k.slice(BASE.length)
for (k of Object.keys(Cc))
if (k.startsWith(BASE))];
}),
charsetBundle: Class.Memoize(
() => services.stringBundle.createBundle("chrome://global/locale/charsetTitles.properties")),
charsetTitle: function charsetTitle(charset, default_=charset) {
try {
return this.charsetBundle.GetStringFromName(charset + ".title");
}
catch (e) {}
return default_;
},
validateCharset: function validateCharset(charset) {
new TextDecoder(charset);
},
// TODO: there seems to be no way, short of a new component, to change
// the process's CWD - see https://bugzilla.mozilla.org/show_bug.cgi?id=280953
/**
@@ -942,16 +964,9 @@ unlet s:cpo_save
context.anchored = false;
context.keys = {
text: util.identity,
description: function (charset) {
try {
return services.charset.getCharsetTitle(charset);
}
catch (e) {
return charset;
}
}
description: charset => io.charsetTitle(charset),
};
context.generate = () => iter(services.charset.getDecoderList());
context.completions = io.charsets;
};
completion.directory = function directory(context, full) {