-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'caleb/06-08-24/feat/style-library'
- Loading branch information
Showing
27 changed files
with
822 additions
and
143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# doc: Render | ||
|
||
(style/render style text) | ||
|
||
Apply styling effects to some text. This function generates a string containing ANSI escape sequences that will style the provided `text` according to `style`. | ||
|
||
All `cy` API functions that render text to the screen, such as {{api layout/set}} and {{api input/find}} accept input styled with {{api style/render}}. | ||
|
||
`style` is a struct with any of the following properties: | ||
|
||
- `:fg`: The foreground [color](/api.md#color) of the text. | ||
- `:bg`: The background [color](/api.md#color) of the text. | ||
- `:width`: The number of horizontal cells the text should occupy. Padding is added if this value exceeds the length of `text`. | ||
- `:height`: The number of vertical cells the text should occupy. Padding is added if this value exceeds the height of `text`. | ||
- `:align-horizontal`: One of `:left`, `:center`, or `:right`. If `:width` is greater than the length of the text, the text will be aligned according to this property. | ||
- `:align-vertical`: One of `:top`, `:center`, or `:bottom`. If `:height` is greater than the height of the text, the text will be aligned according to this property. | ||
- `:bold`: A boolean indicating whether the text should be bolded. | ||
- `:italic`: A boolean indicating whether the text should be italic. | ||
- `:underline`: A boolean indicating whether the text should be underlined. | ||
- `:strikethrough`: A boolean indicating whether the text should be struck through. | ||
- `:reverse`: A boolean indicating whether the foreground and background colorshould be reversed. | ||
- `:blink`: A boolean indicating whether the text should blink. | ||
- `:faint`: A boolean indicating whether the text should be faint. | ||
|
||
For example: | ||
|
||
```janet | ||
(style/render | ||
{:bg "4" | ||
:bold true | ||
:width 15 | ||
} "some text") | ||
``` |
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,12 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/cfoust/cy/pkg/style" | ||
) | ||
|
||
type StyleModule struct { | ||
} | ||
|
||
func (s *StyleModule) Render(style *style.Style, text string) string { | ||
return style.Render(text) | ||
} |
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,6 @@ | ||
(test "render" | ||
(style/render {:fg "#0000ff" | ||
:bg "#ff0000" | ||
:width 15 | ||
:italic true | ||
:align-horizontal :right} "test")) |
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,41 @@ | ||
(defn | ||
style/text | ||
````Style the provided text with the attributes provided. This function is a convenient wrapper around {{api style/render}}; instead of providing a struct, you may pass any of the attributes {{api style/render}} supports as named parameters. | ||
For example: | ||
```janet | ||
(style/text "foobar" :bg "#00ff00") | ||
(style/text "foobar" :italic true :bold true :width 15) | ||
``` | ||
```` | ||
[text | ||
&named | ||
fg | ||
bg | ||
width | ||
height | ||
align-horizontal | ||
align-vertical | ||
bold | ||
italic | ||
underline | ||
strikethrough | ||
reverse | ||
blink | ||
faint] | ||
|
||
(style/render | ||
{:fg fg | ||
:bg bg | ||
:width width | ||
:height height | ||
:align-horizontal align-horizontal | ||
:align-vertical align-vertical | ||
:bold bold | ||
:italic italic | ||
:underline underline | ||
:strikethrough strikethrough | ||
:reverse reverse | ||
:blink blink | ||
:faint faint} | ||
text)) |
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.