From 7f627f4763044a42437a73c7dd1c063c7b1a14f1 Mon Sep 17 00:00:00 2001 From: trapezoid Date: Fri, 21 Mar 2008 14:23:55 +0000 Subject: lang/javascript/vimperator-plugins/trunk/encodingSwitcher.js: 0.6pre対応しました git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@8261 d0d07461-0603-4401-acd4-de1884942a52 --- encodingSwitcher.js | 53 ++++++++++++++++++++--------------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) (limited to 'encodingSwitcher.js') diff --git a/encodingSwitcher.js b/encodingSwitcher.js index fc98f4c..4f99667 100644 --- a/encodingSwitcher.js +++ b/encodingSwitcher.js @@ -59,19 +59,18 @@ function createDetector(name){ return [name,null,'']; } function getDetector(name){ - detectors.forEach(function(detector){ - if (detector[0].toLowerCase() == name.toLowerCase()){ - return detector[0] + detector[2]; + for (var i=0; i:lsenc command', - defaultValue: DEFAULT_CHARSET, setter: function(value){ if (!value) return; value = getEncoding(value); SetForcedCharset(value); - SetDefaultCharacterSet(value); + //SetDefaultCharacterSet(value); BrowserSetForcedCharacterSet(value); }, getter: function(){ @@ -106,18 +102,15 @@ liberator.options.add(new liberator.Option( ['fileencoding','fenc'], 'string', return isValid( encodings, value); }, completer: function(filter){ - return completion( encodings, filter); + return [0,completion( encodings, filter)]; } } -)); +); var sbCharDetector = sbService.createBundle(gPrefService.getDefaultBranch('intl.charset.').getCharPref('detector')); const DEFAULT_DETECTOR = createDetector(sbCharDetector.GetStringFromName('intl.charset.detector'))[0]; -liberator.options.add(new liberator.Option( ['autodetector','audet'], 'string', +liberator.options.add(['autodetector','audet'],'set auto detect character encoding','string',DEFAULT_DETECTOR, { - shortHelp: 'set auto detect character encoding', - help: 'Please make certain of available value with :lsdet command', - defaultValue: DEFAULT_DETECTOR, setter: function(value){ SetForcedDetector(true); var pref = Cc['@mozilla.org/preferences-service;1'].getService(Ci.nsIPrefBranch); @@ -143,11 +136,11 @@ liberator.options.add(new liberator.Option( ['autodetector','audet'], 'string', return isValid( detectors, value); }, completer: function(filter){ - return completion( detectors, filter); + return [0,completion( detectors, filter)]; } } -)); +); function listCharset(arg, current, list){ if (!arg) arg = '.'; var reg = new RegExp(arg,'i'); @@ -167,30 +160,24 @@ function listCharset(arg, current, list){ str.push(''); liberator.echo( str.join(''), true); } -liberator.commands.add(new liberator.Command(['listencoding','lsenc'], +liberator.commands.addUserCommand(['listencoding','lsenc'],'list all encodings', function(arg){ listCharset(arg, liberator.options.fileencoding, encodings); },{ - usage: ['listencoding [expr]','lsenc [expr]'], - shortHelp: 'list all encodings', - help: 'current encoding is hi-light', completer: function(filter){ - return completion(encodings, filter); + return [0,completion(encodings, filter)]; } } -)); -liberator.commands.add(new liberator.Command(['listdetector','lsdet'], +); +liberator.commands.addUserCommand(['listdetector','lsdet'],'list all auto detectors', function(arg){ listCharset(arg, liberator.options.autodetector, detectors); },{ - usage: ['listdetector [expr]','lsdet [expr]'], - shortHelp: 'list all auto detectors', - help: 'current encoding is hi-light', completer: function(filter){ - return completion(detectors, filter); + return [0,completion(detectors, filter)]; } } -)); +); })(); -- cgit v1.2.3