From 9ceec175f3b6e402c81fc8bc0de56473ebe5be29 Mon Sep 17 00:00:00 2001 From: Noboru Saito Date: Mon, 23 Jun 2025 15:26:37 +0900 Subject: [PATCH] Allow separate style settings for help and log documents - Added HelpDoc and LogDoc sections to the configuration for independent style settings - Help and log documents now use their own style settings instead of inheriting from the main document - View mode is not used for help and log pages; only style can be implemented #799 --- oviewer/config.go | 4 ++++ oviewer/help.go | 40 ++++++++++++++++++++++++++++++++++++++++ oviewer/logdoc.go | 24 ++++++++++++++++++++++++ oviewer/oviewer.go | 5 +++-- 4 files changed, 71 insertions(+), 2 deletions(-) diff --git a/oviewer/config.go b/oviewer/config.go index cdcccfc3..138fa053 100644 --- a/oviewer/config.go +++ b/oviewer/config.go @@ -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 diff --git a/oviewer/help.go b/oviewer/help.go index 745d9947..4375966d 100644 --- a/oviewer/help.go +++ b/oviewer/help.go @@ -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 @@ -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, + }, + } +} diff --git a/oviewer/logdoc.go b/oviewer/logdoc.go index 21cf40d4..4d403e17 100644 --- a/oviewer/logdoc.go +++ b/oviewer/logdoc.go @@ -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, + }, + } +} diff --git a/oviewer/oviewer.go b/oviewer/oviewer.go index 040a5775..e7cb20e4 100644 --- a/oviewer/oviewer.go +++ b/oviewer/oviewer.go @@ -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.