Skip to content

Commit

Permalink
use error scheme color for stderr in cogent code; improve command ico…
Browse files Browse the repository at this point in the history
…n handling
  • Loading branch information
kkoreilly committed Jul 5, 2024
1 parent fa44b39 commit cb4e367
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 5 additions & 6 deletions code/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -818,17 +818,14 @@ func CommandMenu(fn *filetree.Node) func(mm *core.Scene) {
continue
}
cmdCat := cc[0]
ic := icons.Icon(strings.ToLower(cmdCat))
if !ic.IsValid() {
fmt.Println("icon not found", cmdCat)
}
cb := core.NewButton(mm).SetText(cmdCat).SetType(core.ButtonMenu).SetIcon(ic)
icon := CommandIcons[cmdCat]
cb := core.NewButton(mm).SetText(cmdCat).SetType(core.ButtonMenu).SetIcon(icon)
cb.SetMenu(func(m *core.Scene) {
for ii := 1; ii < n; ii++ {
ii := ii
it := cc[ii]
cmdNm := CommandName(cmdCat, it)
bt := core.NewButton(m).SetText(it).SetIcon(ic)
bt := core.NewButton(m).SetText(it).SetIcon(icon)
bt.OnClick(func(e events.Event) {
// e.SetHandled() // note: this allows menu to stay open :)
cmd := CmdName(cmdNm)
Expand All @@ -845,3 +842,5 @@ func CommandMenu(fn *filetree.Node) func(mm *core.Scene) {
}
}
}

var CommandIcons = map[string]icons.Icon{"File": icons.File, "Git": icons.Git, "Build": icons.Build, "Core": icons.CogentCore, "Go": icons.Go}
4 changes: 3 additions & 1 deletion code/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"sync"

"cogentcore.org/core/base/errors"
"cogentcore.org/core/colors"
"cogentcore.org/core/core"
"cogentcore.org/core/texteditor"
)
Expand Down Expand Up @@ -107,7 +108,8 @@ func MarkupStdout(out []byte) []byte {
}

func MarkupStderr(out []byte) []byte {
sst := []byte(`<span style="color:red">`)
ec := colors.AsHex(colors.ToUniform(colors.Scheme.Error.Base))
sst := []byte(`<span style="color:` + ec + `">`)
est := []byte(`</span>`)
esz := len(sst) + len(est)

Expand Down

0 comments on commit cb4e367

Please sign in to comment.