mirror of
https://github.com/rclone/rclone
synced 2024-11-23 00:06:55 +01:00
parent
82c8d78a44
commit
0bd0a992a4
@ -112,6 +112,7 @@ func helpText() (tr []string) {
|
|||||||
tr = append(tr, []string{
|
tr = append(tr, []string{
|
||||||
" Y display current path",
|
" Y display current path",
|
||||||
" ^L refresh screen (fix screen corruption)",
|
" ^L refresh screen (fix screen corruption)",
|
||||||
|
" r recalculate file sizes",
|
||||||
" ? to toggle help on and off",
|
" ? to toggle help on and off",
|
||||||
" q/ESC/^c to quit",
|
" q/ESC/^c to quit",
|
||||||
}...)
|
}...)
|
||||||
@ -122,6 +123,7 @@ func helpText() (tr []string) {
|
|||||||
type UI struct {
|
type UI struct {
|
||||||
s tcell.Screen
|
s tcell.Screen
|
||||||
f fs.Fs // fs being displayed
|
f fs.Fs // fs being displayed
|
||||||
|
cancel func() // cancel the current scanning process
|
||||||
fsName string // human name of Fs
|
fsName string // human name of Fs
|
||||||
root *scan.Dir // root directory
|
root *scan.Dir // root directory
|
||||||
d *scan.Dir // current directory being displayed
|
d *scan.Dir // current directory being displayed
|
||||||
@ -900,6 +902,15 @@ func NewUI(f fs.Fs) *UI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *UI) scan() (chan *scan.Dir, chan error, chan struct{}) {
|
||||||
|
if cancel := u.cancel; cancel != nil {
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
ctx := context.Background()
|
||||||
|
ctx, u.cancel = context.WithCancel(ctx)
|
||||||
|
return scan.Scan(ctx, u.f)
|
||||||
|
}
|
||||||
|
|
||||||
// Run shows the user interface
|
// Run shows the user interface
|
||||||
func (u *UI) Run() error {
|
func (u *UI) Run() error {
|
||||||
var err error
|
var err error
|
||||||
@ -936,8 +947,7 @@ func (u *UI) Run() error {
|
|||||||
defer u.s.Fini()
|
defer u.s.Fini()
|
||||||
|
|
||||||
// scan the disk in the background
|
// scan the disk in the background
|
||||||
u.listing = true
|
rootChan, errChan, updated := u.scan()
|
||||||
rootChan, errChan, updated := scan.Scan(context.Background(), u.f)
|
|
||||||
|
|
||||||
// Poll the events into a channel
|
// Poll the events into a channel
|
||||||
events := make(chan tcell.Event)
|
events := make(chan tcell.Event)
|
||||||
@ -1038,6 +1048,9 @@ outer:
|
|||||||
u.deleteSelected()
|
u.deleteSelected()
|
||||||
case '?':
|
case '?':
|
||||||
u.togglePopupBox(helpText())
|
u.togglePopupBox(helpText())
|
||||||
|
case 'r':
|
||||||
|
// restart scan
|
||||||
|
rootChan, errChan, updated = u.scan()
|
||||||
|
|
||||||
// Refresh the screen. Not obvious what key to map
|
// Refresh the screen. Not obvious what key to map
|
||||||
// this onto, but ^L is a common choice.
|
// this onto, but ^L is a common choice.
|
||||||
|
Loading…
Reference in New Issue
Block a user