mirror of
https://github.com/mum4k/termdash.git
synced 2025-04-25 13:48:50 +08:00
Format files with gofmt from Golang 1.20.
Signed-off-by: Jakub Sobon <jakub.sobon@elohim.sk>
This commit is contained in:
parent
52ebd80b87
commit
94d07aea18
@ -53,11 +53,13 @@ func (b *Builder) Build() ([]container.Option, error) {
|
|||||||
|
|
||||||
// validate recursively validates the elements that were added to the builder.
|
// validate recursively validates the elements that were added to the builder.
|
||||||
// Validates the following per each level of Rows or Columns.:
|
// Validates the following per each level of Rows or Columns.:
|
||||||
// The subElements are either exactly one Widget or any number of Rows and
|
//
|
||||||
// Columns.
|
// The subElements are either exactly one Widget or any number of Rows and
|
||||||
// Each individual width or height is in the range 0 < v < 100.
|
// Columns.
|
||||||
// The sum of all widths is <= 100.
|
// Each individual width or height is in the range 0 < v < 100.
|
||||||
// The sum of all heights is <= 100.
|
// The sum of all widths is <= 100.
|
||||||
|
// The sum of all heights is <= 100.
|
||||||
|
//
|
||||||
// Argument fixedSizeParent indicates if any of the parent elements uses fixed
|
// Argument fixedSizeParent indicates if any of the parent elements uses fixed
|
||||||
// size splitType.
|
// size splitType.
|
||||||
func validate(elems []Element, fixedSizeParent bool) error {
|
func validate(elems []Element, fixedSizeParent bool) error {
|
||||||
@ -182,17 +184,26 @@ func build(elems []Element, parentHeightPerc, parentWidthPerc int) []container.O
|
|||||||
// E.g. multiple rows would specify that they want the outer split percentage
|
// E.g. multiple rows would specify that they want the outer split percentage
|
||||||
// of 25% each, but we are representing them in a tree of containers so the
|
// of 25% each, but we are representing them in a tree of containers so the
|
||||||
// inner splits vary:
|
// inner splits vary:
|
||||||
// ╭─────────╮
|
//
|
||||||
|
// ╭─────────╮
|
||||||
|
//
|
||||||
// 25% │ 25% │
|
// 25% │ 25% │
|
||||||
// │╭───────╮│ ---
|
//
|
||||||
|
// │╭───────╮│ ---
|
||||||
|
//
|
||||||
// 25% ││ 33% ││
|
// 25% ││ 33% ││
|
||||||
// ││╭─────╮││
|
//
|
||||||
|
// ││╭─────╮││
|
||||||
|
//
|
||||||
// 25% │││ 50% │││
|
// 25% │││ 50% │││
|
||||||
// ││├─────┤││ 75%
|
//
|
||||||
|
// ││├─────┤││ 75%
|
||||||
|
//
|
||||||
// 25% │││ 50% │││
|
// 25% │││ 50% │││
|
||||||
// ││╰─────╯││
|
//
|
||||||
// │╰───────╯│
|
// ││╰─────╯││
|
||||||
// ╰─────────╯ ---
|
// │╰───────╯│
|
||||||
|
// ╰─────────╯ ---
|
||||||
//
|
//
|
||||||
// Argument outerPerc is the user specified percentage for the split, i.e. the
|
// Argument outerPerc is the user specified percentage for the split, i.e. the
|
||||||
// 25% in the example above.
|
// 25% in the example above.
|
||||||
|
@ -27,13 +27,13 @@ right and down.
|
|||||||
|
|
||||||
Each cell:
|
Each cell:
|
||||||
|
|
||||||
X→ 0 1 Y
|
X→ 0 1 Y
|
||||||
┌───┐ ↓
|
┌───┐ ↓
|
||||||
│● ●│ 0
|
│● ●│ 0
|
||||||
│● ●│ 1
|
│● ●│ 1
|
||||||
│● ●│ 2
|
│● ●│ 2
|
||||||
│● ●│ 3
|
│● ●│ 3
|
||||||
└───┘
|
└───┘
|
||||||
|
|
||||||
When using the braille canvas, the coordinates address the sub-cell points
|
When using the braille canvas, the coordinates address the sub-cell points
|
||||||
rather then cells themselves. However all points in the cell still share the
|
rather then cells themselves. However all points in the cell still share the
|
||||||
|
@ -75,11 +75,12 @@ func VerticalTextOverrunMode(om OverrunMode) VerticalTextOption {
|
|||||||
|
|
||||||
// VerticalText prints the provided text on the canvas starting at the provided point.
|
// VerticalText prints the provided text on the canvas starting at the provided point.
|
||||||
// The text is printed in a vertical orientation, i.e:
|
// The text is printed in a vertical orientation, i.e:
|
||||||
// H
|
//
|
||||||
// e
|
// H
|
||||||
// l
|
// e
|
||||||
// l
|
// l
|
||||||
// o
|
// l
|
||||||
|
// o
|
||||||
func VerticalText(c *canvas.Canvas, text string, start image.Point, opts ...VerticalTextOption) error {
|
func VerticalText(c *canvas.Canvas, text string, start image.Point, opts ...VerticalTextOption) error {
|
||||||
ar := c.Area()
|
ar := c.Area()
|
||||||
if !start.In(ar) {
|
if !start.In(ar) {
|
||||||
|
@ -128,9 +128,10 @@ func (ar *angleRange) contains(angle int) bool {
|
|||||||
// normalizeRange normalizes the start and end angles in degrees into ranges of
|
// normalizeRange normalizes the start and end angles in degrees into ranges of
|
||||||
// angles. Useful for cases where the 0/360 point falls within the range.
|
// angles. Useful for cases where the 0/360 point falls within the range.
|
||||||
// E.g:
|
// E.g:
|
||||||
// 0,25 => angleRange{0, 26}
|
//
|
||||||
// 0,360 => angleRange{0, 361}
|
// 0,25 => angleRange{0, 26}
|
||||||
// 359,20 => angleRange{359, 361}, angleRange{0, 21}
|
// 0,360 => angleRange{0, 361}
|
||||||
|
// 359,20 => angleRange{359, 361}, angleRange{0, 21}
|
||||||
func normalizeRange(start, end int) ([]*angleRange, error) {
|
func normalizeRange(start, end int) ([]*angleRange, error) {
|
||||||
if start < MinAngle || start > MaxAngle {
|
if start < MinAngle || start > MaxAngle {
|
||||||
return nil, fmt.Errorf("invalid start angle:%d, must be in range %d <= start <= %d", start, MinAngle, MaxAngle)
|
return nil, fmt.Errorf("invalid start angle:%d, must be in range %d <= start <= %d", start, MinAngle, MaxAngle)
|
||||||
@ -159,8 +160,9 @@ func normalizeRange(start, end int) ([]*angleRange, error) {
|
|||||||
|
|
||||||
// RangeSize returns the size of the degree range.
|
// RangeSize returns the size of the degree range.
|
||||||
// E.g:
|
// E.g:
|
||||||
// 0,25 => 25
|
//
|
||||||
// 359,1 => 2
|
// 0,25 => 25
|
||||||
|
// 359,1 => 2
|
||||||
func RangeSize(start, end int) (int, error) {
|
func RangeSize(start, end int) (int, error) {
|
||||||
ranges, err := normalizeRange(start, end)
|
ranges, err := normalizeRange(start, end)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -174,8 +176,9 @@ func RangeSize(start, end int) (int, error) {
|
|||||||
|
|
||||||
// RangeMid returns an angle that lies in the middle between start and end.
|
// RangeMid returns an angle that lies in the middle between start and end.
|
||||||
// E.g:
|
// E.g:
|
||||||
// 0,10 => 5
|
//
|
||||||
// 350,10 => 0
|
// 0,10 => 5
|
||||||
|
// 350,10 => 0
|
||||||
func RangeMid(start, end int) (int, error) {
|
func RangeMid(start, end int) (int, error) {
|
||||||
ranges, err := normalizeRange(start, end)
|
ranges, err := normalizeRange(start, end)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -21,19 +21,19 @@ display dot characters.
|
|||||||
|
|
||||||
The following outlines segments in the display and their names.
|
The following outlines segments in the display and their names.
|
||||||
|
|
||||||
---------------
|
---------------
|
||||||
| |
|
| |
|
||||||
| |
|
| |
|
||||||
| |
|
| |
|
||||||
| o D1 |
|
| o D1 |
|
||||||
| |
|
| |
|
||||||
| |
|
| |
|
||||||
| |
|
| |
|
||||||
| o D2 |
|
| o D2 |
|
||||||
| |
|
| |
|
||||||
| |
|
| |
|
||||||
| o D3 |
|
| o D3 |
|
||||||
---------------
|
---------------
|
||||||
*/
|
*/
|
||||||
package dotseg
|
package dotseg
|
||||||
|
|
||||||
|
@ -95,14 +95,15 @@ func SkipSlopesLTE(v int) Option {
|
|||||||
// This only has a visible effect when the horizontal segment has height of two
|
// This only has a visible effect when the horizontal segment has height of two
|
||||||
// or the vertical segment has width of two.
|
// or the vertical segment has width of two.
|
||||||
// Without this option segments with height / width of two look like this:
|
// Without this option segments with height / width of two look like this:
|
||||||
// - |
|
// - |
|
||||||
// --- ||
|
// --- ||
|
||||||
// |
|
// |
|
||||||
//
|
//
|
||||||
// With this option:
|
// With this option:
|
||||||
// --- |
|
//
|
||||||
// - ||
|
// --- |
|
||||||
// |
|
// - ||
|
||||||
|
// |
|
||||||
func ReverseSlopes() Option {
|
func ReverseSlopes() Option {
|
||||||
return option(func(opts *options) {
|
return option(func(opts *options) {
|
||||||
opts.reverseSlopes = true
|
opts.reverseSlopes = true
|
||||||
|
@ -21,21 +21,21 @@ display ASCII characters.
|
|||||||
|
|
||||||
The following outlines segments in the display and their names.
|
The following outlines segments in the display and their names.
|
||||||
|
|
||||||
A1 A2
|
A1 A2
|
||||||
------- -------
|
------- -------
|
||||||
| \ | / |
|
| \ | / |
|
||||||
| \ | / |
|
| \ | / |
|
||||||
F | H J K | B
|
F | H J K | B
|
||||||
| \ | / |
|
| \ | / |
|
||||||
| \ | / |
|
| \ | / |
|
||||||
-G1---- ----G2-
|
-G1---- ----G2-
|
||||||
| / | \ |
|
| / | \ |
|
||||||
| / | \ |
|
| / | \ |
|
||||||
E | N M L | C
|
E | N M L | C
|
||||||
| / | \ |
|
| / | \ |
|
||||||
| / | \ |
|
| / | \ |
|
||||||
------- -------
|
------- -------
|
||||||
D1 D2
|
D1 D2
|
||||||
*/
|
*/
|
||||||
package sixteen
|
package sixteen
|
||||||
|
|
||||||
|
@ -976,8 +976,10 @@ func newLayoutButtons(c *container.Container, w *widgets) (*layoutButtons, error
|
|||||||
|
|
||||||
// rotateFloats returns a new slice with inputs rotated by step.
|
// rotateFloats returns a new slice with inputs rotated by step.
|
||||||
// I.e. for a step of one:
|
// I.e. for a step of one:
|
||||||
// inputs[0] -> inputs[len(inputs)-1]
|
//
|
||||||
// inputs[1] -> inputs[0]
|
// inputs[0] -> inputs[len(inputs)-1]
|
||||||
|
// inputs[1] -> inputs[0]
|
||||||
|
//
|
||||||
// And so on.
|
// And so on.
|
||||||
func rotateFloats(inputs []float64, step int) []float64 {
|
func rotateFloats(inputs []float64, step int) []float64 {
|
||||||
return append(inputs[step:], inputs[:step]...)
|
return append(inputs[step:], inputs[:step]...)
|
||||||
@ -985,8 +987,10 @@ func rotateFloats(inputs []float64, step int) []float64 {
|
|||||||
|
|
||||||
// rotateRunes returns a new slice with inputs rotated by step.
|
// rotateRunes returns a new slice with inputs rotated by step.
|
||||||
// I.e. for a step of one:
|
// I.e. for a step of one:
|
||||||
// inputs[0] -> inputs[len(inputs)-1]
|
//
|
||||||
// inputs[1] -> inputs[0]
|
// inputs[0] -> inputs[len(inputs)-1]
|
||||||
|
// inputs[1] -> inputs[0]
|
||||||
|
//
|
||||||
// And so on.
|
// And so on.
|
||||||
func rotateRunes(inputs []rune, step int) []rune {
|
func rotateRunes(inputs []rune, step int) []rune {
|
||||||
return append(inputs[step:], inputs[:step]...)
|
return append(inputs[step:], inputs[:step]...)
|
||||||
|
@ -328,9 +328,10 @@ func (xs *XScale) CellLabel(x int) (*Value, error) {
|
|||||||
// the position. Positions grow up, coordinates grow down.
|
// the position. Positions grow up, coordinates grow down.
|
||||||
//
|
//
|
||||||
// Positions Y Coordinates
|
// Positions Y Coordinates
|
||||||
// 2 | 0
|
//
|
||||||
// 1 | 1
|
// 2 | 0
|
||||||
// 0 | 2
|
// 1 | 1
|
||||||
|
// 0 | 2
|
||||||
func positionToY(pos int, height int) (int, error) {
|
func positionToY(pos int, height int) (int, error) {
|
||||||
max := height - 1
|
max := height - 1
|
||||||
if min := 0; pos < min || pos > max {
|
if min := 0; pos < min || pos > max {
|
||||||
|
@ -62,8 +62,10 @@ func clock(ctx context.Context, sd *segmentdisplay.SegmentDisplay) {
|
|||||||
|
|
||||||
// rotate returns a new slice with inputs rotated by step.
|
// rotate returns a new slice with inputs rotated by step.
|
||||||
// I.e. for a step of one:
|
// I.e. for a step of one:
|
||||||
// inputs[0] -> inputs[len(inputs)-1]
|
//
|
||||||
// inputs[1] -> inputs[0]
|
// inputs[0] -> inputs[len(inputs)-1]
|
||||||
|
// inputs[1] -> inputs[0]
|
||||||
|
//
|
||||||
// And so on.
|
// And so on.
|
||||||
func rotate(inputs []rune, step int) []rune {
|
func rotate(inputs []rune, step int) []rune {
|
||||||
return append(inputs[step:], inputs[:step]...)
|
return append(inputs[step:], inputs[:step]...)
|
||||||
|
@ -105,7 +105,9 @@ func (t *Text) contentCells() int {
|
|||||||
// Write writes text for the widget to display. Multiple calls append
|
// Write writes text for the widget to display. Multiple calls append
|
||||||
// additional text. The text contain cannot control characters
|
// additional text. The text contain cannot control characters
|
||||||
// (unicode.IsControl) or space character (unicode.IsSpace) other than:
|
// (unicode.IsControl) or space character (unicode.IsSpace) other than:
|
||||||
// ' ', '\n'
|
//
|
||||||
|
// ' ', '\n'
|
||||||
|
//
|
||||||
// Any newline ('\n') characters are interpreted as newlines when displaying
|
// Any newline ('\n') characters are interpreted as newlines when displaying
|
||||||
// the text.
|
// the text.
|
||||||
func (t *Text) Write(text string, wOpts ...WriteOption) error {
|
func (t *Text) Write(text string, wOpts ...WriteOption) error {
|
||||||
|
@ -34,8 +34,10 @@ import (
|
|||||||
|
|
||||||
// rotate returns a new slice with inputs rotated by step.
|
// rotate returns a new slice with inputs rotated by step.
|
||||||
// I.e. for a step of one:
|
// I.e. for a step of one:
|
||||||
// inputs[0] -> inputs[len(inputs)-1]
|
//
|
||||||
// inputs[1] -> inputs[0]
|
// inputs[0] -> inputs[len(inputs)-1]
|
||||||
|
// inputs[1] -> inputs[0]
|
||||||
|
//
|
||||||
// And so on.
|
// And so on.
|
||||||
func rotate(inputs []rune, step int) []rune {
|
func rotate(inputs []rune, step int) []rune {
|
||||||
return append(inputs[step:], inputs[:step]...)
|
return append(inputs[step:], inputs[:step]...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user