Browse Source

Fix WordWrap bounds out of range

Resolves #27.
tablepad
Trevor Slocum 2 years ago
parent
commit
a3a0d67f65
  1. 1
      CHANGELOG
  2. 2
      README.md
  3. 2
      go.mod
  4. 4
      go.sum
  5. 5
      slider.go
  6. 5
      util.go

1
CHANGELOG

@ -4,6 +4,7 @@ v1.5.1 (WIP)
- Add TextView.SetBytes and TextView.GetBytes
- Add TableCell.SetBytes, TableCell.GetBytes and TableCell.GetText
- Fix List.Transform not calling handler set via SetChangedFunc
- Fix WordWrap bounds out of range
- Allow modification of scroll bar render text
- Optimize TextView (writing is 90% faster, drawing is 50% faster)
- Remove return values from methods which return their primitive (breaks chaining)

2
README.md

@ -41,7 +41,7 @@ go get gitlab.com/tslocum/cview
## Hello World
This basic example creates a box titled "Hello, World!" and displays it in your terminal:
This basic example creates a TextView titled "Hello, World!" and displays it in your terminal:
```go
package main

2
go.mod

@ -8,5 +8,5 @@ require (
github.com/mattn/go-runewidth v0.0.9
github.com/rivo/uniseg v0.1.0
gitlab.com/tslocum/cbind v0.1.2
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect
golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634 // indirect
)

4
go.sum

@ -15,8 +15,8 @@ gitlab.com/tslocum/cbind v0.1.2/go.mod h1:HfB7qAhHSZbn1rFK8M9SvSN5NG6ScAg/3h3iE6
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6 h1:DvY3Zkh7KabQE/kfzMvYvKirSiguP9Q/veMtkYyf0o8=
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634 h1:bNEHhJCnrwMKNMmOx3yAynp5vs5/gRy+XWFtZFu7NBM=
golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

5
slider.go

@ -153,10 +153,7 @@ func (s *Slider) GetFieldHeight() int {
// GetFieldWidth returns this primitive's field width.
func (s *Slider) GetFieldWidth() int {
s.RLock()
defer s.RUnlock()
return 7
return 0
}
// SetIncrement sets the amount the slider is incremented by when modified via

5
util.go

@ -7,7 +7,7 @@ import (
"strconv"
"github.com/gdamore/tcell/v2"
runewidth "github.com/mattn/go-runewidth"
"github.com/mattn/go-runewidth"
"github.com/rivo/uniseg"
)
@ -490,6 +490,9 @@ func WordWrap(text string, width int) (lines []string) {
for index := escapePos; index >= 0; index-- {
if index < len(escapeIndices) && startIndex > escapeIndices[index][0] && startIndex < escapeIndices[index][1]-1 {
pos := escapeIndices[index][1] - 2 - startIndex
if pos < 0 || pos > len(substr) {
return substr
}
return substr[:pos] + substr[pos+1:]
}
}

Loading…
Cancel
Save