use term.GetSize
This commit is contained in:
parent
01609df902
commit
bc9dbfd905
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/term"
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
|
|
||||||
"github.com/denisbrodbeck/machineid"
|
"github.com/denisbrodbeck/machineid"
|
||||||
|
|
@ -1735,8 +1736,9 @@ func (c *Client) createEmptyFileAndFinish(fileInfo FileInfo, i int) (err error)
|
||||||
} else {
|
} else {
|
||||||
description = " " + description
|
description = " " + description
|
||||||
}
|
}
|
||||||
if len(description) > 20 {
|
width, _, err := term.GetSize(int(os.Stdout.Fd()))
|
||||||
description = description[:17] + "..."
|
if len(description) > width {
|
||||||
|
description = description[:(width-3)] + "..."
|
||||||
}
|
}
|
||||||
c.bar = progressbar.NewOptions64(1,
|
c.bar = progressbar.NewOptions64(1,
|
||||||
progressbar.OptionOnCompletion(func() {
|
progressbar.OptionOnCompletion(func() {
|
||||||
|
|
@ -1914,8 +1916,10 @@ func (c *Client) setBar() {
|
||||||
} else if !c.Options.IsSender {
|
} else if !c.Options.IsSender {
|
||||||
description = " " + description
|
description = " " + description
|
||||||
}
|
}
|
||||||
if len(description) > 20 {
|
width, _, _ := term.GetSize(int(os.Stdout.Fd()))
|
||||||
description = description[:17] + "..."
|
description = strings.TrimSpace(description)
|
||||||
|
if len(description) > width {
|
||||||
|
description = description[:(width-3)] + "..."
|
||||||
}
|
}
|
||||||
c.bar = progressbar.NewOptions64(
|
c.bar = progressbar.NewOptions64(
|
||||||
c.FilesToTransfer[c.FilesToTransferCurrentNum].Size,
|
c.FilesToTransfer[c.FilesToTransferCurrentNum].Size,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue