Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions ov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
# BeforeWriteOriginal: 1000
# AfterWriteOriginal: 0
# MemoryLimit: 10000
# Prompt:
# Normal:
# ShowFilename: true
# InvertColor: true

General:
TabWidth: 8
Expand Down
6 changes: 6 additions & 0 deletions oviewer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,11 @@ func NewConfig() Config {
TabWidth: 8,
MarkStyleWidth: 1,
},
Prompt: OVPromptConfig{
Normal: OVPromptConfigNormal{
ShowFilename: true,
InvertColor: true,
},
},
}
}
21 changes: 14 additions & 7 deletions oviewer/draw.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
14 changes: 13 additions & 1 deletion oviewer/oviewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down