-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdefault_registry.go
More file actions
84 lines (71 loc) · 2.69 KB
/
default_registry.go
File metadata and controls
84 lines (71 loc) · 2.69 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (c) Liam Stanley <[email protected]>. All rights reserved. Use of
// this source code is governed by the MIT license that can be found in
// the LICENSE file.
package tint
// Register registers one or more tints, using the default registry. It does not
// change to the provided tint.
func Register(tint ...*Tint) {
DefaultRegistry.Register(tint...)
}
// Unregister unregisters one or more provided tints, using the default registry.
func Unregister(tint ...*Tint) {
DefaultRegistry.Unregister(tint...)
}
// UnregisterIDs unregisters the tints with the provided ID(s), using the default
// registry.
func UnregisterIDs(id ...string) {
DefaultRegistry.UnregisterIDs(id...)
}
// UnregisterAll unregisters all tints, using the default registry.
func UnregisterAll() {
DefaultRegistry.UnregisterAll()
}
// Tints returns a list of all registered tints, sorted alphabetically by their ID,
// using the default registry.
func Tints() []*Tint {
return DefaultRegistry.Tints()
}
// TintIDs returns a list of all registered tint IDs, sorted alphabetically by their
// ID, using the default registry.
func TintIDs() (ids []string) { //nolint:revive
return DefaultRegistry.TintIDs()
}
// GetTint returns the tint with the provided ID, or nil if it doesn't exist, using
// the default registry.
func GetTint(id string) (tint *Tint, ok bool) {
return DefaultRegistry.GetTint(id)
}
// SetTint sets the current tint to the provided tint, and adds it to the list of
// registered tints if it isn't already, using the default registry. Panics if the
// provided tint is nil.
func SetTint(tint *Tint) {
DefaultRegistry.SetTint(tint)
}
// SetTintID sets the current tint to the provided tint ID, using the default
// registry.
func SetTintID(id string) (ok bool) {
return DefaultRegistry.SetTintID(id)
}
// PreviousTint sets the current tint to the previous tint in the list of
// registered tints, using the default registry. If the current tint is the first
// tint in the list, it will pin to the first tint in the list (i.e. won't rollback
// to the end).
//
// PreviousTint uses a sorted list of tint IDs.
func PreviousTint() {
DefaultRegistry.PreviousTint()
}
// NextTint sets the current tint to the next tint in the list of registered
// tints, using the default registry. If the current tint is the last tint in the
// list, it will pin to the last tint in the list (i.e. won't rollback to the start).
//
// NextTint uses a sorted list of tint IDs.
func NextTint() {
DefaultRegistry.NextTint()
}
// Current returns the current tint, using the default registry. Panics if no tint
// has been set yet, and the registry has no tints registered that it can fall back
// to.
func Current() (tint *Tint) {
return DefaultRegistry.Current()
}