about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-06-19 17:35:06 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-06-19 17:35:06 -0700
commitc56cdd63089f9487ba3380ffc41c6eb5fc3cb461 (patch)
treedac77e68cd2a438f5c0d3630e5d4197c0ff4319c
parentf91179bdfc4b8049e9b4609396e1d7a01e302304 (diff)
downloadmu-c56cdd63089f9487ba3380ffc41c6eb5fc3cb461.tar.gz
1601
-rw-r--r--042new.cc8
-rw-r--r--edit.mu19
2 files changed, 25 insertions, 2 deletions
diff --git a/042new.cc b/042new.cc
index 7b4054ec..324fad16 100644
--- a/042new.cc
+++ b/042new.cc
@@ -35,7 +35,8 @@ if (inst.operation == Recipe_number["new"]) {
   // End NEW Transform Special-cases
   // first arg must be of type 'type'
   assert(SIZE(inst.ingredients) >= 1);
-  assert(is_literal(inst.ingredients.at(0)));
+  if (!is_literal(inst.ingredients.at(0)))
+    raise << "expected literal, got " << inst.ingredients.at(0).to_string() << '\n' << die();
   if (inst.ingredients.at(0).properties.at(0).second.at(0) != "type")
     raise << "tried to allocate non-type " << inst.ingredients.at(0).to_string() << " in recipe " << Recipe[r].name << '\n' << die();
   if (Type_number.find(inst.ingredients.at(0).name) == Type_number.end())
@@ -190,7 +191,10 @@ recipe main [
 +mem: storing 171 in location 3
 
 :(before "End NEW Transform Special-cases")
-  if (inst.ingredients.at(0).properties.at(0).second.at(0) == "literal-string") {
+  if (!inst.ingredients.empty()
+      && !inst.ingredients.at(0).properties.empty()
+      && !inst.ingredients.at(0).properties.at(0).second.empty()
+      && inst.ingredients.at(0).properties.at(0).second.at(0) == "literal-string") {
     // skip transform
     inst.ingredients.at(0).initialized = true;
     goto end_new_transform;
diff --git a/edit.mu b/edit.mu
index 85250b27..9faf9059 100644
--- a/edit.mu
+++ b/edit.mu
@@ -30,6 +30,25 @@ scenario edit-prints-string-to-screen [
   ]
 ]
 
+container editor-data [
+  initial-contents:address:stream  # lazily added to other fields as necessary
+  lines:address:duplex-list  # doubly linked list of lines, each line containing a buffer of characters
+  top-of-screen:address:duplex-list
+  screen:address:screen  # will be used later for colorizing
+]
+
+recipe new-editor-data [
+  default-space:address:array:location <- new location:type, 30:literal
+  s:address:array:character <- next-ingredient
+  screen:address <- next-ingredient
+  result:address:editor-data <- new editor-data:type
+  init:address:address:stream <- get-address result:address:editor-data/deref, initial-contents:offset
+  init:address:address:stream/deref <- new-stream s:address:array:character
+  screen-dest:address:address:screen <- get-address result:address:editor-data/deref, screen:offset
+  screen-dest:address:address:screen/deref <- copy screen:address
+  reply result:address:editor-data
+]
+
 recipe edit [
   default-space:address:array:location <- new location:type, 30:literal
   s:address:array:character <- next-ingredient