fix multi byte rendering (cursor position, selection)
This commit is contained in:
parent
38bc952daf
commit
4e21d9edd8
5 changed files with 81 additions and 36 deletions
|
|
@ -78,7 +78,7 @@
|
||||||
<option value="js">JS Document</option>
|
<option value="js">JS Document</option>
|
||||||
<option value="html">HTML Document</option>
|
<option value="html">HTML Document</option>
|
||||||
<option value="css">CSS Document</option>
|
<option value="css">CSS Document</option>
|
||||||
<option value="python">Python Document</option>
|
<option value="python" selected>Python Document</option>
|
||||||
<option value="php">PHP Document</option>
|
<option value="php">PHP Document</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -90,7 +90,7 @@
|
||||||
<option value="xml">XML</option>
|
<option value="xml">XML</option>
|
||||||
<option value="html">HTML</option>
|
<option value="html">HTML</option>
|
||||||
<option value="css">CSS</option>
|
<option value="css">CSS</option>
|
||||||
<option value="python">Python</option>
|
<option value="python" selected>Python</option>
|
||||||
<option value="php">PHP</option>
|
<option value="php">PHP</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
<option value="ace/theme/textmate">TextMate</option>
|
<option value="ace/theme/textmate">TextMate</option>
|
||||||
<option value="ace/theme/eclipse">Eclipse</option>
|
<option value="ace/theme/eclipse">Eclipse</option>
|
||||||
<option value="ace/theme/dawn">Dawn</option>
|
<option value="ace/theme/dawn">Dawn</option>
|
||||||
<option value="ace/theme/idle_fingers">idleFingers</option>
|
<option value="ace/theme/idle_fingers" selected>idleFingers</option>
|
||||||
<option value="ace/theme/pastel_on_dark">Pastel on dark</option>
|
<option value="ace/theme/pastel_on_dark">Pastel on dark</option>
|
||||||
<option value="ace/theme/twilight">Twilight</option>
|
<option value="ace/theme/twilight">Twilight</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
@ -118,7 +118,9 @@
|
||||||
<input type="checkbox" name="show_hidden" id="show_hidden">
|
<input type="checkbox" name="show_hidden" id="show_hidden">
|
||||||
</td>
|
</td>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<img src="demo/logo.png">
|
<div id="debuger" style="color: #fff;font-weight:bold;">
|
||||||
|
info
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
@ -163,6 +165,7 @@ import string, sys
|
||||||
if len(sys.argv)==1:
|
if len(sys.argv)==1:
|
||||||
print 'Usage: celsius temp1 temp2 ...'
|
print 'Usage: celsius temp1 temp2 ...'
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
print '这里是中文'
|
||||||
|
|
||||||
# Loop over the arguments
|
# Loop over the arguments
|
||||||
for i in sys.argv[1:]:
|
for i in sys.argv[1:]:
|
||||||
|
|
@ -200,6 +203,9 @@ echo $output;
|
||||||
<script src="demo/require.js" type="text/javascript" charset="utf-8"></script>
|
<script src="demo/require.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<script src="demo/boot.js" type="text/javascript" charset="utf-8"></script>
|
<script src="demo/boot.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
window['debug'] = function(t){
|
||||||
|
document.getElementById('debuger').innerHTML = t;
|
||||||
|
}
|
||||||
require("demo/boot");
|
require("demo/boot");
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ var EditSession = function(text, mode) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.tokenRe = /^[\w\d]+/g;
|
this.tokenRe = /^[\w\d]+/g;
|
||||||
this.nonTokenRe = /^[^\w\d]+/g;
|
this.nonTokenRe = /^[^\w\d|\x00-\xff]+/g;
|
||||||
|
|
||||||
this.getWordRange = function(row, column) {
|
this.getWordRange = function(row, column) {
|
||||||
var line = this.getLine(row);
|
var line = this.getLine(row);
|
||||||
|
|
@ -633,19 +633,23 @@ var EditSession = function(text, mode) {
|
||||||
|
|
||||||
var screenColumn = 0;
|
var screenColumn = 0;
|
||||||
var remaining = docColumn;
|
var remaining = docColumn;
|
||||||
|
var line = this.getLine(row);
|
||||||
|
|
||||||
var line = this.getLine(row).split("\t");
|
for(var i=0; i<line.length; i++){
|
||||||
for (var i=0; i<line.length; i++) {
|
var c = line[i];
|
||||||
var len = line[i].length;
|
if(remaining > 0){
|
||||||
if (remaining > len) {
|
remaining -= 1;
|
||||||
remaining -= (len + 1);
|
if(c == '\t'){
|
||||||
screenColumn += len + tabSize;
|
screenColumn += tabSize;
|
||||||
}
|
} else if(/[^\x00-\xff]/.exec(c)){
|
||||||
else {
|
screenColumn += 2;
|
||||||
screenColumn += remaining;
|
} else {
|
||||||
break;
|
screenColumn += 1;
|
||||||
}
|
}
|
||||||
}
|
}else{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return screenColumn;
|
return screenColumn;
|
||||||
};
|
};
|
||||||
|
|
@ -655,23 +659,24 @@ var EditSession = function(text, mode) {
|
||||||
|
|
||||||
var docColumn = 0;
|
var docColumn = 0;
|
||||||
var remaining = screenColumn;
|
var remaining = screenColumn;
|
||||||
|
var line = this.getLine(row);
|
||||||
|
|
||||||
|
for(var i=0; i<line.length; i++){
|
||||||
|
var c = line[i];
|
||||||
|
if(remaining > 0){
|
||||||
|
docColumn += 1;
|
||||||
|
if(c == '\t'){
|
||||||
|
remaining -= tabSize;
|
||||||
|
} else if(/[^\x00-\xff]/.exec(c)){
|
||||||
|
remaining -= 2;
|
||||||
|
} else {
|
||||||
|
remaining -= 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var line = this.getLine(row).split("\t");
|
|
||||||
for (var i=0; i<line.length; i++) {
|
|
||||||
var len = line[i].length;
|
|
||||||
if (remaining >= len + tabSize) {
|
|
||||||
remaining -= (len + tabSize);
|
|
||||||
docColumn += (len + 1);
|
|
||||||
}
|
|
||||||
else if (remaining > len){
|
|
||||||
docColumn += len;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
docColumn += remaining;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return docColumn;
|
return docColumn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -275,6 +275,17 @@ var Text = function(parentEl) {
|
||||||
.replace(spaceRe, spaceReplace)
|
.replace(spaceRe, spaceReplace)
|
||||||
.replace(/\t/g, this.$tabString);
|
.replace(/\t/g, this.$tabString);
|
||||||
|
|
||||||
|
var buffer = '';
|
||||||
|
for (var j=0;j<output.length;j++){
|
||||||
|
var w = output.charAt(j);
|
||||||
|
if(/[^\x00-\xff]/.exec(w)){
|
||||||
|
buffer = buffer + "<span style='width: "+ this.config.characterWidth * 2 +"px; display: inline-block; text-align: center;'>" + w + "</span>";
|
||||||
|
}else{
|
||||||
|
buffer = buffer + w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
output = buffer;
|
||||||
|
|
||||||
if (!this.$textToken[token.type]) {
|
if (!this.$textToken[token.type]) {
|
||||||
var classes = "ace_" + token.type.replace(/\./g, " ace_");
|
var classes = "ace_" + token.type.replace(/\./g, " ace_");
|
||||||
stringBuilder.push("<span class='", classes, "'>", output, "</span>");
|
stringBuilder.push("<span class='", classes, "'>", output, "</span>");
|
||||||
|
|
|
||||||
|
|
@ -591,12 +591,35 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.showComposition = function(position) {
|
this.showComposition = function(position) {
|
||||||
|
var cur = this.$cursorLayer.element.firstChild;
|
||||||
|
var scroll = this.scroller;
|
||||||
|
var top = (parseInt(cur.style.top) || 0) + (parseInt(scroll.style.top) || 0);
|
||||||
|
var left = (parseInt(cur.style.left) || 0) + (parseInt(scroll.style.left) || 0);
|
||||||
|
|
||||||
|
var edit = document.getElementById("editor").lastChild;
|
||||||
|
edit.style.color = '#66ff33';
|
||||||
|
edit.style.top = (top - 1) + "px";
|
||||||
|
edit.style.left = (left + 3) + "px";
|
||||||
|
edit.style.background = "transparent";
|
||||||
|
edit.style.border = "none";
|
||||||
|
edit.style.resize = "none";
|
||||||
|
edit.style.outline = "none";
|
||||||
|
edit.style.width = "10000px";
|
||||||
|
edit.style.height = "10000px";
|
||||||
|
edit.style.fontSize = "12px";
|
||||||
|
|
||||||
|
this.hideCursor();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setCompositionText = function(text) {
|
this.setCompositionText = function(text) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.hideComposition = function() {
|
this.hideComposition = function() {
|
||||||
|
this.showCursor();
|
||||||
|
var edit = document.getElementById("editor").lastChild;
|
||||||
|
edit.className = '';
|
||||||
|
edit.style.top = "-10000px";
|
||||||
|
edit.style.left = "-10000px";
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setTheme = function(theme) {
|
this.setTheme = function(theme) {
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,7 @@ def test():
|
||||||
app = Cling(getcwd())
|
app = Cling(getcwd())
|
||||||
try:
|
try:
|
||||||
print "Serving " + getcwd() + " to http://localhost:9999"
|
print "Serving " + getcwd() + " to http://localhost:9999"
|
||||||
make_server('localhost', 9999, validator(app)).serve_forever()
|
make_server('0.0.0.0', 9999, validator(app)).serve_forever()
|
||||||
except KeyboardInterrupt, ki:
|
except KeyboardInterrupt, ki:
|
||||||
print ""
|
print ""
|
||||||
print "Ciao, baby!"
|
print "Ciao, baby!"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue