File: cell.go

package info (click to toggle)
golang-github-olekukonko-tablewriter 1.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid
  • size: 1,380 kB
  • sloc: makefile: 4
file content (64 lines) | stat: -rw-r--r-- 2,327 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package tw

// CellFormatting holds formatting options for table cells.
type CellFormatting struct {
	AutoWrap  int // Wrapping behavior (e.g., WrapTruncate, WrapNormal)
	MergeMode int // Bitmask for merge behavior (e.g., MergeHorizontal, MergeVertical)

	// Changed form bool to State
	// See https://github.com/olekukonko/tablewriter/issues/261
	AutoFormat State // Enables automatic formatting (e.g., title case for headers)

	// Deprecated: kept for compatibility
	// will be removed soon
	Alignment Align // Text alignment within the cell (e.g., Left, Right, Center)

}

// CellPadding defines padding settings for table cells.
type CellPadding struct {
	Global    Padding   // Default padding applied to all cells
	PerColumn []Padding // Column-specific padding overrides
}

// CellFilter defines filtering functions for cell content.
type CellFilter struct {
	Global    func([]string) []string // Processes the entire row
	PerColumn []func(string) string   // Processes individual cells by column
}

// CellCallbacks holds callback functions for cell processing.
// Note: These are currently placeholders and not fully implemented.
type CellCallbacks struct {
	Global    func()   // Global callback applied to all cells
	PerColumn []func() // Column-specific callbacks
}

// CellAlignment defines alignment settings for table cells.
type CellAlignment struct {
	Global    Align   // Default alignment applied to all cells
	PerColumn []Align // Column-specific alignment overrides
}

// CellConfig combines formatting, padding, and callback settings for a table section.
type CellConfig struct {
	Formatting   CellFormatting // Cell formatting options
	Padding      CellPadding    // Padding configuration
	Callbacks    CellCallbacks  // Callback functions (unused)
	Filter       CellFilter     // Function to filter cell content (renamed from Filter Filter)
	Alignment    CellAlignment  // Alignment configuration for cells
	ColMaxWidths CellWidth      // Per-column maximum width overrides

	// Deprecated: use Alignment.PerColumn instead. Will be removed in a future version.
	// will be removed soon
	ColumnAligns []Align // Per-column alignment overrides
}

type CellWidth struct {
	Global    int
	PerColumn Mapper[int, int]
}

func (c CellWidth) Constrained() bool {
	return c.Global > 0 || c.PerColumn.Len() > 0
}