all: remove exported Decode methods on operations

Add decode functions to the packages that need them instead. For
TransformOp that is used in multiple packages, add the decode
function to the internal ops package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-08-07 15:52:22 +02:00
parent 4d66669a9e
commit 6e26c92c75
10 changed files with 141 additions and 136 deletions
+11 -2
View File
@@ -97,8 +97,7 @@ loop:
for encOp, ok := q.reader.Decode(); ok; encOp, ok = q.reader.Decode() {
switch opconst.OpType(encOp.Data[0]) {
case opconst.TypeKeyHandler:
var op key.HandlerOp
op.Decode(encOp.Data, encOp.Refs)
op := decodeKeyHandlerOp(encOp.Data, encOp.Refs)
var newPri listenerPriority
switch {
case op.Focus:
@@ -139,3 +138,13 @@ func (p listenerPriority) replaces(p2 listenerPriority) bool {
// Favor earliest default focus or latest requested focus.
return p > p2 || p == p2 && p == priNewFocus
}
func decodeKeyHandlerOp(d []byte, refs []interface{}) key.HandlerOp {
if opconst.OpType(d[0]) != opconst.TypeKeyHandler {
panic("invalid op")
}
return key.HandlerOp{
Focus: d[1] != 0,
Key: refs[0].(input.Key),
}
}