當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Key.ValueState方法代碼示例

本文整理匯總了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)
}
開發者ID:sqp,項目名稱:godock,代碼行數:35,代碼來源:cfprint.go

示例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++
	}
}
開發者ID:sqp,項目名稱:godock,代碼行數:45,代碼來源:cfprint.go

示例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++
	}
}
開發者ID:sqp,項目名稱:godock,代碼行數:39,代碼來源:cfprint.go


注:本文中的github.com/sqp/godock/widgets/cfbuild/cftype.Key.ValueState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。