Commit Graph

304 Commits

Author SHA1 Message Date
Christian Rocha
5a82e41aea chore: update CODEOWNERS 2024-06-18 16:16:32 -04:00
Florian Rey
33b3263db7 fix: Deprecate UnsetBorderTopBackgroundColor in favor of UnsetBorderTopBackground 2024-06-08 13:42:55 -04:00
Christian Rocha
bbd02ab316
chore(ci): also build examples (#310)
* chore(ci): also build examples
* fix(examples): fix tree styles example
* fix: ssh examples dependencies
* chore: use creack/pty
* chore(examples): update deps
* chore(examples): bump examples (and ci) to 1.19 so a slog dep will build

---------

Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com>
2024-06-04 15:26:11 -04:00
Christian Rocha
7838b4e195 feat: deprecate Style.ColorWhitespace
You can get the exact same effect with margins and padding.
2024-05-31 13:28:32 -04:00
Christian Rocha
e54d9dd05a fix(tree): examples 2024-05-31 12:54:58 -04:00
Maas Lalani
878d31f064
fix: sublist example, minor edits 2024-05-31 11:45:23 -04:00
Maas Lalani
6e07abb123
refactor: use lipgloss copy for example (#308) 2024-05-30 18:37:17 -04:00
Christian Rocha
70c908de3e
chore: remove deprecated Copy() calls (#306)
Co-authored-by: Maas Lalani <maas@lalani.dev>
2024-05-30 17:57:06 -04:00
Maas Lalani
1afeca0d80
Tree API Changes (#307)
* refactor: clean tree_test.go

* refactor: remove subtests

* refactor: rename `Data` to `Items` for `Lists` and `Children` for `Trees`

* chore: support only NodeData

* fix: enumerations -> enumerators for consistency

* fix: item -> children

* fix: use l for List, rather than n

* fix: move list Enumerator definition to enumerator.go

* fix: list enumerator comments

* docs: add package documentation

* fix: examples

* feat: split enumerator and indenters

* docs: add comments

* refactor: package comment

* docs: use more tree terminology

* docs: refactor indentor comments

* fix: lint
2024-05-30 17:11:28 -04:00
Carlos Alexandro Becker
d21c576fdf
feat: trees and lists (#264)
* feat: implement list renderer

* feat: data model for list

* feat: add Offset, Height, Indent

* feat: tree renderer

* fix: list example

* test: last tree node is a subtree

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: tree

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: lint

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* docs: example

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* test: inc cov

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: multiline items

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* feat: one approach to sublists

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: tree improvements

* wip

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* wip

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* wip

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* wip

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: prevent having to pass renderer to all trees

* test: force linux line endings

* fix: windows

* fix: lint issues

* fix: ignore lint issue failing forever

* fix: renames

* fix: renderer

* ci: fix coveralls hopefully

* wip

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: style

* docs: update

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: renderer

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* test: cover with tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* feat: more list enumerators

* fix: drop renderer api

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* feat: improve api

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: prealloc

* fix: clean up

* fix: list setup

* fix: improve sublist tests

* fix: improve sublists

* refactor: simplify

* docs: more examples, readme updates

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* docs: readme

* fix: set item style

* fix(tree): do not use golden files

* test: do not use golden files

* refactor: remove unused code

* feat: hide nodes

* feat: filter

* fix: allow fmt.Stringer

* test: table within a tree

* docs: update

* fix: rename atter to data

* test: test public api only

* docs: sublist with table example

* docs: update example

* fix: lint issues

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* docs: update examples

* docs: update

* feat: offset

* feat: offsetstart && offsetend

* fix: remove last from enumerator

* refactor: make tree more explicit

* `New()` now take no args
* added a new `Root(string)` method
* added a new `Items(...any)` method

* refactor: improve list

* docs: fix examples

* test: ensure embed lists in trees

* docs: sublist example with list as tree node

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* refactor: first pass at examples cleanup

* refactor: first pass at examples cleanup

* fix: support multi-line prefixes

* test: more glow-style lists within trees

* docs: simplify examples

* fix: improve handling of different types

* chore: go mod tidy

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: code review suggestions

Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com>
Co-authored-by: bashbunni <15822994+bashbunni@users.noreply.github.com>

* fix: apply code review suggestion

* feat(tree): rounded enumerator (#280)

* chore(examples): go mod tidy

* feat(tree): add rounded corner enumerator

* test: rounded enumerator test

* docs: readme updates

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* docs: readme updates

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* chore: fmt

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* docs: godoc

* docs: godoc

* fix: bash's issue

* fix: bad example

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* docs: improve godoc for trees and lists (#296)

* docs(godoc): add overview

* docs(godoc): include examples in godoc

* docs(godoc): fix roman numerals example

* docs(godoc): fix tree examples

* docs(godoc): attempt to fix list Enumerator examples

* docs: added some examples to godoc

* fix(list): New(items...) with sublist

* docs: update examples

* chore(tree): improve var names in rounded example

* fix: use padding instead of margin to better styles

* fix: lint

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Co-authored-by: Maas Lalani <maas@lalani.dev>
Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com>
Co-authored-by: bashbunni <15822994+bashbunni@users.noreply.github.com>
Co-authored-by: Christian Rocha <christian@rocha.is>
2024-05-24 12:02:18 -03:00
Tanish Azad
5cd858cbff
fix: respect UnderlineSpaces and StrikethroughSpaces (#299)
* fixed boolean logic related to spaces styling

* cleanup

* added tests

* fixed tests
2024-05-22 12:13:55 -04:00
Ayman Bagabas
c91ab3ea94
chore(ci): enable gofumpt 2024-05-22 11:45:37 -04:00
Ayman Bagabas
83fa9be7fe
chore: use x/ansi instead of exp/term 2024-05-15 14:59:47 -04:00
dependabot[bot]
ce5323ee41
chore(deps): bump golangci/golangci-lint-action from 5 to 6 (#290)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 5 to 6.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v5...v6)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-13 11:09:26 -03:00
Ayman Bagabas
e3596ae70d chore(ci): test for different GOOS & GOARCH 2024-05-09 13:23:31 -04:00
Hugo Leonardo Costa e Silva
2fe044adcb fix: Change the propkeys from int to int64
When I create binaries for each OS using goreleaser, the propKeys
generates an int overflow since the iota duplicates for each propKey

This commit changes the int type to works well with binaries generated
for arm and i386 archs.
2024-05-09 12:20:39 -04:00
Christian Rocha
3ee5dcab73 chore(docs): doc updates with regard to style.Copy() deprecation 2024-05-06 16:27:54 -04:00
Ayman Bagabas
517b1a163e
fix: remove unused type 2024-05-06 09:16:14 -04:00
Ayman Bagabas
d2795c783a
refactor: replace props map with struct fields (#276)
Use an int to store property existence and style struct fields to store
the actual values for each non-bool property.

Fixes: https://github.com/charmbracelet/lipgloss/pull/139
Fixes: https://github.com/charmbracelet/lipgloss/pull/141
2024-05-02 13:36:30 -04:00
Christian Rocha
c986440c2a
chore(lint): remove deprecated ifshort linting option 2024-05-01 15:59:54 -04:00
Christian Rocha
e35d216358
chore(lint): end comments with periods 2024-05-01 15:59:30 -04:00
Christian Rocha
9f111af5aa
chore(lint): add nolint directives 2024-05-01 15:59:11 -04:00
Ayman Bagabas
2b58c4b607
Merge branch 'master' into who-needs-copy 2024-05-01 15:04:00 -04:00
Ayman Bagabas
efbfa4d2db
chore: update README.md
Co-authored-by: Christian Rocha <christian@rocha.is>
2024-05-01 14:26:50 -04:00
Ayman Bagabas
8e3f4122dc
docs: update Copy() notes 2024-05-01 14:22:21 -04:00
Ayman Bagabas
0d3715fd49
chore: update examples to remove deprecated Copy() 2024-05-01 14:15:02 -04:00
dependabot[bot]
1d4cfcb75b
chore(deps): bump golangci/golangci-lint-action from 4 to 5 (#283)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 4 to 5.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-29 13:51:19 -04:00
Michael Lorant
d0be07ea6b
chore(deps): Upgrade dependencies (#279)
Upgrade dependencies to latest stable versions.

As part of this dependency upgrade, the `term` package is being updated
to include an important fix for wrapping strings containing ANSI codes.
See charmbracelet/x/issues/58 for more details.

Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
2024-04-13 13:28:30 -04:00
dependabot[bot]
29fafad5be
chore(deps): bump golang.org/x/crypto from 0.1.0 to 0.17.0 in /examples (#277)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.1.0 to 0.17.0.
- [Commits](https://github.com/golang/crypto/compare/v0.1.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-29 15:44:34 -04:00
Ayman Bagabas
83959f5d94
chore: go mod tidy 2024-03-29 15:16:13 -04:00
Ayman Bagabas
2434fdaf07
fix: combining both conditional and unconditional wrapping (#275)
* feat: switch to term/ansi for text manipulation

Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: https://github.com/muesli/reflow/pull/71
Fixes: https://github.com/charmbracelet/lipgloss/issues/258
Fixes: https://github.com/charmbracelet/lipgloss/issues/220

* fix: combining both conditional and unconditional wrapping

Uses `ansi.SmartWrap` https://github.com/charmbracelet/x/pull/57

Fixes: https://github.com/muesli/reflow/issues/43

* chore: update deps

* Update get.go
2024-03-29 15:14:02 -04:00
Ayman Bagabas
f6f93348b0
feat: switch to term/ansi for text manipulation (#268)
* feat: switch to term/ansi for text manipulation

Use ANSI aware, wide characters support, uniseg backed term/ansi package
to calculate string widths, truncate, and wrap strings.

Related: https://github.com/muesli/reflow/pull/71
Fixes: https://github.com/charmbracelet/lipgloss/issues/258
Fixes: https://github.com/charmbracelet/lipgloss/issues/220

* Update get.go
2024-03-29 15:05:18 -04:00
Ayman Bagabas
387f2d73e8
refactor: replace props map with struct fields
Use an int to store property existence and style struct fields to store
the actual values for each non-bool property.

Fixes: https://github.com/charmbracelet/lipgloss/pull/139
Fixes: https://github.com/charmbracelet/lipgloss/pull/141
2024-03-28 17:47:40 -04:00
Ayman Bagabas
f16ea2bdcb feat(table): replace stripansi with ansi.Strip
Use term/ansi to strip out ANSI sequences
2024-03-25 09:03:15 -04:00
Christian Rocha
b71dd12664 fix: transform shouldn't operate on ANSI sequences 2024-03-22 16:19:39 -04:00
Christian Rocha
734aea5ee0
chore(README): various header improvements
* Update header image colors
* Link header to high-res mascot
* Add phorm badge
2024-03-18 22:09:05 -04:00
Maas Lalani
d760238dd2
fix(style): possible nil panic (#245) 2024-03-15 10:56:32 -04:00
Unseen Daan
96795629c1
fix: always render horizontal border edge when enabled (#211)
When a style has a border set and an empty string is rendered, it should
still render the border. When the left border is set, width is
incremented by 1, so in most cases the width will not be 0.

When we render an empty string, with a double border and no left border
we expect the following:
╗
║
╝
But if we don't render a horizontal edge when the string width is less
than 1 we see this:

║

The string width can't be lower than 0, so we can safely remove the
(width < 1) check to create the expected behavior.

Co-authored-by: Daan Schoone <daaschoone@gmail.com>
2024-03-14 11:12:23 -04:00
Ben Iofel
552cd7298f
Fix JoinHorizontal docs (#247) 2024-03-14 11:00:06 -04:00
Maas Lalani
439c06fae6
docs(table): ANSI-aware cell example 2024-03-05 10:35:45 -05:00
dependabot[bot]
652c37dd07
feat(deps): bump github.com/rivo/uniseg from 0.4.6 to 0.4.7 (#262)
Bumps [github.com/rivo/uniseg](https://github.com/rivo/uniseg) from 0.4.6 to 0.4.7.
- [Release notes](https://github.com/rivo/uniseg/releases)
- [Commits](https://github.com/rivo/uniseg/compare/v0.4.6...v0.4.7)

---
updated-dependencies:
- dependency-name: github.com/rivo/uniseg
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-02 14:48:57 -05:00
dependabot[bot]
8464a7c90b
chore(deps): bump golangci/golangci-lint-action from 3 to 4 (#259)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3 to 4.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-02 14:46:51 -05:00
Maas Lalani
207eb25c9f
Create CODEOWNERS 2024-02-28 21:02:24 -05:00
Christian Rocha
13584f26de chore: go mod tidy 2024-02-13 10:31:21 -05:00
Ayman Bagabas
bb7ffe226d
fix(ci): update coverage workflow 2024-02-13 10:26:46 -05:00
Michael Lorant
2745d8a3d8
Improve maximum width of characters in a string (#257)
The function `maxRuneWidth` was using a flawed approach by only
evaluating strings based on each rune. The `uniseg` package provides a
more accurate method based on grapheme clusters.

This change switches over to the improved implementation which should
achieve better results when determining the maximum width of all
grapheme clusters in a string.

Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
2024-02-13 10:03:24 -05:00
Michael Lorant
de4601232b
Fix truncate of table cells containing ANSI (#256) 2024-02-02 19:04:43 -05:00
Michael Lorant
92946d34c2
chore: refactor padding functions (#254)
The `padLeft` and `padRight` functions were nearly identical and could
benefit from being refactored to share common code.

A new function called `pad` was added that applies padding based on the
sign of the amount of padding needed. A positive value applies padding
to the right side while a negative value applies padding to the left
side.

Issue: #252

Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
2024-01-30 22:18:35 -05:00
Michael Lorant
59874c2afa
chore: apply gofumpt to all files (#255)
Apply gofumpt to all files to correct minor formatting issues.

Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
2024-01-30 17:44:00 -05:00
Michael Lorant
04def9df3e
fix: the empty string can have padding on the right (#253)
An empty string could not have padding applied on the right side.

Issue: #252

Signed-off-by: Michael Lorant <michael.lorant@nine.com.au>
2024-01-30 17:38:39 -05:00