Rounded Corners (#1653)

* add option to draw outer corners rounded

* gofmt

---------

Co-authored-by: Gökçehan Kara <gokcehankara@gmail.com>
This commit is contained in:
J-KappesandGökçehan Kara authored and GitHub committed 2024-04-07 15:36:54 +02:00
1 parent f507b618c9
commit 647fa469fb
6 files changed
+29 -4

No files matched your search

+5
View File
@@ -181,6 +181,7 @@ The following options can be used to customize the behavior of lf:
ratios []int (default '1:2:3') ratios []int (default '1:2:3')
relativenumber bool (default false) relativenumber bool (default false)
reverse bool (default false) reverse bool (default false)
roundbox bool (default false)
ruler []string (default 'acc:progress:selection:filter:ind') 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") 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) 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. 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`) ## ruler ([]string) (default `acc:progress:selection:filter:ind`)
This option is deprecated in favor of using the `rulerfmt` option (see below). This option is deprecated in favor of using the `rulerfmt` option (see below).
+5
View File
@@ -171,6 +171,7 @@ The following options can be used to customize the behavior of lf:
ratios []int (default '1:2:3') ratios []int (default '1:2:3')
relativenumber bool (default false) relativenumber bool (default false)
reverse bool (default false) reverse bool (default false)
roundbox bool (default false)
ruler []string (default 'acc:progress:selection:filter:ind') 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") 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) scrolloff int (default 0)
@@ -959,6 +960,10 @@ reverse (bool) (default false)
Reverse the direction of sort. 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) ruler ([]string) (default acc:progress:selection:filter:ind)
This option is deprecated in favor of using the rulerfmt option (see This option is deprecated in favor of using the rulerfmt option (see
+2
View File
@@ -176,6 +176,8 @@ func (e *setExpr) eval(app *app, args []string) {
app.nav.sort() app.nav.sort()
app.ui.sort() app.ui.sort()
} }
case "roundbox", "noroundbox", "roundbox!":
err = applyBoolOpt(&gOpts.roundbox, e)
case "sixel", "nosixel", "sixel!": case "sixel", "nosixel", "sixel!":
err = applyBoolOpt(&gOpts.sixel, e) err = applyBoolOpt(&gOpts.sixel, e)
case "smartcase", "nosmartcase", "smartcase!": case "smartcase", "nosmartcase", "smartcase!":
+4
View File
@@ -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]) ratios []int (default \[aq]1:2:3\[aq])
relativenumber bool (default false) relativenumber bool (default false)
reverse bool (default false) reverse bool (default false)
roundbox bool (default false)
ruler []string (default \[aq]acc:progress:selection:filter:ind\[aq]) 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]) 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) scrolloff int (default 0)
@@ -974,6 +975,9 @@ position, otherwise nothing is shown.
.SS reverse (bool) (default false) .SS reverse (bool) (default false)
.PP .PP
Reverse the direction of sort. 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]) .SS ruler ([]string) (default \f[C]acc:progress:selection:filter:ind\f[R])
.PP .PP
This option is deprecated in favor of using the \f[C]rulerfmt\f[R] This option is deprecated in favor of using the \f[C]rulerfmt\f[R]
+2
View File
@@ -59,6 +59,7 @@ var gOpts struct {
preview bool preview bool
relativenumber bool relativenumber bool
reverse bool reverse bool
roundbox bool
selectfmt string selectfmt string
sixel bool sixel bool
sortby sortMethod sortby sortMethod
@@ -205,6 +206,7 @@ func init() {
gOpts.preview = true gOpts.preview = true
gOpts.relativenumber = false gOpts.relativenumber = false
gOpts.reverse = false gOpts.reverse = false
gOpts.roundbox = false
gOpts.selectfmt = "\033[7;35m" gOpts.selectfmt = "\033[7;35m"
gOpts.sixel = false gOpts.sixel = false
gOpts.sortby = naturalSort gOpts.sortby = naturalSort
+11 -4
View File
@@ -980,10 +980,17 @@ func (ui *ui) drawBox() {
ui.screen.SetContent(w-1, i, tcell.RuneVLine, nil, st) ui.screen.SetContent(w-1, i, tcell.RuneVLine, nil, st)
} }
ui.screen.SetContent(0, 1, tcell.RuneULCorner, nil, st) if gOpts.roundbox {
ui.screen.SetContent(w-1, 1, tcell.RuneURCorner, nil, st) ui.screen.SetContent(0, 1, '╭', nil, st)
ui.screen.SetContent(0, h-2, tcell.RuneLLCorner, nil, st) ui.screen.SetContent(w-1, 1, '╮', nil, st)
ui.screen.SetContent(w-1, h-2, tcell.RuneLRCorner, 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 wacc := 0
for wind := 0; wind < len(ui.wins)-1; wind++ { for wind := 0; wind < len(ui.wins)-1; wind++ {