mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-01-22 08:48:53 +00:00
fix textarea for full unicode.
This commit is contained in:
parent
5dacfbad97
commit
7b31f45468
@ -1215,15 +1215,15 @@ Screen.prototype.draw = function(start, end) {
|
|||||||
// If we're at the end, we don't have enough space for a
|
// If we're at the end, we don't have enough space for a
|
||||||
// double-width. Overwrite it with a space and ignore.
|
// double-width. Overwrite it with a space and ignore.
|
||||||
ch = ' ';
|
ch = ' ';
|
||||||
o[x][1] = ' ';
|
o[x][1] = '\0';
|
||||||
} else {
|
} else {
|
||||||
// ALWAYS refresh double-width chars because this special cursor
|
// ALWAYS refresh double-width chars because this special cursor
|
||||||
// behavior is needed. There may be a more efficient way of doing
|
// behavior is needed. There may be a more efficient way of doing
|
||||||
// this. See above.
|
// this. See above.
|
||||||
o[x][1] = ' ';
|
o[x][1] = '\0';
|
||||||
// Eat the next character by moving forward and marking as a
|
// Eat the next character by moving forward and marking as a
|
||||||
// space (which it is).
|
// space (which it is).
|
||||||
o[++x][1] = ' ';
|
o[++x][1] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5878,8 +5878,17 @@ Textarea.prototype._listener = function(ch, key) {
|
|||||||
done(null, null);
|
done(null, null);
|
||||||
} else if (key.name === 'backspace') {
|
} else if (key.name === 'backspace') {
|
||||||
if (this.value.length) {
|
if (this.value.length) {
|
||||||
|
if (this.screen.fullUnicode) {
|
||||||
|
if (this.value[this.value.length - 2]
|
||||||
|
&& unicode.isSurrogate(this.value[this.value.length - 2])) {
|
||||||
|
this.value = this.value.slice(0, -2);
|
||||||
|
} else {
|
||||||
this.value = this.value.slice(0, -1);
|
this.value = this.value.slice(0, -1);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.value = this.value.slice(0, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (ch) {
|
} else if (ch) {
|
||||||
if (!/^[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f]$/.test(ch)) {
|
if (!/^[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f]$/.test(ch)) {
|
||||||
this.value += ch;
|
this.value += ch;
|
||||||
|
@ -17,6 +17,7 @@ screen = blessed.screen({
|
|||||||
// screen.tput.strings.enter_alt_charset_mode = false;
|
// screen.tput.strings.enter_alt_charset_mode = false;
|
||||||
|
|
||||||
// var DOUBLE = '杜';
|
// var DOUBLE = '杜';
|
||||||
|
// '杜'
|
||||||
var DOUBLE = String.fromCodePoint
|
var DOUBLE = String.fromCodePoint
|
||||||
? String.fromCodePoint(0x675c)
|
? String.fromCodePoint(0x675c)
|
||||||
: String.fromCharCode(0x675c);
|
: String.fromCharCode(0x675c);
|
||||||
|
@ -2,7 +2,8 @@ var blessed = require('../')
|
|||||||
, screen;
|
, screen;
|
||||||
|
|
||||||
screen = blessed.screen({
|
screen = blessed.screen({
|
||||||
dump: __dirname + '/logs/textarea.log'
|
dump: __dirname + '/logs/textarea.log',
|
||||||
|
fullUnicode: true
|
||||||
});
|
});
|
||||||
|
|
||||||
var box = blessed.textarea({
|
var box = blessed.textarea({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user