Example #1
0
File: editui.go Project: sqp/godock
func (ed *Editor) showPack(appID int) {
	appID = ternary.Max(0, ternary.Min(appID, len(ed.packs)-1))
	pack := ed.packs[appID]
	catstr, _ := packages.FormatCategory(pack.Category)

	ed.appinfo.BorderLabel = pack.Path
	ed.appinfo.Items = []string{
		"",
		pack.DisplayedName,
		pack.Author,
		pack.Version,
		strconv.Itoa(pack.Category) + " : " + catstr,
		formatBool(pack.ActAsLauncher),
		formatBool(pack.IsMultiInstance),
	}

	ed.locked.Text = "this\nis\ndetails"

	ed.desc.Text = strings.Replace(pack.Description, "\\n", "\n", -1)

	// Update edited fields.
	for k, v := range ed.edits {
		switch k {
		case fieldVersion:
			ed.appinfo.Items[k], _ = packages.FormatNewVersion(pack.Version, v.(int))
			switch v.(int) {
			case 2:
				ed.appinfo.Items[k] = "[" + ed.appinfo.Items[k] + "](fg-magenta)"
				continue

			case 3:
				ed.appinfo.Items[k] = "[" + ed.appinfo.Items[k] + "](fg-red)"
				continue
			}

		case fieldCategory:
			catstr, _ := packages.FormatCategory(v.(int))
			ed.appinfo.Items[k] = strconv.Itoa(v.(int)) + " : " + catstr

		case fieldActAsLauncher, fieldMultiInstance:
			ed.appinfo.Items[k] = formatBool(v.(bool))
		}

		// Add color to field to indicate it's modified.
		ed.appinfo.Items[k] = "[" + ed.appinfo.Items[k] + "](fg-green)"
	}
}
Example #2
0
// Format applet packages using simple table formater.
//
func printConsole(list packages.AppletPackages) {
	lf := tablist.NewFormater(
		tablist.NewColRight(0, "Inst"),
		tablist.NewColLeft(0, "[ Applet ]"),
		tablist.NewColLeft(0, "Category"),
	)

	for _, pack := range list {
		line := lf.AddLine()
		if pack.Type == packages.TypeUser {
			line.Colored(0, color.FgGreen, " * ")
		}
		if pack.Type == packages.TypeInDev {
			line.Colored(0, color.FgYellow, " * ")
		}

		line.Set(1, pack.DisplayedName)
		cat, _ := packages.FormatCategory(pack.Category)
		line.Set(2, cat)
	}
	lf.Print()
}
Example #3
0
// FormatCategory formats the applet category text.
//
func (v *AppletDownload) FormatCategory() string {
	txt, color := packages.FormatCategory(int(v.Category))
	return "<span fgcolor='#" + color + "'>" + tran.Slate(txt) + "</span>"
}