aboutsummaryrefslogtreecommitdiffstats
path: root/ime_controller.js
diff options
context:
space:
mode:
authorteramako2008-04-08 12:51:39 +0000
committerteramako2008-04-08 12:51:39 +0000
commite873c881947f5cde6f357a4ce2edbb3e4e028999 (patch)
tree74f5384c62cab9b0b1c65ded927e8abbd8e86ac6 /ime_controller.js
parent75eb697dfb8b9afa638d335bd3e66f9cee2b5512 (diff)
downloadvimperator-plugins-e873c881947f5cde6f357a4ce2edbb3e4e028999.tar.bz2
lang/javascript/vimperator-plugins/trunk/ime_controller.js: INSERTモードからTEXTAREAモードへの移行時にもIMEのon/offを可能にした
それに伴って関数の追加&変更 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@9148 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'ime_controller.js')
-rw-r--r--ime_controller.js58
1 files changed, 37 insertions, 21 deletions
diff --git a/ime_controller.js b/ime_controller.js
index d7bb3fb..bc8588c 100644
--- a/ime_controller.js
+++ b/ime_controller.js
@@ -9,50 +9,66 @@
* @minVersion 0.6pre
* ==/VimperatorPlugin==
*
- * Please set g:ex_ime_mode value.
+ * Please set g:ex_ime_mode and g:textarea_ime_mode value.
+ *
+ * g:ex_ime_mode:
+ * used at into EX mode
+ *
+ * g:textarea_ime_mode:
+ * used at into TEXTAREA mode from INSERT mode and "noinsertmode" is set.
+ *
* ex).
* :let g:ex_ime_mode = "inactive"
+ * :let g:textarea_ime_mode = "inactive"
*
* following values are available:
* "auto" : No change
* "active" : Initially IME on
* "inactive" : Initially IME off
- * "disable" : Disable IME
+ * "disabled" : Disable IME
*
* more details: see http://developer.mozilla.org/en/docs/CSS:ime-mode
*
- * default value is "inactive"
+ * if these values are null, "inactive" is used
*
- * TODO: TEXTAREAモード時にもIMEのON/OFF切り替え機能をつける
*/
-if(!liberator.plugins) vimperator.plugins = {};
+if(!liberator.plugins) vimperator.plugins = {};
liberator.plugins.imeController = (function(){
var inputElement = document.getAnonymousElementByAttribute(
document.getElementById('liberator-commandline-command'),'anonid','input'
- );
+ );
+ function getMode(name){
+ return globalVariables[name] ? globalVariables[name] : 'inactive';
+ }
function preExec(target,name,func){
var original = target[name];
target[name] = function(){
func.apply(this,arguments);
return original.apply(target,arguments);
- };
- }
- if(!globalVariables.ex_ime_mode){
- globalVariables.ex_ime_mode = 'inactive';
- }
+ }
+ }
preExec(commandline,'open',function(){
- liberator.plugins.imeController.set();
- });
+ liberator.plugins.imeController.set(inputElement, getMode('ex_ime_mode'));
+ });
+ preExec(events,'onEscape',function(){
+ if (liberator.mode == liberator.modes.INSERT && (liberator.modes.extended & liberator.modes.TEXTAREA) && !liberator.options.insertmode){
+ var inputField = liberator.buffer.lastInputField;
+ if (liberator.plugins.imeController.set(inputField, getMode('textarea_ime_mode'))){
+ inputField.blur();
+ setTimeout(function(){inputField.focus();},0);
+ }
+ }
+ });
return {
- set: function(mode){
- if(!mode) mode = globalVariables.ex_ime_mode ? globalVariables.ex_ime_mode : 'inactive';
- inputElement.style.imeMode = mode;
- },
+ set: function(elem, mode){
+ if (elem && mode) return elem.style.imeMode = mode;
+ return false;
+ },
reset: function(){
- //keyElement.setAttribute('oncommand', original);
- inputElement.style.imeMode = 'auto';
- }
- };
+ delete globalVariables.ex_ime_mode;
+ delete globalVariables.textarea_ime_mode;
+ }
+ };
})();
// vim: sw=4 ts=4 et: