-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.go
More file actions
40 lines (31 loc) · 1.05 KB
/
Copy pathmodel.go
File metadata and controls
40 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package widgets
import (
"strings"
"github.com/yuys13/agystatusline/types"
)
// ModelWidget displays the active model name.
type ModelWidget struct{}
func (m *ModelWidget) GetDefaultColor() string { return "brightMagenta" }
func (m *ModelWidget) GetDisplayName() string { return "Model" }
func (m *ModelWidget) GetBodyColor(item types.WidgetItem, ctx types.RenderContext) string {
return "brightMagenta"
}
func (m *ModelWidget) Render(item types.WidgetItem, ctx types.RenderContext, settings types.Settings) (string, string, error) {
displayName := ctx.Data.Model.DisplayName
if displayName == "" {
displayName = ctx.Data.Model.ID
}
if displayName == "" {
return "", "", nil
}
modelName := strings.TrimSpace(displayName)
preserveColors := item.PreserveColors != nil && *item.PreserveColors
if preserveColors {
// Under statusline.sh spec, model name is italic magenta
return "", "\x1b[3m\x1b[95m" + modelName + "\x1b[23m\x1b[39m", nil
}
if item.RawValue != nil && *item.RawValue {
return "", modelName, nil
}
return "", modelName, nil
}