mirror of
https://github.com/gdamore/tcell.git
synced 2025-04-24 13:48:51 +08:00
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) {
|
function drawCell(x, y, s, fg, bg, attrs, us, uc) {
|
||||||
var combString = String.fromCharCode(mainc);
|
|
||||||
combc.forEach((char) => {
|
|
||||||
combString += String.fromCharCode(char);
|
|
||||||
});
|
|
||||||
|
|
||||||
var span = document.createElement("span");
|
var span = document.createElement("span");
|
||||||
var use = false;
|
var use = false;
|
||||||
|
|
||||||
@ -123,11 +118,11 @@ function drawCell(x, y, mainc, combc, fg, bg, attrs, us, uc) {
|
|||||||
if ((attrs & (1 << 1)) != 0) {
|
if ((attrs & (1 << 1)) != 0) {
|
||||||
var blink = document.createElement("span");
|
var blink = document.createElement("span");
|
||||||
blink.classList.add("blink");
|
blink.classList.add("blink");
|
||||||
var textnode = document.createTextNode(combString);
|
var textnode = document.createTextNode(s);
|
||||||
blink.appendChild(textnode);
|
blink.appendChild(textnode);
|
||||||
span.appendChild(blink);
|
span.appendChild(blink);
|
||||||
} else {
|
} else {
|
||||||
var textnode = document.createTextNode(combString);
|
var textnode = document.createTextNode(s);
|
||||||
span.appendChild(textnode);
|
span.appendChild(textnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
wscreen.go
13
wscreen.go
@ -143,13 +143,18 @@ func (t *wScreen) drawCell(x, y int) int {
|
|||||||
uc = 0x000000
|
uc = 0x000000
|
||||||
}
|
}
|
||||||
|
|
||||||
var combcarr []interface{} = make([]interface{}, len(combc))
|
s := ""
|
||||||
for i, c := range combc {
|
if len(combc) > 0 {
|
||||||
combcarr[i] = c
|
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)
|
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
|
return width
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user