code-surfer icon indicating copy to clipboard operation
code-surfer copied to clipboard

Support for animations that update a line

Open meithecatte opened this issue 5 years ago • 1 comments

Say you want to modify the code slightly in the next slide:

[](string const &L, string const &R) {
// to
[](string const &L, string const &R) -> bool {

It would be nice if the modified part of the line appeared, instead of the entire line disappearing and appearing again.

(Is this already supported? If so, I missed it in the documentation. If you don't have the time to implement this, but wouldn't mind a PR, I'd appreciate your insight as to how to fit this into the infrastructure of your code)

meithecatte avatar May 08 '20 19:05 meithecatte

One of the questions here is how to make code surfer aware which "words" should go where. For instance, it might be complicated in case the line is moved and altered at the same time.

It would be nice to be able to specify which words go where.

For instance:

public static void main(String[] args) {
  int x = 2;
  int y = 5;
  assert x + 3 == y * 2;
}

=>

public static void main(String[] args) {
  RecorderRuntime $rr = new RecorderRuntime();
  $rr.powerAssert(
    "x + 3 == y * 2",
    $rr.recordValue(
      $rr.recordValue($rr.recordValue(x, 144) + 3, 146) ==
      $rr.recordValue($rr.recordValue(y, 153) * 2, 155),
      153
    ),
    144
  );
}

Note how x + 3 == y * 2 is still visible on the second source (see $rr.recordValue(x, 144) + 3).

I wonder if the following might work. Then, the markup can be made less verbose by using Unicode characters (which is way less likely to clash with existing code).

public static void main(String[] args) {
  int x = 2;
  int y = 5;
  assert @@<var_x[x]>@@ + @@<var_plus3[3]>@@ == y * 2;
}
public static void main(String[] args) {
  RecorderRuntime $rr = new RecorderRuntime();
  $rr.powerAssert(
    "x + 3 == y * 2",
    $rr.recordValue(
      $rr.recordValue($rr.recordValue(@@<var_x[x]>@@, 144) @@<var_plus3[+ 3]>@@, 146) ==
      $rr.recordValue($rr.recordValue(y, 153) * 2, 155),
      153
    ),
    144
  );
}

vlsi avatar Jul 03 '20 11:07 vlsi