Documentation ¶
Index ¶
- Constants
- Variables
- func AskUser(question string) (bool, error)
- func GetSymbols(sty Style) []string
- func Plot(c Config, t time.Time) error
- func PlotTime(plt Plotter, cfg Config, t time.Time) error
- type Config
- type ContextType
- type DaySegmentation
- type Location
- type PlotColors
- type Plotter
- type Style
- type TimeSymbol
Constants ¶
const ( ColorBlack string = "\u001b[30m" ColorWhite string = "\u001b[37m" ColorRed string = "\u001b[31m" ColorYellow string = "\u001b[33m" ColorMagenta string = "\u001b[35m" ColorGreen string = "\u001b[32m" ColorCyan string = "\u001b[36m" ColorBlue string = "\u001b[34m" ColorReset string = "\u001b[0m" )
Terminal color codes.
const ( // SymbolModeRectangles uses different kinds of rectangles to represent the // hours SymbolModeRectangles = "rectangles" // SymbolModeSunMoon uses the sun and moon symbols to represent the hours. SymbolModeSunMoon = "sun-moon" // SymbolModeMono uses a single character to represent the hours (use // coloring instead). SymbolModeMono = "mono" // SymbolModeBlocks uses all blocks to represent the hours. SymbolModeBlocks = "blocks" // SymbolModeCustom uses a custom user-defined symbols to represent the // hours. SymbolModeCustom = "custom" // SymbolModeDefault is the default symbol mode. SymbolModeDefault = SymbolModeRectangles )
Define symbol modes
const ConfigVersion = "1.0"
ConfigVersion is the current version of the configuration file.
Variables ¶
var ( // SunMoonSymbols is a map of day segment to sun/moon symbol. SunMoonSymbols = map[ContextType]string{ ContextNight: "☾", ContextMorning: "☼", ContextDay: "☀", ContextEvening: "☼", } // RectangleSymbols is a map of day segment to rectangle symbol. RectangleSymbols = map[ContextType]string{ ContextNight: " ", ContextMorning: "▒", ContextDay: "█", ContextEvening: "▒", } )
var NamedStaticColors = map[string]string{ "black": ColorBlack, "white": ColorWhite, "red": ColorRed, "yellow": ColorYellow, "magenta": ColorMagenta, "green": ColorGreen, "blue": ColorBlue, "cyan": ColorCyan, }
NamedStaticColors defines all terminal colors supported by name.
Functions ¶
func AskUser ¶ added in v0.1.1
AskUser asks the user a yes/no question and returns true if the user answers yes.
func GetSymbols ¶ added in v0.1.4
Types ¶
type Config ¶
type Config struct { // Version is the version of the configuration file. ConfigVersion string `json:"config_version"` // All timezones to display. Timezones []Location `json:"timezones"` // Style defines the style of the timezone plot. Style Style `json:"style"` // Indicates whether to plot tics on the time axis. Tics bool `json:"tics"` // Indicates whether to stretch across the terminal width at cost of // accuracy. Stretch bool `json:"stretch"` // Inline indicates whether location and time info will be plotted on one // line with the bars. Inline bool `json:"inline"` // Indicates whether to use the 24-hour clock. Hours12 bool `json:"hours12"` // Indicates whether to continuously update. Live bool `json:"live"` }
Config is the configuration struct.
func ParseFlags ¶
parseArgs parses the command line arguments and applies them to the given configuration.
func SaveDefault ¶ added in v0.1.1
SaveDefault creates a default config and immediately saves it.
type ContextType ¶ added in v0.1.0
type ContextType string
const ( ContextNormal ContextType = "normal" ContextMorning ContextType = "morning" ContextDay ContextType = "day" ContextEvening ContextType = "evening" ContextNight ContextType = "night" )
type DaySegmentation ¶
type DaySegmentation struct { // MorningHour is the hour at which the morning starts. MorningHour int `json:"morning"` // DayHour is the hour at which the day starts (basically business hours). DayHour int `json:"day"` // EveningHour is the hour at which the evening starts. EveningHour int `json:"evening"` // NightHour is the hour at which the night starts. NightHour int `json:"night"` }
DaySegmentation defines how to segment the day.
type Location ¶
type Location struct { // Descriptive name of the timezone. Name string // Machine-readable timezone name. TZ string }
Location describes a timezone the user wants to display.
type PlotColors ¶ added in v0.1.0
type PlotColors struct { // StaticColorMorning is the color to use for the morning segment. StaticColorMorning string // StaticColorDay is the color to use for the day segment. StaticColorDay string // StaticColorEvening is the color to use for the evening segment. StaticColorEvening string // StaticColorNight is the color to use for the night segment. StaticColorNight string // StaticColorForeground is the color to use for the foreground. StaticColorForeground string // DynamicColorMorning is the color to use for the morning segment (in live mode). DynamicColorMorning string // DynamicColorDay is the color to use for the morning segment (in live mode). DynamicColorDay string // DynamicColorEvening is the color to use for the morning segment (in live mode). DynamicColorEvening string // DynamicColorNight is the color to use for the morning segment (in live mode). DynamicColorNight string // DynamicColorForeground is the color to use for the foreground (in live mode). DynamicColorForeground string // DynamicColorBackground is the color to use for the background (in live mode). DynamicColorBackground string }
PlotColors defines the colors to be used in the plot.
type Plotter ¶ added in v0.1.0
type Plotter struct { // func for plotting a line (with line-break) PlotLine func(t ContextType, msgs ...interface{}) // func for plotting simple strings PlotString func(t ContextType, msg string) // All symbols to represent the hours Symbols []string // Terminal width TerminalWidth int // Whether to plot the current time Now bool }
Plotter compiles functionality & configuration for plotting.
type Style ¶ added in v0.1.0
type Style struct { // Defines the symbols to be used. Symbols string `json:"symbols"` // Defines the symbols to be used in custom mode. CustomSymbols []TimeSymbol `json:"custom_symbols,omitempty"` // Indicates whether to use colors. Colorize bool `json:"colorize"` // Defines how the day is split up into different ranges. DaySegmentation DaySegmentation `json:"day_segments"` // Defines the colors to be used in the plot. Coloring PlotColors `json:"coloring"` }
type TimeSymbol ¶ added in v0.1.4
type TimeSymbol struct { // Start of the time range. Start int // Symbol to be used for the time. Symbol string }
TimeSymbol defines a symbol to be used from a start time until another symbol is reached.