mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Make the line wrap settings for the Textfile module configurable via the 'wrapText' setting
This commit is contained in:
parent
98f0d5fa4b
commit
d9c362ee9f
2
go.sum
2
go.sum
@ -37,6 +37,7 @@ github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBo
|
||||
github.com/alecthomas/kong v0.1.15/go.mod h1:0m2VYms8rH0qbCqVB2gvGHk74bqLIq0HXjCs5bNbNQU=
|
||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
|
||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
||||
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 h1:GDQdwm/gAcJcLAKQQZGOJ4knlw+7rfEQQcmwTbt4p5E=
|
||||
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
@ -146,6 +147,7 @@ github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcncea
|
||||
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
|
||||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
|
@ -7,14 +7,17 @@ import (
|
||||
|
||||
const defaultTitle = "Textfile"
|
||||
|
||||
// Settings defines the configuration properties for this module
|
||||
type Settings struct {
|
||||
common *cfg.Common
|
||||
|
||||
filePaths []interface{}
|
||||
format bool
|
||||
formatStyle string
|
||||
wrapText bool
|
||||
}
|
||||
|
||||
// NewSettingsFromYAML creates a new settings instance from a YAML config block
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
||||
|
||||
settings := Settings{
|
||||
@ -23,6 +26,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
||||
filePaths: ymlConfig.UList("filePaths"),
|
||||
format: ymlConfig.UBool("format", false),
|
||||
formatStyle: ymlConfig.UString("formatStyle", "vim"),
|
||||
wrapText: ymlConfig.UBool("wrapText", true),
|
||||
}
|
||||
|
||||
return &settings
|
||||
|
@ -44,7 +44,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
|
||||
widget.SetDisplayFunction(widget.display)
|
||||
widget.View.SetWordWrap(true)
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetWrap(settings.wrapText)
|
||||
|
||||
widget.KeyboardWidget.SetView(widget.View)
|
||||
|
||||
@ -79,7 +79,7 @@ func (widget *Widget) display() {
|
||||
text += widget.plainText()
|
||||
}
|
||||
|
||||
widget.Redraw(title, text, true)
|
||||
widget.Redraw(title, text, widget.settings.wrapText)
|
||||
}
|
||||
|
||||
func (widget *Widget) fileName() string {
|
||||
|
@ -111,7 +111,6 @@ func (widget *TextWidget) TextView() *tview.TextView {
|
||||
}
|
||||
|
||||
func (widget *TextWidget) Redraw(title, text string, wrap bool) {
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.Clear()
|
||||
widget.View.SetWrap(wrap)
|
||||
|
Loading…
x
Reference in New Issue
Block a user