about summary refs log tree commit diff stats
path: root/edit.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-06-11 01:10:14 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-06-11 01:13:06 -0700
commit55ca145e619fb9efafc021c3047f9ed5cb6fecf8 (patch)
treed50ccd859fe42496775ba4a0f3ebcd0e7a3a880d /edit.mu
parentbeab6db09909f6514a3f5154701b2d50e816aedb (diff)
downloadmu-55ca145e619fb9efafc021c3047f9ed5cb6fecf8.tar.gz
1551 - initial sketch of layout
Two columns: edit code on left and run code on right.
In both columns, the action is at the top of the screen, and stuff
gradually flows downward unless pulled back up.
Stuff you run on the right side will eventually become reproducible test
cases that runs constantly on every change.

We also have a tentative signature for the 'edit' routine: it'll take an
input string and return an output string when it finishes.

More columns expand to the right. Number of columns shown will remain
fixed at any time depending on screen width. But for now we support
exactly two columns.
Diffstat (limited to 'edit.mu')
-rw-r--r--edit.mu54
1 files changed, 53 insertions, 1 deletions
diff --git a/edit.mu b/edit.mu
index 90becd29..517d5e2a 100644
--- a/edit.mu
+++ b/edit.mu
@@ -1,11 +1,63 @@
 recipe main [
   default-space:address:array:location <- new location:type, 30:literal
   switch-to-display
-  draw-bounding-box 0:literal/screen, 5:literal, 5:literal, 30:literal, 45:literal
+  width:number <- display-width
+  {
+    wide-enough?:boolean <- greater-than width:number, 100:literal
+    break-if wide-enough?:boolean
+    return-to-console
+    assert wide-enough?:boolean, [screen too narrow; we don't support less than 100 characters yet]
+  }
+  divider:number, _ <- divide-with-remainder width:number, 2:literal
+  draw-column 0:literal/screen, divider:number
+  x:address:array:character <- new [1:integer <- add 2:literal, 2:literal]
+  y:address:array:character <- edit x:address:array:character, 0:literal/screen, 0:literal, 0:literal, 5:literal, divider:number
+#?   draw-bounding-box 0:literal/screen, 0:literal, 0:literal, 5:literal, divider:number
+  left:number <- add divider:number, 1:literal
+  y:address:array:character <- edit 0:literal, 0:literal/screen, 0:literal, left:number, 2:literal, width:number
+  move-cursor 0:literal/screen, 0:literal, 0:literal
   wait-for-key-from-keyboard
   return-to-console
 ]
 
+recipe draw-column [
+  default-space:address:array:location <- new location:type, 30:literal
+  screen:address <- next-ingredient
+  col:number <- next-ingredient
+  curr:number <- copy 0:literal
+  max:number <- screen-height screen:address
+  {
+    continue?:boolean <- lesser-than curr:number, max:number
+    break-unless continue?:boolean
+    move-cursor screen:address, curr:number, col:number
+    print-character screen:address, 9474:literal/vertical, 245:literal/grey
+    curr:number <- add curr:number, 1:literal
+    loop
+  }
+  move-cursor screen:address, 0:literal, 0:literal
+]
+
+recipe edit [
+  default-space:address:array:location <- new location:type, 30:literal
+  in:address:array:character <- next-ingredient
+  screen:address <- next-ingredient
+  top:number <- next-ingredient
+  left:number <- next-ingredient
+  bottom:number <- next-ingredient
+  right:number <- next-ingredient
+  # draw bottom boundary
+  curr:number <- copy left:number
+  {
+    continue?:boolean <- lesser-than curr:number, right:number
+    break-unless continue?:boolean
+    move-cursor screen:address, bottom:number, curr:number
+    print-character screen:address, 9472:literal/vertical, 245:literal/grey
+    curr:number <- add curr:number, 1:literal
+    loop
+  }
+  move-cursor screen:address, top:number, left:number
+]
+
 recipe draw-bounding-box [
   default-space:address:array:location <- new location:type, 30:literal
   screen:address <- next-ingredient