diff --git a/pkg/gocui/view.go b/pkg/gocui/view.go index 40e067f00..f48a4704e 100644 --- a/pkg/gocui/view.go +++ b/pkg/gocui/view.go @@ -2035,33 +2035,6 @@ func (v *View) isHoveredHyperlink(x, y int) bool { return false } -// realPosition returns the position in the internal buffer corresponding to the -// point (x, y) of the view. -func (v *View) realPosition(vx, vy int) (x, y int, ok bool) { - vx = v.ox + vx - vy = v.oy + vy - - if vx < 0 || vy < 0 { - return 0, 0, false - } - - if len(v.viewLines) == 0 { - return vx, vy, true - } - - if vy < len(v.viewLines) { - vline := v.viewLines[vy] - x = vline.linesX + vx - y = vline.linesY - } else { - vline := v.viewLines[len(v.viewLines)-1] - x = vx - y = vline.linesY + vy - len(v.viewLines) + 1 - } - - return x, y, true -} - // clearRunes erases all the cells in the view. func (v *View) clearRunes() { maxX, maxY := v.InnerSize() @@ -2290,56 +2263,6 @@ func (v *View) ViewBuffer() string { return strings.Join(strs, "\n") } -// Line returns a string with the line of the view's internal buffer -// at the position corresponding to the point (x, y). -func (v *View) Line(y int) (string, bool) { - _, y, ok := v.realPosition(0, y) - if !ok { - return "", false - } - - if y < 0 || y >= len(v.buf.lines) { - return "", false - } - - return v.buf.lines[y].cells.String(), true -} - -// Word returns a string with the word of the view's internal buffer -// at the position corresponding to the point (x, y). -func (v *View) Word(x, y int) (string, bool) { - x, y, ok := v.realPosition(x, y) - if !ok { - return "", false - } - - if x < 0 || y < 0 || y >= len(v.buf.lines) || x >= len(v.buf.lines[y].cells) { - return "", false - } - - str := v.buf.lines[y].cells.String() - - nl := strings.LastIndexFunc(str[:x], indexFunc) - if nl == -1 { - nl = 0 - } else { - nl = nl + 1 - } - nr := strings.IndexFunc(str[x:], indexFunc) - if nr == -1 { - nr = len(str) - } else { - nr = nr + x - } - return str[nl:nr], true -} - -// indexFunc allows to split lines by words taking into account spaces -// and 0. -func indexFunc(r rune) bool { - return r == ' ' || r == 0 -} - // applySelTextColor adds the attributes of selTextColor to fgColor, and // replaces the color of fgColor with that of selTextColor if it has one. func applySelTextColor(fgColor, selTextColor Attribute) Attribute {