-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b51296
commit 36eac98
Showing
3 changed files
with
60 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
import ( | ||
"image/color" | ||
"log" | ||
|
||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/charmbracelet/colorprofile" | ||
"github.com/charmbracelet/x/ansi" | ||
"github.com/lucasb-eyer/go-colorful" | ||
) | ||
|
||
var myFancyColor color.Color | ||
|
||
type model struct{} | ||
|
||
var _ tea.Model = model{} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
aymanbagabas
Author
Member
|
||
|
||
// Init implements tea.Model. | ||
func (m model) Init() (tea.Model, tea.Cmd) { | ||
return m, tea.Batch( | ||
tea.RequestCapability("RGB"), | ||
tea.RequestCapability("Tc"), | ||
) | ||
} | ||
|
||
// Update implements tea.Model. | ||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | ||
switch msg := msg.(type) { | ||
case tea.KeyMsg: | ||
return m, tea.Quit | ||
case tea.ColorProfileMsg: | ||
return m, tea.Println("Color profile changed to ", msg) | ||
} | ||
return m, nil | ||
} | ||
|
||
// View implements tea.Model. | ||
func (m model) View() string { | ||
return "This will produce the wrong colors on Apple Terminal :)\n\n" + | ||
ansi.Style{}.ForegroundColor(myFancyColor).Styled("Howdy!") + | ||
"\n\n" + | ||
"Press any key to exit." | ||
} | ||
|
||
func main() { | ||
myFancyColor, _ = colorful.Hex("#6b50ff") | ||
|
||
p := tea.NewProgram(model{}, tea.WithColorProfile(colorprofile.TrueColor)) | ||
if _, err := p.Run(); err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What happens here?