about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-05-19 12:22:59 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-05-19 12:27:00 -0700
commit02a35f220553b01e09c64383e6c05e86a5c61c15 (patch)
treedc985958f12016c002d004d46afc32e3d8b2aa07
parentdd30f56dbebc54957a87d100a53415de743c7f57 (diff)
downloadmu-02a35f220553b01e09c64383e6c05e86a5c61c15.tar.gz
2978 - support new 'edit' button in edit/
-rw-r--r--edit/006-sandbox-edit.mu121
-rw-r--r--edit/007-sandbox-delete.mu4
-rw-r--r--edit/010-errors.mu2
3 files changed, 101 insertions, 26 deletions
diff --git a/edit/006-sandbox-edit.mu b/edit/006-sandbox-edit.mu
index a9256096..edea112d 100644
--- a/edit/006-sandbox-edit.mu
+++ b/edit/006-sandbox-edit.mu
@@ -25,9 +25,69 @@ recipe foo [
     .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
     .                                                  ┊                                                 .
   ]
-  # click somewhere in the first row of the sandbox
+  # click at left edge of edit button
   assume-console [
-    left-click 3, 90
+    left-click 3, 55
+  ]
+  run [
+    event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
+  ]
+  # it pops back into editor
+  screen-should-contain [
+    .                                                                                 run (F4)           .
+    .                                                  ┊foo                                              .
+    .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  reply 4                                         ┊                                                 .
+    .]                                                 ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+  # cursor should be in the right place
+  assume-console [
+    type [0]
+  ]
+  run [
+    event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .                                                                                 run (F4)           .
+    .                                                  ┊0foo                                             .
+    .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  reply 4                                         ┊                                                 .
+    .]                                                 ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+]
+
+scenario clicking-on-a-sandbox-moves-it-to-editor-2 [
+  trace-until 100/app  # trace too long
+  assume-screen 100/width, 10/height
+  # basic recipe
+  1:address:array:character <- new [ 
+recipe foo [
+  reply 4
+]]
+  # run it
+  2:address:array:character <- new [foo]
+  assume-console [
+    press F4
+  ]
+  3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
+  event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
+  screen-should-contain [
+    .                                                                                 run (F4)           .
+    .                                                  ┊                                                 .
+    .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  reply 4                                         ┊0   edit          copy            delete         .
+    .]                                                 ┊foo                                              .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4                                                .
+    .                                                  ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .                                                  ┊                                                 .
+  ]
+  # click at right edge of edit button (just before 'copy')
+  assume-console [
+    left-click 3, 68
   ]
   run [
     event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
@@ -63,24 +123,8 @@ recipe foo [
 after <global-touch> [
   # below sandbox editor? pop appropriate sandbox contents back into sandbox editor
   {
-    sandbox-left-margin:number <- get *current-sandbox, left:offset
-    click-column:number <- get t, column:offset
-    on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin
-    break-unless on-sandbox-side?
-    first-sandbox:address:sandbox-data <- get *env, sandbox:offset
-    break-unless first-sandbox
-    first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset
-    click-row:number <- get t, row:offset
-    below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins
-    break-unless below-sandbox-editor?
-    empty-sandbox-editor?:boolean <- empty-editor? current-sandbox
-    break-unless empty-sandbox-editor?  # don't clobber existing contents
-    # identify the sandbox to edit and remove it from the sandbox list
-    sandbox:address:sandbox-data <- extract-sandbox env, click-row
-    break-unless sandbox
-    text:address:array:character <- get *sandbox, data:offset
-    current-sandbox <- insert-text current-sandbox, text
-    *env <- put *env, render-from:offset, -1
+    was-edit?:boolean <- try-edit-sandbox t, env
+    break-unless was-edit?
     hide-screen screen
     screen <- render-sandbox-side screen, env
     screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
@@ -89,6 +133,37 @@ after <global-touch> [
   }
 ]
 
+def try-edit-sandbox t:touch-event, env:address:programming-environment-data -> was-edit?:boolean, env:address:programming-environment-data [
+  local-scope
+  load-ingredients
+  click-column:number <- get t, column:offset
+  current-sandbox:address:editor-data <- get *env, current-sandbox:offset
+  sandbox-left-margin:number <- get *current-sandbox, left:offset
+  on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin
+  return-unless on-sandbox-side?, 0/false
+  first-sandbox:address:sandbox-data <- get *env, sandbox:offset
+  return-unless first-sandbox, 0/false
+  first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset
+  click-row:number <- get t, row:offset
+  below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins
+  return-unless below-sandbox-editor?, 0/false
+  empty-sandbox-editor?:boolean <- empty-editor? current-sandbox
+  return-unless empty-sandbox-editor?, 0/false  # don't clobber existing contents
+  sandbox-right-margin:number <- get *current-sandbox, right:offset
+  edit-button-left:number, edit-button-right:number, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin
+  left-of-edit-button?:boolean <- lesser-than click-column, edit-button-left
+  return-if left-of-edit-button?, 0/false
+  right-of-edit-button?:boolean <- greater-than click-column, edit-button-right
+  return-if right-of-edit-button?, 0/false
+  # identify the sandbox to edit and remove it from the sandbox list
+  sandbox:address:sandbox-data <- extract-sandbox env, click-row
+  return-unless sandbox, 0/false
+  text:address:array:character <- get *sandbox, data:offset
+  current-sandbox <- insert-text current-sandbox, text
+  *env <- put *env, render-from:offset, -1
+  return 1/true
+]
+
 def empty-editor? editor:address:editor-data -> result:boolean [
   local-scope
   load-ingredients
@@ -169,7 +244,7 @@ scenario sandbox-with-print-can-be-edited [
   ]
   # edit the sandbox
   assume-console [
-    left-click 3, 70
+    left-click 3, 65
   ]
   run [
     event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
@@ -213,7 +288,7 @@ scenario editing-sandbox-after-scrolling-resets-scroll [
   ]
   # edit the second sandbox
   assume-console [
-    left-click 2, 90
+    left-click 2, 55
   ]
   run [
     event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
@@ -262,7 +337,7 @@ scenario editing-sandbox-updates-sandbox-count [
   ]
   # edit the second sandbox, then resave
   assume-console [
-    left-click 3, 90
+    left-click 3, 60
     press F4
   ]
   run [
diff --git a/edit/007-sandbox-delete.mu b/edit/007-sandbox-delete.mu
index a758e663..c915dc75 100644
--- a/edit/007-sandbox-delete.mu
+++ b/edit/007-sandbox-delete.mu
@@ -67,7 +67,7 @@ scenario deleting-sandboxes [
 after <global-touch> [
   # on a sandbox delete icon? process delete
   {
-    was-delete?:boolean <- delete-sandbox t, env
+    was-delete?:boolean <- try-delete-sandbox t, env
     break-unless was-delete?
     hide-screen screen
     screen <- render-sandbox-side screen, env
@@ -77,7 +77,7 @@ after <global-touch> [
   }
 ]
 
-def delete-sandbox t:touch-event, env:address:programming-environment-data -> was-delete?:boolean, env:address:programming-environment-data [
+def try-delete-sandbox t:touch-event, env:address:programming-environment-data -> was-delete?:boolean, env:address:programming-environment-data [
   local-scope
   load-ingredients
   click-column:number <- get t, column:offset
diff --git a/edit/010-errors.mu b/edit/010-errors.mu
index 2fc21464..a5bfdeb6 100644
--- a/edit/010-errors.mu
+++ b/edit/010-errors.mu
@@ -218,7 +218,7 @@ scenario run-hides-errors-from-past-sandboxes [
     event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
   ]
   assume-console [
-    left-click 3, 80
+    left-click 3, 58
     press ctrl-k
     type [add 2, 2]  # valid code
     press F4  # update sandbox
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902