Commit Graph

274 Commits

Author SHA1 Message Date
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
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
dependabot[bot]
fb3000d55f
chore(deps): bump actions/setup-go from 4 to 5 (#244)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4 to 5.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-go
  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>
2023-12-07 08:55:19 -03:00
Christian Rocha
d354842a40
feat: Style.Transform for altering strings at render time (#232)
* feat: Style.Transform for altering strings at render time

* feat: add `UnsetTransform`

---------

Co-authored-by: Maas Lalani <maas@lalani.dev>
2023-11-27 14:33:38 -05:00
Julien Ammous
59fcf6fa80
fix(align): fixed help comment (#239) 2023-11-22 15:16:16 -05:00
Reid Mason
49671292f7
fix: Corrected border shorthand functions explanation (#237) 2023-10-20 19:52:10 -04:00
Christian Rocha
b0605d31b2
docs: also link to table examples in the README 2023-10-12 07:30:51 -04:00
Maas Lalani
f093bc1509
Make headers []string (#234)
* fix: make headers `[]string`

* downgrade Lip Gloss to 1.17
2023-10-12 00:53:13 -04:00
Maas Lalani
42db873617
test(table): ensure README example works 2023-10-10 11:32:42 -04:00
Maas Lalani
4476263d05
Feature: Tables (#218)
* feat: tables

* fix(table): examples

* docs(table): `any` -> `string`

* chore: go mod tidy

* docs(table): update image

* fix(table): lint

* fix: remove binary

* chore: color adjustments to pokemon example (#231)

* fix(table): support rendering empty data sets

* chore(table): simplify table's data interface

* fix(table): correct GoDoc + add doc comments to Data methods

---------

Co-authored-by: Christian Rocha <christian@rocha.is>
Co-authored-by: Christian Muehlhaeuser <muesli@gmail.com>
2023-10-10 10:27:52 -04:00
Maas Lalani
408dcf3b9e
feat: add Middle borders (#230) 2023-10-05 12:26:16 -04:00
Ayman Bagabas
93cd5e0d35
feat: bump minimum go version to 1.18 (#216)
* feat: bump minimum go version to 1.18

* chore: bump go version in build.yml

---------

Co-authored-by: Maas Lalani <maas@lalani.dev>
2023-10-05 12:07:18 -04:00
dependabot[bot]
b766f24d45
feat(deps): bump github.com/mattn/go-runewidth from 0.0.14 to 0.0.15 (#215)
Bumps [github.com/mattn/go-runewidth](https://github.com/mattn/go-runewidth) from 0.0.14 to 0.0.15.
- [Commits](https://github.com/mattn/go-runewidth/compare/v0.0.14...v0.0.15)

---
updated-dependencies:
- dependency-name: github.com/mattn/go-runewidth
  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>
2023-10-05 12:01:04 -04:00
nervo
b0eb95dbc1
fix(border): both GetHorizontalBorderSize and GetVerticalBorderSize (#225) 2023-10-05 11:48:38 -04:00
nervo
2d2a577e2d
fix(border): GetBorderRightSize (#224) 2023-10-05 11:45:52 -04:00
dependabot[bot]
18166eaa8a
chore(deps): bump actions/checkout from 3 to 4 (#222) 2023-09-05 11:57:55 +00:00
Ayman Bagabas
07d22725d9
chore(ci): bump workflow actions 2023-08-04 13:49:32 -04:00
dependabot[bot]
7611cdfffe
chore(deps): bump golang.org/x/crypto in /examples (#192)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.0.0-20220307211146-efcb8507fb70 to 0.1.0.
- [Release notes](https://github.com/golang/crypto/releases)
- [Commits](https://github.com/golang/crypto/commits/v0.1.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>
2023-08-04 12:59:17 -04:00
Ayman Bagabas
160ffe826e
fix: cache color profile and background (#212)
* fix: renderer race condition

Guard accessing the underlying Termenv output behind a mutex. Multiple goroutines can set/get the dark background color causing a race condition.

* fix: cache color profile and background

* docs: add comment
2023-08-04 12:58:59 -04:00
Ayman Bagabas
ac8231edce
fix: renderer race condition (#210)
Guard accessing the underlying Termenv output behind a mutex. Multiple goroutines can set/get the dark background color causing a race condition.

Needs: https://github.com/muesli/termenv/pull/146
2023-08-01 08:23:15 -04:00
Christian Rocha
b3bce2366a
chore(docs): add section about tab conversion (#207) 2023-07-24 12:42:34 -04:00
Christian Rocha
01248034d0
chore(lint): add various nolint directives (#206)
Generally run-of-the-mill directives to disable magic number and exhaustive switches. Reasonings should be self explanatory while reading the code and comments, where applicable.
2023-07-24 11:50:04 -04:00
Christian Rocha
df8b3fa1f2
feat: convert tabs to spaces with Style.TabWidth(int) (#204)
* feat: convert tabs to spaces with Style.TabWidth(int)

By default tabs will be converted to 4 spaces. To disable tab
conversion set Style.TabWidth(NoTabConversion).
2023-07-24 11:22:48 -04:00
Christian Muehlhaeuser
233079e2d9 fix: go mod tidy examples 2023-06-28 17:01:41 +02:00
Carlos Alexandro Becker
3556cdfa89
feat(deps): update termenv (#202)
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2023-06-27 12:07:45 -03:00
bashbunni
859b49e848
docs: add FAQ (#189)
* docs: add FAQ

* chore(docs): update encoding/locale answer in FAQ

* chore(docs): update color profile disclaimer

* chore(docs): faq copyedits

* chore(docs): additional faq copy edits

* fix(docs): add missing closing code block in faq

---------

Co-authored-by: Christian Rocha <christian@rocha.is>
2023-05-23 11:58:52 -07:00
bashbunni
9bc85709f2
docs: add issue template (#193)
* docs: add issue template

* chore(template): add locale
2023-05-23 11:58:18 -07:00
Ayman Bagabas
97bf676aa0
fix(ci): remove soft-serve workflow 2023-05-12 14:11:20 -04:00
Carlos Alexandro Becker
63540b90ab
docs: update license
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2023-05-11 12:39:34 +00:00
mieubrisse
7fef6782b8 Undo additions to .gitignore 2023-05-01 09:37:20 -04:00
mieubrisse
4c3e61d4d1 Fix bugs with border size calculation 2023-05-01 09:37:20 -04:00
dependabot[bot]
da2d04b534 chore(deps): bump actions/checkout from 3.4.0 to 3.5.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.4.0 to 3.5.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3.4.0...v3.5.0)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-25 08:24:43 +01:00