about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-06-16 17:04:39 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-06-16 17:05:22 -0700
commit8f496ddcd96e1c66b6fee759b8c67d80b2bcc5b4 (patch)
treee54ea318a1eeb9af32897e3a3ef4e15a43f12826
parentb529c1d471095685d7aaa50beb5b9682f7e4d247 (diff)
downloadmu-8f496ddcd96e1c66b6fee759b8c67d80b2bcc5b4.tar.gz
1576
-rw-r--r--edit.mu50
1 files changed, 50 insertions, 0 deletions
diff --git a/edit.mu b/edit.mu
index 9110a857..72e9e349 100644
--- a/edit.mu
+++ b/edit.mu
@@ -3,6 +3,7 @@
 recipe main [
   1:address:array:character <- new [abcdef]
   switch-to-display
+  draw-box 0:literal/screen, 4:literal/left, 4:literal/left, 10:literal/bottom, 10:literal/right
   edit 1:address:array:character, 0:literal/screen, 5:literal/top, 5:literal/left, 10:literal/bottom, 10:literal/right, 0:literal/keyboard
   wait-for-key-from-keyboard
   return-to-console
@@ -144,3 +145,52 @@ scenario edit-wraps-long-lines [
     .     .
   ]
 ]
+
+recipe draw-box [
+  default-space:address:array:location <- new location:type, 30:literal
+  screen:address <- next-ingredient
+  top:number <- next-ingredient
+  left:number <- next-ingredient
+  bottom:number <- next-ingredient
+  right:number <- next-ingredient
+  # top border
+  move-cursor screen:address, top:number, left:number
+  print-character screen:address, 9484:literal/down-right, 245:literal/grey
+  x:number <- add left:number, 1:literal  # exclude corner
+  {
+    continue?:boolean <- lesser-than x:number, right:number
+    break-unless continue?:boolean
+    print-character screen:address, 9472:literal/horizontal, 245:literal/grey
+    x:number <- add x:number, 1:literal
+    loop
+  }
+  print-character screen:address, 9488:literal/down-left, 245:literal/grey
+  # bottom border
+  move-cursor screen:address, bottom:number, left:number
+  print-character screen:address, 9492:literal/up-right, 245:literal/grey
+  x:number <- add left:number, 1:literal  # exclude corner
+  {
+    continue?:boolean <- lesser-than x:number, right:number
+    break-unless continue?:boolean
+    print-character screen:address, 9472:literal/horizontal, 245:literal/grey
+    x:number <- add x:number, 1:literal
+    loop
+  }
+  print-character screen:address, 9496:literal/up-left, 245:literal/grey
+  # left and right borders
+  x:number <- add top:number, 1:literal  # exclude corner
+  {
+    continue?:boolean <- lesser-than x:number, bottom:number
+    break-unless continue?:boolean
+    move-cursor screen:address, x:number, left:number
+    print-character screen:address, 9474:literal/vertical, 245:literal/grey
+    move-cursor screen:address, x:number, right:number
+    print-character screen:address, 9474:literal/vertical, 245:literal/grey
+    x:number <- add x:number, 1:literal
+    loop
+  }
+  # position cursor inside box
+  move-cursor screen:address, top:number, left:number
+  cursor-down screen:address
+  cursor-right screen:address
+]