forked from BambooEngine/goibus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext.go
More file actions
57 lines (48 loc) · 1.2 KB
/
text.go
File metadata and controls
57 lines (48 loc) · 1.2 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
package goibus
import (
"github.com/godbus/dbus/v5"
)
type Attribute struct {
Name string
Attachments map[string]dbus.Variant
Type uint32
Value uint32
StartIndex uint32
EndIndex uint32
}
type AttrList struct {
Name string
Attachments map[string]dbus.Variant
Attributes []dbus.Variant
}
type Text struct {
Name string
Attachments map[string]dbus.Variant
Text string
AttrList dbus.Variant
}
func NewAttribute(attrType, attrValue, startIndex uint32, endIndex uint32) *Attribute {
var attr = Attribute{
Name: "IBusAttribute",
Type: attrType,
Value: attrValue,
StartIndex: startIndex,
EndIndex: endIndex,
}
return &attr
}
func (t *Text) AppendAttr(attrType, attrValue, startIndex uint32, endIndex uint32) {
attrList := &AttrList{}
attrList.Name = "IBusAttrList"
attrList.Attributes = append(attrList.Attributes, dbus.MakeVariant(*NewAttribute(attrType, attrValue, startIndex, endIndex)))
t.AttrList = dbus.MakeVariant(*attrList)
}
func NewText(text string) *Text {
attrList := AttrList{}
attrList.Name = "IBusAttrList"
t := Text{}
t.Name = "IBusText"
t.Text = text
t.AttrList = dbus.MakeVariant(attrList)
return &t
}