Skip to content
Browse files

growing Canvas, add ScriptRunner and ScriptView

  • Loading branch information...
1 parent 8556fbd commit f78e5337468732d2e58e61ea7a0b9e1e334156d3 @paulhodge paulhodge committed
Showing with 53 additions and 9 deletions.
  1. +1 −0 canvas/Test.ca
  2. +20 −0 canvas/ca/ScriptRunner.ca
  3. +22 −0 canvas/ca/ScriptView.ca
  4. +5 −1 canvas/ca/View.ca
  5. +2 −1 canvas/src/Scripts.cpp
  6. +0 −5 src/branch.cpp
  7. +0 −2 src/building.cpp
  8. +3 −0 src/metaprogramming.cpp
View
1 canvas/Test.ca
@@ -0,0 +1 @@
+
View
20 canvas/ca/ScriptRunner.ca
@@ -0,0 +1,20 @@
+
+msg = input()
+
+state Branch branch
+
+if msg[0] == 'loadFile'
+ print('loading file: ' msg[1])
+ branch = load_script_value(msg[1])
+ branch.dump
+elif msg[0] == 'call'
+
+ if not(branch.is_null)
+
+ --branch.load_latest
+
+
+ branch.call([])
+
+else
+ print("ScriptRunner didn't recognize: " msg)
View
22 canvas/ca/ScriptView.ca
@@ -0,0 +1,22 @@
+
+msg = input()
+
+
+def Point.inside(self, Rect rect) -> bool
+ return (self.x >= rect.x1) and (self.x <= rect.x2) and (self.y >= rect.y1) and (self.y <= rect.y2)
+
+
+loadButton = [10 10 100 40]
+
+if msg[0] == 'onPaintEvent'
+ painter = msg[1] -> Painter
+
+ send('ScriptRunner' ['call' painter])
+
+ painter.fillRect(loadButton #f00)
+ painter.drawText(loadButton :none "Load")
+
+elif msg[0] == 'onInputEvent'
+ event = msg[1] -> InputEvent
+ if event.eventType == MouseDown and event.mousePos.inside(loadButton)
+ send('ScriptRunner' ['loadFile' 'Test.ca'])
View
6 canvas/ca/View.ca
@@ -18,6 +18,7 @@ def fadein(Color c) -> Color
msg = input() -> List
state Point mouse
+state string currentScreen = 'ScriptView'
msg_name = msg[0]
@@ -36,8 +37,9 @@ if msg_name == 'onPaintEvent'
text = concat(mouse)
painter.drawText([10 10 100 100] :none text)
- send('CodeViewer' msg)
+ --send('CodeViewer' msg)
--send('IntroScreen' msg)
+ send(currentScreen msg)
elif msg_name == 'onInputEvent'
event = msg[1] -> InputEvent
@@ -47,5 +49,7 @@ elif msg_name == 'onInputEvent'
-- send test branch
if event.eventType == MouseDown
send('CodeViewer' ['loadTestBranch'])
+
+ send(currentScreen msg)
else
assert(false)
View
3 canvas/src/Scripts.cpp
@@ -42,5 +42,6 @@ void scripts_pre_message_send()
void scripts_post_message_send()
{
//TODO: repeat while messages are being sent
- circa_actor_run_all_queues(g_world, 10);
+ for (int i=0; i < 5; i++)
+ circa_actor_run_all_queues(g_world, 10);
}
View
5 src/branch.cpp
@@ -269,11 +269,6 @@ void Branch::removeNameBinding(Term* term)
void Branch::shorten(int newLength)
{
- if (newLength == 0) {
- clear_branch(this);
- return;
- }
-
for (int i=newLength; i < length(); i++)
set(i, NULL);
View
2 src/building.cpp
@@ -1375,8 +1375,6 @@ Term* write_setter_chain_from_getter_chain(Branch* branch, Term* getterRoot, Ter
if (result == NULL)
break;
- //hide_from_source(result);
-
desired = result;
getter = getter->input(0);
View
3 src/metaprogramming.cpp
@@ -70,6 +70,9 @@ void update_all_code_references(caValue* value, Branch* oldBranch, Branch* newBr
} else if (is_branch(val)) {
+ if (as_branch(val) == NULL)
+ continue;
+
Term* oldTerm = as_branch(val)->owningTerm;
if (oldTerm == NULL)
continue;

0 comments on commit f78e533

Please sign in to comment.
Something went wrong with that request. Please try again.