Merge pull request #1406 from ajaxorg/ime

fix chinese Ime handling on windows
This commit is contained in:
Lennart Kats 2013-05-01 06:06:37 -07:00
commit 342bb71a3a
4 changed files with 34 additions and 10 deletions

View file

@ -947,7 +947,7 @@ oop.inherits(FoldMode, BaseFoldMode);
<li> <li>
<img src="https://www.decor-tab-creator.com/_files/decor_logo_white_new.png" <img src="https://www.decor-tab-creator.com/_files/decor_logo_white_new.png"
style="position: relative; left: -5px; width: 111px;top: 29px;"> style="position: relative; left: -5px; width: 111px;top: 20px;">
<a href="https://www.decor-tab-creator.com">Decor</a> <a href="https://www.decor-tab-creator.com">Decor</a>
</li> </li>
<li> <li>
@ -956,7 +956,7 @@ oop.inherits(FoldMode, BaseFoldMode);
<a href="http://www.divshot.com/">Divshot</a> <a href="http://www.divshot.com/">Divshot</a>
</li> </li>
<li> <li>
<img src="https://codio.com/base/images/logo.png" <img src="https://codio.com/s/img/logo-beta-e0ba4559.png"
style="position: relative; left: -4px; width: 110px;top: 16px;"> style="position: relative; left: -4px; width: 110px;top: 16px;">
<a href="https://codio.com/">Codio</a> <a href="https://codio.com/">Codio</a>
</li> </li>
@ -972,6 +972,18 @@ oop.inherits(FoldMode, BaseFoldMode);
style="position: relative; left: 4px; width: 96px;top: -17px;"> style="position: relative; left: 4px; width: 96px;top: -17px;">
<a href="http://multiPlay.io/">MultiPlay.io</a> <a href="http://multiPlay.io/">MultiPlay.io</a>
</li> </li>
<li>
<div class="text-logo" style="font-size: 18px;margin-left: -3px;">Codeshare.io</div>
<a href="http://codeshare.io">Codeshare.io</a>
</li>
<li>
<div class="text-logo" style="font-size: 23px;">Runnable</div>
<a href="http://runnable.com">Runnable</a>
</li>
<li>
<div class="text-logo" style="font-size: 22px;margin-left: -5px;">DocsCamp</div>
<a href="http://docscamp.com/">DocsCamp</a>
</li>
<li> <li>
<a href="https://github.com/Gozala/sky-edit">Sky Edit</a> <a href="https://github.com/Gozala/sky-edit">Sky Edit</a>
</li> </li>

View file

@ -294,7 +294,8 @@
baseUrl: window.location.protocol + "//" + window.location.host + window.location.pathname.split("/").slice(0, -1).join("/"), baseUrl: window.location.protocol + "//" + window.location.host + window.location.pathname.split("/").slice(0, -1).join("/"),
paths: { paths: {
ace: "lib/ace" ace: "lib/ace"
} },
waitSeconds: 30
}; };
</script> </script>
<script src="demo/kitchen-sink/require.js" data-main="demo/kitchen-sink/demo" type="text/javascript"></script> <script src="demo/kitchen-sink/require.js" data-main="demo/kitchen-sink/demo" type="text/javascript"></script>

View file

@ -231,6 +231,7 @@ var TextInput = function(parentNode, host) {
afterContextMenu = false; afterContextMenu = false;
}; };
var onInput = function(e) { var onInput = function(e) {
// console.log("onInput", inComposition)
if (inComposition) if (inComposition)
return; return;
var data = text.value; var data = text.value;
@ -349,6 +350,8 @@ var TextInput = function(parentNode, host) {
// COMPOSITION // COMPOSITION
var onCompositionStart = function(e) { var onCompositionStart = function(e) {
if (inComposition) return;
// console.log("onCompositionStart", inComposition)
inComposition = {}; inComposition = {};
host.onCompositionStart(); host.onCompositionStart();
setTimeout(onCompositionUpdate, 0); setTimeout(onCompositionUpdate, 0);
@ -362,6 +365,7 @@ var TextInput = function(parentNode, host) {
}; };
var onCompositionUpdate = function() { var onCompositionUpdate = function() {
// console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value))
if (!inComposition) return; if (!inComposition) return;
host.onCompositionUpdate(text.value); host.onCompositionUpdate(text.value);
if (inComposition.lastValue) if (inComposition.lastValue)
@ -378,27 +382,34 @@ var TextInput = function(parentNode, host) {
}; };
var onCompositionEnd = function(e) { var onCompositionEnd = function(e) {
// console.log("onCompositionEnd", inComposition &&inComposition.lastValue)
var c = inComposition; var c = inComposition;
inComposition = false; inComposition = false;
var timer = setTimeout(function() { var timer = setTimeout(function() {
var str = text.value.replace(/\x01/g, ""); var str = text.value.replace(/\x01/g, "");
if (!inComposition && str == c.lastValue) // console.log(str, c.lastValue)
if (inComposition)
return
else if (str == c.lastValue)
resetValue(); resetValue();
else if (!c.lastValue && str) {
resetValue();
sendText(str);
}
}); });
inputHandler = function compositionInputHandler(str) { inputHandler = function compositionInputHandler(str) {
// console.log("onCompositionEnd", str, c.lastValue)
clearTimeout(timer); clearTimeout(timer);
str = str.replace(/\x01/g, ""); str = str.replace(/\x01/g, "");
if (str == c.lastValue) if (str == c.lastValue)
return ""; return "";
if (!str) { if (c.lastValue)
if (c.lastValue) host.undo();
host.undo();
}
return str; return str;
} }
host.onCompositionEnd(); host.onCompositionEnd();
host.removeListener("mousedown", onCompositionEnd); host.removeListener("mousedown", onCompositionEnd);
if (e.type == "compositionend") { if (e.type == "compositionend" && c.range) {
host.selection.setRange(c.range); host.selection.setRange(c.range);
} }
}; };

View file

@ -545,7 +545,7 @@ var VirtualRenderer = function(container, theme) {
var w = this.characterWidth; var w = this.characterWidth;
if (this.$composition) { if (this.$composition) {
var val = this.textarea.value.replace(/^\x01+/, ""); var val = this.textarea.value.replace(/^\x01+/, "");
w *= this.session.$getStringScreenWidth(val)[0]; w *= (this.session.$getStringScreenWidth(val)[0]+2);
h += 2; h += 2;
posTop -= 1; posTop -= 1;
} }