canvas.go
func DrawScrollBar(x, y, w, h, pos int) {
	xx, yy, ww, hh := clip(x, y, w, h)
	if ww < 1 || hh < 1 {
		return
	}

	PushAttributes()
	defer PopAttributes()

	fg, bg := RealColor(ColorDefault, "", ColorScrollText), RealColor(ColorDefault, "", ColorScrollBack)
	// TODO: add thumb styling
	// fgThumb, bgThumb := RealColor(ColorDefault, "", ColorThumbText), RealColor(ColorDefault, "", ColorThumbBack)
	SetTextColor(fg)
	SetBackColor(bg)

	parts := []rune(SysObject(ObjScrollBar))
	chLine, chThumb, chUp, chDown := parts[0], parts[1], parts[2], parts[3]
	chLeft, chRight := parts[4], parts[5]

	chStart, chEnd := chUp, chDown
	var dx, dy int
	if w > h {
		chStart, chEnd = chLeft, chRight
		dx = w - 1
		dy = 0
	} else {
		dx = 0
		dy = h - 1
	}

	if InClipRect(x, y) {
		putCharUnsafe(x, y, chStart)
	}
	if InClipRect(x+dx, y+dy) {
		putCharUnsafe(x+dx, y+dy, chEnd)
	}
	if xx == x && w > h {
		xx = x + 1
		ww--
	}
	if yy == y && w < h {
		yy = y + 1
		hh--
	}
	if xx+ww == x+w && w > h {
		ww--
	}
	if yy+hh == y+h && w < h {
		hh--
	}

	if w > h {
		DrawHorizontalLine(xx, yy, ww, chLine)
	} else {
		DrawVerticalLine(xx, yy, hh, chLine)
	}

	if pos >= 0 {
		if w > h {
			if pos < w-2 && InClipRect(x+1+pos, y) {
				putCharUnsafe(x+1+pos, y, chThumb)
			}
		} else {
			if pos < h-2 && InClipRect(x, y+1+pos) {
				putCharUnsafe(x, y+1+pos, chThumb)
			}
		}
	}
}
func DrawScrollBar(x, y, w, h, pos int) {
	xx, yy, ww, hh := clip(x, y, w, h)
	if ww < 1 || hh < 1 {
		return
	}

	PushAttributes()
	defer PopAttributes()

	fg, bg := RealColor(ColorDefault, "", ColorScrollText), RealColor(ColorDefault, "", ColorScrollBack)
	// TODO: add thumb styling
	// fgThumb, bgThumb := RealColor(ColorDefault, "", ColorThumbText), RealColor(ColorDefault, "", ColorThumbBack)
	SetTextColor(fg)
	SetBackColor(bg)

	parts := []rune(SysObject(ObjScrollBar))
	chLine, chThumb, chUp, chDown := parts[0], parts[1], parts[2], parts[3]
	chLeft, chRight := parts[4], parts[5]

	chStart, chEnd := chUp, chDown
	var dx, dy int
	if w > h {
		chStart, chEnd = chLeft, chRight
		dx = w - 1
		dy = 0
	} else {
		dx = 0
		dy = h - 1
	}

	if InClipRect(x, y) {
		putCharUnsafe(x, y, chStart)
	}
	if InClipRect(x+dx, y+dy) {
		putCharUnsafe(x+dx, y+dy, chEnd)
	}
	if xx == x && w > h {
		xx = x + 1
		ww--
	}
	if yy == y && w < h {
		yy = y + 1
		hh--
	}
	if xx+ww == x+w && w > h {
		ww--
	}
	if yy+hh == y+h && w < h {
		hh--
	}

	if w > h {
		DrawHorizontalLine(xx, yy, ww, chLine)
	} else {
		DrawVerticalLine(xx, yy, hh, chLine)
	}

	if pos >= 0 {
		if w > h {
			if pos < w-2 && InClipRect(x+1+pos, y) {
				putCharUnsafe(x+1+pos, y, chThumb)
			}
		} else {
			if pos < h-2 && InClipRect(x, y+1+pos) {
				putCharUnsafe(x, y+1+pos, chThumb)
			}
		}
	}
}
// DrawScrollBar displays a scrollbar. pos is the position of the thumb.
// The function detects direction of the scrollbar automatically: if w is greater
// than h then it draws horizontal scrollbar and vertical otherwise