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
61f326c
commit ac39caa
Showing
24 changed files
with
282 additions
and
331 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
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
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,32 @@ | ||
package lipgloss | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/charmbracelet/x/term" | ||
Check failure on line 6 in default.go GitHub Actions / test-goos
|
||
) | ||
|
||
var ( | ||
// ColorProfile is the color profile used by lipgloss. | ||
// This is the default color profile used to create new styles. | ||
// By default, it allows for 24-bit color (TrueColor), decorations, and | ||
// doesn't do color conversion. | ||
ColorProfile Profile | ||
|
||
// HasLightBackground is true if the terminal has a light background. | ||
// This is the default value used to create new styles. | ||
HasLightBackground bool | ||
) | ||
|
||
// UseDefault will set the default color profile and background color detection | ||
// from the given terminal file descriptors and environment variables. | ||
func UseDefault(in term.File, out term.File, env []string) { | ||
ColorProfile = DetectColorProfile(out, env) | ||
HasLightBackground = QueryHasLightBackground(in, out) | ||
} | ||
|
||
// UseStdDefaults will set the default color profile and background color | ||
// detection from the standard input, output, and OS environment variables. | ||
func UseStdDefaults() { | ||
UseDefault(os.Stdin, os.Stdout, os.Environ()) | ||
} |
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,26 @@ | ||
// Package defaults is a helper package that sets the default Lip Gloss profile | ||
// and background color detection from the standard input, output, and OS | ||
// environment variables. | ||
// | ||
// This is useful for standalone Lip Gloss applications that only use the | ||
// standard input and output i.e. only run locally in a terminal. | ||
// You can simply import this package to set the default profile and background | ||
// color detection for Lip Gloss styles. | ||
// | ||
// package main | ||
// | ||
// import ( | ||
// "github.com/charmbracelet/lipgloss" | ||
// _ "github.com/charmbracelet/lipgloss/defaults" // use std profile defaults | ||
// ) | ||
// | ||
// func main() { | ||
// // Your code here | ||
// } | ||
package defaults | ||
|
||
import "github.com/charmbracelet/lipgloss" | ||
|
||
func init() { | ||
lipgloss.UseStdDefaults() | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/charmbracelet/lipgloss" | ||
"github.com/charmbracelet/x/exp/term/ansi" | ||
) | ||
|
||
var box = lipgloss.NewStyle().Width(8).Height(8).Border(lipgloss.RoundedBorder()) | ||
|
||
func main() { | ||
// fmt.Println(box.Render("สวัสดีสวัสดี" + "สวัสดีสวัสดี")) | ||
fmt.Println(box.Render("สวัสดีสวัสดี" + ansi.SetHyperlink("http://example.com") + "สวัสดีสวัสดี" + ansi.ResetHyperlink())) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/charmbracelet/lipgloss" | ||
"github.com/charmbracelet/x/exp/term/ansi" | ||
) | ||
|
||
func main() { | ||
str := "1 " | ||
red := lipgloss.Color("9") | ||
|
||
style1 := lipgloss.NewStyle(). | ||
Foreground(red). | ||
Render(str) | ||
|
||
style2 := lipgloss.NewStyle(). | ||
Width(1). | ||
Render(style1) | ||
|
||
fmt.Println("Lipgloss") | ||
fmt.Printf("Before Width: '%v'\n", style1) | ||
fmt.Printf("After Width : '%v'\n", style2) | ||
fmt.Println() | ||
|
||
fmt.Println("ANSI") | ||
fmt.Printf("ASCII Width : '%v'\n", ansi.Wrap(str, 1, "")) | ||
fmt.Printf("ANSI Width : '%v'\n", ansi.Wrap(style1, 1, "")) | ||
} |
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,18 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/charmbracelet/lipgloss" | ||
) | ||
|
||
func main() { | ||
fancy := "Fancy" | ||
fmt.Println(fancy) | ||
|
||
fancyBold := lipgloss.NewStyle().Bold(true).Render(fancy) | ||
fmt.Printf("%q\n", fancyBold) | ||
|
||
fancyBoldStrikethrough := lipgloss.NewStyle().Strikethrough(true).Render(fancyBold) | ||
fmt.Printf("%q\n", fancyBoldStrikethrough) | ||
} |
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
Oops, something went wrong.