mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
op: change signature of Ops.Write
By returning the allocated data buffer, Ops can become an interface in a future change without forcing operations to allocate. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+2
-4
@@ -89,18 +89,16 @@ func (m Modifiers) Contain(m2 Modifiers) bool {
|
||||
}
|
||||
|
||||
func (h InputOp) Add(o *op.Ops) {
|
||||
data := make([]byte, opconst.TypeKeyInputLen)
|
||||
data := o.Write(opconst.TypeKeyInputLen, h.Key)
|
||||
data[0] = byte(opconst.TypeKeyInput)
|
||||
if h.Focus {
|
||||
data[1] = 1
|
||||
}
|
||||
o.Write(data, h.Key)
|
||||
}
|
||||
|
||||
func (h HideInputOp) Add(o *op.Ops) {
|
||||
data := make([]byte, opconst.TypeHideInputLen)
|
||||
data := o.Write(opconst.TypeHideInputLen)
|
||||
data[0] = byte(opconst.TypeHideInput)
|
||||
o.Write(data)
|
||||
}
|
||||
|
||||
func (EditEvent) ImplementsEvent() {}
|
||||
|
||||
@@ -136,7 +136,7 @@ func (op EllipseAreaOp) Add(ops *op.Ops) {
|
||||
}
|
||||
|
||||
func (op areaOp) add(o *op.Ops) {
|
||||
data := make([]byte, opconst.TypeAreaLen)
|
||||
data := o.Write(opconst.TypeAreaLen)
|
||||
data[0] = byte(opconst.TypeArea)
|
||||
data[1] = byte(op.kind)
|
||||
bo := binary.LittleEndian
|
||||
@@ -144,25 +144,22 @@ func (op areaOp) add(o *op.Ops) {
|
||||
bo.PutUint32(data[6:], uint32(op.rect.Min.Y))
|
||||
bo.PutUint32(data[10:], uint32(op.rect.Max.X))
|
||||
bo.PutUint32(data[14:], uint32(op.rect.Max.Y))
|
||||
o.Write(data)
|
||||
}
|
||||
|
||||
func (h InputOp) Add(o *op.Ops) {
|
||||
data := make([]byte, opconst.TypePointerInputLen)
|
||||
data := o.Write(opconst.TypePointerInputLen, h.Key)
|
||||
data[0] = byte(opconst.TypePointerInput)
|
||||
if h.Grab {
|
||||
data[1] = 1
|
||||
}
|
||||
o.Write(data, h.Key)
|
||||
}
|
||||
|
||||
func (op PassOp) Add(o *op.Ops) {
|
||||
data := make([]byte, opconst.TypePassLen)
|
||||
data := o.Write(opconst.TypePassLen)
|
||||
data[0] = byte(opconst.TypePass)
|
||||
if op.Pass {
|
||||
data[1] = 1
|
||||
}
|
||||
o.Write(data)
|
||||
}
|
||||
|
||||
func (t Type) String() string {
|
||||
|
||||
@@ -24,9 +24,8 @@ type Event struct {
|
||||
}
|
||||
|
||||
func (p Op) Add(o *op.Ops) {
|
||||
data := make([]byte, opconst.TypeProfileLen)
|
||||
data := o.Write(opconst.TypeProfileLen, p.Key)
|
||||
data[0] = byte(opconst.TypeProfile)
|
||||
o.Write(data, p.Key)
|
||||
}
|
||||
|
||||
func (p Event) ImplementsEvent() {}
|
||||
|
||||
Reference in New Issue
Block a user