diff --git a/cmd/gdu/app/app.go b/cmd/gdu/app/app.go index eb0ea6bf6..f7c0c17e0 100644 --- a/cmd/gdu/app/app.go +++ b/cmd/gdu/app/app.go @@ -68,7 +68,13 @@ type Flags struct { // Style define style config type Style struct { - SelectedRow ColorStyle `yaml:"selected-row"` + SelectedRow ColorStyle `yaml:"selected-row"` + ProgressModal ProgressModalOpts `yaml:"progress-modal"` +} + +// ProgressModalOpts defines options for progress modal +type ProgressModalOpts struct { + CurrentItemNameMaxLen int `yaml:"current-item-path-max-len"` } // ColorStyle defines styling of some item @@ -218,6 +224,11 @@ func (a *App) createUI() (UI, error) { ui.SetSelectedBackgroundColor(tcell.GetColor(a.Flags.Style.SelectedRow.BackgroundColor)) }) } + if a.Flags.Style.ProgressModal.CurrentItemNameMaxLen > 0 { + opts = append(opts, func(ui *tui.UI) { + ui.SetCurrentItemNameMaxLen(a.Flags.Style.ProgressModal.CurrentItemNameMaxLen) + }) + } ui = tui.CreateUI( a.TermApp, diff --git a/cmd/gdu/app/app_test.go b/cmd/gdu/app/app_test.go index 13524f620..799a2d95b 100644 --- a/cmd/gdu/app/app_test.go +++ b/cmd/gdu/app/app_test.go @@ -146,6 +146,9 @@ func TestAnalyzePathWithStyle(t *testing.T) { TextColor: "black", BackgroundColor: "red", }, + ProgressModal: ProgressModalOpts{ + CurrentItemNameMaxLen: 10, + }, }, }, []string{"test_dir"}, diff --git a/tui/progress.go b/tui/progress.go index e46e15f5c..d21bb7571 100644 --- a/tui/progress.go +++ b/tui/progress.go @@ -40,7 +40,7 @@ func (ui *UI) updateProgress() { color + delta.String() + "[white:black:-]\nCurrent item: [white:black:b]" + - path.ShortenPath(currentItem, 70)) + path.ShortenPath(currentItem, ui.currentItemNameMaxLen)) }) }(progress.ItemCount, progress.TotalSize, progress.CurrentItemName) diff --git a/tui/tui.go b/tui/tui.go index 3d34f1168..9cab6234d 100644 --- a/tui/tui.go +++ b/tui/tui.go @@ -75,6 +75,7 @@ type UI struct { linkedItems fs.HardLinkedItems selectedTextColor tcell.Color selectedBackgroundColor tcell.Color + currentItemNameMaxLen int } // Option is optional function customizing the bahaviour of UI @@ -112,6 +113,7 @@ func CreateUI( linkedItems: make(fs.HardLinkedItems, 10), selectedTextColor: tview.Styles.TitleColor, selectedBackgroundColor: tview.Styles.MoreContrastBackgroundColor, + currentItemNameMaxLen: 70, } for _, o := range opts { o(ui) @@ -192,6 +194,12 @@ func (ui *UI) SetSelectedBackgroundColor(color tcell.Color) { ui.selectedBackgroundColor = color } +// SetCurrentItemNameMaxLen sets the maximum length of the path of the currently processed item +// to be shown in the progress modal +func (ui *UI) SetCurrentItemNameMaxLen(len int) { + ui.currentItemNameMaxLen = len +} + // StartUILoop starts tview application func (ui *UI) StartUILoop() error { return ui.app.Run()