From b7b626b04e2d11f3480ecd9f89210475caee30e8 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 16 Jun 2015 21:32:33 -0700 Subject: [PATCH] Making caption fixed length and bumping caption usage to 18% --- cmd-cp.go | 3 +-- cmd-sync.go | 3 +-- pb.go | 10 +++++++--- version.go | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cmd-cp.go b/cmd-cp.go index b5726597..52f78e46 100644 --- a/cmd-cp.go +++ b/cmd-cp.go @@ -20,7 +20,6 @@ import ( "fmt" "io" "math" - "path/filepath" "runtime" "sync" @@ -71,7 +70,7 @@ EXAMPLES: // doCopy - Copy a singe file from source to destination func doCopy(cURLs cpURLs, bar *barSend) error { if !globalQuietFlag { - bar.SetCaption(filepath.Base(cURLs.SourceContent.Name) + ": ") + bar.SetCaption(cURLs.SourceContent.Name + ": ") } reader, length, err := getSource(cURLs.SourceContent.Name) if err != nil { diff --git a/cmd-sync.go b/cmd-sync.go index 734c0bce..45b79195 100644 --- a/cmd-sync.go +++ b/cmd-sync.go @@ -20,7 +20,6 @@ import ( "fmt" "io" "math" - "path/filepath" "runtime" "sync" @@ -72,7 +71,7 @@ EXAMPLES: func doSync(sURLs syncURLs, bar *barSend, syncQueue chan bool, errCh chan error, wg *sync.WaitGroup) { defer wg.Done() if !globalQuietFlag { - bar.SetCaption(filepath.Base(sURLs.SourceContent.Name) + ": ") + bar.SetCaption(sURLs.SourceContent.Name + ": ") } reader, length, err := getSource(sURLs.SourceContent.Name) if err != nil { diff --git a/pb.go b/pb.go index 3303fccf..7c863263 100644 --- a/pb.go +++ b/pb.go @@ -19,6 +19,7 @@ package main import ( "io" "runtime" + "strings" "sync/atomic" "time" @@ -108,12 +109,15 @@ func cursorAnimate() <-chan rune { } func fixateBarCaption(c string, s string, width int) string { - if len(c) > width { + switch { + case len(c) > width: // Trim caption to fit within the screen - trimSize := len(c) - width + 3 + 1 + trimSize := len(c) - width + 3 if trimSize < len(c) { c = "..." + c[trimSize:] } + case len(c) < width: + c = c + strings.Repeat(" ", width-len(c)) } return s + " " + c } @@ -143,7 +147,7 @@ func newCpBar() barSend { for msg := range cmdCh { switch msg.Cmd { case pbBarCmdSetCaption: - bar.Prefix(fixateBarCaption(msg.Arg.(string), string(<-cursorCh), getFixedWidth(bar.GetWidth(), 10))) + bar.Prefix(fixateBarCaption(msg.Arg.(string), string(<-cursorCh), getFixedWidth(bar.GetWidth(), 18))) case pbBarCmdExtend: atomic.AddInt64(&bar.Total, msg.Arg.(int64)) case pbBarCmdProgress: diff --git a/version.go b/version.go index f8b4f5a5..b84708de 100644 --- a/version.go +++ b/version.go @@ -9,7 +9,7 @@ import ( ) // Version autogenerated -var Version = "2015-06-17T02:33:42.328610257Z" +var Version = "2015-06-17T04:33:45.409511167Z" // Tag is of following format // @@ -17,7 +17,7 @@ var Version = "2015-06-17T02:33:42.328610257Z" // // STRING is release string of your choice. // EPOCH is unix seconds since Jan 1, 1970 UTC. -var Tag = "release-1434508422" +var Tag = "release-1434515625" // getVersion - func getVersion() string {