summaryrefslogtreecommitdiff
path: root/humanTable.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-04 00:14:02 -0500
committerJeff Carr <[email protected]>2025-09-04 00:14:02 -0500
commit041d8945c97e4045e887785b6e0d0cc2ff57183e (patch)
treeebf0e76512992dcc4ded4f31d6653f3f14ed632b /humanTable.go
parent8e0697d0321a2d29da9b36f4320aa2fbdd4b8278 (diff)
truncate lines at stty -a row (or col, notsure)
Diffstat (limited to 'humanTable.go')
-rw-r--r--humanTable.go24
1 files changed, 13 insertions, 11 deletions
diff --git a/humanTable.go b/humanTable.go
index 3b3f8c3..050e7ec 100644
--- a/humanTable.go
+++ b/humanTable.go
@@ -14,6 +14,7 @@ import (
// log.Info(standardTableSize10(sizes, args))
func StandardTableSize5(sizes []int, args []string) string {
+ WIDTH, _ := getTerminalWidth()
var s string
for i, si := range sizes {
if si == 0 {
@@ -32,19 +33,13 @@ func StandardTableSize5(sizes []int, args []string) string {
arg4 := args[3]
arg5 := args[4]
- return fmt.Sprintf(s, arg1, arg2, arg3, arg4, arg5)
+ all := fmt.Sprintf(s, arg1, arg2, arg3, arg4, arg5)
+ return all[0:WIDTH]
}
-/*
-func standardTable10(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 string) string {
- args := []string{arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10}
- sizes := []int{40, 12, 6, 12, 16, 16, 16, 12, 12, 8}
-
- return standardTableSize10(sizes, args)
-}
-*/
-
func StandardTableSize10(sizes []int, args []string) string {
+ WIDTH, _ := getTerminalWidth()
+ // log.Info("WIDTH IS", WIDTH)
var s string
for i, si := range sizes {
if si == 0 {
@@ -68,5 +63,12 @@ func StandardTableSize10(sizes []int, args []string) string {
arg9 := args[8]
arg10 := args[9]
- return fmt.Sprintf(s, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
+ all := fmt.Sprintf(s, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
+ var small int
+ if len(all) > WIDTH {
+ small = WIDTH
+ } else {
+ small = len(all) - 3
+ }
+ return all[0:small]
}