1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 18:07:58 +01:00

Add 'encoding'

This commit is contained in:
Kris Maglione
2009-04-13 12:22:17 -04:00
parent 5231ce880f
commit df5b66d838
4 changed files with 62 additions and 1 deletions

View File

@@ -139,6 +139,55 @@ function Buffer() //{{{
////////////////////// OPTIONS /////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
function getWebNav() {
function call(val, fn) {
try
{
return fn(val);
}
catch(e)
{
return val
}
}
return [
function() getBrowser().webNavigation,
function(webNav) webNav.sessionHistory.QueryInterface(Ci.nsIWebNavigation)
].reduce(call, null);
}
options.add(["encoding", "enc"],
"Sets the current buffer's character encoding",
"string", "UTF-8",
{
scope: options.OPTION_SCOPE_LOCAL,
getter: function() getBrowser().docShell.QueryInterface(Ci.nsIDocCharset).charset,
setter: function(val)
{
// Stolen from browser.jar/content/browser/browser.js, more or
// less.
try
{
var docCharset = getBrowser().docShell.QueryInterface(Ci.nsIDocCharset).charset = val
PlacesUtils.history.setCharsetForURI(getWebNavigation().currentURI, val);
getWebNav().reload(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
}
catch (e) { liberator.reportError(e) }
},
completer: function(context) {
context.anchored = false;
context.generate = function() {
let names = util.Array.uniq(
util.Array.flatten(
'more1 more2 more3 more4 more5 unicode'.split(' ').map(function(key)
options.getPref('intl.charsetmenu.browser.' + key).split(', '))));
let bundle = document.getElementById('liberator-charset-bundle');
return names.map(function(name) [name, bundle.getString(name.toLowerCase() + '.title')])
};
}
});
// FIXME: Most certainly belongs elsewhere.
options.add(["fullscreen", "fs"],
"Show the current window fullscreen",
"boolean", false,

View File

@@ -43,6 +43,10 @@ the terms of any one of the MPL, the GPL or the LGPL.
<script type="application/x-javascript;version=1.8" src="&liberator.content;liberator-overlay.js"/>
<window id="&liberator.mainWindow;">
<stringbundleset id="liberator-stringbundles">
<stringbundle id="liberator-charset-bundle"
src="chrome://global/locale/charsetTitles.properties"/>
</stringbundleset>
<keyset id="mainKeyset">
<key id="key_open_vimbar" key=":" oncommand="liberator.modules.commandline.open(':', '', liberator.modules.modes.EX);" modifiers=""/>

View File

@@ -1,5 +1,6 @@
2009-XX-XX:
* version 2.1 (probably)
* add 'encoding'
* add 'hintinputs'
* add :silent
* add $MY_VIMPERATORRC

View File

@@ -307,6 +307,13 @@ A list of autocommand event names which should be ignored. If the list contains
the value "all" then all events are ignored.
____
|\'enc'| |\'encoding'|
||'encoding'|| string (default: "UTF-8")
____
Changes the character encodign of the current buffer. Valid only for the
current page.
____
|\'nofc'| |\'nofocuscontent'| |\'fc'| |\'focuscontent'|
||'focuscontent' 'fc'|| boolean (default: off)