mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-27 21:33:33 +01:00
Fix charset bustage.
This commit is contained in:
@@ -529,7 +529,7 @@ var Bookmarks = Module("bookmarks", {
|
|||||||
description: "The character encoding of the bookmark",
|
description: "The character encoding of the bookmark",
|
||||||
type: CommandOption.STRING,
|
type: CommandOption.STRING,
|
||||||
completer: function (context) completion.charset(context),
|
completer: function (context) completion.charset(context),
|
||||||
validator: Option.validateCompleter
|
validator: io.bound.validateCharset
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
names: ["-id"],
|
names: ["-id"],
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function module(url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var { XPCOMUtils } = module("resource://gre/modules/XPCOMUtils.jsm");
|
var { XPCOMUtils } = module("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
var { OS, TextDecoder, TextEncoder } = module("resource://gre/modules/osfile.jsm");
|
var { OS } = module("resource://gre/modules/osfile.jsm");
|
||||||
try {
|
try {
|
||||||
var { ctypes } = module("resource://gre/modules/ctypes.jsm");
|
var { ctypes } = module("resource://gre/modules/ctypes.jsm");
|
||||||
}
|
}
|
||||||
@@ -748,9 +748,13 @@ function memoize(obj, key, getter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"].createInstance());
|
|
||||||
|
let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"].createInstance(),
|
||||||
|
{ wantGlobalProperties: ["TextDecoder", "TextEncoder"] });
|
||||||
sandbox.__proto__ = this;
|
sandbox.__proto__ = this;
|
||||||
|
|
||||||
|
var { TextEncoder, TextDecoder } = sandbox;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates an object with the properties of another object. Getters
|
* Updates an object with the properties of another object. Getters
|
||||||
* and setters are copied as expected. Moreover, any function
|
* and setters are copied as expected. Moreover, any function
|
||||||
|
|||||||
@@ -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
|
// 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
|
// 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.anchored = false;
|
||||||
context.keys = {
|
context.keys = {
|
||||||
text: util.identity,
|
text: util.identity,
|
||||||
description: function (charset) {
|
description: charset => io.charsetTitle(charset),
|
||||||
try {
|
|
||||||
return services.charset.getCharsetTitle(charset);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return charset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
context.generate = () => iter(services.charset.getDecoderList());
|
context.completions = io.charsets;
|
||||||
};
|
};
|
||||||
|
|
||||||
completion.directory = function directory(context, full) {
|
completion.directory = function directory(context, full) {
|
||||||
|
|||||||
Reference in New Issue
Block a user