Add color option

pull/85/head
rkfg 2 years ago
parent 66b0b3e134
commit a178a82fef

@ -89,6 +89,13 @@ columns = [
# "NUPD", # number of channel updates
]
[views.channels.options]
# Currently only one option for the AGE column. If enabled, uses multiple colors
# from green to orange to indicate the channel age using 256 color scheme in
# supported terminals
# AGE = { color = "color" }
[views.transactions]
# It is possible to add, remove and order columns of the
# table with the array columns. The available values are:

@ -42,8 +42,19 @@ type Views struct {
Routing *View `toml:"routing"`
}
type ColumnOptions map[string]map[string]string
type View struct {
Columns []string `toml:"columns"`
Columns []string `toml:"columns"`
Options ColumnOptions `toml:"options"`
}
func (co ColumnOptions) GetOption(columnName, option string) string {
if o, ok := co[columnName]; !ok {
return ""
} else {
return o[option]
}
}
type Aliases map[string]string

@ -50,6 +50,13 @@ columns = [
# "NUPD", # number of channel updates
]
[views.channels.options]
# Currently only one option for the AGE column. If enabled, uses multiple colors
# from green to orange to indicate the channel age using 256 color scheme in
# supported terminals
# AGE = { color = "color" }
[views.transactions]
# It is possible to add, remove and order columns of the
# table with the array columns. The available values are:

@ -651,7 +651,12 @@ func NewChannels(cfg *config.View, chans *models.Channels) *Channels {
if c.ID == 0 {
return fmt.Sprintf("%10s", "")
}
return ColorizeAge(c.Age, printer.Sprintf("%10s", FormatAge(c.Age)), opts...)
result := printer.Sprintf("%10s", FormatAge(c.Age))
if cfg.Options.GetOption("AGE", "color") == "color" {
return ColorizeAge(c.Age, result, opts...)
} else {
return color.White(opts...)(result)
}
},
}

Loading…
Cancel
Save