rf icon indicating copy to clipboard operation
rf copied to clipboard

rf: ex and replace one statement with a couple of statements

Open sbinet opened this issue 5 years ago • 2 comments

hi,

I've tried to use rf ex to replace one statement with a pair of statements.

I tried the following:

      ex {
            import "gioui.org/op";
            import "gioui.org/op/clip";
    
            var o *op.Ops;
            var p clip.Path;
            var sty clip.StrokeStyle;
            var width float32;
    
            p.Stroke(width, sty).Add(o) ->  \
                    p.Op().Add(o)           \
                    clip.StrokeOp{          \
                            Width: width,   \
                            Cap: sty.Cap,   \
                            Join: sty.Join, \
                    }.Add(o);
      }

ie: replacing:

p.Stroke(width, sty).Add(o)

with:

p.Op().Add(o)
clip.StrokeOp{
    Width: width,
    Cap: sty.Cap,
    Join: sty.Join,
}

trying to run the above ex script, I get:

$> rf ex ...
ex: missing substitution in example: p.Stroke(width, sty).Add(o) ->

is this something that should be possible to achieve with rf ex (or with rf at all) ?

sbinet avatar Dec 07 '20 09:12 sbinet

ex currently only supports replacement with a single statement.

mdempsky avatar Dec 07 '20 20:12 mdempsky

I suppose we could make it so that if you do -> { ... } then maybe we could drop the { } during the insert, although then if you want braces you'd have to double them I guess. Worth keeping mind for the next iteration but for now unlikely to happen.

rsc avatar Dec 10 '20 01:12 rsc