-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack cells #7
Comments
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. |
+1 |
@schachmat, here's a quick program showing how you can detect terminal width. You might have to run package main
import (
"fmt"
"golang.org/x/crypto/ssh/terminal"
)
func main() {
width, _, _ := terminal.GetSize(0)
fmt.Println("Width:", width)
} Outputs for me:
|
👍 |
@schachmat Take a look at this package - tablewriter |
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. |
Apparently you can elegantly solve the problem using the core package Check here and here |
I don't know how compatible the renderings are, but you might be able to accomplish this with TermUI? |
The package golang.org/x/crypto/ssh/terminal is deprecated. Sample: package main
import (
"log/slog"
"os"
"golang.org/x/term"
)
func main() {
ttyFd := int(os.Stdin.Fd())
if !term.IsTerminal(ttyFd) {
slog.Default().Error("Current Stdin File Descriptor is no terminal, aborting")
os.Exit(1)
}
width, height, err := term.GetSize(ttyFd)
if err != nil {
slog.Default().Error(
"Unable to get terminal size, aborting.",
slog.Any("error", err),
)
os.Exit(1)
}
slog.Default().Info(
"Detected terminal size.",
slog.Int("columns", width),
slog.Int("rows", height),
)
} Output inside vim:
Output from within
|
I suppose cells should be stacked when terminal width is not sufficient for 4 cells of each day. Now in my terminal with 90 symbols width the output is a real mess.
The text was updated successfully, but these errors were encountered: