Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inancgumus/screen
Little helper for clearing the screen using pure Go in a cross-platform way
https://github.com/inancgumus/screen
bash go golang windows
Last synced: about 5 hours ago
JSON representation
Little helper for clearing the screen using pure Go in a cross-platform way
- Host: GitHub
- URL: https://github.com/inancgumus/screen
- Owner: inancgumus
- License: mit
- Created: 2018-12-07T15:20:07.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-27T21:08:49.000Z (11 months ago)
- Last Synced: 2024-12-17T04:43:10.498Z (7 days ago)
- Topics: bash, go, golang, windows
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 79
- Watchers: 2
- Forks: 12
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Screen
The screen package provides an easy way for clearing the screen, moving the cursor and getting the size of the current window in a cross-platform way (Linux, OS X and Windows).
## Installation
```
$ go get -u github.com/inancgumus/screen
```## Clearing the Screen
You can clear the screen and move the cursor to the top-left corner of the screen. This is good enough to create an animated program (such as an always updating clock or a progress bar).
```go
package mainimport (
"fmt"
"time""github.com/inancgumus/screen"
)func main() {
// Clear all the characters on the screen
screen.Clear()for {
// Moves the cursor to the top-left position of the screen
screen.MoveTopLeft()// Animate the time always in the same position
fmt.Println(time.Now())time.Sleep(time.Second)
}
}
```## Getting the Width and Height
You can get the current terminal width and height. Actually, you don't have to use this package to do that. It's just a simple wrapper over [terminal](https://godoc.org/golang.org/x/crypto/ssh/terminal) package.
```go
package mainimport (
"fmt"
"github.com/inancgumus/screen"
)func main() {
w, h := screen.Size()
fmt.Printf("Width: %d Height: %d\n", w, h)
}
```---
_MIT License_