diff --git a/doc.go b/doc.go index da7fe6ed..4bd3e84f 100644 --- a/doc.go +++ b/doc.go @@ -126,7 +126,7 @@ The following options can be used to customize the behavior of lf: dirfirst bool (default true) dironly bool (default false) dirpreviews bool (default false) - drawbox bool (default false) + drawbox string (default "none") dupfilefmt string (default '%f.~%n~') errorfmt string (default "\033[7;31;47m") filesep string (default "\n") @@ -718,9 +718,9 @@ Show only directories. If enabled, directories will also be passed to the previewer script. This allows custom previews for directories. - drawbox bool (default false) + drawbox string (default "none") -Draw boxes around panes with box drawing characters. +Draw boxes around panes with box drawing characters. "outline" draws a box around all panes. "separators" draws vertical lines between all panes. "both" or "true" draws both outline and separators. "none" or "false" draws neither outline nor separators. dupfilefmt string (default '%f.~%n~') diff --git a/docstring.go b/docstring.go index a16a31c1..376905b2 100644 --- a/docstring.go +++ b/docstring.go @@ -129,7 +129,7 @@ The following options can be used to customize the behavior of lf: dirfirst bool (default true) dironly bool (default false) dirpreviews bool (default false) - drawbox bool (default false) + drawbox string (default "none") dupfilefmt string (default '%f.~%n~') errorfmt string (default "\033[7;31;47m") filesep string (default "\n") @@ -759,9 +759,12 @@ Show only directories. If enabled, directories will also be passed to the previewer script. This allows custom previews for directories. - drawbox bool (default false) + drawbox string (default "none") -Draw boxes around panes with box drawing characters. +Draw boxes around panes with box drawing characters. "outline" draws a box +around all panes. "separators" draws vertical lines between all panes. "both" +or "true" draws both outline and separators. "none" or "false" draws neither +outline nor separators. dupfilefmt string (default '%f.~%n~') diff --git a/eval.go b/eval.go index ff04308e..ee13d2a6 100644 --- a/eval.go +++ b/eval.go @@ -192,12 +192,16 @@ func (e *setExpr) eval(app *app, args []string) { } gOpts.dirpreviews = !gOpts.dirpreviews case "drawbox": - if e.val == "" || e.val == "true" { - gOpts.drawbox = true - } else if e.val == "false" { - gOpts.drawbox = false + if e.val == "" || e.val == "true" || e.val == "both" { + gOpts.drawbox = "both" + } else if e.val == "false" || e.val == "none" { + gOpts.drawbox = "none" + } else if e.val == "outline" { + gOpts.drawbox = "outline" + } else if e.val == "separators" { + gOpts.drawbox = "separators" } else { - app.ui.echoerr("drawbox: value should be empty, 'true', or 'false'") + app.ui.echoerr("drawbox: value should be empty, 'true', 'false', 'both', 'none', 'outline', or 'separators'") return } app.ui.renew() @@ -211,7 +215,7 @@ func (e *setExpr) eval(app *app, args []string) { app.ui.echoerrf("nodrawbox: unexpected value: %s", e.val) return } - gOpts.drawbox = false + gOpts.drawbox = "none" app.ui.renew() if app.nav.height != app.ui.wins[0].h { app.nav.height = app.ui.wins[0].h @@ -223,7 +227,11 @@ func (e *setExpr) eval(app *app, args []string) { app.ui.echoerrf("drawbox!: unexpected value: %s", e.val) return } - gOpts.drawbox = !gOpts.drawbox + if gOpts.drawbox == "none" { + gOpts.drawbox = "both" + } else { + gOpts.drawbox = "none" + } app.ui.renew() if app.nav.height != app.ui.wins[0].h { app.nav.height = app.ui.wins[0].h diff --git a/lf.1 b/lf.1 index f7682fa0..57c36185 100644 --- a/lf.1 +++ b/lf.1 @@ -145,7 +145,7 @@ The following options can be used to customize the behavior of lf: dirfirst bool (default true) dironly bool (default false) dirpreviews bool (default false) - drawbox bool (default false) + drawbox string (default "none") dupfilefmt string (default '%f.~%n~') errorfmt string (default "\e033[7;31;47m") filesep string (default "\en") @@ -874,10 +874,10 @@ Show only directories. If enabled, directories will also be passed to the previewer script. This allows custom previews for directories. .PP .EX - drawbox bool (default false) + drawbox string (default "none") .EE .PP -Draw boxes around panes with box drawing characters. +Draw boxes around panes with box drawing characters. "outline" draws a box around all panes. "separators" draws vertical lines between all panes. "both" or "true" draws both outline and separators. "none" or "false" draws neither outline nor separators. .PP .EX dupfilefmt string (default '%f.~%n~') diff --git a/opts.go b/opts.go index bbce7997..d58ed047 100644 --- a/opts.go +++ b/opts.go @@ -41,7 +41,7 @@ var gOpts struct { dircounts bool dironly bool dirpreviews bool - drawbox bool + drawbox string dupfilefmt string globsearch bool icons bool @@ -188,7 +188,7 @@ func init() { gOpts.dircounts = false gOpts.dironly = false gOpts.dirpreviews = false - gOpts.drawbox = false + gOpts.drawbox = "none" gOpts.dupfilefmt = "%f.~%n~" gOpts.borderfmt = "\033[0m" gOpts.cursoractivefmt = "\033[7m" diff --git a/ui.go b/ui.go index 9a181201..f787e37a 100644 --- a/ui.go +++ b/ui.go @@ -445,8 +445,8 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir // make space for select marker, and leave another space at the end maxWidth := win.w - lnwidth - 2 - // make extra space to separate windows if drawbox is not enabled - if !gOpts.drawbox { + // make extra space to separate windows if drawbox separators are not enabled + if gOpts.drawbox == "none" || gOpts.drawbox == "outline" { maxWidth -= 1 } @@ -522,7 +522,7 @@ func getWidths(wtot int) []int { wlen := len(gOpts.ratios) widths := make([]int, wlen) - if gOpts.drawbox { + if gOpts.drawbox == "both" || gOpts.drawbox == "separators" { wtot -= (wlen + 1) } @@ -546,9 +546,14 @@ func getWins(screen tcell.Screen) []*win { wacc := 0 wlen := len(widths) for i := 0; i < wlen; i++ { - if gOpts.drawbox { + if gOpts.drawbox == "both" { wacc++ wins = append(wins, newWin(widths[i], htot-4, wacc, 2)) + } else if gOpts.drawbox == "separators" { + wacc++ + wins = append(wins, newWin(widths[i], htot-2, wacc, 1)) + } else if gOpts.drawbox == "outline" { + wins = append(wins, newWin(widths[i], htot-4, wacc, 2)) } else { wins = append(wins, newWin(widths[i], htot-2, wacc, 1)) } @@ -966,29 +971,39 @@ func (ui *ui) drawBox() { w, h := ui.screen.Size() - for i := 1; i < w-1; i++ { - ui.screen.SetContent(i, 1, tcell.RuneHLine, nil, st) - ui.screen.SetContent(i, h-2, tcell.RuneHLine, nil, st) - } + if gOpts.drawbox == "both" || gOpts.drawbox == "outline" { + for i := 1; i < w-1; i++ { + ui.screen.SetContent(i, 1, tcell.RuneHLine, nil, st) + ui.screen.SetContent(i, h-2, tcell.RuneHLine, nil, st) + } - for i := 2; i < h-2; i++ { - ui.screen.SetContent(0, i, tcell.RuneVLine, nil, st) - ui.screen.SetContent(w-1, i, tcell.RuneVLine, nil, st) - } + for i := 2; i < h-2; i++ { + ui.screen.SetContent(0, i, tcell.RuneVLine, nil, st) + ui.screen.SetContent(w-1, i, tcell.RuneVLine, nil, st) + } - ui.screen.SetContent(0, 1, tcell.RuneULCorner, nil, st) - ui.screen.SetContent(w-1, 1, tcell.RuneURCorner, nil, st) - ui.screen.SetContent(0, h-2, tcell.RuneLLCorner, nil, st) - ui.screen.SetContent(w-1, h-2, tcell.RuneLRCorner, nil, st) + ui.screen.SetContent(0, 1, tcell.RuneULCorner, nil, st) + ui.screen.SetContent(w-1, 1, tcell.RuneURCorner, nil, st) + ui.screen.SetContent(0, h-2, tcell.RuneLLCorner, nil, st) + ui.screen.SetContent(w-1, h-2, tcell.RuneLRCorner, nil, st) + } wacc := 0 - for wind := 0; wind < len(ui.wins)-1; wind++ { - wacc += ui.wins[wind].w + 1 - ui.screen.SetContent(wacc, 1, tcell.RuneTTee, nil, st) - for i := 2; i < h-2; i++ { - ui.screen.SetContent(wacc, i, tcell.RuneVLine, nil, st) + top := tcell.RuneTTee + bottom := tcell.RuneBTee + if gOpts.drawbox == "separators" { + top = tcell.RuneVLine + bottom = tcell.RuneVLine + } + if gOpts.drawbox == "both" || gOpts.drawbox == "separators" { + for wind := 0; wind < len(ui.wins)-1; wind++ { + wacc += ui.wins[wind].w + 1 + ui.screen.SetContent(wacc, 1, top, nil, st) + for i := 2; i < h-2; i++ { + ui.screen.SetContent(wacc, i, tcell.RuneVLine, nil, st) + } + ui.screen.SetContent(wacc, h-2, bottom, nil, st) } - ui.screen.SetContent(wacc, h-2, tcell.RuneBTee, nil, st) } } @@ -1069,7 +1084,7 @@ func (ui *ui) draw(nav *nav) { } } - if gOpts.drawbox { + if gOpts.drawbox != "none" { ui.drawBox() } @@ -1081,7 +1096,7 @@ func (ui *ui) draw(nav *nav) { ui.menuWin.h = len(lines) - 1 ui.menuWin.y = ui.wins[0].h - ui.menuWin.h - if gOpts.drawbox { + if gOpts.drawbox == "outline" || gOpts.drawbox == "both" { ui.menuWin.y += 2 }