From 647fa469fb4a65a15d335ca981808c3e2a344a6e Mon Sep 17 00:00:00 2001 From: J-Kappes <87168492+J-Kappes@users.noreply.github.com> Date: Sun, 7 Apr 2024 13:36:54 +0000 Subject: Rounded Corners (#1653) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add option to draw outer corners rounded * gofmt --------- Co-authored-by: Gökçehan Kara --- doc.md | 5 +++++ doc.txt | 5 +++++ eval.go | 2 ++ lf.1 | 4 ++++ opts.go | 2 ++ ui.go | 15 +++++++++++---- 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/doc.md b/doc.md index e608e71..d84e7bd 100644 --- a/doc.md +++ b/doc.md @@ -181,6 +181,7 @@ The following options can be used to customize the behavior of lf: ratios []int (default '1:2:3') relativenumber bool (default false) reverse bool (default false) + roundbox bool (default false) ruler []string (default 'acc:progress:selection:filter:ind') rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t") scrolloff int (default 0) @@ -889,6 +890,10 @@ When `number` is enabled, the current line shows the absolute position, otherwis Reverse the direction of sort. +## roundbox (bool) (default false) + +Draw rounded outer corners when the `drawbox` option is enabled. + ## ruler ([]string) (default `acc:progress:selection:filter:ind`) This option is deprecated in favor of using the `rulerfmt` option (see below). diff --git a/doc.txt b/doc.txt index fd90003..64c41a6 100644 --- a/doc.txt +++ b/doc.txt @@ -171,6 +171,7 @@ The following options can be used to customize the behavior of lf: ratios []int (default '1:2:3') relativenumber bool (default false) reverse bool (default false) + roundbox bool (default false) ruler []string (default 'acc:progress:selection:filter:ind') rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t") scrolloff int (default 0) @@ -959,6 +960,10 @@ reverse (bool) (default false) Reverse the direction of sort. +roundbox (bool) (default false) + +Draw rounded outer corners when the drawbox option is enabled. + ruler ([]string) (default acc:progress:selection:filter:ind) This option is deprecated in favor of using the rulerfmt option (see diff --git a/eval.go b/eval.go index c3282b3..64308f7 100644 --- a/eval.go +++ b/eval.go @@ -176,6 +176,8 @@ func (e *setExpr) eval(app *app, args []string) { app.nav.sort() app.ui.sort() } + case "roundbox", "noroundbox", "roundbox!": + err = applyBoolOpt(&gOpts.roundbox, e) case "sixel", "nosixel", "sixel!": err = applyBoolOpt(&gOpts.sixel, e) case "smartcase", "nosmartcase", "smartcase!": diff --git a/lf.1 b/lf.1 index 41f5f9c..cff175a 100644 --- a/lf.1 +++ b/lf.1 @@ -189,6 +189,7 @@ promptfmt string (default \[dq]\[rs]033[32;1m%u\[at]%h\[rs]033[0m:\ ratios []int (default \[aq]1:2:3\[aq]) relativenumber bool (default false) reverse bool (default false) +roundbox bool (default false) ruler []string (default \[aq]acc:progress:selection:filter:ind\[aq]) rulerfmt string (default \[dq] %a| %p| \[rs]033[7;31m %m \[rs]033[0m| \[rs]033[7;33m %c \[rs]033[0m| \[rs]033[7;35m %s \[rs]033[0m| \[rs]033[7;34m %f \[rs]033[0m| %i/%t\[dq]) scrolloff int (default 0) @@ -974,6 +975,9 @@ position, otherwise nothing is shown. .SS reverse (bool) (default false) .PP Reverse the direction of sort. +.SS roundbox (bool) (default false) +.PP +Draw rounded outer corners when the \f[C]drawbox\f[R] option is enabled. .SS ruler ([]string) (default \f[C]acc:progress:selection:filter:ind\f[R]) .PP This option is deprecated in favor of using the \f[C]rulerfmt\f[R] diff --git a/opts.go b/opts.go index 681673b..035de65 100644 --- a/opts.go +++ b/opts.go @@ -59,6 +59,7 @@ var gOpts struct { preview bool relativenumber bool reverse bool + roundbox bool selectfmt string sixel bool sortby sortMethod @@ -205,6 +206,7 @@ func init() { gOpts.preview = true gOpts.relativenumber = false gOpts.reverse = false + gOpts.roundbox = false gOpts.selectfmt = "\033[7;35m" gOpts.sixel = false gOpts.sortby = naturalSort diff --git a/ui.go b/ui.go index 10c0f90..5aabf66 100644 --- a/ui.go +++ b/ui.go @@ -980,10 +980,17 @@ func (ui *ui) drawBox() { 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) + if gOpts.roundbox { + ui.screen.SetContent(0, 1, '╭', nil, st) + ui.screen.SetContent(w-1, 1, '╮', nil, st) + ui.screen.SetContent(0, h-2, '╰', nil, st) + ui.screen.SetContent(w-1, h-2, '╯', nil, st) + } else { + 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++ { -- cgit v1.2.3