diff options
-rw-r--r-- | edit.mu | 50 |
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 +] |