From 6a45de171ccd4b40e10c61c85029e22340f31b74 Mon Sep 17 00:00:00 2001 From: Anders Kvist Date: Fri, 1 Nov 2019 09:07:11 +0100 Subject: [PATCH] Limit width to make sure lines don't wrap. --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index ea4e5ff..2b5e6d1 100644 --- a/main.go +++ b/main.go @@ -387,7 +387,7 @@ MAINLOOP: continue MAINLOOP } - _, height := getTerminalSize() + width, height := getTerminalSize() delta := t.Sub(lastTime) sort.Sort(processSort(s.Processes)) @@ -464,8 +464,8 @@ MAINLOOP: fmt.Printf("\033[33m") } - // Print the process line. - fmt.Printf("%7d %10s %10s %10d %10s %7s %s\033[K", pro.Pid, up.String(), pro.State, pro.LastRequestMemory, durStr, pro.RequestMethod, pro.RequestURI) + // Print the process line. 61 is a magic width constant :) + fmt.Printf("%7d %10s %10s %10d %10s %7s %.*s\033[K", pro.Pid, up.String(), pro.State, pro.LastRequestMemory, durStr, pro.RequestMethod, width-61, pro.RequestURI) // Rerset ANSI colors etc. fmt.Printf("\033[0m")