Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sysread/textsel
A TextView widget for rivo/tview that supports text selection.
https://github.com/sysread/textsel
Last synced: about 1 month ago
JSON representation
A TextView widget for rivo/tview that supports text selection.
- Host: GitHub
- URL: https://github.com/sysread/textsel
- Owner: sysread
- License: mit
- Created: 2024-08-02T22:24:52.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-10T20:21:03.000Z (4 months ago)
- Last Synced: 2024-08-11T01:57:50.744Z (4 months ago)
- Language: Go
- Size: 64.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES
- License: LICENSE
Awesome Lists containing this project
README
# TextSel
[![Go Reference](https://pkg.go.dev/badge/github.com/sysread/textsel.svg)](https://pkg.go.dev/github.com/sysread/textsel#section-readme)
`textsel` is a Go package that extends the `tview.TextView` widget to include
cursor movement and text selection capabilities. It allows users to navigate
and select text within the `TextView`, making it easier to copy and highlight
text.## Features
- Cursor movement (up, down, left, right).
- Text selection with visual highlighting.
- Customizable colors for cursor and selection.## Installation
To install `textsel`, you need to have Go installed and set up on your machine.
Use the following command to install the package:```bash
go get github.com/sysread/textsel
```## Usage
Here's an example of how to use `textsel` in your project:
```go
package mainimport (
"github.com/sysread/textsel"
"github.com/rivo/tview"
)func main() {
app := tview.NewApplication()textSel := textsel.NewTextSel().SetText("Hello, World!")
if err := app.SetRoot(textSel, true).Run(); err != nil {
panic(err)
}
}
```## Customization
You can customize the colors used for cursor and selection highlighting by
modifying the `defaultColor`, `cursorColor`, `selectionColor`, and
`cursorInSelectionColor` fields in the `TextSel` struct.Example:
```go
textSel := textsel.NewTextSel()
textSel.defaultColor = "[#FFFFFF:#000000:-]"
textSel.cursorColor = "[#000000:#FFFFFF:-]"
textSel.selectionColor = "[#000000:#FF0000:-]"
textSel.cursorInSelectionColor = "[#000000:#FF0000:bu]"
```## Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request with your improvements.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.