Comments (8)
Correct, that is a problem. I have not researched how to reliably and portably detect terminal width in go yet. If you have some hints/ideas, let me know.
from wego.
+1
from wego.
@schachmat, here's a quick program showing how you can detect terminal width.
You might have to run go get golang.org/x/crypto/ssh/terminal
before running if you haven't already got this installed.
package main
import (
"fmt"
"golang.org/x/crypto/ssh/terminal"
)
func main() {
width, _, _ := terminal.GetSize(0)
fmt.Println("Width:", width)
}
Outputs for me:
Width: 159
from wego.
from wego.
@schachmat Take a look at this package - tablewriter
from wego.
tablewriter does not seem to support correct connections for the vertical and horizontal lines. Also embedding the date between the βNoonβ and βEveningβ columns can't be done.
from wego.
Apparently you can elegantly solve the problem using the core package syscall
and doing an ioctl β but check the parameters you pass, to truly achieve portability among Windows, Linux and OSX (the last two ones behave differently in this case).
Check here
and here
from wego.
I don't know how compatible the renderings are, but you might be able to accomplish this with TermUI?
from wego.
Related Issues (20)
- Table misalignment HOT 9
- Better representation for Lightning in ASCII Art. HOT 6
- Weird table indentation HOT 2
- Expose formatCond method in frontend interface
- Feature request: Can you add UV index into the result HOT 1
- can't find backend 'openweathermap' HOT 4
- Dark Sky API being shut down after 2021 HOT 4
- [Feature Request] ASCII Frontend for Radar View HOT 1
- Yr HOT 1
- Question/Enhancement: Please add local build instructions HOT 1
- Bug/Enhancement: Visibility, Sunrise, Sunset data returned by OpenWeatherMap is not captured in by json frontend
- API on OWM not working
- Go module support HOT 1
- Can't install. HOT 2
- "Could not find selected backend 'forecast.io'?" HOT 4
- please add backend `www.weatherapi.com`
- Move config file default path to os.UserConfigDir()
- Debian Support? HOT 2
- wegorc file does not generate HOT 4
- Is it possible to change the color settings?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wego.