本文整理匯總了Golang中github.com/sqp/godock/widgets/cfbuild/cftype.Key.ValueState方法的典型用法代碼示例。如果您正苦於以下問題:Golang Key.ValueState方法的具體用法?Golang Key.ValueState怎麽用?Golang Key.ValueState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/sqp/godock/widgets/cfbuild/cftype.Key
的用法示例。
在下文中一共展示了Key.ValueState方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: addTest
func (lf *lineFeed) addTest(key *cftype.Key) {
def, e := key.Storage().Default(key.Group, key.Name)
if e != nil {
println("default: ", e.Error())
return
}
valStatus := key.ValueState(def)
if !valStatus.IsChanged() {
return
}
lf.countChanged++
lf.valuePrint = func(key *cftype.Key, line tablist.Liner) {
for i, st := range valStatus {
curline := lf.testNewLine(line, i)
switch {
// case cftype.StateUnchanged:
// curline.Set(RowOld, st.Old)
case st.State == cftype.StateEdited && st.New != "":
curline.Set(RowOld, st.New)
case st.State == cftype.StateAdded:
curline.Colored(RowOld, color.FgYellow, st.New)
case st.State == cftype.StateEdited, st.State == cftype.StateRemoved:
curline.Colored(RowOld, color.FgMagenta, "**EMPTY**")
}
}
}
lf.Add(key)
}
示例2: valueDefault
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++
}
}
示例3: valueUpdated
func (lf *lineFeed) valueUpdated(key *cftype.Key, line tablist.Liner) {
flag := false
older := key.Storage().Valuer(key.Group, key.Name)
valStatus := key.ValueState(older)
for i, st := range valStatus {
curline := lf.testNewLine(line, i)
switch st.State {
case cftype.StateBothEmpty:
line.Colored(RowOld, color.FgMagenta, "**EMPTY**")
line.Colored(RowNew, color.BgRed, " == ")
case cftype.StateUnchanged:
curline.Set(RowOld, st.Old)
curline.Colored(RowNew, color.BgRed, " == ")
case cftype.StateEdited:
curline.Set(RowOld, st.Old)
st.New = ternary.String(st.New == "", "**EMPTY**", st.New)
curline.Colored(RowNew, color.FgGreen, st.New)
flag = true
case cftype.StateAdded:
curline.Set(RowOld, "**EMPTY**")
curline.Colored(RowNew, color.FgGreen, st.New)
flag = true
case cftype.StateRemoved:
curline.Set(RowOld, st.Old)
curline.Colored(RowNew, color.FgGreen, "**EMPTY**")
flag = true
}
}
if flag {
lf.countChanged++
}
}