Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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 💻 ⌨️

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 main

import (
"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()
}

```