From 996ce5f101e597cf70bda0864f964b356a1005a3 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 6 May 2017 15:03:13 -0700 Subject: 3845 --- html/081print.mu.html | 220 +++++++++++++++++++++++--------------------------- 1 file changed, 102 insertions(+), 118 deletions(-) (limited to 'html/081print.mu.html') diff --git a/html/081print.mu.html b/html/081print.mu.html index 2ec87eb7..6b1b7367 100644 --- a/html/081print.mu.html +++ b/html/081print.mu.html @@ -660,127 +660,111 @@ if ('onhashchange' in window) { 597 height <- display-height 598 ] 599 -600 def hide-cursor screen:&:screen -> screen:&:screen [ +600 def print screen:&:screen, s:text -> screen:&:screen [ 601 local-scope 602 load-ingredients -603 return-if screen # fake screen; do nothing -604 # real screen -605 hide-cursor-on-display -606 ] -607 -608 def show-cursor screen:&:screen -> screen:&:screen [ -609 local-scope -610 load-ingredients -611 return-if screen # fake screen; do nothing -612 # real screen -613 show-cursor-on-display -614 ] -615 -616 def print screen:&:screen, s:text -> screen:&:screen [ -617 local-scope -618 load-ingredients -619 color:num, color-found?:bool <- next-ingredient -620 { -621 ¦ # default color to white -622 ¦ break-if color-found? -623 ¦ color <- copy 7/white +603 color:num, color-found?:bool <- next-ingredient +604 { +605 ¦ # default color to white +606 ¦ break-if color-found? +607 ¦ color <- copy 7/white +608 } +609 bg-color:num, bg-color-found?:bool <- next-ingredient +610 { +611 ¦ # default bg-color to black +612 ¦ break-if bg-color-found? +613 ¦ bg-color <- copy 0/black +614 } +615 len:num <- length *s +616 i:num <- copy 0 +617 { +618 ¦ done?:bool <- greater-or-equal i, len +619 ¦ break-if done? +620 ¦ c:char <- index *s, i +621 ¦ print screen, c, color, bg-color +622 ¦ i <- add i, 1 +623 ¦ loop 624 } -625 bg-color:num, bg-color-found?:bool <- next-ingredient -626 { -627 ¦ # default bg-color to black -628 ¦ break-if bg-color-found? -629 ¦ bg-color <- copy 0/black -630 } -631 len:num <- length *s -632 i:num <- copy 0 -633 { -634 ¦ done?:bool <- greater-or-equal i, len -635 ¦ break-if done? -636 ¦ c:char <- index *s, i -637 ¦ print screen, c, color, bg-color -638 ¦ i <- add i, 1 -639 ¦ loop -640 } -641 ] -642 -643 scenario print-text-stops-at-right-margin [ -644 local-scope -645 fake-screen:&:screen <- new-fake-screen 3/width, 2/height -646 run [ -647 ¦ fake-screen <- print fake-screen, [abcd] -648 ¦ cell:&:@:screen-cell <- get *fake-screen, data:offset -649 ¦ 10:@:screen-cell/raw <- copy *cell -650 ] -651 memory-should-contain [ -652 ¦ 10 <- 6 # width*height -653 ¦ 11 <- 97 # 'a' -654 ¦ 12 <- 7 # white -655 ¦ 13 <- 98 # 'b' -656 ¦ 14 <- 7 # white -657 ¦ 15 <- 100 # 'd' overwrites 'c' -658 ¦ 16 <- 7 # white -659 ¦ # rest of screen is empty -660 ¦ 17 <- 0 -661 ] -662 ] -663 -664 def print screen:&:screen, n:num -> screen:&:screen [ -665 local-scope -666 load-ingredients -667 color:num, color-found?:bool <- next-ingredient -668 { -669 ¦ # default color to white -670 ¦ break-if color-found? -671 ¦ color <- copy 7/white -672 } -673 bg-color:num, bg-color-found?:bool <- next-ingredient -674 { -675 ¦ # default bg-color to black -676 ¦ break-if bg-color-found? -677 ¦ bg-color <- copy 0/black -678 } -679 # todo: other bases besides decimal -680 s:text <- to-text n -681 screen <- print screen, s, color, bg-color -682 ] -683 -684 def print screen:&:screen, n:bool -> screen:&:screen [ -685 local-scope -686 load-ingredients -687 color:num, color-found?:bool <- next-ingredient -688 { -689 ¦ # default color to white -690 ¦ break-if color-found? -691 ¦ color <- copy 7/white -692 } -693 bg-color:num, bg-color-found?:bool <- next-ingredient -694 { -695 ¦ # default bg-color to black -696 ¦ break-if bg-color-found? -697 ¦ bg-color <- copy 0/black -698 } -699 n2:num <- copy n -700 screen <- print screen, n2, color, bg-color -701 ] -702 -703 def print screen:&:screen, n:&:_elem -> screen:&:screen [ -704 local-scope -705 load-ingredients -706 color:num, color-found?:bool <- next-ingredient -707 { -708 ¦ # default color to white -709 ¦ break-if color-found? -710 ¦ color <- copy 7/white -711 } -712 bg-color:num, bg-color-found?:bool <- next-ingredient -713 { -714 ¦ # default bg-color to black -715 ¦ break-if bg-color-found? -716 ¦ bg-color <- copy 0/black -717 } -718 n2:num <- copy n -719 screen <- print screen, n2, color, bg-color -720 ] +625 ] +626 +627 scenario print-text-stops-at-right-margin [ +628 local-scope +629 fake-screen:&:screen <- new-fake-screen 3/width, 2/height +630 run [ +631 ¦ fake-screen <- print fake-screen, [abcd] +632 ¦ cell:&:@:screen-cell <- get *fake-screen, data:offset +633 ¦ 10:@:screen-cell/raw <- copy *cell +634 ] +635 memory-should-contain [ +636 ¦ 10 <- 6 # width*height +637 ¦ 11 <- 97 # 'a' +638 ¦ 12 <- 7 # white +639 ¦ 13 <- 98 # 'b' +640 ¦ 14 <- 7 # white +641 ¦ 15 <- 100 # 'd' overwrites 'c' +642 ¦ 16 <- 7 # white +643 ¦ # rest of screen is empty +644 ¦ 17 <- 0 +645 ] +646 ] +647 +648 def print screen:&:screen, n:num -> screen:&:screen [ +649 local-scope +650 load-ingredients +651 color:num, color-found?:bool <- next-ingredient +652 { +653 ¦ # default color to white +654 ¦ break-if color-found? +655 ¦ color <- copy 7/white +656 } +657 bg-color:num, bg-color-found?:bool <- next-ingredient +658 { +659 ¦ # default bg-color to black +660 ¦ break-if bg-color-found? +661 ¦ bg-color <- copy 0/black +662 } +663 # todo: other bases besides decimal +664 s:text <- to-text n +665 screen <- print screen, s, color, bg-color +666 ] +667 +668 def print screen:&:screen, n:bool -> screen:&:screen [ +669 local-scope +670 load-ingredients +671 color:num, color-found?:bool <- next-ingredient +672 { +673 ¦ # default color to white +674 ¦ break-if color-found? +675 ¦ color <- copy 7/white +676 } +677 bg-color:num, bg-color-found?:bool <- next-ingredient +678 { +679 ¦ # default bg-color to black +680 ¦ break-if bg-color-found? +681 ¦ bg-color <- copy 0/black +682 } +683 n2:num <- copy n +684 screen <- print screen, n2, color, bg-color +685 ] +686 +687 def print screen:&:screen, n:&:_elem -> screen:&:screen [ +688 local-scope +689 load-ingredients +690 color:num, color-found?:bool <- next-ingredient +691 { +692 ¦ # default color to white +693 ¦ break-if color-found? +694 ¦ color <- copy 7/white +695 } +696 bg-color:num, bg-color-found?:bool <- next-ingredient +697 { +698 ¦ # default bg-color to black +699 ¦ break-if bg-color-found? +700 ¦ bg-color <- copy 0/black +701 } +702 n2:num <- copy n +703 screen <- print screen, n2, color, bg-color +704 ] -- cgit 1.4.1-2-gfad0