edit.go
func (e *EditField) Draw() {
	if e.hidden {
		return
	}

	PushAttributes()
	defer PopAttributes()

	x, y := e.Pos()
	w, _ := e.Size()

	parts := []rune(SysObject(ObjEdit))
	chLeft, chRight := string(parts[0]), string(parts[1])
	chStar := "*"
	if len(parts) > 3 {
		chStar = string(parts[3])
	}

	var textOut string
	curOff := 0
	if e.offset == 0 && xs.Len(e.title) < e.width {
		if e.showStars {
			textOut = strings.Repeat(chStar, xs.Len(e.title))
		} else {
			textOut = e.title
		}
	} else {
		fromIdx := 0
		toIdx := 0
		if e.offset == 0 {
			toIdx = e.width - 1
			if e.showStars {
				textOut = strings.Repeat(chStar, toIdx) + chRight
			} else {
				textOut = xs.Slice(e.title, 0, toIdx) + chRight
			}
			curOff = -e.offset
		} else {
			curOff = 1 - e.offset
			fromIdx = e.offset
			if e.width-1 <= xs.Len(e.title)-e.offset {
				toIdx = e.offset + e.width - 2
				if e.showStars {
					textOut = chLeft + strings.Repeat(chStar, toIdx-fromIdx) + chRight
				} else {
					textOut = chLeft + xs.Slice(e.title, fromIdx, toIdx) + chRight
				}
			} else {
				if e.showStars {
					textOut = chLeft + strings.Repeat(chStar, xs.Len(e.title)-fromIdx)
				} else {
					textOut = chLeft + xs.Slice(e.title, fromIdx, -1)
				}
			}
		}
	}

	fg, bg := RealColor(e.fg, e.Style(), ColorEditText), RealColor(e.bg, e.Style(), ColorEditBack)
	if !e.Enabled() {
		fg, bg = RealColor(e.fg, e.Style(), ColorDisabledText), RealColor(e.fg, e.Style(), ColorDisabledBack)
	} else if e.Active() {
		fg, bg = RealColor(e.fg, e.Style(), ColorEditActiveText), RealColor(e.bg, e.Style(), ColorEditActiveBack)
	}

	SetTextColor(fg)
	SetBackColor(bg)
	FillRect(x, y, w, 1, ' ')
	DrawRawText(x, y, textOut)
	if e.Active() {
		SetCursorPos(e.cursorPos+e.x+curOff, e.y)
	}
}
func (e *EditField) Draw() {
	if e.hidden {
		return
	}

	PushAttributes()
	defer PopAttributes()

	x, y := e.Pos()
	w, _ := e.Size()

	parts := []rune(SysObject(ObjEdit))
	chLeft, chRight := string(parts[0]), string(parts[1])
	chStar := "*"
	if len(parts) > 3 {
		chStar = string(parts[3])
	}

	var textOut string
	curOff := 0
	if e.offset == 0 && xs.Len(e.title) < e.width {
		if e.showStars {
			textOut = strings.Repeat(chStar, xs.Len(e.title))
		} else {
			textOut = e.title
		}
	} else {
		fromIdx := 0
		toIdx := 0
		if e.offset == 0 {
			toIdx = e.width - 1
			if e.showStars {
				textOut = strings.Repeat(chStar, toIdx) + chRight
			} else {
				textOut = xs.Slice(e.title, 0, toIdx) + chRight
			}
			curOff = -e.offset
		} else {
			curOff = 1 - e.offset
			fromIdx = e.offset
			if e.width-1 <= xs.Len(e.title)-e.offset {
				toIdx = e.offset + e.width - 2
				if e.showStars {
					textOut = chLeft + strings.Repeat(chStar, toIdx-fromIdx) + chRight
				} else {
					textOut = chLeft + xs.Slice(e.title, fromIdx, toIdx) + chRight
				}
			} else {
				if e.showStars {
					textOut = chLeft + strings.Repeat(chStar, xs.Len(e.title)-fromIdx)
				} else {
					textOut = chLeft + xs.Slice(e.title, fromIdx, -1)
				}
			}
		}
	}

	fg, bg := RealColor(e.fg, e.Style(), ColorEditText), RealColor(e.bg, e.Style(), ColorEditBack)
	if !e.Enabled() {
		fg, bg = RealColor(e.fg, e.Style(), ColorDisabledText), RealColor(e.fg, e.Style(), ColorDisabledBack)
	} else if e.Active() {
		fg, bg = RealColor(e.fg, e.Style(), ColorEditActiveText), RealColor(e.bg, e.Style(), ColorEditActiveBack)
	}

	SetTextColor(fg)
	SetBackColor(bg)
	FillRect(x, y, w, 1, ' ')
	DrawRawText(x, y, textOut)
	if e.Active() {
		SetCursorPos(e.cursorPos+e.x+curOff, e.y)
	}
}
// Repaint draws the control on its View surface