lipgloss 0.1.0-aarch64-linux-musl

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.
data/go/tree.go ADDED
@@ -0,0 +1,138 @@
1
+ package main
2
+
3
+ import "C"
4
+
5
+ import (
6
+ "encoding/json"
7
+ lipglosstree "github.com/charmbracelet/lipgloss/tree"
8
+ )
9
+
10
+ func allocTree(tree *lipglosstree.Tree) uint64 {
11
+ treesMu.Lock()
12
+ defer treesMu.Unlock()
13
+ id := getNextID()
14
+ trees[id] = tree
15
+
16
+ return id
17
+ }
18
+
19
+ func getTree(id uint64) *lipglosstree.Tree {
20
+ treesMu.RLock()
21
+ defer treesMu.RUnlock()
22
+
23
+ return trees[id]
24
+ }
25
+
26
+ //export lipgloss_tree_new
27
+ func lipgloss_tree_new() C.ulonglong {
28
+ return C.ulonglong(allocTree(lipglosstree.New()))
29
+ }
30
+
31
+ //export lipgloss_tree_root
32
+ func lipgloss_tree_root(root *C.char) C.ulonglong {
33
+ return C.ulonglong(allocTree(lipglosstree.Root(C.GoString(root))))
34
+ }
35
+
36
+ //export lipgloss_tree_free
37
+ func lipgloss_tree_free(id C.ulonglong) {
38
+ treesMu.Lock()
39
+ defer treesMu.Unlock()
40
+ delete(trees, uint64(id))
41
+ }
42
+
43
+ //export lipgloss_tree_set_root
44
+ func lipgloss_tree_set_root(id C.ulonglong, root *C.char) C.ulonglong {
45
+ tree := getTree(uint64(id)).Root(C.GoString(root))
46
+
47
+ return C.ulonglong(allocTree(tree))
48
+ }
49
+
50
+ //export lipgloss_tree_child
51
+ func lipgloss_tree_child(id C.ulonglong, child *C.char) C.ulonglong {
52
+ tree := getTree(uint64(id)).Child(C.GoString(child))
53
+
54
+ return C.ulonglong(allocTree(tree))
55
+ }
56
+
57
+ //export lipgloss_tree_child_tree
58
+ func lipgloss_tree_child_tree(id C.ulonglong, childTreeID C.ulonglong) C.ulonglong {
59
+ childTree := getTree(uint64(childTreeID))
60
+ tree := getTree(uint64(id)).Child(childTree)
61
+
62
+ return C.ulonglong(allocTree(tree))
63
+ }
64
+
65
+ //export lipgloss_tree_children
66
+ func lipgloss_tree_children(id C.ulonglong, childrenJSON *C.char) C.ulonglong {
67
+ var children []string
68
+
69
+ if err := json.Unmarshal([]byte(C.GoString(childrenJSON)), &children); err != nil {
70
+ return id
71
+ }
72
+
73
+ anyChildren := make([]any, len(children))
74
+
75
+ for index, child := range children {
76
+ anyChildren[index] = child
77
+ }
78
+
79
+ tree := getTree(uint64(id)).Child(anyChildren...)
80
+
81
+ return C.ulonglong(allocTree(tree))
82
+ }
83
+
84
+ //export lipgloss_tree_enumerator
85
+ func lipgloss_tree_enumerator(id C.ulonglong, enumType C.int) C.ulonglong {
86
+ var enumerator lipglosstree.Enumerator
87
+
88
+ switch int(enumType) {
89
+ case 0:
90
+ enumerator = lipglosstree.DefaultEnumerator
91
+ case 1:
92
+ enumerator = lipglosstree.RoundedEnumerator
93
+ default:
94
+ enumerator = lipglosstree.DefaultEnumerator
95
+ }
96
+
97
+ tree := getTree(uint64(id)).Enumerator(enumerator)
98
+
99
+ return C.ulonglong(allocTree(tree))
100
+ }
101
+
102
+ //export lipgloss_tree_enumerator_style
103
+ func lipgloss_tree_enumerator_style(id C.ulonglong, styleID C.ulonglong) C.ulonglong {
104
+ style := getStyle(uint64(styleID))
105
+ tree := getTree(uint64(id)).EnumeratorStyle(style)
106
+
107
+ return C.ulonglong(allocTree(tree))
108
+ }
109
+
110
+ //export lipgloss_tree_item_style
111
+ func lipgloss_tree_item_style(id C.ulonglong, styleID C.ulonglong) C.ulonglong {
112
+ style := getStyle(uint64(styleID))
113
+ tree := getTree(uint64(id)).ItemStyle(style)
114
+
115
+ return C.ulonglong(allocTree(tree))
116
+ }
117
+
118
+ //export lipgloss_tree_root_style
119
+ func lipgloss_tree_root_style(id C.ulonglong, styleID C.ulonglong) C.ulonglong {
120
+ style := getStyle(uint64(styleID))
121
+ tree := getTree(uint64(id)).RootStyle(style)
122
+
123
+ return C.ulonglong(allocTree(tree))
124
+ }
125
+
126
+ //export lipgloss_tree_offset
127
+ func lipgloss_tree_offset(id C.ulonglong, start C.int, end C.int) C.ulonglong {
128
+ tree := getTree(uint64(id)).Offset(int(start), int(end))
129
+
130
+ return C.ulonglong(allocTree(tree))
131
+ }
132
+
133
+ //export lipgloss_tree_render
134
+ func lipgloss_tree_render(id C.ulonglong) *C.char {
135
+ tree := getTree(uint64(id))
136
+
137
+ return C.CString(tree.String())
138
+ }
Binary file
Binary file
Binary file
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module Lipgloss
5
+ module Border
6
+ # Standard border with normal weight and 90 degree corners
7
+ # ┌───┐
8
+ # │ │
9
+ # └───┘
10
+ NORMAL = :normal
11
+
12
+ # Border with rounded corners
13
+ # ╭───╮
14
+ # │ │
15
+ # ╰───╯
16
+ ROUNDED = :rounded
17
+
18
+ # Thicker border
19
+ # ┏━━━┓
20
+ # ┃ ┃
21
+ # ┗━━━┛
22
+ THICK = :thick
23
+
24
+ # Double-line border
25
+ # ╔═══╗
26
+ # ║ ║
27
+ # ╚═══╝
28
+ DOUBLE = :double
29
+
30
+ # ASCII border (compatible with all terminals)
31
+ # +---+
32
+ # | |
33
+ # +---+
34
+ ASCII = :ascii
35
+
36
+ # Hidden border (spaces, maintains layout)
37
+ HIDDEN = :hidden
38
+
39
+ # Block border (full blocks)
40
+ # ████
41
+ # █ █
42
+ # ████
43
+ BLOCK = :block
44
+
45
+ OUTER_HALF_BLOCK = :outer_half_block
46
+ INNER_HALF_BLOCK = :inner_half_block
47
+ end
48
+ end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module Lipgloss
5
+ # @rbs!
6
+ # type adaptive_color_hash = { light: String, dark: String }
7
+ # type complete_color_hash = { true_color: String, ansi256: String, ansi: String }
8
+ # type complete_adaptive_color_hash = { light: complete_color_hash, dark: complete_color_hash }
9
+
10
+ # Adaptive color that changes based on terminal background
11
+ #
12
+ # @example
13
+ # color = Lipgloss::AdaptiveColor.new(light: "#000000", dark: "#FFFFFF")
14
+ # style = Lipgloss::Style.new.foreground(color)
15
+ class AdaptiveColor
16
+ # @rbs @light: String
17
+ # @rbs @dark: String
18
+
19
+ attr_reader :light #: String
20
+ attr_reader :dark #: String
21
+
22
+ # @rbs light: String -- color to use on light backgrounds
23
+ # @rbs dark: String -- color to use on dark backgrounds
24
+ # @rbs return: void
25
+ def initialize(light:, dark:)
26
+ @light = light
27
+ @dark = dark
28
+ end
29
+
30
+ # @rbs return: adaptive_color_hash
31
+ def to_h
32
+ { light: @light, dark: @dark }
33
+ end
34
+ end
35
+
36
+ # Complete color with explicit values for each color profile
37
+ #
38
+ # @example
39
+ # color = Lipgloss::CompleteColor.new(
40
+ # true_color: "#0000FF",
41
+ # ansi256: "21",
42
+ # ansi: "4"
43
+ # )
44
+ class CompleteColor
45
+ # @rbs @true_color: String
46
+ # @rbs @ansi256: String
47
+ # @rbs @ansi: String
48
+
49
+ attr_reader :true_color #: String
50
+ attr_reader :ansi256 #: String
51
+ attr_reader :ansi #: String
52
+
53
+ # @rbs true_color: String -- 24-bit color (e.g., "#0000FF")
54
+ # @rbs ansi256: String -- 8-bit ANSI color (e.g., "21")
55
+ # @rbs ansi: String -- 4-bit ANSI color (e.g., "4")
56
+ # @rbs return: void
57
+ def initialize(true_color:, ansi256:, ansi:)
58
+ @true_color = true_color
59
+ @ansi256 = ansi256
60
+ @ansi = ansi
61
+ end
62
+
63
+ # @rbs return: complete_color_hash
64
+ def to_h
65
+ { true_color: @true_color, ansi256: @ansi256, ansi: @ansi }
66
+ end
67
+ end
68
+
69
+ # Complete adaptive color with explicit values for each color profile
70
+ # and separate options for light and dark backgrounds
71
+ #
72
+ # @example
73
+ # color = Lipgloss::CompleteAdaptiveColor.new(
74
+ # light: Lipgloss::CompleteColor.new(true_color: "#000", ansi256: "0", ansi: "0"),
75
+ # dark: Lipgloss::CompleteColor.new(true_color: "#FFF", ansi256: "15", ansi: "15")
76
+ # )
77
+ class CompleteAdaptiveColor
78
+ # @rbs @light: CompleteColor
79
+ # @rbs @dark: CompleteColor
80
+
81
+ attr_reader :light #: CompleteColor
82
+ attr_reader :dark #: CompleteColor
83
+
84
+ # @rbs light: CompleteColor -- color for light backgrounds
85
+ # @rbs dark: CompleteColor -- color for dark backgrounds
86
+ # @rbs return: void
87
+ def initialize(light:, dark:)
88
+ @light = light
89
+ @dark = dark
90
+ end
91
+
92
+ # @rbs return: complete_adaptive_color_hash
93
+ def to_h
94
+ { light: @light.to_h, dark: @dark.to_h }
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module Lipgloss
5
+ # Position constants for alignment
6
+ #
7
+ # Positions are represented as floats from 0.0 to 1.0:
8
+ # - 0.0 = top/left
9
+ # - 0.5 = center
10
+ # - 1.0 = bottom/right
11
+ module Position
12
+ # Top alignment (0.0)
13
+ TOP = 0.0
14
+
15
+ # Bottom alignment (1.0)
16
+ BOTTOM = 1.0
17
+
18
+ # Left alignment (0.0)
19
+ LEFT = 0.0
20
+
21
+ # Right alignment (1.0)
22
+ RIGHT = 1.0
23
+
24
+ # Center alignment (0.5)
25
+ CENTER = 0.5
26
+ end
27
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module Lipgloss
5
+ # Ruby enhancements for the Table class
6
+ #
7
+ # The Table class is implemented in C, but this module adds
8
+ # Ruby-level conveniences like style_func with blocks.
9
+ class Table
10
+ # Header row constant (used in style_func)
11
+ HEADER_ROW = -1
12
+
13
+ # Set a style function that determines the style for each cell
14
+ #
15
+ # @example Alternating row colors
16
+ # table.style_func(rows: 2, columns: 2) do |row, column|
17
+ # if row == Lipgloss::Table::HEADER_ROW
18
+ # Lipgloss::Style.new.bold(true)
19
+ # elsif row.even?
20
+ # Lipgloss::Style.new.background("#333")
21
+ # else
22
+ # Lipgloss::Style.new.background("#444")
23
+ # end
24
+ # end
25
+ #
26
+ # @example Column-specific styling
27
+ # table.style_func(rows: 2, columns: 2) do |row, column|
28
+ # case column
29
+ # when 0 then Lipgloss::Style.new.bold(true)
30
+ # when 1 then Lipgloss::Style.new.foreground("#00FF00")
31
+ # else Lipgloss::Style.new
32
+ # end
33
+ # end
34
+ #
35
+ # @rbs rows: Integer -- number of data rows in the table
36
+ # @rbs columns: Integer -- number of columns in the table
37
+ # @rbs &block: (Integer, Integer) -> Style? -- block called for each cell position
38
+ # @rbs return: Table -- a new table with the style function applied
39
+ def style_func(rows:, columns:, &block)
40
+ raise ArgumentError, "block required" unless block_given?
41
+ raise ArgumentError, "rows must be >= 0" if rows.negative?
42
+ raise ArgumentError, "columns must be > 0" if columns <= 0
43
+
44
+ style_map = {} #: Hash[String, Style]
45
+
46
+ # Header row
47
+ columns.times do |column|
48
+ style = block.call(HEADER_ROW, column)
49
+ style_map["#{HEADER_ROW},#{column}"] = style if style
50
+ end
51
+
52
+ # Data rows
53
+ rows.times do |row|
54
+ columns.times do |column|
55
+ style = block.call(row, column)
56
+ style_map["#{row},#{column}"] = style if style
57
+ end
58
+ end
59
+
60
+ _style_func_map(style_map)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module Lipgloss
5
+ VERSION = "0.1.0" #: String
6
+ end
data/lib/lipgloss.rb ADDED
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ require_relative "lipgloss/version"
5
+ require_relative "lipgloss/lipgloss"
6
+ require_relative "lipgloss/position"
7
+ require_relative "lipgloss/border"
8
+ require_relative "lipgloss/color"
9
+ require_relative "lipgloss/table"
10
+
11
+ module Lipgloss
12
+ TOP = Position::TOP #: Float
13
+ BOTTOM = Position::BOTTOM #: Float
14
+ LEFT = Position::LEFT #: Float
15
+ RIGHT = Position::RIGHT #: Float
16
+ CENTER = Position::CENTER #: Float
17
+
18
+ NORMAL_BORDER = Border::NORMAL #: Symbol
19
+ ROUNDED_BORDER = Border::ROUNDED #: Symbol
20
+ THICK_BORDER = Border::THICK #: Symbol
21
+ DOUBLE_BORDER = Border::DOUBLE #: Symbol
22
+ HIDDEN_BORDER = Border::HIDDEN #: Symbol
23
+ BLOCK_BORDER = Border::BLOCK #: Symbol
24
+ ASCII_BORDER = Border::ASCII #: Symbol
25
+
26
+ NO_TAB_CONVERSION = -1 #: Integer
27
+ end
data/lipgloss.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/lipgloss/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "lipgloss"
7
+ spec.version = Lipgloss::VERSION
8
+ spec.authors = ["Marco Roth"]
9
+ spec.email = ["marco.roth@intergga.ch"]
10
+
11
+ spec.summary = "Ruby wrapper for Charm's lipgloss CSS-like terminal styling library."
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/marcoroth/lipgloss-ruby"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.2.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/marcoroth/lipgloss-ruby"
19
+ spec.metadata["changelog_uri"] = "https://github.com/marcoroth/lipgloss-ruby/releases"
20
+ spec.metadata["rubygems_mfa_required"] = "true"
21
+
22
+ spec.files = Dir[
23
+ "lipgloss.gemspec",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "lib/**/*.rb",
27
+ "ext/**/*.{c,h,rb}",
28
+ "go/**/*.{go,mod,sum}",
29
+ "go/build/**/*"
30
+ ]
31
+
32
+ spec.require_paths = ["lib"]
33
+ spec.extensions = ["ext/lipgloss/extconf.rb"]
34
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lipgloss
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: aarch64-linux-musl
6
+ authors:
7
+ - Marco Roth
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Ruby wrapper for Charm's lipgloss CSS-like terminal styling library.
13
+ email:
14
+ - marco.roth@intergga.ch
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE.txt
20
+ - README.md
21
+ - ext/lipgloss/extconf.rb
22
+ - ext/lipgloss/extension.c
23
+ - ext/lipgloss/extension.h
24
+ - ext/lipgloss/list.c
25
+ - ext/lipgloss/style.c
26
+ - ext/lipgloss/style_border.c
27
+ - ext/lipgloss/style_spacing.c
28
+ - ext/lipgloss/style_unset.c
29
+ - ext/lipgloss/table.c
30
+ - ext/lipgloss/tree.c
31
+ - go/build/linux_arm64/liblipgloss.a
32
+ - go/build/linux_arm64/liblipgloss.h
33
+ - go/go.mod
34
+ - go/go.sum
35
+ - go/layout.go
36
+ - go/lipgloss.go
37
+ - go/list.go
38
+ - go/style.go
39
+ - go/style_border.go
40
+ - go/style_spacing.go
41
+ - go/style_unset.go
42
+ - go/table.go
43
+ - go/tree.go
44
+ - lib/lipgloss.rb
45
+ - lib/lipgloss/3.2/lipgloss.so
46
+ - lib/lipgloss/3.3/lipgloss.so
47
+ - lib/lipgloss/3.4/lipgloss.so
48
+ - lib/lipgloss/border.rb
49
+ - lib/lipgloss/color.rb
50
+ - lib/lipgloss/position.rb
51
+ - lib/lipgloss/table.rb
52
+ - lib/lipgloss/version.rb
53
+ - lipgloss.gemspec
54
+ homepage: https://github.com/marcoroth/lipgloss-ruby
55
+ licenses:
56
+ - MIT
57
+ metadata:
58
+ homepage_uri: https://github.com/marcoroth/lipgloss-ruby
59
+ source_code_uri: https://github.com/marcoroth/lipgloss-ruby
60
+ changelog_uri: https://github.com/marcoroth/lipgloss-ruby/releases
61
+ rubygems_mfa_required: 'true'
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '3.2'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: 3.5.dev
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 3.3.22
78
+ requirements: []
79
+ rubygems_version: 3.6.9
80
+ specification_version: 4
81
+ summary: Ruby wrapper for Charm's lipgloss CSS-like terminal styling library.
82
+ test_files: []