mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 05:11:06 +02:00
use term.GetSize
This commit is contained in:
parent
01609df902
commit
bc9dbfd905
1 changed files with 8 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue