mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
ui: rename block to macro
It is a more precise name. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -6,8 +6,8 @@ type OpType byte
|
|||||||
const firstOpIndex = 200
|
const firstOpIndex = 200
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TypeBlockDef OpType = iota + firstOpIndex
|
TypeMacroDef OpType = iota + firstOpIndex
|
||||||
TypeBlock
|
TypeMacro
|
||||||
TypeTransform
|
TypeTransform
|
||||||
TypeLayer
|
TypeLayer
|
||||||
TypeInvalidate
|
TypeInvalidate
|
||||||
@@ -27,8 +27,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TypeBlockDefLen = 1 + 4 + 4
|
TypeMacroDefLen = 1 + 4 + 4
|
||||||
TypeBlockLen = 1 + 4 + 4 + 4
|
TypeMacroLen = 1 + 4 + 4 + 4
|
||||||
TypeTransformLen = 1 + 4*2
|
TypeTransformLen = 1 + 4*2
|
||||||
TypeLayerLen = 1
|
TypeLayerLen = 1
|
||||||
TypeRedrawLen = 1 + 8
|
TypeRedrawLen = 1 + 8
|
||||||
@@ -49,8 +49,8 @@ const (
|
|||||||
|
|
||||||
func (t OpType) Size() int {
|
func (t OpType) Size() int {
|
||||||
return [...]int{
|
return [...]int{
|
||||||
TypeBlockDefLen,
|
TypeMacroDefLen,
|
||||||
TypeBlockLen,
|
TypeMacroLen,
|
||||||
TypeTransformLen,
|
TypeTransformLen,
|
||||||
TypeLayerLen,
|
TypeLayerLen,
|
||||||
TypeRedrawLen,
|
TypeRedrawLen,
|
||||||
@@ -72,7 +72,7 @@ func (t OpType) Size() int {
|
|||||||
|
|
||||||
func (t OpType) NumRefs() int {
|
func (t OpType) NumRefs() int {
|
||||||
switch t {
|
switch t {
|
||||||
case TypeBlock, TypeImage, TypeKeyHandler, TypePointerHandler, TypeProfile:
|
case TypeMacro, TypeImage, TypeKeyHandler, TypePointerHandler, TypeProfile:
|
||||||
return 1
|
return 1
|
||||||
default:
|
default:
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
+5
-5
@@ -24,7 +24,7 @@ type Flex struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FlexChild struct {
|
type FlexChild struct {
|
||||||
block ui.BlockOp
|
macro ui.MacroOp
|
||||||
dims Dimens
|
dims Dimens
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ func (f *Flex) begin(mode flexMode) {
|
|||||||
panic("must End before adding a child")
|
panic("must End before adding a child")
|
||||||
}
|
}
|
||||||
f.mode = mode
|
f.mode = mode
|
||||||
f.ops.Begin()
|
f.ops.Record()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Flex) Rigid() Constraints {
|
func (f *Flex) Rigid() Constraints {
|
||||||
@@ -107,7 +107,7 @@ func (f *Flex) End(dims Dimens) FlexChild {
|
|||||||
if f.mode <= modeBegun {
|
if f.mode <= modeBegun {
|
||||||
panic("End called without an active child")
|
panic("End called without an active child")
|
||||||
}
|
}
|
||||||
block := f.ops.End()
|
macro := f.ops.Stop()
|
||||||
sz := axisMain(f.Axis, dims.Size)
|
sz := axisMain(f.Axis, dims.Size)
|
||||||
f.size += sz
|
f.size += sz
|
||||||
if f.mode == modeRigid {
|
if f.mode == modeRigid {
|
||||||
@@ -120,7 +120,7 @@ func (f *Flex) End(dims Dimens) FlexChild {
|
|||||||
if b := dims.Baseline; b > f.maxBaseline {
|
if b := dims.Baseline; b > f.maxBaseline {
|
||||||
f.maxBaseline = b
|
f.maxBaseline = b
|
||||||
}
|
}
|
||||||
return FlexChild{block, dims}
|
return FlexChild{macro, dims}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Flex) Layout(children ...FlexChild) Dimens {
|
func (f *Flex) Layout(children ...FlexChild) Dimens {
|
||||||
@@ -160,7 +160,7 @@ func (f *Flex) Layout(children ...FlexChild) Dimens {
|
|||||||
ui.TransformOp{
|
ui.TransformOp{
|
||||||
Transform: ui.Offset(toPointF(axisPoint(f.Axis, mainSize, cross))),
|
Transform: ui.Offset(toPointF(axisPoint(f.Axis, mainSize, cross))),
|
||||||
}.Add(f.ops)
|
}.Add(f.ops)
|
||||||
child.block.Add(f.ops)
|
child.macro.Add(f.ops)
|
||||||
ui.PopOp{}.Add(f.ops)
|
ui.PopOp{}.Add(f.ops)
|
||||||
mainSize += axisMain(f.Axis, dims.Size)
|
mainSize += axisMain(f.Axis, dims.Size)
|
||||||
if i < len(children)-1 {
|
if i < len(children)-1 {
|
||||||
|
|||||||
+3
-3
@@ -129,7 +129,7 @@ func (a *Align) Begin(ops *ui.Ops, cs Constraints) Constraints {
|
|||||||
a.begun = true
|
a.begun = true
|
||||||
a.ops = ops
|
a.ops = ops
|
||||||
a.cs = cs
|
a.cs = cs
|
||||||
ops.Begin()
|
ops.Record()
|
||||||
cs.Width.Min = 0
|
cs.Width.Min = 0
|
||||||
cs.Height.Min = 0
|
cs.Height.Min = 0
|
||||||
return cs
|
return cs
|
||||||
@@ -141,7 +141,7 @@ func (a *Align) End(dims Dimens) Dimens {
|
|||||||
}
|
}
|
||||||
a.begun = false
|
a.begun = false
|
||||||
ops := a.ops
|
ops := a.ops
|
||||||
block := ops.End()
|
macro := ops.Stop()
|
||||||
sz := dims.Size
|
sz := dims.Size
|
||||||
if sz.X < a.cs.Width.Min {
|
if sz.X < a.cs.Width.Min {
|
||||||
sz.X = a.cs.Width.Min
|
sz.X = a.cs.Width.Min
|
||||||
@@ -164,7 +164,7 @@ func (a *Align) End(dims Dimens) Dimens {
|
|||||||
}
|
}
|
||||||
ui.PushOp{}.Add(ops)
|
ui.PushOp{}.Add(ops)
|
||||||
ui.TransformOp{Transform: ui.Offset(toPointF(p))}.Add(ops)
|
ui.TransformOp{Transform: ui.Offset(toPointF(p))}.Add(ops)
|
||||||
block.Add(ops)
|
macro.Add(ops)
|
||||||
ui.PopOp{}.Add(ops)
|
ui.PopOp{}.Add(ops)
|
||||||
return Dimens{
|
return Dimens{
|
||||||
Size: sz,
|
Size: sz,
|
||||||
|
|||||||
+8
-8
@@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
type scrollChild struct {
|
type scrollChild struct {
|
||||||
size image.Point
|
size image.Point
|
||||||
block ui.BlockOp
|
macro ui.MacroOp
|
||||||
}
|
}
|
||||||
|
|
||||||
type List struct {
|
type List struct {
|
||||||
@@ -70,7 +70,7 @@ func (l *List) Init(ops *ui.Ops, cs Constraints, len int) {
|
|||||||
if l.first > len {
|
if l.first > len {
|
||||||
l.first = len
|
l.first = len
|
||||||
}
|
}
|
||||||
ops.Begin()
|
ops.Record()
|
||||||
l.Next()
|
l.Next()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ func (l *List) Next() {
|
|||||||
i = l.len - 1 - i
|
i = l.len - 1 - i
|
||||||
}
|
}
|
||||||
l.index = i
|
l.index = i
|
||||||
l.ops.Begin()
|
l.ops.Record()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Index is the current element index.
|
// Index is the current element index.
|
||||||
@@ -146,8 +146,8 @@ func (l *List) next() (int, bool) {
|
|||||||
|
|
||||||
// Elem completes an element.
|
// Elem completes an element.
|
||||||
func (l *List) Elem(dims Dimens) {
|
func (l *List) Elem(dims Dimens) {
|
||||||
block := l.ops.End()
|
macro := l.ops.Stop()
|
||||||
child := scrollChild{dims.Size, block}
|
child := scrollChild{dims.Size, macro}
|
||||||
switch l.dir {
|
switch l.dir {
|
||||||
case iterateForward:
|
case iterateForward:
|
||||||
mainSize := axisMain(l.Axis, child.size)
|
mainSize := axisMain(l.Axis, child.size)
|
||||||
@@ -227,7 +227,7 @@ func (l *List) Layout() Dimens {
|
|||||||
ui.TransformOp{
|
ui.TransformOp{
|
||||||
Transform: ui.Offset(toPointF(axisPoint(l.Axis, transPos, cross))),
|
Transform: ui.Offset(toPointF(axisPoint(l.Axis, transPos, cross))),
|
||||||
}.Add(ops)
|
}.Add(ops)
|
||||||
child.block.Add(ops)
|
child.macro.Add(ops)
|
||||||
ui.PopOp{}.Add(ops)
|
ui.PopOp{}.Add(ops)
|
||||||
pos += childSize
|
pos += childSize
|
||||||
}
|
}
|
||||||
@@ -237,9 +237,9 @@ func (l *List) Layout() Dimens {
|
|||||||
l.scroll.Stop()
|
l.scroll.Stop()
|
||||||
}
|
}
|
||||||
dims := axisPoint(l.Axis, mainc.Constrain(pos), maxCross)
|
dims := axisPoint(l.Axis, mainc.Constrain(pos), maxCross)
|
||||||
block := ops.End()
|
macro := ops.Stop()
|
||||||
pointer.RectAreaOp{Size: dims}.Add(ops)
|
pointer.RectAreaOp{Size: dims}.Add(ops)
|
||||||
l.scroll.Add(ops)
|
l.scroll.Add(ops)
|
||||||
block.Add(ops)
|
macro.Add(ops)
|
||||||
return Dimens{Size: dims}
|
return Dimens{Size: dims}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -20,7 +20,7 @@ type Stack struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type StackChild struct {
|
type StackChild struct {
|
||||||
block ui.BlockOp
|
macro ui.MacroOp
|
||||||
dims Dimens
|
dims Dimens
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ func (s *Stack) begin() {
|
|||||||
panic("must End before adding a child")
|
panic("must End before adding a child")
|
||||||
}
|
}
|
||||||
s.begun = true
|
s.begun = true
|
||||||
s.ops.Begin()
|
s.ops.Record()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stack) Rigid() Constraints {
|
func (s *Stack) Rigid() Constraints {
|
||||||
@@ -71,7 +71,7 @@ func (s *Stack) Expand() Constraints {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stack) End(dims Dimens) StackChild {
|
func (s *Stack) End(dims Dimens) StackChild {
|
||||||
b := s.ops.End()
|
b := s.ops.Stop()
|
||||||
s.begun = false
|
s.begun = false
|
||||||
if w := dims.Size.X; w > s.maxSZ.X {
|
if w := dims.Size.X; w > s.maxSZ.X {
|
||||||
s.maxSZ.X = w
|
s.maxSZ.X = w
|
||||||
@@ -105,7 +105,7 @@ func (s *Stack) Layout(children ...StackChild) Dimens {
|
|||||||
}
|
}
|
||||||
ui.PushOp{}.Add(s.ops)
|
ui.PushOp{}.Add(s.ops)
|
||||||
ui.TransformOp{Transform: ui.Offset(toPointF(p))}.Add(s.ops)
|
ui.TransformOp{Transform: ui.Offset(toPointF(p))}.Add(s.ops)
|
||||||
ch.block.Add(s.ops)
|
ch.macro.Add(s.ops)
|
||||||
ui.PopOp{}.Add(s.ops)
|
ui.PopOp{}.Add(s.ops)
|
||||||
}
|
}
|
||||||
b := s.baseline
|
b := s.baseline
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type cachedLayout struct {
|
|||||||
|
|
||||||
type cachedPath struct {
|
type cachedPath struct {
|
||||||
active bool
|
active bool
|
||||||
path ui.BlockOp
|
path ui.MacroOp
|
||||||
}
|
}
|
||||||
|
|
||||||
type layoutKey struct {
|
type layoutKey struct {
|
||||||
@@ -119,7 +119,7 @@ func (f *textFace) Layout(str string, opts text.LayoutOptions) *text.Layout {
|
|||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *textFace) Path(str text.String) ui.BlockOp {
|
func (f *textFace) Path(str text.String) ui.MacroOp {
|
||||||
ppem := fixed.Int26_6(f.faces.Config.Px(f.size) * 64)
|
ppem := fixed.Int26_6(f.faces.Config.Px(f.size) * 64)
|
||||||
pk := pathKey{
|
pk := pathKey{
|
||||||
f: f.font.Font,
|
f: f.font.Font,
|
||||||
@@ -227,14 +227,14 @@ func layoutText(ppem fixed.Int26_6, str string, f *opentype, opts text.LayoutOpt
|
|||||||
return &text.Layout{Lines: lines}
|
return &text.Layout{Lines: lines}
|
||||||
}
|
}
|
||||||
|
|
||||||
func textPath(ppem fixed.Int26_6, f *opentype, str text.String) ui.BlockOp {
|
func textPath(ppem fixed.Int26_6, f *opentype, str text.String) ui.MacroOp {
|
||||||
var lastPos f32.Point
|
var lastPos f32.Point
|
||||||
var builder draw.PathBuilder
|
var builder draw.PathBuilder
|
||||||
ops := new(ui.Ops)
|
ops := new(ui.Ops)
|
||||||
builder.Init(ops)
|
builder.Init(ops)
|
||||||
var x fixed.Int26_6
|
var x fixed.Int26_6
|
||||||
var advIdx int
|
var advIdx int
|
||||||
ops.Begin()
|
ops.Record()
|
||||||
for _, r := range str.String {
|
for _, r := range str.String {
|
||||||
if !unicode.IsSpace(r) {
|
if !unicode.IsSpace(r) {
|
||||||
segs, ok := f.LoadGlyph(ppem, r)
|
segs, ok := f.LoadGlyph(ppem, r)
|
||||||
@@ -287,5 +287,5 @@ func textPath(ppem fixed.Int26_6, f *opentype, str text.String) ui.BlockOp {
|
|||||||
advIdx++
|
advIdx++
|
||||||
}
|
}
|
||||||
builder.End()
|
builder.End()
|
||||||
return ops.End()
|
return ops.Stop()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
// Ops holds a list of serialized Ops.
|
// Ops holds a list of serialized Ops.
|
||||||
type Ops struct {
|
type Ops struct {
|
||||||
// Stack of block start indices.
|
// Stack of macro start indices.
|
||||||
stack []pc
|
stack []pc
|
||||||
ops opsData
|
ops opsData
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ type opsData struct {
|
|||||||
// OpsReader parses an ops list. Internal use only.
|
// OpsReader parses an ops list. Internal use only.
|
||||||
type OpsReader struct {
|
type OpsReader struct {
|
||||||
pc pc
|
pc pc
|
||||||
stack []block
|
stack []macro
|
||||||
ops *opsData
|
ops *opsData
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ type OpKey struct {
|
|||||||
version int
|
version int
|
||||||
}
|
}
|
||||||
|
|
||||||
type block struct {
|
type macro struct {
|
||||||
ops *opsData
|
ops *opsData
|
||||||
retPC pc
|
retPC pc
|
||||||
endPC pc
|
endPC pc
|
||||||
@@ -64,13 +64,13 @@ type PushOp struct{}
|
|||||||
|
|
||||||
type PopOp struct{}
|
type PopOp struct{}
|
||||||
|
|
||||||
type BlockOp struct {
|
type MacroOp struct {
|
||||||
ops *opsData
|
ops *opsData
|
||||||
version int
|
version int
|
||||||
pc pc
|
pc pc
|
||||||
}
|
}
|
||||||
|
|
||||||
type opBlockDef struct {
|
type opMacroDef struct {
|
||||||
endpc pc
|
endpc pc
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,11 +86,12 @@ func (p PopOp) Add(o *Ops) {
|
|||||||
o.Write([]byte{byte(ops.TypePop)})
|
o.Write([]byte{byte(ops.TypePop)})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Begin a block of ops.
|
// Record starts recording a macro. Multiple simultaneous
|
||||||
func (o *Ops) Begin() {
|
// recordings are supported. Stop ends the most recent.
|
||||||
|
func (o *Ops) Record() {
|
||||||
o.stack = append(o.stack, o.ops.pc())
|
o.stack = append(o.stack, o.ops.pc())
|
||||||
// Make room for a block definition. Filled out in End.
|
// Make room for a macro definition. Filled out in Stop.
|
||||||
o.Write(make([]byte, ops.TypeBlockDefLen))
|
o.Write(make([]byte, ops.TypeMacroDefLen))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (op *opAux) decode(data []byte) {
|
func (op *opAux) decode(data []byte) {
|
||||||
@@ -103,14 +104,14 @@ func (op *opAux) decode(data []byte) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (op *opBlockDef) decode(data []byte) {
|
func (op *opMacroDef) decode(data []byte) {
|
||||||
if ops.OpType(data[0]) != ops.TypeBlockDef {
|
if ops.OpType(data[0]) != ops.TypeMacroDef {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
dataIdx := int(bo.Uint32(data[1:]))
|
dataIdx := int(bo.Uint32(data[1:]))
|
||||||
refsIdx := int(bo.Uint32(data[5:]))
|
refsIdx := int(bo.Uint32(data[5:]))
|
||||||
*op = opBlockDef{
|
*op = opMacroDef{
|
||||||
endpc: pc{
|
endpc: pc{
|
||||||
data: dataIdx,
|
data: dataIdx,
|
||||||
refs: refsIdx,
|
refs: refsIdx,
|
||||||
@@ -118,22 +119,22 @@ func (op *opBlockDef) decode(data []byte) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// End the most recent block and return
|
// Stop the most recent recording and return the macro for later
|
||||||
// an op for invoking the completed block.
|
// use.
|
||||||
func (o *Ops) End() BlockOp {
|
func (o *Ops) Stop() MacroOp {
|
||||||
if len(o.stack) == 0 {
|
if len(o.stack) == 0 {
|
||||||
panic(errors.New("End with no matching Begin"))
|
panic(errors.New("not recording a macro"))
|
||||||
}
|
}
|
||||||
start := o.stack[len(o.stack)-1]
|
start := o.stack[len(o.stack)-1]
|
||||||
o.stack = o.stack[:len(o.stack)-1]
|
o.stack = o.stack[:len(o.stack)-1]
|
||||||
pc := o.ops.pc()
|
pc := o.ops.pc()
|
||||||
// Write the block header reserved in Begin.
|
// Write the macro header reserved in Begin.
|
||||||
data := o.ops.data[start.data : start.data+ops.TypeBlockDefLen]
|
data := o.ops.data[start.data : start.data+ops.TypeMacroDefLen]
|
||||||
data[0] = byte(ops.TypeBlockDef)
|
data[0] = byte(ops.TypeMacroDef)
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
bo.PutUint32(data[1:], uint32(pc.data))
|
bo.PutUint32(data[1:], uint32(pc.data))
|
||||||
bo.PutUint32(data[5:], uint32(pc.refs))
|
bo.PutUint32(data[5:], uint32(pc.refs))
|
||||||
return BlockOp{ops: &o.ops, pc: start, version: o.ops.version}
|
return MacroOp{ops: &o.ops, pc: start, version: o.ops.version}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the Ops, preparing it for re-use.
|
// Reset the Ops, preparing it for re-use.
|
||||||
@@ -198,15 +199,15 @@ func (d *opsData) pc() pc {
|
|||||||
return pc{data: len(d.data), refs: len(d.refs)}
|
return pc{data: len(d.data), refs: len(d.refs)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BlockOp) decode(data []byte, refs []interface{}) {
|
func (b *MacroOp) decode(data []byte, refs []interface{}) {
|
||||||
if ops.OpType(data[0]) != ops.TypeBlock {
|
if ops.OpType(data[0]) != ops.TypeMacro {
|
||||||
panic("invalid op")
|
panic("invalid op")
|
||||||
}
|
}
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
dataIdx := int(bo.Uint32(data[1:]))
|
dataIdx := int(bo.Uint32(data[1:]))
|
||||||
refsIdx := int(bo.Uint32(data[5:]))
|
refsIdx := int(bo.Uint32(data[5:]))
|
||||||
version := int(bo.Uint32(data[9:]))
|
version := int(bo.Uint32(data[9:]))
|
||||||
*b = BlockOp{
|
*b = MacroOp{
|
||||||
ops: refs[0].(*opsData),
|
ops: refs[0].(*opsData),
|
||||||
pc: pc{
|
pc: pc{
|
||||||
data: dataIdx,
|
data: dataIdx,
|
||||||
@@ -216,12 +217,12 @@ func (b *BlockOp) decode(data []byte, refs []interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BlockOp) Add(o *Ops) {
|
func (b MacroOp) Add(o *Ops) {
|
||||||
if b.ops == nil {
|
if b.ops == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := make([]byte, ops.TypeBlockLen)
|
data := make([]byte, ops.TypeMacroLen)
|
||||||
data[0] = byte(ops.TypeBlock)
|
data[0] = byte(ops.TypeMacro)
|
||||||
bo := binary.LittleEndian
|
bo := binary.LittleEndian
|
||||||
bo.PutUint32(data[1:], uint32(b.pc.data))
|
bo.PutUint32(data[1:], uint32(b.pc.data))
|
||||||
bo.PutUint32(data[5:], uint32(b.pc.refs))
|
bo.PutUint32(data[5:], uint32(b.pc.refs))
|
||||||
@@ -272,33 +273,33 @@ func (r *OpsReader) Decode() (EncodedOp, bool) {
|
|||||||
op.decode(data)
|
op.decode(data)
|
||||||
n += op.len
|
n += op.len
|
||||||
data = r.ops.data[r.pc.data : r.pc.data+n]
|
data = r.ops.data[r.pc.data : r.pc.data+n]
|
||||||
case ops.TypeBlock:
|
case ops.TypeMacro:
|
||||||
var op BlockOp
|
var op MacroOp
|
||||||
op.decode(data, refs)
|
op.decode(data, refs)
|
||||||
blockOps := op.ops
|
macroOps := op.ops
|
||||||
if ops.OpType(blockOps.data[op.pc.data]) != ops.TypeBlockDef {
|
if ops.OpType(macroOps.data[op.pc.data]) != ops.TypeMacroDef {
|
||||||
panic("invalid block reference")
|
panic("invalid macro reference")
|
||||||
}
|
}
|
||||||
if op.version != op.ops.version {
|
if op.version != op.ops.version {
|
||||||
panic("invalid BlockOp reference to reset Ops")
|
panic("invalid MacroOp reference to reset Ops")
|
||||||
}
|
}
|
||||||
var opDef opBlockDef
|
var opDef opMacroDef
|
||||||
opDef.decode(blockOps.data[op.pc.data : op.pc.data+ops.TypeBlockDef.Size()])
|
opDef.decode(macroOps.data[op.pc.data : op.pc.data+ops.TypeMacroDef.Size()])
|
||||||
retPC := r.pc
|
retPC := r.pc
|
||||||
retPC.data += n
|
retPC.data += n
|
||||||
retPC.refs += nrefs
|
retPC.refs += nrefs
|
||||||
r.stack = append(r.stack, block{
|
r.stack = append(r.stack, macro{
|
||||||
ops: r.ops,
|
ops: r.ops,
|
||||||
retPC: retPC,
|
retPC: retPC,
|
||||||
endPC: opDef.endpc,
|
endPC: opDef.endpc,
|
||||||
})
|
})
|
||||||
r.ops = blockOps
|
r.ops = macroOps
|
||||||
r.pc = op.pc
|
r.pc = op.pc
|
||||||
r.pc.data += ops.TypeBlockDef.Size()
|
r.pc.data += ops.TypeMacroDef.Size()
|
||||||
r.pc.refs += ops.TypeBlockDef.NumRefs()
|
r.pc.refs += ops.TypeMacroDef.NumRefs()
|
||||||
continue
|
continue
|
||||||
case ops.TypeBlockDef:
|
case ops.TypeMacroDef:
|
||||||
var op opBlockDef
|
var op opMacroDef
|
||||||
op.decode(data)
|
op.decode(data)
|
||||||
r.pc = op.endpc
|
r.pc = op.endpc
|
||||||
continue
|
continue
|
||||||
|
|||||||
+2
-2
@@ -28,9 +28,9 @@ type Editor struct {
|
|||||||
SingleLine bool
|
SingleLine bool
|
||||||
Submit bool
|
Submit bool
|
||||||
|
|
||||||
Material ui.BlockOp
|
Material ui.MacroOp
|
||||||
Hint string
|
Hint string
|
||||||
HintMaterial ui.BlockOp
|
HintMaterial ui.MacroOp
|
||||||
|
|
||||||
oldScale int
|
oldScale int
|
||||||
blinkStart time.Time
|
blinkStart time.Time
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ import (
|
|||||||
|
|
||||||
type Label struct {
|
type Label struct {
|
||||||
Face Face
|
Face Face
|
||||||
Material ui.BlockOp
|
Material ui.MacroOp
|
||||||
Alignment Alignment
|
Alignment Alignment
|
||||||
Text string
|
Text string
|
||||||
MaxLines int
|
MaxLines int
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ type LayoutOptions struct {
|
|||||||
|
|
||||||
type Face interface {
|
type Face interface {
|
||||||
Layout(str string, opts LayoutOptions) *Layout
|
Layout(str string, opts LayoutOptions) *Layout
|
||||||
Path(str String) ui.BlockOp
|
Path(str String) ui.MacroOp
|
||||||
}
|
}
|
||||||
|
|
||||||
type Alignment uint8
|
type Alignment uint8
|
||||||
|
|||||||
Reference in New Issue
Block a user