Skip to content
Snippets Groups Projects
Verified Commit a1115264 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: update libs

parent b04039df
No related branches found
No related tags found
No related merge requests found
Showing
with 203 additions and 33390 deletions
...@@ -219,6 +219,26 @@ snippet: ...@@ -219,6 +219,26 @@ snippet:
Relative paths are relative to the specification file. Relative paths are relative to the specification file.
## Contributing
The bob command line tool is written in Go. The environment is defined in the
`flake.nix` file.
If you want to build the project, you can use the `nix build` or use the task build.
```bash
task build
```
To update the version and get the vendor hash,
the task `task update-code` must be called.
The hash is currently always null, as a vendor directory is used
in the project. This is created with `go mod vendor`.
## Questions ## Questions
For questions and commercial support, please contact [schukai GmbH](https://www.schukai.com/). For questions and commercial support, please contact [schukai GmbH](https://www.schukai.com/).
......
...@@ -28,6 +28,7 @@ tasks: ...@@ -28,6 +28,7 @@ tasks:
aliases: aliases:
- uc - uc
cmds: cmds:
- cd source; go mod download ; go mod tidy; go mod vendor; cd ..
- update-hashes || true - update-hashes || true
- update-version - update-version
silent: true silent: true
...@@ -117,9 +117,7 @@ func main() { ...@@ -117,9 +117,7 @@ func main() {
} }
} }
``` ```
The output is: The output is:
``` ```
List of pricing plans: List of pricing plans:
......
...@@ -348,7 +348,7 @@ func matchInclude(val string, s string, ignoreCase bool) bool { ...@@ -348,7 +348,7 @@ func matchInclude(val string, s string, ignoreCase bool) bool {
return false return false
} }
// matches elements where the attribute named key equals val or starts with val plus a hyphen. // matches elements where the attribute named key equals val or starts with val plus a hyphen.
func attributeDashMatch(key, val string, n *html.Node, ignoreCase bool) bool { func attributeDashMatch(key, val string, n *html.Node, ignoreCase bool) bool {
return matchAttribute(n, key, return matchAttribute(n, key,
func(s string) bool { func(s string) bool {
......
# go-osc52 # go-osc52
<p> <p>
...@@ -12,6 +13,7 @@ A Go library to work with the [ANSI OSC52](https://invisible-island.net/xterm/ct ...@@ -12,6 +13,7 @@ A Go library to work with the [ANSI OSC52](https://invisible-island.net/xterm/ct
You can use this small library to construct an ANSI OSC52 sequence suitable for You can use this small library to construct an ANSI OSC52 sequence suitable for
your terminal. your terminal.
### Example ### Example
```go ```go
...@@ -78,4 +80,4 @@ terminal. This requires `allow-passthrough on` in your config. ...@@ -78,4 +80,4 @@ terminal. This requires `allow-passthrough on` in your config.
## Credits ## Credits
- [vim-oscyank](https://github.com/ojroques/vim-oscyank) this is heavily inspired by vim-oscyank. * [vim-oscyank](https://github.com/ojroques/vim-oscyank) this is heavily inspired by vim-oscyank.
# Lip Gloss Lip Gloss
=========
<p> <p>
<img src="https://stuff.charm.sh/lipgloss/lipgloss-header-github.png" width="340" alt="Lip Gloss Title Treatment"><br> <img src="https://stuff.charm.sh/lipgloss/lipgloss-header-github.png" width="340" alt="Lip Gloss Title Treatment"><br>
...@@ -63,6 +64,7 @@ The terminal's color profile will be automatically detected, and colors outside ...@@ -63,6 +64,7 @@ The terminal's color profile will be automatically detected, and colors outside
the gamut of the current palette will be automatically coerced to their closest the gamut of the current palette will be automatically coerced to their closest
available value. available value.
### Adaptive Colors ### Adaptive Colors
You can also specify color options for light and dark backgrounds: You can also specify color options for light and dark backgrounds:
...@@ -113,6 +115,7 @@ var style = lipgloss.NewStyle(). ...@@ -113,6 +115,7 @@ var style = lipgloss.NewStyle().
Reverse(true) Reverse(true)
``` ```
## Block-Level Formatting ## Block-Level Formatting
Lip Gloss also supports rules for block-level formatting: Lip Gloss also supports rules for block-level formatting:
...@@ -151,6 +154,7 @@ lipgloss.NewStyle().Padding(1, 4, 2) ...@@ -151,6 +154,7 @@ lipgloss.NewStyle().Padding(1, 4, 2)
lipgloss.NewStyle().Margin(2, 4, 3, 1) lipgloss.NewStyle().Margin(2, 4, 3, 1)
``` ```
## Aligning Text ## Aligning Text
You can align paragraphs of text to the left, right, or center. You can align paragraphs of text to the left, right, or center.
...@@ -163,6 +167,7 @@ var style = lipgloss.NewStyle(). ...@@ -163,6 +167,7 @@ var style = lipgloss.NewStyle().
Align(lipgloss.Center) // just kidding, align it in the center Align(lipgloss.Center) // just kidding, align it in the center
``` ```
## Width and Height ## Width and Height
Setting a minimum width and height is simple and straightforward. Setting a minimum width and height is simple and straightforward.
...@@ -175,6 +180,7 @@ var style = lipgloss.NewStyle(). ...@@ -175,6 +180,7 @@ var style = lipgloss.NewStyle().
Foreground(lipgloss.Color("63")) Foreground(lipgloss.Color("63"))
``` ```
## Borders ## Borders
Adding borders is easy: Adding borders is easy:
...@@ -222,6 +228,7 @@ lipgloss.NewStyle(). ...@@ -222,6 +228,7 @@ lipgloss.NewStyle().
For more on borders see [the docs][docs]. For more on borders see [the docs][docs].
## Copying Styles ## Copying Styles
Just use `Copy()`: Just use `Copy()`:
...@@ -236,6 +243,7 @@ var wildStyle = style.Copy().Blink(true) ...@@ -236,6 +243,7 @@ var wildStyle = style.Copy().Blink(true)
a true, dereferenced copy of a style. Without copying, it's possible to mutate a true, dereferenced copy of a style. Without copying, it's possible to mutate
styles. styles.
## Inheritance ## Inheritance
Styles can inherit rules from other styles. When inheriting, only unset rules Styles can inherit rules from other styles. When inheriting, only unset rules
...@@ -253,6 +261,7 @@ var styleB = lipgloss.NewStyle(). ...@@ -253,6 +261,7 @@ var styleB = lipgloss.NewStyle().
Inherit(styleA) Inherit(styleA)
``` ```
## Unsetting Rules ## Unsetting Rules
All rules can be unset: All rules can be unset:
...@@ -267,6 +276,7 @@ var style = lipgloss.NewStyle(). ...@@ -267,6 +276,7 @@ var style = lipgloss.NewStyle().
When a rule is unset, it won't be inherited or copied. When a rule is unset, it won't be inherited or copied.
## Enforcing Rules ## Enforcing Rules
Sometimes, such as when developing a component, you want to make sure style Sometimes, such as when developing a component, you want to make sure style
...@@ -343,6 +353,7 @@ For an example on using a custom renderer over SSH with [Wish][wish] see the ...@@ -343,6 +353,7 @@ For an example on using a custom renderer over SSH with [Wish][wish] see the
In addition to pure styling, Lip Gloss also ships with some utilities to help In addition to pure styling, Lip Gloss also ships with some utilities to help
assemble your layouts. assemble your layouts.
### Joining Paragraphs ### Joining Paragraphs
Horizontally and vertically joining paragraphs is a cinch. Horizontally and vertically joining paragraphs is a cinch.
...@@ -359,6 +370,7 @@ lipgloss.JoinVertical(lipgloss.Center, paragraphA, paragraphB) ...@@ -359,6 +370,7 @@ lipgloss.JoinVertical(lipgloss.Center, paragraphA, paragraphB)
lipgloss.JoinHorizontal(0.2, paragraphA, paragraphB, paragraphC) lipgloss.JoinHorizontal(0.2, paragraphA, paragraphB, paragraphC)
``` ```
### Measuring Width and Height ### Measuring Width and Height
Sometimes you’ll want to know the width and height of text blocks when building Sometimes you’ll want to know the width and height of text blocks when building
...@@ -451,7 +463,7 @@ fmt.Println(t) ...@@ -451,7 +463,7 @@ fmt.Println(t)
For more on tables see [the docs](https://pkg.go.dev/github.com/charmbracelet/lipgloss?tab=doc). For more on tables see [the docs](https://pkg.go.dev/github.com/charmbracelet/lipgloss?tab=doc).
--- ***
## FAQ ## FAQ
...@@ -487,11 +499,10 @@ import ( ...@@ -487,11 +499,10 @@ import (
lipgloss.SetColorProfile(termenv.TrueColor) lipgloss.SetColorProfile(termenv.TrueColor)
``` ```
_Note:_ this option limits the flexibility of your application and can cause *Note:* this option limits the flexibility of your application and can cause
ANSI escape codes to be output in cases where that might not be desired. Take ANSI escape codes to be output in cases where that might not be desired. Take
careful note of your use case and environment before choosing to force a color careful note of your use case and environment before choosing to force a color
profile. profile.
</details> </details>
## What about [Bubble Tea][tea]? ## What about [Bubble Tea][tea]?
...@@ -505,6 +516,7 @@ In simple terms, you can use Lip Gloss to help build your Bubble Tea views. ...@@ -505,6 +516,7 @@ In simple terms, you can use Lip Gloss to help build your Bubble Tea views.
[tea]: https://github.com/charmbracelet/tea [tea]: https://github.com/charmbracelet/tea
## Under the Hood ## Under the Hood
Lip Gloss is built on the excellent [Termenv][termenv] and [Reflow][reflow] Lip Gloss is built on the excellent [Termenv][termenv] and [Reflow][reflow]
...@@ -514,6 +526,7 @@ For many use cases Termenv and Reflow will be sufficient for your needs. ...@@ -514,6 +526,7 @@ For many use cases Termenv and Reflow will be sufficient for your needs.
[termenv]: https://github.com/muesli/termenv [termenv]: https://github.com/muesli/termenv
[reflow]: https://github.com/muesli/reflow [reflow]: https://github.com/muesli/reflow
## Rendering Markdown ## Rendering Markdown
For a more document-centric rendering solution with support for things like For a more document-centric rendering solution with support for things like
...@@ -522,19 +535,20 @@ the stylesheet-based Markdown renderer. ...@@ -522,19 +535,20 @@ the stylesheet-based Markdown renderer.
[glamour]: https://github.com/charmbracelet/glamour [glamour]: https://github.com/charmbracelet/glamour
## Feedback ## Feedback
We’d love to hear your thoughts on this project. Feel free to drop us a note! We’d love to hear your thoughts on this project. Feel free to drop us a note!
- [Twitter](https://twitter.com/charmcli) * [Twitter](https://twitter.com/charmcli)
- [The Fediverse](https://mastodon.social/@charmcli) * [The Fediverse](https://mastodon.social/@charmcli)
- [Discord](https://charm.sh/chat) * [Discord](https://charm.sh/chat)
## License ## License
[MIT](https://github.com/charmbracelet/lipgloss/raw/master/LICENSE) [MIT](https://github.com/charmbracelet/lipgloss/raw/master/LICENSE)
--- ***
Part of [Charm](https://charm.sh). Part of [Charm](https://charm.sh).
...@@ -542,6 +556,7 @@ Part of [Charm](https://charm.sh). ...@@ -542,6 +556,7 @@ Part of [Charm](https://charm.sh).
Charm热爱开源 • Charm loves open source Charm热爱开源 • Charm loves open source
[docs]: https://pkg.go.dev/github.com/charmbracelet/lipgloss?tab=doc [docs]: https://pkg.go.dev/github.com/charmbracelet/lipgloss?tab=doc
[wish]: https://github.com/charmbracelet/wish [wish]: https://github.com/charmbracelet/wish
[ssh-example]: examples/ssh [ssh-example]: examples/ssh
# logfmt # logfmt
[![Go Reference](https://pkg.go.dev/badge/github.com/go-logfmt/logfmt.svg)](https://pkg.go.dev/github.com/go-logfmt/logfmt) [![Go Reference](https://pkg.go.dev/badge/github.com/go-logfmt/logfmt.svg)](https://pkg.go.dev/github.com/go-logfmt/logfmt)
[![Go Report Card](https://goreportcard.com/badge/go-logfmt/logfmt)](https://goreportcard.com/report/go-logfmt/logfmt) [![Go Report Card](https://goreportcard.com/badge/go-logfmt/logfmt)](https://goreportcard.com/report/go-logfmt/logfmt)
[![Github Actions](https://github.com/go-logfmt/logfmt/actions/workflows/test.yml/badge.svg)](https://github.com/go-logfmt/logfmt/actions/workflows/test.yml) [![Github Actions](https://github.com/go-logfmt/logfmt/actions/workflows/test.yml/badge.svg)](https://github.com/go-logfmt/logfmt/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/go-logfmt/logfmt/badge.svg?branch=master)](https://coveralls.io/github/go-logfmt/logfmt?branch=main) [![Coverage Status](https://coveralls.io/repos/github/go-logfmt/logfmt/badge.svg?branch=master)](https://coveralls.io/github/go-logfmt/logfmt?branch=main)
Package logfmt implements utilities to marshal and unmarshal data in the [logfmt Package logfmt implements utilities to marshal and unmarshal data in the [logfmt
format][fmt]. It provides an API similar to [encoding/json][json] and format][fmt]. It provides an API similar to [encoding/json][json] and
[encoding/xml][xml]. [encoding/xml][xml].
[fmt]: https://brandur.org/logfmt [fmt]: https://brandur.org/logfmt
[json]: https://pkg.go.dev/encoding/json [json]: https://pkg.go.dev/encoding/json
[xml]: https://pkg.go.dev/encoding/xml [xml]: https://pkg.go.dev/encoding/xml
The logfmt format was first documented by Brandur Leach in [this The logfmt format was first documented by Brandur Leach in [this
article][origin]. The format has not been formally standardized. The most article][origin]. The format has not been formally standardized. The most
authoritative public specification to date has been the documentation of a Go authoritative public specification to date has been the documentation of a Go
Language [package][parser] written by Blake Mizerany and Keith Rarick. Language [package][parser] written by Blake Mizerany and Keith Rarick.
[origin]: https://brandur.org/logfmt [origin]: https://brandur.org/logfmt
[parser]: https://pkg.go.dev/github.com/kr/logfmt [parser]: https://pkg.go.dev/github.com/kr/logfmt
## Goals ## Goals
This project attempts to conform as closely as possible to the prior art, while This project attempts to conform as closely as possible to the prior art, while
also removing ambiguity where necessary to provide well behaved encoder and also removing ambiguity where necessary to provide well behaved encoder and
decoder implementations. decoder implementations.
## Non-goals ## Non-goals
This project does not attempt to formally standardize the logfmt format. In the This project does not attempt to formally standardize the logfmt format. In the
event that logfmt is standardized this project would take conforming to the event that logfmt is standardized this project would take conforming to the
standard as a goal. standard as a goal.
## Versioning ## Versioning
This project publishes releases according to the Go language guidelines for This project publishes releases according to the Go language guidelines for
[developing and publishing modules][pub]. [developing and publishing modules][pub].
[pub]: https://go.dev/doc/modules/developing [pub]: https://go.dev/doc/modules/developing
# Changelog # Changelog
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
...@@ -7,39 +6,37 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ...@@ -7,39 +6,37 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
The format of this file is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format of this file is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
but only releases after v1.0.3 properly adhere to it. but only releases after v1.0.3 properly adhere to it.
## [1.2.0] - 2021-01-27
## [1.2.0] - 2021-01-27
### Added ### Added
- HSLuv and HPLuv color spaces (#41, #51) - HSLuv and HPLuv color spaces (#41, #51)
- CIE LCh(uv) color space, called `LuvLCh` in code (#51) - CIE LCh(uv) color space, called `LuvLCh` in code (#51)
- JSON and envconfig serialization support for `HexColor` (#42) - JSON and envconfig serialization support for `HexColor` (#42)
- `DistanceLinearRGB` (#53) - `DistanceLinearRGB` (#53)
### Fixed ### Fixed
- RGB to/from XYZ conversion is more accurate (#51) - RGB to/from XYZ conversion is more accurate (#51)
- A bug in `XYZToLuvWhiteRef` that only applied to very small values was fixed (#51) - A bug in `XYZToLuvWhiteRef` that only applied to very small values was fixed (#51)
- `BlendHCL` output is clamped so that it's not invalid (#46) - `BlendHCL` output is clamped so that it's not invalid (#46)
- Properly documented `DistanceCIE76` (#40) - Properly documented `DistanceCIE76` (#40)
- Some small godoc fixes - Some small godoc fixes
## [1.0.3] - 2019-11-11
## [1.0.3] - 2019-11-11
- Remove SQLMock dependency - Remove SQLMock dependency
## [1.0.2] - 2019-04-07
## [1.0.2] - 2019-04-07
- Fixes SQLMock dependency - Fixes SQLMock dependency
## [1.0.1] - 2019-03-24
## [1.0.1] - 2019-03-24
- Adds support for Go Modules - Adds support for Go Modules
## [1.0.0] - 2018-05-26
## [1.0.0] - 2018-05-26
- API Breaking change in `MakeColor`: instead of `panic`ing when alpha is zero, it now returns a secondary, boolean return value indicating success. See [the color.Color interface](#the-colorcolor-interface) section and [this FAQ entry](#q-why-would-makecolor-ever-fail) for details. - API Breaking change in `MakeColor`: instead of `panic`ing when alpha is zero, it now returns a secondary, boolean return value indicating success. See [the color.Color interface](#the-colorcolor-interface) section and [this FAQ entry](#q-why-would-makecolor-ever-fail) for details.
## [0.9.0] - 2018-05-26
## [0.9.0] - 2018-05-26
- Initial version number after having ignored versioning for a long time :) - Initial version number after having ignored versioning for a long time :)
# go-colorful go-colorful
===========
[![go reportcard](https://goreportcard.com/badge/github.com/lucasb-eyer/go-colorful)](https://goreportcard.com/report/github.com/lucasb-eyer/go-colorful) [![go reportcard](https://goreportcard.com/badge/github.com/lucasb-eyer/go-colorful)](https://goreportcard.com/report/github.com/lucasb-eyer/go-colorful)
A library for playing with colors in Go. Supports Go 1.13 onwards. A library for playing with colors in Go. Supports Go 1.13 onwards.
# Why? Why?
====
I love games. I make games. I love detail and I get lost in detail. I love games. I make games. I love detail and I get lost in detail.
One such detail popped up during the development of [Memory Which Does Not Suck](https://github.com/lucasb-eyer/mwdns/), One such detail popped up during the development of [Memory Which Does Not Suck](https://github.com/lucasb-eyer/mwdns/),
when we wanted the server to assign the players random colors. Sometimes when we wanted the server to assign the players random colors. Sometimes
...@@ -15,8 +16,8 @@ on HackerNews' frontpage and showed me how to Do It Right™. Last but not ...@@ -15,8 +16,8 @@ on HackerNews' frontpage and showed me how to Do It Right™. Last but not
least, there was no library for handling color spaces available in go. Colorful least, there was no library for handling color spaces available in go. Colorful
does just that and implements Go's `color.Color` interface. does just that and implements Go's `color.Color` interface.
# What? What?
=====
Go-Colorful stores colors in RGB and provides methods from converting these to various color-spaces. Currently supported colorspaces are: Go-Colorful stores colors in RGB and provides methods from converting these to various color-spaces. Currently supported colorspaces are:
- **RGB:** All three of Red, Green and Blue in [0..1]. - **RGB:** All three of Red, Green and Blue in [0..1].
...@@ -26,9 +27,9 @@ Go-Colorful stores colors in RGB and provides methods from converting these to v ...@@ -26,9 +27,9 @@ Go-Colorful stores colors in RGB and provides methods from converting these to v
- **Linear RGB:** See [gamma correct rendering](http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/). - **Linear RGB:** See [gamma correct rendering](http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/).
- **CIE-XYZ:** CIE's standard color space, almost in [0..1]. - **CIE-XYZ:** CIE's standard color space, almost in [0..1].
- **CIE-xyY:** encodes chromacity in x and y and luminance in Y, all in [0..1] - **CIE-xyY:** encodes chromacity in x and y and luminance in Y, all in [0..1]
- **CIE-L\*a\*b\*:** A _perceptually uniform_ color space, i.e. distances are meaningful. L\* in [0..1] and a\*, b\* almost in [-1..1]. - **CIE-L\*a\*b\*:** A *perceptually uniform* color space, i.e. distances are meaningful. L\* in [0..1] and a\*, b\* almost in [-1..1].
- **CIE-L\*u\*v\*:** Very similar to CIE-L\*a\*b\*, there is [no consensus](http://en.wikipedia.org/wiki/CIELUV#Historical_background) on which one is "better". - **CIE-L\*u\*v\*:** Very similar to CIE-L\*a\*b\*, there is [no consensus](http://en.wikipedia.org/wiki/CIELUV#Historical_background) on which one is "better".
- **CIE-L\*C\*h° (HCL):** This is generally the [most useful](http://vis4.net/blog/posts/avoid-equidistant-hsv-colors/) one; CIE-L\*a\*b\* space in polar coordinates, i.e. a _better_ HSV. H° is in [0..360], C\* almost in [-1..1] and L\* as in CIE-L\*a\*b\*. - **CIE-L\*C\*h° (HCL):** This is generally the [most useful](http://vis4.net/blog/posts/avoid-equidistant-hsv-colors/) one; CIE-L\*a\*b\* space in polar coordinates, i.e. a *better* HSV. H° is in [0..360], C\* almost in [-1..1] and L\* as in CIE-L\*a\*b\*.
- **CIE LCh(uv):** Called `LuvLCh` in code, this is a cylindrical transformation of the CIE-L\*u\*v\* color space. Like HCL above: H° is in [0..360], C\* almost in [-1..1] and L\* as in CIE-L\*u\*v\*. - **CIE LCh(uv):** Called `LuvLCh` in code, this is a cylindrical transformation of the CIE-L\*u\*v\* color space. Like HCL above: H° is in [0..360], C\* almost in [-1..1] and L\* as in CIE-L\*u\*v\*.
- **HSLuv:** The better alternative to HSL, see [here](https://www.hsluv.org/) and [here](https://www.kuon.ch/post/2020-03-08-hsluv/). Hue in [0..360], Saturation and Luminance in [0..1]. - **HSLuv:** The better alternative to HSL, see [here](https://www.hsluv.org/) and [here](https://www.kuon.ch/post/2020-03-08-hsluv/). Hue in [0..360], Saturation and Luminance in [0..1].
- **HPLuv:** A variant of HSLuv. The color space is smoother, but only pastel colors can be included. Because the valid colors are limited, it's easy to get invalid Saturation values way above 1.0, indicating the color can't be represented in HPLuv beccause it's not pastel. - **HPLuv:** A variant of HSLuv. The color space is smoother, but only pastel colors can be included. Because the valid colors are limited, it's easy to get invalid Saturation values way above 1.0, indicating the color can't be represented in HPLuv beccause it's not pastel.
...@@ -37,41 +38,42 @@ For the colorspaces where it makes sense (XYZ, Lab, Luv, HCl), the ...@@ -37,41 +38,42 @@ For the colorspaces where it makes sense (XYZ, Lab, Luv, HCl), the
[D65](http://en.wikipedia.org/wiki/Illuminant_D65) is used as reference white [D65](http://en.wikipedia.org/wiki/Illuminant_D65) is used as reference white
by default but methods for using your own reference white are provided. by default but methods for using your own reference white are provided.
A coordinate being _almost in_ a range means that generally it is, but for very A coordinate being *almost in* a range means that generally it is, but for very
bright colors and depending on the reference white, it might overflow this bright colors and depending on the reference white, it might overflow this
range slightly. For example, C\* of #0000ff is 1.338. range slightly. For example, C\* of #0000ff is 1.338.
Unit-tests are provided. Unit-tests are provided.
## Nice, but what's it useful for? Nice, but what's it useful for?
-------------------------------
- Converting color spaces. Some people like to do that. - Converting color spaces. Some people like to do that.
- Blending (interpolating) between colors in a "natural" look by using the right colorspace. - Blending (interpolating) between colors in a "natural" look by using the right colorspace.
- Generating random colors under some constraints (e.g. colors of the same shade, or shades of one color.) - Generating random colors under some constraints (e.g. colors of the same shade, or shades of one color.)
- Generating gorgeous random palettes with distinct colors of a same temperature. - Generating gorgeous random palettes with distinct colors of a same temperature.
# What not (yet)? What not (yet)?
===============
There are a few features which are currently missing and might be useful. There are a few features which are currently missing and might be useful.
I just haven't implemented them yet because I didn't have the need for it. I just haven't implemented them yet because I didn't have the need for it.
Pull requests welcome. Pull requests welcome.
- Sorting colors (potentially using above mentioned distances) - Sorting colors (potentially using above mentioned distances)
# So which colorspace should I use? So which colorspace should I use?
=================================
It depends on what you want to do. I think the folks from _I want hue_ are It depends on what you want to do. I think the folks from *I want hue* are
on-spot when they say that RGB fits to how _screens produce_ color, CIE L\*a\*b\* on-spot when they say that RGB fits to how *screens produce* color, CIE L\*a\*b\*
fits how _humans perceive_ color and HCL fits how _humans think_ colors. fits how *humans perceive* color and HCL fits how *humans think* colors.
Whenever you'd use HSV, rather go for CIE-L\*C\*h°. for fixed lightness L\* and Whenever you'd use HSV, rather go for CIE-L\*C\*h°. for fixed lightness L\* and
chroma C\* values, the hue angle h° rotates through colors of the same chroma C\* values, the hue angle h° rotates through colors of the same
perceived brightness and intensity. perceived brightness and intensity.
# How? How?
====
### Installing ### Installing
Installing the library is as easy as Installing the library is as easy as
```bash ```bash
...@@ -121,7 +123,6 @@ the name of the functions relating to the xyY space are just off. If you have ...@@ -121,7 +123,6 @@ the name of the functions relating to the xyY space are just off. If you have
any good suggestion, please open an issue. (I don't consider XyY good.) any good suggestion, please open an issue. (I don't consider XyY good.)
### The `color.Color` interface ### The `color.Color` interface
Because a `colorful.Color` implements Go's `color.Color` interface (found in the Because a `colorful.Color` implements Go's `color.Color` interface (found in the
`image/color` package), it can be used anywhere that expects a `color.Color`. `image/color` package), it can be used anywhere that expects a `color.Color`.
...@@ -138,8 +139,7 @@ alpha colors, this means the RGB values are lost (set to 0) and it's impossible ...@@ -138,8 +139,7 @@ alpha colors, this means the RGB values are lost (set to 0) and it's impossible
to recover them. In such a case `MakeColor` will return `false` as its second value. to recover them. In such a case `MakeColor` will return `false` as its second value.
### Comparing colors ### Comparing colors
In the RGB color space, the Euclidian distance between colors *doesn't* correspond
In the RGB color space, the Euclidian distance between colors _doesn't_ correspond
to visual/perceptual distance. This means that two pairs of colors which have the to visual/perceptual distance. This means that two pairs of colors which have the
same distance in RGB space can look much further apart. This is fixed by the same distance in RGB space can look much further apart. This is fixed by the
CIE-L\*a\*b\*, CIE-L\*u\*v\* and CIE-L\*C\*h° color spaces. CIE-L\*a\*b\*, CIE-L\*u\*v\* and CIE-L\*C\*h° color spaces.
...@@ -194,7 +194,6 @@ Note that `AlmostEqualRgb` is provided mainly for (unit-)testing purposes. Use ...@@ -194,7 +194,6 @@ Note that `AlmostEqualRgb` is provided mainly for (unit-)testing purposes. Use
it only if you really know what you're doing. It will eat your cat. it only if you really know what you're doing. It will eat your cat.
### Blending colors ### Blending colors
Blending is highly connected to distance, since it basically "walks through" the Blending is highly connected to distance, since it basically "walks through" the
colorspace thus, if the colorspace maps distances well, the walk is "smooth". colorspace thus, if the colorspace maps distances well, the walk is "smooth".
...@@ -274,7 +273,6 @@ func main() { ...@@ -274,7 +273,6 @@ func main() {
``` ```
#### Generating color gradients #### Generating color gradients
A very common reason to blend colors is creating gradients. There is an example A very common reason to blend colors is creating gradients. There is an example
program in [doc/gradientgen.go](doc/gradientgen/gradientgen.go); it doesn't use any API program in [doc/gradientgen.go](doc/gradientgen/gradientgen.go); it doesn't use any API
which hasn't been used in the previous example code, so I won't bother pasting which hasn't been used in the previous example code, so I won't bother pasting
...@@ -283,7 +281,6 @@ the code in here. Just look at that gorgeous gradient it generated in HCL space: ...@@ -283,7 +281,6 @@ the code in here. Just look at that gorgeous gradient it generated in HCL space:
!["Spectral" colorbrewer gradient in HCL space.](doc/gradientgen/gradientgen.png) !["Spectral" colorbrewer gradient in HCL space.](doc/gradientgen/gradientgen.png)
### Getting random colors ### Getting random colors
It is sometimes necessary to generate random colors. You could simply do this It is sometimes necessary to generate random colors. You could simply do this
on your own by generating colors with random values. By restricting the random on your own by generating colors with random values. By restricting the random
values to a range smaller than [0..1] and using a space such as CIE-H\*C\*l° or values to a range smaller than [0..1] and using a space such as CIE-H\*C\*l° or
...@@ -318,7 +315,6 @@ Don't forget to initialize the random seed! You can see the code used for ...@@ -318,7 +315,6 @@ Don't forget to initialize the random seed! You can see the code used for
generating this picture in `doc/colorgens/colorgens.go`. generating this picture in `doc/colorgens/colorgens.go`.
### Getting random palettes ### Getting random palettes
As soon as you need to generate more than one random color, you probably want As soon as you need to generate more than one random color, you probably want
them to be distinguishible. Playing against an opponent which has almost the them to be distinguishible. Playing against an opponent which has almost the
same blue as I do is not fun. This is where random palettes can help. same blue as I do is not fun. This is where random palettes can help.
...@@ -330,7 +326,7 @@ method which works in CIE spaces. For more theory on `SoftPalette`, check out ...@@ -330,7 +326,7 @@ method which works in CIE spaces. For more theory on `SoftPalette`, check out
[I want hue](http://tools.medialab.sciences-po.fr/iwanthue/theory.php). Yet [I want hue](http://tools.medialab.sciences-po.fr/iwanthue/theory.php). Yet
again, there is a `Happy` and a `Warm` version, which do what you expect, but again, there is a `Happy` and a `Warm` version, which do what you expect, but
now there is an additional `Soft` version, which is more configurable: you can now there is an additional `Soft` version, which is more configurable: you can
give a constraint on the color space in order to get colors within a certain _feel_. give a constraint on the color space in order to get colors within a certain *feel*.
Let's start with the simple methods first, all they take is the amount of Let's start with the simple methods first, all they take is the amount of
colors to generate, which could, for example, be the player count. They return colors to generate, which could, for example, be the player count. They return
...@@ -344,7 +340,7 @@ pal4 := colorful.FastHappyPalette(10) ...@@ -344,7 +340,7 @@ pal4 := colorful.FastHappyPalette(10)
pal5, err5 := colorful.SoftPalette(10) pal5, err5 := colorful.SoftPalette(10)
``` ```
Note that the non-fast methods _may_ fail if you ask for way too many colors. Note that the non-fast methods *may* fail if you ask for way too many colors.
Let's move on to the advanced one, namely `SoftPaletteEx`. Besides the color Let's move on to the advanced one, namely `SoftPaletteEx`. Besides the color
count, this function takes a `SoftPaletteSettings` object as argument. The count, this function takes a `SoftPaletteSettings` object as argument. The
interesting part here is its `CheckColor` member, which is a boolean function interesting part here is its `CheckColor` member, which is a boolean function
...@@ -376,11 +372,9 @@ from top to bottom: `Warm`, `FastWarm`, `Happy`, `FastHappy`, `Soft`, ...@@ -376,11 +372,9 @@ from top to bottom: `Warm`, `FastWarm`, `Happy`, `FastHappy`, `Soft`,
Again, the code used for generating the above image is available as [doc/palettegens/palettegens.go](https://github.com/lucasb-eyer/go-colorful/blob/master/doc/palettegens/palettegens.go). Again, the code used for generating the above image is available as [doc/palettegens/palettegens.go](https://github.com/lucasb-eyer/go-colorful/blob/master/doc/palettegens/palettegens.go).
### Sorting colors ### Sorting colors
TODO: Sort using dist fn. TODO: Sort using dist fn.
### Using linear RGB for computations ### Using linear RGB for computations
There are two methods for transforming RGB<->Linear RGB: a fast and almost precise one, There are two methods for transforming RGB<->Linear RGB: a fast and almost precise one,
and a slow and precise one. and a slow and precise one.
...@@ -412,15 +406,14 @@ _, err := db.QueryRow("SELECT '#ff0000';").Scan(&hc) ...@@ -412,15 +406,14 @@ _, err := db.QueryRow("SELECT '#ff0000';").Scan(&hc)
// hc == HexColor{R: 1, G: 0, B: 0}; err == nil // hc == HexColor{R: 1, G: 0, B: 0}; err == nil
``` ```
# FAQ FAQ
===
### Q: I get all f!@#ed up values! Your library sucks! ### Q: I get all f!@#ed up values! Your library sucks!
A: You probably provided values in the wrong range. For example, RGB values are A: You probably provided values in the wrong range. For example, RGB values are
expected to reside between 0 and 1, _not_ between 0 and 255. Normalize your colors. expected to reside between 0 and 1, *not* between 0 and 255. Normalize your colors.
### Q: Lab/Luv/HCl seem broken! Your library sucks! ### Q: Lab/Luv/HCl seem broken! Your library sucks!
They look like this: They look like this:
<img height="150" src="https://user-images.githubusercontent.com/3779568/28646900-6548040c-7264-11e7-8f12-81097a97c260.png"> <img height="150" src="https://user-images.githubusercontent.com/3779568/28646900-6548040c-7264-11e7-8f12-81097a97c260.png">
...@@ -442,7 +435,6 @@ both with code and pretty pictures. Also note that this was somewhat covered abo ...@@ -442,7 +435,6 @@ both with code and pretty pictures. Also note that this was somewhat covered abo
["Blending colors" section](https://github.com/lucasb-eyer/go-colorful#blending-colors). ["Blending colors" section](https://github.com/lucasb-eyer/go-colorful#blending-colors).
### Q: In a tight loop, conversion to Lab/Luv/HCl/... are slooooow! ### Q: In a tight loop, conversion to Lab/Luv/HCl/... are slooooow!
A: Yes, they are. A: Yes, they are.
This library aims for correctness, readability, and modularity; it wasn't written with speed in mind. This library aims for correctness, readability, and modularity; it wasn't written with speed in mind.
A large part of the slowness comes from these conversions going through `LinearRgb` which uses powers. A large part of the slowness comes from these conversions going through `LinearRgb` which uses powers.
...@@ -471,19 +463,20 @@ Thanks to [@ZirconiumX](https://github.com/ZirconiumX) for starting this investi ...@@ -471,19 +463,20 @@ Thanks to [@ZirconiumX](https://github.com/ZirconiumX) for starting this investi
see [issue #18](https://github.com/lucasb-eyer/go-colorful/issues/18) for details. see [issue #18](https://github.com/lucasb-eyer/go-colorful/issues/18) for details.
### Q: Why would `MakeColor` ever fail!? ### Q: Why would `MakeColor` ever fail!?
A: `MakeColor` fails when the alpha channel is zero. In that case, the A: `MakeColor` fails when the alpha channel is zero. In that case, the
conversion is undefined. See [issue 21](https://github.com/lucasb-eyer/go-colorful/issues/21) conversion is undefined. See [issue 21](https://github.com/lucasb-eyer/go-colorful/issues/21)
as well as the short caveat note in the ["The `color.Color` interface"](README.md#the-colorcolor-interface) as well as the short caveat note in the ["The `color.Color` interface"](README.md#the-colorcolor-interface)
section above. section above.
# Who? Who?
====
This library was developed by Lucas Beyer with contributions from This library was developed by Lucas Beyer with contributions from
Bastien Dejean (@baskerville), Phil Kulak (@pkulak) and Christian Muehlhaeuser (@muesli). Bastien Dejean (@baskerville), Phil Kulak (@pkulak) and Christian Muehlhaeuser (@muesli).
It is now maintained by makeworld (@makeworld-the-better-one). It is now maintained by makeworld (@makeworld-the-better-one).
## License ## License
This repo is under the MIT license, see [LICENSE](LICENSE) for details. This repo is under the MIT license, see [LICENSE](LICENSE) for details.
...@@ -11,8 +11,7 @@ import "math" ...@@ -11,8 +11,7 @@ import "math"
// comparing to the test values, this modified white reference is used internally. // comparing to the test values, this modified white reference is used internally.
// //
// See this GitHub thread for details on these values: // See this GitHub thread for details on these values:
// // https://github.com/hsluv/hsluv/issues/79
// https://github.com/hsluv/hsluv/issues/79
var hSLuvD65 = [3]float64{0.95045592705167, 1.0, 1.089057750759878} var hSLuvD65 = [3]float64{0.95045592705167, 1.0, 1.089057750759878}
func LuvLChToHSLuv(l, c, h float64) (float64, float64, float64) { func LuvLChToHSLuv(l, c, h float64) (float64, float64, float64) {
......
...@@ -45,6 +45,6 @@ Yasuhiro Matsumoto (a.k.a mattn) ...@@ -45,6 +45,6 @@ Yasuhiro Matsumoto (a.k.a mattn)
## Thanks ## Thanks
- k-takata: base idea for IsCygwinTerminal * k-takata: base idea for IsCygwinTerminal
https://github.com/k-takata/go-iscygpty https://github.com/k-takata/go-iscygpty
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
echo "" >coverage.txt echo "" > coverage.txt
for d in $(go list ./... | grep -v vendor); do for d in $(go list ./... | grep -v vendor); do
go test -race -coverprofile=profile.out -covermode=atomic "$d" go test -race -coverprofile=profile.out -covermode=atomic "$d"
if [ -f profile.out ]; then if [ -f profile.out ]; then
cat profile.out >>coverage.txt cat profile.out >> coverage.txt
rm profile.out rm profile.out
fi fi
done done
...@@ -42,8 +42,7 @@ func IsTerminal(fd uintptr) bool { ...@@ -42,8 +42,7 @@ func IsTerminal(fd uintptr) bool {
// Check pipe name is used for cygwin/msys2 pty. // Check pipe name is used for cygwin/msys2 pty.
// Cygwin/MSYS2 PTY has a name like: // Cygwin/MSYS2 PTY has a name like:
// // \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
func isCygwinPipeName(name string) bool { func isCygwinPipeName(name string) bool {
token := strings.Split(name, "-") token := strings.Split(name, "-")
if len(token) < 5 { if len(token) < 5 {
......
# go-runewidth go-runewidth
============
[![Build Status](https://github.com/mattn/go-runewidth/workflows/test/badge.svg?branch=master)](https://github.com/mattn/go-runewidth/actions?query=workflow%3Atest) [![Build Status](https://github.com/mattn/go-runewidth/workflows/test/badge.svg?branch=master)](https://github.com/mattn/go-runewidth/actions?query=workflow%3Atest)
[![Codecov](https://codecov.io/gh/mattn/go-runewidth/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-runewidth) [![Codecov](https://codecov.io/gh/mattn/go-runewidth/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-runewidth)
...@@ -7,16 +8,20 @@ ...@@ -7,16 +8,20 @@
Provides functions to get fixed width of the character or string. Provides functions to get fixed width of the character or string.
## Usage Usage
-----
```go ```go
runewidth.StringWidth("つのだ☆HIRO") == 12 runewidth.StringWidth("つのだ☆HIRO") == 12
``` ```
## Author
Author
------
Yasuhiro Matsumoto Yasuhiro Matsumoto
## License License
-------
under the MIT License: http://mattn.mit-license.org/2013 under the MIT License: http://mattn.mit-license.org/2013
...@@ -11,11 +11,11 @@ This Go package implements Unicode Text Segmentation according to [Unicode Stand ...@@ -11,11 +11,11 @@ This Go package implements Unicode Text Segmentation according to [Unicode Stand
In Go, [strings are read-only slices of bytes](https://go.dev/blog/strings). They can be turned into Unicode code points using the `for` loop or by casting: `[]rune(str)`. However, multiple code points may be combined into one user-perceived character or what the Unicode specification calls "grapheme cluster". Here are some examples: In Go, [strings are read-only slices of bytes](https://go.dev/blog/strings). They can be turned into Unicode code points using the `for` loop or by casting: `[]rune(str)`. However, multiple code points may be combined into one user-perceived character or what the Unicode specification calls "grapheme cluster". Here are some examples:
| String | Bytes (UTF-8) | Code points (runes) | Grapheme clusters | |String|Bytes (UTF-8)|Code points (runes)|Grapheme clusters|
| ------ | ----------------------------------------------------- | -------------------------------------- | ------------------------------------- | |-|-|-|-|
| Käse | 6 bytes: `4b 61 cc 88 73 65` | 5 code points: `4b 61 308 73 65` | 4 clusters: `[4b],[61 308],[73],[65]` | |Käse|6 bytes: `4b 61 cc 88 73 65`|5 code points: `4b 61 308 73 65`|4 clusters: `[4b],[61 308],[73],[65]`|
| 🏳️‍🌈 | 14 bytes: `f0 9f 8f b3 ef b8 8f e2 80 8d f0 9f 8c 88` | 4 code points: `1f3f3 fe0f 200d 1f308` | 1 cluster: `[1f3f3 fe0f 200d 1f308]` | |🏳️‍🌈|14 bytes: `f0 9f 8f b3 ef b8 8f e2 80 8d f0 9f 8c 88`|4 code points: `1f3f3 fe0f 200d 1f308`|1 cluster: `[1f3f3 fe0f 200d 1f308]`|
| 🇩🇪 | 8 bytes: `f0 9f 87 a9 f0 9f 87 aa` | 2 code points: `1f1e9 1f1ea` | 1 cluster: `[1f1e9 1f1ea]` | |🇩🇪|8 bytes: `f0 9f 87 a9 f0 9f 87 aa`|2 code points: `1f1e9 1f1ea`|1 cluster: `[1f1e9 1f1ea]`|
This package provides tools to iterate over these grapheme clusters. This may be used to determine the number of user-perceived characters, to split strings in their intended places, or to extract individual characters which form a unit. This package provides tools to iterate over these grapheme clusters. This may be used to determine the number of user-perceived characters, to split strings in their intended places, or to extract individual characters which form a unit.
...@@ -134,4 +134,4 @@ This package does not depend on any packages outside the standard library. ...@@ -134,4 +134,4 @@ This package does not depend on any packages outside the standard library.
## Your Feedback ## Your Feedback
Add your issue here on GitHub, preferably before submitting any PR's. Feel free to get in touch if you have any questions. Add your issue here on GitHub, preferably before submitting any PR's. Feel free to get in touch if you have any questions.
\ No newline at end of file
# Tokenizer # Tokenizer
[![Build Status](https://github.com/bzick/tokenizer/actions/workflows/tokenizer.yml/badge.svg)](https://github.com/bzick/tokenizer/actions/workflows/tokenizer.yml) [![Build Status](https://github.com/bzick/tokenizer/actions/workflows/tokenizer.yml/badge.svg)](https://github.com/bzick/tokenizer/actions/workflows/tokenizer.yml)
[![codecov](https://codecov.io/gh/bzick/tokenizer/branch/master/graph/badge.svg?token=MFY5NWATGC)](https://codecov.io/gh/bzick/tokenizer) [![codecov](https://codecov.io/gh/bzick/tokenizer/branch/master/graph/badge.svg?token=MFY5NWATGC)](https://codecov.io/gh/bzick/tokenizer)
...@@ -9,23 +9,22 @@ Tokenizer — parse any string, slice or infinite buffer to any tokens. ...@@ -9,23 +9,22 @@ Tokenizer — parse any string, slice or infinite buffer to any tokens.
Main features: Main features:
- High performance. * High performance.
- No regexp. * No regexp.
- Provides [simple API](https://pkg.go.dev/github.com/bzick/tokenizer). * Provides [simple API](https://pkg.go.dev/github.com/bzick/tokenizer).
- Supports [integer](#integer-number) and [float](#float-number) numbers. * Supports [integer](#integer-number) and [float](#float-number) numbers.
- Supports [quoted string or other "framed"](#framed-string) strings. * Supports [quoted string or other "framed"](#framed-string) strings.
- Supports [injection](#injection-in-framed-string) in quoted or "framed" strings. * Supports [injection](#injection-in-framed-string) in quoted or "framed" strings.
- Supports unicode. * Supports unicode.
- [Customization of tokens](#user-defined-tokens). * [Customization of tokens](#user-defined-tokens).
- Autodetect white space symbols. * Autodetect white space symbols.
- Parse any data syntax (xml, [json](https://github.com/bzick/tokenizer/blob/master/example_test.go), yaml), any programming language. * Parse any data syntax (xml, [json](https://github.com/bzick/tokenizer/blob/master/example_test.go), yaml), any programming language.
- Single pass through the data. * Single pass through the data.
- Parses [infinite incoming data](#parse-buffer) and don't panic. * Parses [infinite incoming data](#parse-buffer) and don't panic.
Use cases: Use cases:
- Parsing html, xml, [json](./example_test.go), yaml and other text formats. - Parsing html, xml, [json](./example_test.go), yaml and other text formats.
- Parsing huge or infinite texts. - Parsing huge or infinite texts.
- Parsing any programming languages. - Parsing any programming languages.
- Parsing templates. - Parsing templates.
- Parsing formulas. - Parsing formulas.
...@@ -34,7 +33,7 @@ For example, parsing SQL `WHERE` condition `user_id = 119 and modified > "2020-0 ...@@ -34,7 +33,7 @@ For example, parsing SQL `WHERE` condition `user_id = 119 and modified > "2020-0
```go ```go
// define custom tokens keys // define custom tokens keys
const ( const (
TEquality = 1 TEquality = 1
TDot = 2 TDot = 2
TMath = 3 TMath = 3
...@@ -55,14 +54,13 @@ defer stream.Close() ...@@ -55,14 +54,13 @@ defer stream.Close()
for stream.Valid() { for stream.Valid() {
if stream.CurrentToken().Is(tokenizer.TokenKeyword) { if stream.CurrentToken().Is(tokenizer.TokenKeyword) {
field := stream.CurrentToken().ValueString() field := stream.CurrentToken().ValueString()
// ... // ...
} }
stream.Next() stream.Next()
} }
``` ```
tokens stram: tokens stram:
``` ```
string: user_id = 119 and modified > "2020-01-01 00:00:00" or amount >= 122.34 string: user_id = 119 and modified > "2020-01-01 00:00:00" or amount >= 122.34
tokens: |user_id| =| 119| and| modified| >| "2020-01-01 00:00:00"| or| amount| >=| 122.34| tokens: |user_id| =| 119| and| modified| >| "2020-01-01 00:00:00"| or| amount| >=| 122.34|
...@@ -82,7 +80,6 @@ tokens: |user_id| =| 119| and| modified| >| "2020-01-01 00:00:00"| or| amount| > ...@@ -82,7 +80,6 @@ tokens: |user_id| =| 119| and| modified| >| "2020-01-01 00:00:00"| or| amount| >
``` ```
More examples: More examples:
- [JSON parser](./example_test.go) - [JSON parser](./example_test.go)
## Begin ## Begin
...@@ -113,7 +110,7 @@ fp, err := os.Open("data.json") // huge JSON file ...@@ -113,7 +110,7 @@ fp, err := os.Open("data.json") // huge JSON file
stream := parser.ParseStream(fp, 4096).SetHistorySize(10) stream := parser.ParseStream(fp, 4096).SetHistorySize(10)
defer stream.Close() defer stream.Close()
for stream.IsValid() { for stream.IsValid() {
// ... // ...
stream.Next() stream.Next()
} }
...@@ -121,12 +118,12 @@ for stream.IsValid() { ...@@ -121,12 +118,12 @@ for stream.IsValid() {
## Embedded tokens ## Embedded tokens
- `tokenizer.TokenUnknown` — unspecified token key. - `tokenizer.TokenUnknown` — unspecified token key.
- `tokenizer.TokenKeyword` — keyword, any combination of letters, including unicode letters. - `tokenizer.TokenKeyword` — keyword, any combination of letters, including unicode letters.
- `tokenizer.TokenInteger` — integer value - `tokenizer.TokenInteger` — integer value
- `tokenizer.TokenFloat` — float/double value - `tokenizer.TokenFloat` — float/double value
- `tokenizer.TokenString` — quoted string - `tokenizer.TokenString` — quoted string
- `tokenizer.TokenStringFragment` — fragment framed (quoted) string - `tokenizer.TokenStringFragment` — fragment framed (quoted) string
### Unknown token — `tokenizer.TokenUnknown` ### Unknown token — `tokenizer.TokenUnknown`
...@@ -135,7 +132,6 @@ A token marks as `TokenUnknown` if the parser detects an unknown token: ...@@ -135,7 +132,6 @@ A token marks as `TokenUnknown` if the parser detects an unknown token:
```go ```go
parser.ParseString(`one!`) parser.ParseString(`one!`)
``` ```
``` ```
{ {
{ {
...@@ -149,7 +145,7 @@ parser.ParseString(`one!`) ...@@ -149,7 +145,7 @@ parser.ParseString(`one!`)
} }
``` ```
By default, `TokenUnknown` tokens are added to the stream. By default, `TokenUnknown` tokens are added to the stream.
To exclude them from the stream, use the `tokenizer.StopOnUndefinedToken()` method To exclude them from the stream, use the `tokenizer.StopOnUndefinedToken()` method
``` ```
...@@ -174,7 +170,6 @@ The word can contains unicode characters, numbers (see `tokenizer.AllowNumbersIn ...@@ -174,7 +170,6 @@ The word can contains unicode characters, numbers (see `tokenizer.AllowNumbersIn
```go ```go
parser.ParseString(`one two четыре`) parser.ParseString(`one two четыре`)
``` ```
``` ```
tokens: { tokens: {
{ {
...@@ -199,7 +194,6 @@ Any integer is stored as one token with key `tokenizer.Token Integer`. ...@@ -199,7 +194,6 @@ Any integer is stored as one token with key `tokenizer.Token Integer`.
```go ```go
parser.ParseString(`223 999`) parser.ParseString(`223 999`)
``` ```
``` ```
tokens: { tokens: {
{ {
...@@ -223,7 +217,6 @@ fmt.Print("Token is %d", stream.CurrentToken().GetInt()) // Token is 123 ...@@ -223,7 +217,6 @@ fmt.Print("Token is %d", stream.CurrentToken().GetInt()) // Token is 123
### Float number ### Float number
Any float number is stored as one token with key `tokenizer.TokenFloat`. Float number may Any float number is stored as one token with key `tokenizer.TokenFloat`. Float number may
- have point, for example `1.2` - have point, for example `1.2`
- have exponent, for example `1e6` - have exponent, for example `1e6`
- have lower `e` or upper `E` letter in the exponent, for example `1E6`, `1e6` - have lower `e` or upper `E` letter in the exponent, for example `1E6`, `1e6`
...@@ -259,7 +252,6 @@ tokenizer.DefineStringToken(TokenDoubleQuotedString, `"`, `"`).SetEscapeSymbol(' ...@@ -259,7 +252,6 @@ tokenizer.DefineStringToken(TokenDoubleQuotedString, `"`, `"`).SetEscapeSymbol('
stream := tokenizer.ParseString(`"two \"three"`) stream := tokenizer.ParseString(`"two \"three"`)
``` ```
``` ```
{ {
{ {
...@@ -284,7 +276,7 @@ stream.CurrentToken().StringKey() == TokenDoubleQuotedString // true ...@@ -284,7 +276,7 @@ stream.CurrentToken().StringKey() == TokenDoubleQuotedString // true
### Injection in framed string ### Injection in framed string
Strings can contain expression substitutions that can be parsed into tokens. For example `"one {{two}} three"`. Strings can contain expression substitutions that can be parsed into tokens. For example `"one {{two}} three"`.
Fragments of strings before, between and after substitutions will be stored in tokens as `tokenizer.TokenStringFragment`. Fragments of strings before, between and after substitutions will be stored in tokens as `tokenizer.TokenStringFragment`.
```go ```go
const ( const (
...@@ -300,9 +292,7 @@ parser.DefineStringToken(TokenQuotedString, `"`, `"`).AddInjection(TokenOpenInje ...@@ -300,9 +292,7 @@ parser.DefineStringToken(TokenQuotedString, `"`, `"`).AddInjection(TokenOpenInje
parser.ParseString(`"one {{ two }} three"`) parser.ParseString(`"one {{ two }} three"`)
``` ```
Tokens: Tokens:
``` ```
{ {
{ {
...@@ -329,7 +319,6 @@ Tokens: ...@@ -329,7 +319,6 @@ Tokens:
``` ```
Use cases: Use cases:
- parse templates - parse templates
- parse placeholders - parse placeholders
...@@ -363,14 +352,14 @@ parser. ...@@ -363,14 +352,14 @@ parser.
stream := parser.ParseString(`{"key": [1]}`) stream := parser.ParseString(`{"key": [1]}`)
``` ```
## Known issues ## Known issues
- zero-byte `\0` ignores in the source string. * zero-byte `\0` ignores in the source string.
## Benchmark ## Benchmark
Parse string/bytes Parse string/bytes
``` ```
pkg: tokenizer pkg: tokenizer
cpu: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz cpu: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
...@@ -383,7 +372,6 @@ BenchmarkParseBytes-8 158481 7358 ns/op ...@@ -383,7 +372,6 @@ BenchmarkParseBytes-8 158481 7358 ns/op
``` ```
Parse infinite stream Parse infinite stream
``` ```
pkg: tokenizer pkg: tokenizer
cpu: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz cpu: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
......
...@@ -165,17 +165,13 @@ func (t Token) IsString() bool { ...@@ -165,17 +165,13 @@ func (t Token) IsString() bool {
} }
// ValueUnescaped returns clear (unquoted) string // ValueUnescaped returns clear (unquoted) string
// - without edge-tokens (quotes) // - without edge-tokens (quotes)
// - with character escaping handling // - with character escaping handling
// //
// For example quoted string // For example quoted string
// // "one \"two\"\t three"
// "one \"two\"\t three"
//
// transforms to // transforms to
// // one "two" three
// one "two" three
//
// Method doesn't use cache. Each call starts a string parser. // Method doesn't use cache. Each call starts a string parser.
func (t *Token) ValueUnescaped() []byte { func (t *Token) ValueUnescaped() []byte {
if t.string != nil { if t.string != nil {
......
...@@ -187,10 +187,10 @@ func (t *Tokenizer) DefineTokens(key TokenKey, tokens []string) *Tokenizer { ...@@ -187,10 +187,10 @@ func (t *Tokenizer) DefineTokens(key TokenKey, tokens []string) *Tokenizer {
// DefineStringToken defines a token string. // DefineStringToken defines a token string.
// For example, a piece of data surrounded by quotes: "string in quotes" or 'string on sigle quotes'. // For example, a piece of data surrounded by quotes: "string in quotes" or 'string on sigle quotes'.
// Arguments startToken and endToken defines open and close "quotes". // Arguments startToken and endToken defines open and close "quotes".
// - t.DefineStringToken("`", "`") - parse string "one `two three`" will be parsed as // - t.DefineStringToken("`", "`") - parse string "one `two three`" will be parsed as
// [{key: TokenKeyword, value: "one"}, {key: TokenString, value: "`two three`"}] // [{key: TokenKeyword, value: "one"}, {key: TokenString, value: "`two three`"}]
// - t.DefineStringToken("//", "\n") - parse string "parse // like comment\n" will be parsed as // - t.DefineStringToken("//", "\n") - parse string "parse // like comment\n" will be parsed as
// [{key: TokenKeyword, value: "parse"}, {key: TokenString, value: "// like comment"}] // [{key: TokenKeyword, value: "parse"}, {key: TokenString, value: "// like comment"}]
func (t *Tokenizer) DefineStringToken(key TokenKey, startToken, endToken string) *StringSettings { func (t *Tokenizer) DefineStringToken(key TokenKey, startToken, endToken string) *StringSettings {
q := &StringSettings{ q := &StringSettings{
Key: key, Key: key,
......
<a name="v1.16.0"></a>
<a name="v1.16.0"></a>
## [v1.16.0] - 2023-05-20 ## [v1.16.0] - 2023-05-20
<a name="v1.15.0"></a> <a name="v1.15.0"></a>
## [v1.15.0] - 2023-03-09 ## [v1.15.0] - 2023-03-09
<a name="v1.14.0"></a> <a name="v1.14.0"></a>
## [v1.14.0] - 2023-03-09 ## [v1.14.0] - 2023-03-09
<a name="v1.13.2"></a> <a name="v1.13.2"></a>
## [v1.13.2] - 2022-12-23 ## [v1.13.2] - 2022-12-23
<a name="v1.13.1"></a> <a name="v1.13.1"></a>
## [v1.13.1] - 2022-12-23 ## [v1.13.1] - 2022-12-23
<a name="v1.13.0"></a> <a name="v1.13.0"></a>
## [v1.13.0] - 2022-10-23 ## [v1.13.0] - 2022-10-23
### Add Features ### Add Features
- feat change proxy to map and expose map - feat change proxy to map and expose map
### Changes ### Changes
- chore add licenses - chore add licenses
<a name="v1.12.0"></a>
<a name="v1.12.0"></a>
## [v1.12.0] - 2022-10-19 ## [v1.12.0] - 2022-10-19
### Bug Fixes ### Bug Fixes
- fix remove tag for command [#4](https://gitlab.schukai.com/oss/libraries/go/application/xflags/issues/4) - fix remove tag for command [#4](https://gitlab.schukai.com/oss/libraries/go/application/xflags/issues/4)
<a name="v1.11.0"></a>
<a name="v1.11.0"></a>
## [v1.11.0] - 2022-10-19 ## [v1.11.0] - 2022-10-19
### Add Features ### Add Features
- feat improve the help output - feat improve the help output
<a name="v1.10.2"></a>
<a name="v1.10.2"></a>
## [v1.10.2] - 2022-10-16 ## [v1.10.2] - 2022-10-16
### Bug Fixes ### Bug Fixes
- fix copy only explicite values [#3](https://gitlab.schukai.com/oss/libraries/go/application/xflags/issues/3) - fix copy only explicite values [#3](https://gitlab.schukai.com/oss/libraries/go/application/xflags/issues/3)
<a name="v1.10.1"></a>
<a name="v1.10.1"></a>
## [v1.10.1] - 2022-10-16 ## [v1.10.1] - 2022-10-16
### Bug Fixes ### Bug Fixes
- fix assign the correct value to the proxy - fix assign the correct value to the proxy
### Changes ### Changes
- chore add license texts - chore add license texts
<a name="v1.10.0"></a>
<a name="v1.10.0"></a>
## [v1.10.0] - 2022-10-15 ## [v1.10.0] - 2022-10-15
### Code Refactoring ### Code Refactoring
- refactor functions moved to a separate repos - refactor functions moved to a separate repos
<a name="v1.9.0"></a>
<a name="v1.9.0"></a>
## [v1.9.0] - 2022-10-15 ## [v1.9.0] - 2022-10-15
### Add Features ### Add Features
- feat implements proxy interface [#2](https://gitlab.schukai.com/oss/libraries/go/application/xflags/issues/2) - feat implements proxy interface [#2](https://gitlab.schukai.com/oss/libraries/go/application/xflags/issues/2)
<a name="v1.8.3"></a>
<a name="v1.8.3"></a>
## [v1.8.3] - 2022-10-15 ## [v1.8.3] - 2022-10-15
### Bug Fixes ### Bug Fixes
- fix help request should not removed from errors - fix help request should not removed from errors
<a name="v1.8.2"></a>
<a name="v1.8.2"></a>
## [v1.8.2] - 2022-10-15 ## [v1.8.2] - 2022-10-15
### Bug Fixes ### Bug Fixes
- fix pathfinder panic - fix pathfinder panic
<a name="v1.8.1"></a>
<a name="v1.8.1"></a>
## [v1.8.1] - 2022-10-15 ## [v1.8.1] - 2022-10-15
<a name="v1.8.0"></a> <a name="v1.8.0"></a>
## [v1.8.0] - 2022-10-15 ## [v1.8.0] - 2022-10-15
### Bug Fixes ### Bug Fixes
- fix invalid type exception - fix invalid type exception
<a name="v1.7.0"></a>
<a name="v1.7.0"></a>
## [v1.7.0] - 2022-10-14 ## [v1.7.0] - 2022-10-14
### Add Features ### Add Features
- feat introduction of copy-interface - feat introduction of copy-interface
- feat new method to get the output of the flags - feat new method to get the output of the flags
<a name="v1.6.0"></a>
<a name="v1.6.0"></a>
## [v1.6.0] - 2022-10-13 ## [v1.6.0] - 2022-10-13
### Code Refactoring ### Code Refactoring
- refactor the execute function, the execute function should not print messages - refactor the execute function, the execute function should not print messages
<a name="v1.5.0"></a>
<a name="v1.5.0"></a>
## [v1.5.0] - 2022-10-13 ## [v1.5.0] - 2022-10-13
### Add Features ### Add Features
- feat new opportunities for interaction with flags [#1](https://gitlab.schukai.com/oss/libraries/go/application/xflags/issues/1) - feat new opportunities for interaction with flags [#1](https://gitlab.schukai.com/oss/libraries/go/application/xflags/issues/1)
### Changes ### Changes
- chore add license - chore add license
<a name="v1.4.0"></a>
<a name="v1.4.0"></a>
## [v1.4.0] - 2022-10-09 ## [v1.4.0] - 2022-10-09
### Add Features ### Add Features
- feat new Execute() Method for the automatic execution of command - feat new Execute() Method for the automatic execution of command
- feat new function GetDefaults() - feat new function GetDefaults()
<a name="v1.3.1"></a>
<a name="v1.3.1"></a>
## [v1.3.1] - 2022-10-08 ## [v1.3.1] - 2022-10-08
### Bug Fixes ### Bug Fixes
- fix remove one test renmant - fix remove one test renmant
<a name="v1.3.0"></a>
<a name="v1.3.0"></a>
## [v1.3.0] - 2022-10-08 ## [v1.3.0] - 2022-10-08
### Code Refactoring ### Code Refactoring
- refactor change func name FlagOutput() to Output() - refactor change func name FlagOutput() to Output()
<a name="v1.2.3"></a>
<a name="v1.2.3"></a>
## [v1.2.3] - 2022-10-07 ## [v1.2.3] - 2022-10-07
### Changes ### Changes
- chore change license things - chore change license things
- chore change license things - chore change license things
<a name="v1.2.2"></a>
<a name="v1.2.2"></a>
## [v1.2.2] - 2022-10-06 ## [v1.2.2] - 2022-10-06
### Changes ### Changes
- chore add licenses - chore add licenses
<a name="v1.2.1"></a>
<a name="v1.2.1"></a>
## [v1.2.1] - 2022-10-06 ## [v1.2.1] - 2022-10-06
### Changes ### Changes
- chore add licenses header - chore add licenses header
<a name="v1.2.0"></a>
<a name="v1.2.0"></a>
## [v1.2.0] - 2022-10-05 ## [v1.2.0] - 2022-10-05
### Add Features ### Add Features
- feat new function ParseOsArgs - feat new function ParseOsArgs
### Bug Fixes ### Bug Fixes
- fix Settings should be exported - fix Settings should be exported
- fix parse only the arguments and not the programm - fix parse only the arguments and not the programm
<a name="v1.1.1"></a>
<a name="v1.1.1"></a>
## [v1.1.1] - 2022-10-05 ## [v1.1.1] - 2022-10-05
### Bug Fixes ### Bug Fixes
- fix repository_url was wrong - fix repository_url was wrong
<a name="v1.1.0"></a>
<a name="v1.1.0"></a>
## [v1.1.0] - 2022-10-05 ## [v1.1.0] - 2022-10-05
<a name="v1.0.0"></a> <a name="v1.0.0"></a>
## v1.0.0 - 2022-10-04 ## v1.0.0 - 2022-10-04
[v1.16.0]: https://gitlab.schukai.com/oss/libraries/go/application/xflags/compare/v1.15.0...v1.16.0 [v1.16.0]: https://gitlab.schukai.com/oss/libraries/go/application/xflags/compare/v1.15.0...v1.16.0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment