From 8f496ddcd96e1c66b6fee759b8c67d80b2bcc5b4 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 16 Jun 2015 17:04:39 -0700 Subject: 1576 --- edit.mu | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) 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 +] -- cgit 1.4.1-2-gfad0