func (lf *lineFeed) valueDefault(key *cftype.Key, line tablist.Liner) { flag := false def, e := key.Storage().Default(key.Group, key.Name) if e != nil { println("default: ", e.Error()) } valStatus := key.ValueState(def) for i, st := range valStatus { curline := lf.testNewLine(line, i) switch st.State { case cftype.StateBothEmpty: line.Set(RowOld, "**EMPTY**") case cftype.StateUnchanged: curline.Set(RowOld, st.Old) case cftype.StateEdited: curline.Set(RowOld, st.Old) if st.New == "" { curline.Colored(RowNew, color.FgMagenta, "**EMPTY**") } else { curline.Colored(RowNew, color.FgGreen, st.New) } flag = true case cftype.StateAdded: curline.Set(RowOld, "**EMPTY**") curline.Colored(RowNew, color.FgYellow, st.New) flag = true case cftype.StateRemoved: curline.Set(RowOld, st.Old) curline.Colored(RowNew, color.FgMagenta, "**EMPTY**") flag = true } } if flag { lf.countChanged++ } }
// Add adds a key to the printer. // func (lf *lineFeed) Add(key *cftype.Key) { if key.Group != lf.lastGroup { lf.AddGroup(RowName, key.Group) lf.lastGroup = key.Group lf.hasFrame = false } var line tablist.Liner var title string switch { case key.IsType(cftype.KeyFrame, cftype.KeyExpander): line = lf.AddEmptyFilled() lf.hasFrame = true line.Set(RowType, key.Type.String()) if len(key.AuthorizedValues) == 0 { title = "[*FRAME NO TITLE*]" } else { title = key.AuthorizedValues[0] } case key.IsType(cftype.KeySeparator): line = lf.AddEmptyFilled() line.Set(RowType, key.Type.String()) title = lf.indent() + "---------" case key.IsType(cftype.KeyTextLabel, cftype.KeyLaunchCmdSimple): line = lf.AddEmptyFilled() line.Set(RowType, key.Type.String()) title = lf.indent() + key.Name default: line = lf.AddLine() lf.valuePrint(key, line) line.Colored(RowType, color.FgGreen, key.Type.String()) title = lf.indent() + key.Name lf.countChangeable++ } line.Set(RowName, title) }