Skip to content

Commit

Permalink
fix: few improvements and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dundee committed Mar 24, 2024
1 parent 9ccd58e commit d511c55
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/gdu/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func init() {
flags.BoolVar(&af.UseSIPrefix, "si", false, "Show sizes with decimal SI prefixes (kB, MB, GB) instead of binary prefixes (KiB, MiB, GiB)")
flags.BoolVar(&af.NoPrefix, "no-prefix", false, "Show sizes as raw numbers without any prefixes (SI or binary) in non-interactive mode")
flags.BoolVar(&af.NoMouse, "no-mouse", false, "Do not use mouse")
flags.BoolVar(&af.NoDelete, "no-delete", false, "Do not allowe deletions")
flags.BoolVar(&af.NoDelete, "no-delete", false, "Do not allow deletions")
flags.BoolVar(&af.WriteConfig, "write-config", false, "Write current configuration to file (default is $HOME/.gdu.yaml)")

initConfig()
Expand Down
6 changes: 3 additions & 3 deletions tui/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func (ui *UI) showHelp() {
text.SetTitle(" gdu help ")
text.SetScrollable(true)

formattedHelpText := formatHelpTextFor(ui)
formattedHelpText := ui.formatHelpTextFor()
text.SetText(formattedHelpText)

maxHeight := strings.Count(formattedHelpText, "\n") + 7
Expand All @@ -272,7 +272,7 @@ func (ui *UI) showHelp() {
ui.app.SetFocus(text)
}

func formatHelpTextFor(ui *UI) string {
func (ui *UI) formatHelpTextFor() string {
lines := strings.Split(helpText, "\n")

for i, line := range lines {
Expand All @@ -286,7 +286,7 @@ func formatHelpTextFor(ui *UI) string {

if ui.noDelete && (strings.Contains(line, "Empty file or directory") ||
strings.Contains(line, "Delete file or directory")) {
lines[i] += " (Disabled)"
lines[i] += " (disabled)"
}
}

Expand Down
8 changes: 5 additions & 3 deletions tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,14 @@ func (ui *UI) confirmDeletion(shouldEmpty bool) {
previousHeaderText := ui.header.GetText(false)

// show feedback to user
ui.header.SetText("Deletion is disabled!")
ui.header.SetText(" Deletion is disabled!")

go func() {
time.Sleep(2 * time.Second)
ui.header.Clear()
ui.header.SetText(previousHeaderText)
ui.app.QueueUpdateDraw(func() {
ui.header.Clear()
ui.header.SetText(previousHeaderText)
})
}()

return
Expand Down

0 comments on commit d511c55

Please sign in to comment.