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