Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/solidiquis/termscroll
Simple terminal utility to render, scroll, and select through a list of items 💻 ⌨️
https://github.com/solidiquis/termscroll
go golang productivity terminal terminal-based
Last synced: 6 days ago
JSON representation
Simple terminal utility to render, scroll, and select through a list of items 💻 ⌨️
- Host: GitHub
- URL: https://github.com/solidiquis/termscroll
- Owner: solidiquis
- License: mit
- Created: 2021-03-07T00:18:34.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-03-07T02:16:13.000Z (over 3 years ago)
- Last Synced: 2024-06-20T10:20:08.478Z (5 months ago)
- Topics: go, golang, productivity, terminal, terminal-based
- Language: Go
- Homepage:
- Size: 8.15 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# termscroll
Example program that leverages termscroll to change wallpapers from the terminal:
## Installation & Usage
`$ go get github.com/solidiquis/termscroll````go
package mainimport (
"fmt"
ts "github.com/solidiquis/termscroll"
)func main() {
items := []string{
"item a",
"item b",
"item c",
"item d",
// ...
}// Graceful exit necessary to unhide cursor
done := make(chan bool)
listenForExitSig, cleanup := ts.InitExitStrat(done)
go listenForExitSig()// up() traverses list up
// down() traverses list down
// current() gets current active index
up, down, current := ts.InitRender(items)// Read from stdin without buffering
stdin := make(chan string, 1)
go ts.ReadStdin(stdin)readInput:
for {
select {
case <-done:
break readInput
case ch := <-stdin:
switch ch {
case "k":
up()
case "j":
down()
case "\n": // Enter
fmt.Printf("You've selected %s\n", items[current()])
break readInput
}
}
}
// unhide cursor
cleanup()
}```