-
Notifications
You must be signed in to change notification settings - Fork 3
/
flags.go
58 lines (52 loc) · 1.43 KB
/
flags.go
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
package internals
// TypeContent is the type of content, used for enums
type TypeContent uint8
const (
// TypeHeading is the type of heading
TypeHeading TypeContent = iota
// TypeParagraph is the type of paragraph, which is just text
TypeParagraph
// TypeList is the type of unordered list
TypeList
// TypeListNumbered is the type of numbered list
TypeListNumbered
// TypeLink is the type of link
TypeLink
// TypeSourceCode is the type of source code block
TypeSourceCode
// TypeRawHTML is the type of raw HTML block
TypeRawHTML
// TypeHorizontalLine is the type of horizontal line
TypeHorizontalLine
// TypeAttentionText is the type of attention text block
TypeAttentionText
// TypeTable is the type of a table
TypeTable
// TypeDetails is the type for html details
TypeDetails
)
type Bits uint16
const (
InListFlag Bits = 1 << iota
InTableFlag
InTableHasHeadersFlag
InSourceCodeFlag
InRawHTMLFlag
InQuoteFlag
InCenterFlag
InDetailsFlag
InDropCapFlag
)
var (
LatchFlags = func(v *Bits) (
func(f Bits), func(f Bits), func(f Bits), func(f Bits) bool) {
return func(f Bits) { AddFlag(v, f) },
func(f Bits) { RemoveFlag(v, f) },
func(f Bits) { FlipFlag(v, f) },
func(f Bits) bool { return HasFlag(v, f) }
}
AddFlag = func(v *Bits, f Bits) { *v |= f }
RemoveFlag = func(v *Bits, f Bits) { *v &^= f }
FlipFlag = func(v *Bits, f Bits) { *v ^= f }
HasFlag = func(v *Bits, f Bits) bool { return *v&f != 0 }
)