mirror of https://github.com/gdamore/tcell.git
Fixes for unicode in Web terminal
This is very partial, and my experience shows that the terminal renders these poorly at best; in particular spacing in the DOM model seems to be unpredictable with emoji and some of the esoteric combining characters. Still this represents a significant improvement by actually including the combining characters. Plus it is faster.
This commit is contained in:
parent
c9ba0cf327
commit
feef990b56
|
@ -61,12 +61,7 @@ function clearScreen(fg, bg) {
|
|||
}
|
||||
}
|
||||
|
||||
function drawCell(x, y, mainc, combc, fg, bg, attrs, us, uc) {
|
||||
var combString = String.fromCharCode(mainc);
|
||||
combc.forEach((char) => {
|
||||
combString += String.fromCharCode(char);
|
||||
});
|
||||
|
||||
function drawCell(x, y, s, fg, bg, attrs, us, uc) {
|
||||
var span = document.createElement("span");
|
||||
var use = false;
|
||||
|
||||
|
@ -123,11 +118,11 @@ function drawCell(x, y, mainc, combc, fg, bg, attrs, us, uc) {
|
|||
if ((attrs & (1 << 1)) != 0) {
|
||||
var blink = document.createElement("span");
|
||||
blink.classList.add("blink");
|
||||
var textnode = document.createTextNode(combString);
|
||||
var textnode = document.createTextNode(s);
|
||||
blink.appendChild(textnode);
|
||||
span.appendChild(blink);
|
||||
} else {
|
||||
var textnode = document.createTextNode(combString);
|
||||
var textnode = document.createTextNode(s);
|
||||
span.appendChild(textnode);
|
||||
}
|
||||
|
||||
|
|
13
wscreen.go
13
wscreen.go
|
@ -143,13 +143,18 @@ func (t *wScreen) drawCell(x, y int) int {
|
|||
uc = 0x000000
|
||||
}
|
||||
|
||||
var combcarr []interface{} = make([]interface{}, len(combc))
|
||||
for i, c := range combc {
|
||||
combcarr[i] = c
|
||||
s := ""
|
||||
if len(combc) > 0 {
|
||||
b := make([]rune, 0, 1 + len(combc))
|
||||
b = append(b, mainc)
|
||||
b = append(b, combc...)
|
||||
s = string(b)
|
||||
} else {
|
||||
s = string(mainc)
|
||||
}
|
||||
|
||||
t.cells.SetDirty(x, y, false)
|
||||
js.Global().Call("drawCell", x, y, mainc, combcarr, fg, bg, int(style.attrs), int(us), int(uc))
|
||||
js.Global().Call("drawCell", x, y, s, fg, bg, int(style.attrs), int(us), int(uc))
|
||||
|
||||
return width
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue