Underline colors for webassembly.

This commit is contained in:
Garrett D'Amore 2024-03-05 02:40:30 -08:00
parent 24d9487d4a
commit 81f6648f64
2 changed files with 22 additions and 12 deletions

View File

@ -60,7 +60,7 @@ function clearScreen(fg, bg) {
}
}
function drawCell(x, y, mainc, combc, fg, bg, attrs) {
function drawCell(x, y, mainc, combc, fg, bg, attrs, us, uc) {
var combString = String.fromCharCode(mainc);
combc.forEach((char) => {
combString += String.fromCharCode(char);
@ -91,9 +91,6 @@ function drawCell(x, y, mainc, combc, fg, bg, attrs) {
if ((attrs & 1) != 0) {
span.classList.add("bold");
}
if ((attrs & (1 << 3)) != 0) {
span.classList.add("underline");
}
if ((attrs & (1 << 4)) != 0) {
span.classList.add("dim");
}
@ -103,19 +100,25 @@ function drawCell(x, y, mainc, combc, fg, bg, attrs) {
if ((attrs & (1 << 6)) != 0) {
span.classList.add("strikethrough");
}
if ((attrs & (1 << 7)) != 0) {
}
if (us != 0) {
use = true;
if (us == 1) {
span.classList.add("underline");
} else if (us == 2) {
span.classList.add("double_underline");
}
if ((attrs & (1 << 8)) != 0) {
} else if (us == 3) {
span.classList.add("curly_underline");
}
if ((attrs & (1 << 9)) != 0) {
} else if (us == 4) {
span.classList.add("dotted_underline");
}
if ((attrs & (1 << 10)) != 0) {
} else if (us == 5) {
span.classList.add("dashed_underline");
}
if (uc != -1) {
span.style.textDecorationColor = intToHex(uc);
}
}
if ((attrs & (1 << 1)) != 0) {
var blink = document.createElement("span");
blink.classList.add("blink");

View File

@ -66,6 +66,9 @@ func (t *wScreen) Init() error {
t.Unlock()
js.Global().Set("onKeyEvent", js.FuncOf(t.onKeyEvent))
js.Global().Set("onMouseClick", js.FuncOf(t.unset))
js.Global().Set("onMouseMove", js.FuncOf(t.unset))
js.Global().Set("onFocus", js.FuncOf(t.unset))
return nil
}
@ -133,6 +136,10 @@ func (t *wScreen) drawCell(x, y int) int {
if bg == -1 {
bg = 0x000000
}
us, uc := style.ulStyle, paletteColor(style.ulColor)
if uc == -1 {
uc = 0x000000
}
var combcarr []interface{} = make([]interface{}, len(combc))
for i, c := range combc {
@ -140,7 +147,7 @@ func (t *wScreen) drawCell(x, y int) int {
}
t.cells.SetDirty(x, y, false)
js.Global().Call("drawCell", x, y, mainc, combcarr, fg, bg, int(style.attrs))
js.Global().Call("drawCell", x, y, mainc, combcarr, fg, bg, int(style.attrs), int(us), int(uc))
return width
}