lipgloss 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +21 -0
- data/README.md +438 -16
- data/ext/lipgloss/extconf.rb +61 -0
- data/ext/lipgloss/extension.c +150 -0
- data/ext/lipgloss/extension.h +76 -0
- data/ext/lipgloss/list.c +147 -0
- data/ext/lipgloss/style.c +398 -0
- data/ext/lipgloss/style_border.c +209 -0
- data/ext/lipgloss/style_spacing.c +97 -0
- data/ext/lipgloss/style_unset.c +151 -0
- data/ext/lipgloss/table.c +242 -0
- data/ext/lipgloss/tree.c +192 -0
- data/go/go.mod +20 -0
- data/go/go.sum +34 -0
- data/go/layout.go +71 -0
- data/go/lipgloss.go +78 -0
- data/go/list.go +118 -0
- data/go/style.go +281 -0
- data/go/style_border.go +197 -0
- data/go/style_spacing.go +94 -0
- data/go/style_unset.go +129 -0
- data/go/table.go +218 -0
- data/go/tree.go +138 -0
- data/lib/lipgloss/border.rb +48 -0
- data/lib/lipgloss/color.rb +97 -0
- data/lib/lipgloss/position.rb +27 -0
- data/lib/lipgloss/table.rb +63 -0
- data/lib/lipgloss/version.rb +2 -1
- data/lib/lipgloss.rb +21 -2
- data/lipgloss.gemspec +34 -0
- metadata +37 -14
- data/CHANGELOG.md +0 -5
- data/CODE_OF_CONDUCT.md +0 -132
- data/Rakefile +0 -12
- data/sig/lipgloss.rbs +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9901ec6ebe58427fd807f2b904bc0462afa0c98778ebf7e07bb4e2ab9119a1d3
|
|
4
|
+
data.tar.gz: db8ccca392715e11e439378696308b8fa7f6aa50a5883b68593aeab54a6076ff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f1b4cf84ccca46aadebd0b8c34439460c228f9e221f0282e5f7af7e802dc72e8bfd009b99ee7c577e37942395c400e21edde4f20a8a45a9b537f0089994625f
|
|
7
|
+
data.tar.gz: 667e9132355d975ffb0db3db29d13eb92680135cf19eea208e51f881041d4cb9d6871c62d642b11b42260496ac9a391342212691f1113e60cedde1b75156ede4
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Marco Roth
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,39 +1,461 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>Lipgloss for Ruby</h1>
|
|
3
|
+
<h4>CSS-like Terminal Styling for Ruby CLI Apps</h4>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://rubygems.org/gems/lipgloss"><img alt="Gem Version" src="https://img.shields.io/gem/v/lipgloss"></a>
|
|
7
|
+
<a href="https://github.com/marcoroth/lipgloss-ruby/blob/main/LICENSE.txt"><img alt="License" src="https://img.shields.io/github/license/marcoroth/lipgloss-ruby"></a>
|
|
8
|
+
</p>
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
<p>Ruby bindings for <a href="https://github.com/charmbracelet/lipgloss">charmbracelet/lipgloss</a>.<br/>Style definitions for nice terminal layouts with a fluent, CSS-like API.</p>
|
|
11
|
+
</div>
|
|
6
12
|
|
|
7
13
|
## Installation
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
**Add to your Gemfile:**
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
|
17
|
+
```ruby
|
|
18
|
+
gem "lipgloss"
|
|
15
19
|
```
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
**Or install directly:**
|
|
18
22
|
|
|
19
23
|
```bash
|
|
20
|
-
gem install
|
|
24
|
+
gem install lipgloss
|
|
21
25
|
```
|
|
22
26
|
|
|
23
27
|
## Usage
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
### Basic Styling
|
|
30
|
+
|
|
31
|
+
**Create and render styled text:**
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
require "lipgloss"
|
|
35
|
+
|
|
36
|
+
style = Lipgloss::Style.new
|
|
37
|
+
.bold(true)
|
|
38
|
+
.foreground("#FAFAFA")
|
|
39
|
+
.background("#7D56F4")
|
|
40
|
+
.padding(1, 2)
|
|
41
|
+
|
|
42
|
+
puts style.render("Hello, Lipgloss!")
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Reusable styles:**
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
heading = Lipgloss::Style.new
|
|
49
|
+
.bold(true)
|
|
50
|
+
.foreground("#FF6B6B")
|
|
51
|
+
.margin_bottom(1)
|
|
52
|
+
|
|
53
|
+
body = Lipgloss::Style.new
|
|
54
|
+
.width(40)
|
|
55
|
+
.align(Lipgloss::CENTER)
|
|
56
|
+
|
|
57
|
+
puts heading.render("Welcome")
|
|
58
|
+
puts body.render("Styled terminal output")
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Borders
|
|
62
|
+
|
|
63
|
+
**Add borders to your content:**
|
|
64
|
+
|
|
65
|
+
```ruby
|
|
66
|
+
box = Lipgloss::Style.new
|
|
67
|
+
.border(:rounded)
|
|
68
|
+
.border_foreground("#874BFD")
|
|
69
|
+
.padding(1, 2)
|
|
70
|
+
|
|
71
|
+
puts box.render("Boxed content")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Available border styles:**
|
|
75
|
+
|
|
76
|
+
| Style | Description |
|
|
77
|
+
|------------|-----------------------------------|
|
|
78
|
+
| `:normal` | Standard box drawing characters |
|
|
79
|
+
| `:rounded` | Rounded corners |
|
|
80
|
+
| `:thick` | Thick lines |
|
|
81
|
+
| `:double` | Double lines |
|
|
82
|
+
| `:hidden` | Hidden (spacing only) |
|
|
83
|
+
| `:block` | Block characters |
|
|
84
|
+
| `:ascii` | ASCII characters (`+`, `-`, `\|`) |
|
|
85
|
+
|
|
86
|
+
**Custom borders:**
|
|
87
|
+
|
|
88
|
+
```ruby
|
|
89
|
+
style = Lipgloss::Style.new
|
|
90
|
+
.border_custom(
|
|
91
|
+
top: "~", bottom: "~",
|
|
92
|
+
left: "|", right: "|",
|
|
93
|
+
top_left: "+", top_right: "+",
|
|
94
|
+
bottom_left: "+", bottom_right: "+"
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
puts style.render("Custom border!")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Per-side border colors:**
|
|
101
|
+
|
|
102
|
+
```ruby
|
|
103
|
+
style = Lipgloss::Style.new
|
|
104
|
+
.border(:rounded)
|
|
105
|
+
.border_top_foreground("#FF0000")
|
|
106
|
+
.border_right_foreground("#00FF00")
|
|
107
|
+
.border_bottom_foreground("#0000FF")
|
|
108
|
+
.border_left_foreground("#FFFF00")
|
|
109
|
+
|
|
110
|
+
puts style.render("Rainbow border!")
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Layout
|
|
114
|
+
|
|
115
|
+
**Join content horizontally:**
|
|
116
|
+
|
|
117
|
+
```ruby
|
|
118
|
+
left = box.render("Left")
|
|
119
|
+
right = box.render("Right")
|
|
120
|
+
|
|
121
|
+
puts Lipgloss.join_horizontal(Lipgloss::TOP, [left, right])
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Join content vertically:**
|
|
125
|
+
|
|
126
|
+
```ruby
|
|
127
|
+
puts Lipgloss.join_vertical(Lipgloss::CENTER, [left, right])
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Place content in whitespace:**
|
|
131
|
+
|
|
132
|
+
```ruby
|
|
133
|
+
puts Lipgloss.place(40, 10, Lipgloss::CENTER, Lipgloss::CENTER, "Centered")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Colors
|
|
137
|
+
|
|
138
|
+
**Simple hex colors:**
|
|
139
|
+
|
|
140
|
+
```ruby
|
|
141
|
+
style = Lipgloss::Style.new
|
|
142
|
+
.foreground("#FF0000")
|
|
143
|
+
.background("#0000FF")
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Adaptive colors (auto-detect light/dark terminal):**
|
|
147
|
+
|
|
148
|
+
```ruby
|
|
149
|
+
style = Lipgloss::Style.new
|
|
150
|
+
.foreground(Lipgloss::AdaptiveColor.new(light: "#000", dark: "#FFF"))
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Complete colors with fallbacks:**
|
|
154
|
+
|
|
155
|
+
```ruby
|
|
156
|
+
color = Lipgloss::CompleteColor.new(
|
|
157
|
+
true_color: "#FF6B6B", # 24-bit color
|
|
158
|
+
ansi256: "196", # 256-color fallback
|
|
159
|
+
ansi: "9" # 16-color fallback
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
style = Lipgloss::Style.new.foreground(color)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Complete adaptive colors:**
|
|
166
|
+
|
|
167
|
+
```ruby
|
|
168
|
+
light = Lipgloss::CompleteColor.new(true_color: "#000", ansi256: "0", ansi: "0")
|
|
169
|
+
dark = Lipgloss::CompleteColor.new(true_color: "#FFF", ansi256: "15", ansi: "15")
|
|
170
|
+
color = Lipgloss::CompleteAdaptiveColor.new(light: light, dark: dark)
|
|
171
|
+
|
|
172
|
+
style = Lipgloss::Style.new.foreground(color)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Style Inheritance
|
|
176
|
+
|
|
177
|
+
**Inherit styles from a parent:**
|
|
178
|
+
|
|
179
|
+
```ruby
|
|
180
|
+
base = Lipgloss::Style.new
|
|
181
|
+
.foreground("#FF0000")
|
|
182
|
+
.bold(true)
|
|
183
|
+
|
|
184
|
+
child = Lipgloss::Style.new
|
|
185
|
+
.padding(1)
|
|
186
|
+
.inherit(base) # Inherits foreground and bold
|
|
187
|
+
|
|
188
|
+
puts child.render("Inherited style!")
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Unset specific properties:**
|
|
192
|
+
|
|
193
|
+
```ruby
|
|
194
|
+
style = Lipgloss::Style.new
|
|
195
|
+
.bold(true)
|
|
196
|
+
.foreground("#FF0000")
|
|
197
|
+
.unset_bold # Remove bold
|
|
198
|
+
.unset_foreground # Remove foreground color
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### SetString
|
|
202
|
+
|
|
203
|
+
**Set default text for a style:**
|
|
204
|
+
|
|
205
|
+
```ruby
|
|
206
|
+
style = Lipgloss::Style.new
|
|
207
|
+
.bold(true)
|
|
208
|
+
.foreground("#7D56F4")
|
|
209
|
+
.set_string("Hello!")
|
|
210
|
+
|
|
211
|
+
puts style.to_s # Renders "Hello!" with the style
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Tables
|
|
215
|
+
|
|
216
|
+
**Create styled tables:**
|
|
217
|
+
|
|
218
|
+
```ruby
|
|
219
|
+
table = Lipgloss::Table.new
|
|
220
|
+
.headers(["Language", "Greeting"])
|
|
221
|
+
.rows([
|
|
222
|
+
["English", "Hello"],
|
|
223
|
+
["Spanish", "Hola"],
|
|
224
|
+
["Japanese", "こんにちは"]
|
|
225
|
+
])
|
|
226
|
+
.border(:rounded)
|
|
227
|
+
|
|
228
|
+
puts table.render
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Style cells with StyleFunc:**
|
|
232
|
+
|
|
233
|
+
```ruby
|
|
234
|
+
header_style = Lipgloss::Style.new.bold(true).background("#5A56E0")
|
|
235
|
+
even_style = Lipgloss::Style.new.background("#3C3C3C")
|
|
236
|
+
odd_style = Lipgloss::Style.new.background("#4A4A4A")
|
|
237
|
+
|
|
238
|
+
table = Lipgloss::Table.new
|
|
239
|
+
.headers(["Name", "Role"])
|
|
240
|
+
.rows([["Alice", "Engineer"], ["Bob", "Designer"]])
|
|
241
|
+
.border(:rounded)
|
|
242
|
+
.style_func(rows: 2, columns: 2) do |row, column|
|
|
243
|
+
if row == Lipgloss::Table::HEADER_ROW
|
|
244
|
+
header_style
|
|
245
|
+
elsif row.even?
|
|
246
|
+
even_style
|
|
247
|
+
else
|
|
248
|
+
odd_style
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
puts table.render
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Lists
|
|
256
|
+
|
|
257
|
+
**Create styled lists:**
|
|
258
|
+
|
|
259
|
+
```ruby
|
|
260
|
+
list = Lipgloss::List.new
|
|
261
|
+
.items(["First item", "Second item", "Third item"])
|
|
262
|
+
.enumerator(:bullet)
|
|
263
|
+
|
|
264
|
+
puts list.render
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Available enumerators:**
|
|
268
|
+
|
|
269
|
+
| Enumerator | Output |
|
|
270
|
+
|-------------|--------------------|
|
|
271
|
+
| `:bullet` | `•` |
|
|
272
|
+
| `:dash` | `-` |
|
|
273
|
+
| `:asterisk` | `*` |
|
|
274
|
+
| `:arabic` | `1.`, `2.`, `3.` |
|
|
275
|
+
| `:alphabet` | `A.`, `B.`, `C.` |
|
|
276
|
+
| `:roman` | `I.`, `II.`, `III.` |
|
|
277
|
+
|
|
278
|
+
**Styled list items:**
|
|
279
|
+
|
|
280
|
+
```ruby
|
|
281
|
+
list = Lipgloss::List.new
|
|
282
|
+
.items(["Red", "Green", "Blue"])
|
|
283
|
+
.enumerator(:bullet)
|
|
284
|
+
.enumerator_style(Lipgloss::Style.new.foreground("#FF0000"))
|
|
285
|
+
.item_style(Lipgloss::Style.new.bold(true))
|
|
286
|
+
|
|
287
|
+
puts list.render
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Trees
|
|
291
|
+
|
|
292
|
+
**Create tree structures:**
|
|
293
|
+
|
|
294
|
+
```ruby
|
|
295
|
+
tree = Lipgloss::Tree.new
|
|
296
|
+
.root("Project")
|
|
297
|
+
.child("src")
|
|
298
|
+
.child("lib")
|
|
299
|
+
.child("test")
|
|
300
|
+
|
|
301
|
+
puts tree.render
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**Nested trees:**
|
|
305
|
+
|
|
306
|
+
```ruby
|
|
307
|
+
src = Lipgloss::Tree.new.root("src").child("main.rb").child("helper.rb")
|
|
308
|
+
test = Lipgloss::Tree.new.root("test").child("test_main.rb")
|
|
309
|
+
|
|
310
|
+
tree = Lipgloss::Tree.new
|
|
311
|
+
.root("Project")
|
|
312
|
+
.child(src)
|
|
313
|
+
.child(test)
|
|
314
|
+
|
|
315
|
+
puts tree.render
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Style Methods
|
|
319
|
+
|
|
320
|
+
### Text Formatting
|
|
321
|
+
|
|
322
|
+
| Method | Description |
|
|
323
|
+
|-----------------------|-------------------------------|
|
|
324
|
+
| `bold(bool)` | Bold text |
|
|
325
|
+
| `italic(bool)` | Italic text |
|
|
326
|
+
| `underline(bool)` | Underlined text |
|
|
327
|
+
| `strikethrough(bool)` | Strikethrough text |
|
|
328
|
+
| `reverse(bool)` | Reverse foreground/background |
|
|
329
|
+
| `blink(bool)` | Blinking text |
|
|
330
|
+
| `faint(bool)` | Dimmed text |
|
|
331
|
+
|
|
332
|
+
### Colors
|
|
333
|
+
|
|
334
|
+
| Method | Description |
|
|
335
|
+
|----------------------------|-------------------------|
|
|
336
|
+
| `foreground(color)` | Text color |
|
|
337
|
+
| `background(color)` | Background color |
|
|
338
|
+
| `margin_background(color)` | Margin background color |
|
|
339
|
+
|
|
340
|
+
### Dimensions
|
|
341
|
+
|
|
342
|
+
| Method | Description |
|
|
343
|
+
|------------------|----------------|
|
|
344
|
+
| `width(int)` | Set width |
|
|
345
|
+
| `height(int)` | Set height |
|
|
346
|
+
| `max_width(int)` | Maximum width |
|
|
347
|
+
| `max_height(int)`| Maximum height |
|
|
348
|
+
|
|
349
|
+
### Spacing
|
|
350
|
+
|
|
351
|
+
| Method | Description |
|
|
352
|
+
|------------------------------------------------|-----------------------|
|
|
353
|
+
| `padding(top, right, bottom, left)` | Padding (CSS shorthand) |
|
|
354
|
+
| `padding_top(int)`, `padding_right(int)`, etc. | Individual padding |
|
|
355
|
+
| `margin(top, right, bottom, left)` | Margin (CSS shorthand) |
|
|
356
|
+
| `margin_top(int)`, `margin_right(int)`, etc. | Individual margin |
|
|
357
|
+
|
|
358
|
+
### Borders
|
|
359
|
+
|
|
360
|
+
| Method | Description |
|
|
361
|
+
|------------------------------------------------|-----------------------------|
|
|
362
|
+
| `border(type, *sides)` | Set border type and sides |
|
|
363
|
+
| `border_style(type)` | Set border type only |
|
|
364
|
+
| `border_foreground(color)` | Border color (all sides) |
|
|
365
|
+
| `border_background(color)` | Border background (all sides) |
|
|
366
|
+
| `border_top_foreground(color)`, etc. | Per-side border colors |
|
|
367
|
+
| `border_top_background(color)`, etc. | Per-side border backgrounds |
|
|
368
|
+
| `border_top(bool)`, `border_right(bool)`, etc. | Enable/disable sides |
|
|
369
|
+
| `border_custom(**opts)` | Custom border characters |
|
|
370
|
+
|
|
371
|
+
### Alignment
|
|
372
|
+
|
|
373
|
+
| Method | Description |
|
|
374
|
+
|-------------------------------|----------------------|
|
|
375
|
+
| `align(horizontal, vertical)` | Set alignment |
|
|
376
|
+
| `align_horizontal(position)` | Horizontal alignment |
|
|
377
|
+
| `align_vertical(position)` | Vertical alignment |
|
|
378
|
+
|
|
379
|
+
**Position constants:** `Lipgloss::TOP`, `Lipgloss::BOTTOM`, `Lipgloss::LEFT`, `Lipgloss::RIGHT`, `Lipgloss::CENTER`
|
|
380
|
+
|
|
381
|
+
### Other
|
|
382
|
+
|
|
383
|
+
| Method | Description |
|
|
384
|
+
|--------------------|-------------------------------------------|
|
|
385
|
+
| `inline(bool)` | Render inline (no margins/padding/borders) |
|
|
386
|
+
| `tab_width(int)` | Tab character width (-1 to disable) |
|
|
387
|
+
| `set_string(text)` | Set default text |
|
|
388
|
+
| `inherit(style)` | Inherit from another style |
|
|
389
|
+
| `to_s` | Render with default text |
|
|
390
|
+
|
|
391
|
+
### Unset Methods
|
|
392
|
+
|
|
393
|
+
| Method | Description |
|
|
394
|
+
|----------------------------------------|----------------------|
|
|
395
|
+
| `unset_bold`, `unset_italic`, etc. | Clear text formatting |
|
|
396
|
+
| `unset_foreground`, `unset_background` | Clear colors |
|
|
397
|
+
| `unset_width`, `unset_height` | Clear dimensions |
|
|
398
|
+
| `unset_padding_top`, etc. | Clear padding |
|
|
399
|
+
| `unset_margin_top`, etc. | Clear margin |
|
|
400
|
+
| `unset_border_style` | Clear border |
|
|
401
|
+
| `unset_inline` | Clear inline |
|
|
402
|
+
|
|
403
|
+
## Module Methods
|
|
404
|
+
|
|
405
|
+
| Method | Description |
|
|
406
|
+
|---------------------------------------------------------------------------------|--------------------------|
|
|
407
|
+
| `Lipgloss.join_horizontal(position, strings)` | Join strings horizontally |
|
|
408
|
+
| `Lipgloss.join_vertical(position, strings)` | Join strings vertically |
|
|
409
|
+
| `Lipgloss.width(string)` | Get rendered width |
|
|
410
|
+
| `Lipgloss.height(string)` | Get rendered height |
|
|
411
|
+
| `Lipgloss.size(string)` | Get `[width, height]` |
|
|
412
|
+
| `Lipgloss.place(width, height, horizontal_position, vertical_position, string)` | Place in whitespace |
|
|
413
|
+
| `Lipgloss.place_horizontal(width, position, string)` | Place horizontally |
|
|
414
|
+
| `Lipgloss.place_vertical(height, position, string)` | Place vertically |
|
|
415
|
+
| `Lipgloss.has_dark_background?` | Check terminal background |
|
|
26
416
|
|
|
27
417
|
## Development
|
|
28
418
|
|
|
29
|
-
|
|
419
|
+
**Requirements:**
|
|
420
|
+
- Go 1.23+
|
|
421
|
+
- Ruby 3.2+
|
|
30
422
|
|
|
31
|
-
|
|
423
|
+
**Install dependencies:**
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
bundle install
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
**Build the Go library and compile the extension:**
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
bundle exec rake compile
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**Run tests:**
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
bundle exec rake test
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
**Run demos:**
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
./demo/basic
|
|
445
|
+
./demo/colors
|
|
446
|
+
./demo/table
|
|
447
|
+
./demo/list
|
|
448
|
+
./demo/tree
|
|
449
|
+
```
|
|
32
450
|
|
|
33
451
|
## Contributing
|
|
34
452
|
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/lipgloss.
|
|
453
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/lipgloss-ruby.
|
|
454
|
+
|
|
455
|
+
## License
|
|
456
|
+
|
|
457
|
+
The gem is available as open source under the terms of the MIT License.
|
|
36
458
|
|
|
37
|
-
##
|
|
459
|
+
## Acknowledgments
|
|
38
460
|
|
|
39
|
-
|
|
461
|
+
This gem wraps [charmbracelet/lipgloss](https://github.com/charmbracelet/lipgloss), part of the excellent [Charm](https://charm.sh) ecosystem.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "mkmf"
|
|
4
|
+
|
|
5
|
+
extension_name = "lipgloss"
|
|
6
|
+
|
|
7
|
+
def detect_platform
|
|
8
|
+
cpu = RbConfig::CONFIG["host_cpu"]
|
|
9
|
+
os = RbConfig::CONFIG["host_os"]
|
|
10
|
+
|
|
11
|
+
arch = case cpu
|
|
12
|
+
when /aarch64|arm64/ then "arm64"
|
|
13
|
+
when /x86_64|amd64/ then "amd64"
|
|
14
|
+
when /arm/ then "arm"
|
|
15
|
+
when /i[3-6]86/ then "386"
|
|
16
|
+
else cpu
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
goos = case os
|
|
20
|
+
when /darwin/ then "darwin"
|
|
21
|
+
when /mswin|mingw/ then "windows"
|
|
22
|
+
else "linux"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
"#{goos}_#{arch}"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
platform = detect_platform
|
|
29
|
+
go_lib_dir = File.expand_path("../../go/build/#{platform}", __dir__)
|
|
30
|
+
|
|
31
|
+
puts "Looking for Go library in: #{go_lib_dir}"
|
|
32
|
+
|
|
33
|
+
unless File.exist?(File.join(go_lib_dir, "liblipgloss.a"))
|
|
34
|
+
abort <<~ERROR
|
|
35
|
+
Could not find liblipgloss.a for platform #{platform}
|
|
36
|
+
|
|
37
|
+
Please build the Go archive first:
|
|
38
|
+
cd go && go build -buildmode=c-archive -o build/#{platform}/liblipgloss.a .
|
|
39
|
+
|
|
40
|
+
Or run:
|
|
41
|
+
bundle exec rake go:build
|
|
42
|
+
ERROR
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
$LDFLAGS << " -L#{go_lib_dir}"
|
|
46
|
+
$INCFLAGS << " -I#{go_lib_dir}"
|
|
47
|
+
|
|
48
|
+
$LOCAL_LIBS << " #{go_lib_dir}/liblipgloss.a"
|
|
49
|
+
|
|
50
|
+
case RbConfig::CONFIG["host_os"]
|
|
51
|
+
when /darwin/
|
|
52
|
+
$LDFLAGS << " -framework CoreFoundation -framework Security -framework SystemConfiguration"
|
|
53
|
+
$LDFLAGS << " -lresolv"
|
|
54
|
+
when /linux/
|
|
55
|
+
$LDFLAGS << " -lpthread -lm -ldl"
|
|
56
|
+
$LDFLAGS << " -lresolv" if find_library("resolv", "res_query")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
$srcs = ["extension.c", "style.c", "style_spacing.c", "style_border.c", "style_unset.c", "table.c", "list.c", "tree.c"]
|
|
60
|
+
|
|
61
|
+
create_makefile("#{extension_name}/#{extension_name}")
|