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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user