Skip to content
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

Move config struct to config.go #687

Merged
merged 1 commit into from
Jan 20, 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
96 changes: 96 additions & 0 deletions oviewer/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,101 @@
package oviewer

// Config represents the settings of ov.
type Config struct {
// KeyBinding
Keybind map[string][]string
// Mode represents the operation of the customized mode.
Mode map[string]general
// ViewMode represents the view mode.
// ViewMode sets several settings together and can be easily switched.
ViewMode string
// Default keybindings. Disabled if the default keybinding is "disable".
DefaultKeyBind string
// StyleColumnRainbow is the style that applies to the column rainbow color highlight.
StyleColumnRainbow []OVStyle
// StyleMultiColorHighlight is the style that applies to the multi color highlight.
StyleMultiColorHighlight []OVStyle

// Prompt is the prompt setting.
Prompt OVPromptConfig

// StyleHeader is the style that applies to the header.
StyleHeader OVStyle
// StyleBody is the style that applies to the body.
StyleBody OVStyle
// StyleLineNumber is a style that applies line number.
StyleLineNumber OVStyle
// StyleSearchHighlight is the style that applies to the search highlight.
StyleSearchHighlight OVStyle
// StyleColumnHighlight is the style that applies to the column highlight.
StyleColumnHighlight OVStyle
// StyleMarkLine is a style that marked line.
StyleMarkLine OVStyle
// StyleSectionLine is a style that section delimiter line.
StyleSectionLine OVStyle
// StyleJumpTargetLine is the line that displays the search results.
StyleJumpTargetLine OVStyle
// StyleAlternate is a style that applies line by line.
StyleAlternate OVStyle
// StyleOverStrike is a style that applies to overstrike.
StyleOverStrike OVStyle
// StyleOverLine is a style that applies to overstrike underlines.
StyleOverLine OVStyle
// General represents the general behavior.
General general
// BeforeWriteOriginal specifies the number of lines before the current position.
// 0 is the top of the current screen
BeforeWriteOriginal int
// AfterWriteOriginal specifies the number of lines after the current position.
// 0 specifies the bottom of the screen.
AfterWriteOriginal int
// MemoryLimit is a number that limits chunk loading.
MemoryLimit int
// MemoryLimitFile is a number that limits the chunks loading a file into memory.
MemoryLimitFile int
// DisableMouse indicates whether mouse support is disabled.
DisableMouse bool
// IsWriteOriginal indicates whether the current screen should be written on quit.
IsWriteOriginal bool
// QuitSmall indicates whether to quit if the output fits on one screen.
QuitSmall bool
// QuitSmallFilter indicates whether to quit if the output fits on one screen and a filter is applied.
QuitSmallFilter bool
// CaseSensitive is case-sensitive if true.
CaseSensitive bool
// SmartCaseSensitive indicates whether lowercase search should ignore case.
SmartCaseSensitive bool
// RegexpSearch indicates whether to use regular expression search.
RegexpSearch bool
// Incsearch indicates whether to use incremental search.
Incsearch bool
// NotifyEOF specifies the number of times to notify EOF.
NotifyEOF int

// ShrinkChar specifies the character to display when the column is shrunk.
ShrinkChar string
// DisableColumnCycle indicates whether to disable column cycling.
DisableColumnCycle bool
// Debug indicates whether to enable debug output.
Debug bool
}

// OVPromptConfigNormal is the normal prompt setting.
type OVPromptConfigNormal struct {
// ShowFilename controls whether to display filename.
ShowFilename bool
// InvertColor controls whether the text is colored and inverted.
InvertColor bool
// ProcessOfCount controls whether to display the progress of the count.
ProcessOfCount bool
}

// OVPromptConfig is the prompt setting.
type OVPromptConfig struct {
// Normal is the normal prompt setting.
Normal OVPromptConfigNormal
}

// NewConfig return the structure of Config with default values.
func NewConfig() Config {
return Config{
Expand Down
96 changes: 0 additions & 96 deletions oviewer/oviewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,102 +189,6 @@ type general struct {
HideOtherSection bool
}

// OVPromptConfigNormal is the normal prompt setting.
type OVPromptConfigNormal struct {
// ShowFilename controls whether to display filename.
ShowFilename bool
// InvertColor controls whether the text is colored and inverted.
InvertColor bool
// ProcessOfCount controls whether to display the progress of the count.
ProcessOfCount bool
}

// OVPromptConfig is the prompt setting.
type OVPromptConfig struct {
// Normal is the normal prompt setting.
Normal OVPromptConfigNormal
}

// Config represents the settings of ov.
type Config struct {
// KeyBinding
Keybind map[string][]string
// Mode represents the operation of the customized mode.
Mode map[string]general
// ViewMode represents the view mode.
// ViewMode sets several settings together and can be easily switched.
ViewMode string
// Default keybindings. Disabled if the default keybinding is "disable".
DefaultKeyBind string
// StyleColumnRainbow is the style that applies to the column rainbow color highlight.
StyleColumnRainbow []OVStyle
// StyleMultiColorHighlight is the style that applies to the multi color highlight.
StyleMultiColorHighlight []OVStyle

// Prompt is the prompt setting.
Prompt OVPromptConfig

// StyleHeader is the style that applies to the header.
StyleHeader OVStyle
// StyleBody is the style that applies to the body.
StyleBody OVStyle
// StyleLineNumber is a style that applies line number.
StyleLineNumber OVStyle
// StyleSearchHighlight is the style that applies to the search highlight.
StyleSearchHighlight OVStyle
// StyleColumnHighlight is the style that applies to the column highlight.
StyleColumnHighlight OVStyle
// StyleMarkLine is a style that marked line.
StyleMarkLine OVStyle
// StyleSectionLine is a style that section delimiter line.
StyleSectionLine OVStyle
// StyleJumpTargetLine is the line that displays the search results.
StyleJumpTargetLine OVStyle
// StyleAlternate is a style that applies line by line.
StyleAlternate OVStyle
// StyleOverStrike is a style that applies to overstrike.
StyleOverStrike OVStyle
// StyleOverLine is a style that applies to overstrike underlines.
StyleOverLine OVStyle
// General represents the general behavior.
General general
// BeforeWriteOriginal specifies the number of lines before the current position.
// 0 is the top of the current screen
BeforeWriteOriginal int
// AfterWriteOriginal specifies the number of lines after the current position.
// 0 specifies the bottom of the screen.
AfterWriteOriginal int
// MemoryLimit is a number that limits chunk loading.
MemoryLimit int
// MemoryLimitFile is a number that limits the chunks loading a file into memory.
MemoryLimitFile int
// Mouse support disable.
DisableMouse bool
// IsWriteOriginal is true, write the current screen on quit.
IsWriteOriginal bool
// QuitSmall Quit if the output fits on one screen.
QuitSmall bool
// QuitSmallFilter Quit if the output fits on one screen and the filter is applied.
QuitSmallFilter bool
// CaseSensitive is case-sensitive if true.
CaseSensitive bool
// SmartCaseSensitive is lowercase search ignores case, if true.
SmartCaseSensitive bool
// RegexpSearch is Regular expression search if true.
RegexpSearch bool
// Incsearch is incremental search if true.
Incsearch bool
// NotifyEOF specifies the number of times to notify EOF.
NotifyEOF int

// ShrinkChar is the character to display when the column is shrunk.
ShrinkChar string
// DisableColumnCycle is disable column cycle.
DisableColumnCycle bool
// Debug represents whether to enable the debug output.
Debug bool
}

var (
// MemoryLimit is a number that limits the chunks to load into memory.
MemoryLimit int
Expand Down
Loading