diff --git a/webfiles/tcell.js b/webfiles/tcell.js index 5e17b52..0ffaf22 100644 --- a/webfiles/tcell.js +++ b/webfiles/tcell.js @@ -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); } diff --git a/wscreen.go b/wscreen.go index ebcb7e9..8f66079 100644 --- a/wscreen.go +++ b/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 }