8000 Allow separate style settings for help and log documents by noborus · Pull Request #801 · noborus/ov · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow separate style settings for help and log documents #801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
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
4 changes: 4 additions & 0 deletions oviewer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type Config struct {

// GeneralConfig is the general setting.
General General
// helpConfig is the help setting.
HelpDoc General
// LogConfig is the log setting.
LogDoc General
// BeforeWriteOriginal specifies the number of lines before the current position.
// 0 is the top of the current screen
BeforeWriteOriginal int
Expand Down
40 changes: 40 additions & 0 deletions oviewer/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func NewHelp(k KeyBind) (*Document, error) {
m.SectionHeader = true
m.setSectionDelimiter("\t")
m.SectionHeaderNum = 1
m.Style = NewHelpStyle()
atomic.StoreInt32(&m.closed, 1)
if err := m.ControlReader(helpStr, nil); err != nil {
return nil, err
Expand Down Expand Up @@ -66,3 +67,42 @@ func DuplicateKeyBind(k KeyBind) string {
}
return w.String()
}

// NewHelpStyle returns a Style for the help document.
func NewHelpStyle() Style {
return Style{
Header: OVStyle{
Foreground: "gold",
Background: "darkblue",
Bold: true,
},
SectionLine: OVStyle{
Background: "slateblue",
Bold: true,
},
Alternate: OVStyle{
Background: "gray",
},
LineNumber: OVStyle{
Bold: true,
},
SearchHighlight: OVStyle{
Reverse: true,
},
MarkLine: OVStyle{
Background: "darkgoldenrod",
},
MultiColorHighlight: []OVStyle{
{Foreground: "red"},
{Foreground: "aqua"},
{Foreground: "yellow"},
{Foreground: "fuchsia"},
{Foreground: "lime"},
{Foreground: "blue"},
{Foreground: "grey"},
},
JumpTargetLine: OVStyle{
Underline: true,
},
}
}
24 changes: 24 additions & 0 deletions oviewer/logdoc.go
A25D
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,27 @@ func (logDoc *LogDocument) chanWrite() {
s.mu.Unlock()
}
}

// NewLogStyle generates a style for log documents.
func NewLogStyle() Style {
return Style{
SearchHighlight: OVStyle{
Reverse: true,
},
MarkLine: OVStyle{
Background: "darkgoldenrod",
},
MultiColorHighlight: []OVStyle{
{Foreground: "red"},
{Foreground: "aqua"},
{Foreground: "yellow"},
{Foreground: "fuchsia"},
{Foreground: "lime"},
{Foreground: "blue"},
{Foreground: "grey"},
},
JumpTargetLine: OVStyle{
Underline: true,
},
}
}
5 changes: 3 additions & 2 deletions oviewer/oviewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,9 @@ func (root *Root) prepareAllDocuments() {
}
log.Printf("open [%d]%s%s\n", n, doc.FileName, w)
}
root.helpDoc.Style = root.settings.Style
root.logDoc.Style = root.settings.Style

root.helpDoc.RunTimeSettings = updateRunTimeSettings(root.helpDoc.RunTimeSettings, root.Config.HelpDoc)
root.logDoc.RunTimeSettings = updateRunTimeSettings(root.logDoc.RunTimeSettings, root.Config.LogDoc)
}

// Close closes the oviewer.
Expand Down
Loading
0