Making caption fixed length and bumping caption usage to 18%
This commit is contained in:
@@ -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 {
|
||||
|
||||
+1
-2
@@ -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 {
|
||||
|
||||
@@ -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:
|
||||
|
||||
+2
-2
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user