INNER CODE UNIT · Go

len

jpbruinsslot/slack-term · components/input.go:152

		if i.Offset < len(i.Text) {
			i.Offset = i.CalculateOffset()
			i.CursorPositionScreen = i.GetRuneWidthOffsetToCursor()
		}
	} else {
		i.CursorPositionScreen += i.GetRuneWidthLeft()
	}
}

// CalculateOffset will, based on the width of the runes on the
// left of the text cursor, calculate the offset that needs to
// be used by the Inpute Component
func (i *Input) CalculateOffset() int {
	var offset int

	var currentRuneWidth int
	for j := (i.CursorPositionText - 1); currentRuneWidth < i.GetMaxWidth()-1; j-- {
		currentRuneWidth += runewidth.RuneWidth(i.Text[j])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…