diff --git a/main.go b/main.go index 6535f588..95b81ec1 100644 --- a/main.go +++ b/main.go @@ -455,7 +455,13 @@ func initConfig() { viper.AutomaticEnv() // read in environment variables that match // If a config file is found, read it in. - _ = viper.ReadInConfig() + if err := viper.ReadInConfig(); err != nil { + if _, ok := err.(viper.ConfigFileNotFoundError); !ok { + fmt.Fprintln(os.Stderr, err) + return + } + } + if err := viper.Unmarshal(&config); err != nil { fmt.Fprintln(os.Stderr, err) return diff --git a/ov.yaml b/ov.yaml index 707f031b..5b361f2f 100644 --- a/ov.yaml +++ b/ov.yaml @@ -8,6 +8,10 @@ # BeforeWriteOriginal: 1000 # AfterWriteOriginal: 0 # MemoryLimit: 10000 +# Prompt: +# Normal: +# ShowFilename: true +# InvertColor: true General: TabWidth: 8 diff --git a/oviewer/config.go b/oviewer/config.go index 85038d09..5b5af001 100644 --- a/oviewer/config.go +++ b/oviewer/config.go @@ -57,5 +57,11 @@ func NewConfig() Config { TabWidth: 8, MarkStyleWidth: 1, }, + Prompt: OVPromptConfig{ + Normal: OVPromptConfigNormal{ + ShowFilename: true, + InvertColor: true, + }, + }, } } diff --git a/oviewer/draw.go b/oviewer/draw.go index 70500490..8ca7ef74 100644 --- a/oviewer/draw.go +++ b/oviewer/draw.go @@ -487,20 +487,27 @@ func (root *Root) normalLeftStatus() (contents, int) { } else if root.Doc.FollowSection { modeStatus = "(Follow Section)" } - caption := root.Doc.FileName + + caption := "" if root.Doc.Caption != "" { caption = root.Doc.Caption + } else if root.Config.Prompt.Normal.ShowFilename { + caption = root.Doc.FileName } leftStatus := fmt.Sprintf("%s%s%s:%s", number, modeStatus, caption, root.message) leftContents := StrToContents(leftStatus, -1) - color := tcell.ColorWhite - if root.CurrentDoc != 0 { - color = tcell.Color((root.CurrentDoc + 8) % 16) - } - for i := 0; i < len(leftContents); i++ { - leftContents[i].style = leftContents[i].style.Foreground(tcell.ColorValid + color).Reverse(true) + + if root.Config.Prompt.Normal.InvertColor { + color := tcell.ColorWhite + if root.CurrentDoc != 0 { + color = tcell.Color((root.CurrentDoc + 8) % 16) + } + for i := 0; i < len(leftContents); i++ { + leftContents[i].style = leftContents[i].style.Foreground(tcell.ColorValid + color).Reverse(true) + } } + return leftContents, len(leftContents) } diff --git a/oviewer/oviewer.go b/oviewer/oviewer.go index e10db060..c0db8dc0 100644 --- a/oviewer/oviewer.go +++ b/oviewer/oviewer.go @@ -157,6 +157,15 @@ type general struct { PlainMode bool } +type OVPromptConfigNormal struct { + ShowFilename bool + InvertColor bool +} + +type OVPromptConfig struct { + Normal OVPromptConfigNormal +} + // Config represents the settings of ov. type Config struct { // KeyBinding @@ -172,7 +181,10 @@ type Config struct { StyleColumnRainbow []OVStyle // StyleMultiColorHighlight is the style that applies to the multi color highlight. StyleMultiColorHighlight []OVStyle - // StyleHeader is the style that applies to the header. + + Prompt OVPromptConfig + + // StyleHeader is the style that applies to the header. StyleHeader OVStyle // StyleBody is the style that applies to the body. StyleBody OVStyle