Skip to content

Commit

Permalink
Underline colors for webassembly.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Mar 5, 2024
1 parent 24d9487 commit 81f6648
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
25 changes: 14 additions & 11 deletions webfiles/tcell.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
Expand All @@ -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");
Expand Down
9 changes: 8 additions & 1 deletion wscreen.go
Expand Up @@ -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
}
Expand Down Expand Up @@ -133,14 +136,18 @@ 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 {
combcarr[i] = c
}

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
}
Expand Down

0 comments on commit 81f6648

Please sign in to comment.