@ -1,26 +1,26 @@
# code-point-utf8 stacks are the smallest unit of editable t e x t
type code-point-utf8 -stack {
type grapheme -stack {
data: (handle array c o d e - p o i n t - u t f 8 )
top: i n t
}
fn initialize-code-point-utf8-stack _self: (addr code-point-utf8 -stack), n: int {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn initialize-grapheme-stack _self: (addr grapheme -stack), n: int {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var d/edi: (addr handle array code-point-utf8) <- get self, d a t a
populate d, n
var top/eax: (addr int) <- get self, t o p
copy-to *top, 0
}
fn clear-code-point-utf8-stack _self: (addr code-point-utf8 -stack) {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn clear-grapheme-stack _self: (addr grapheme -stack) {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var top/eax: (addr int) <- get self, t o p
copy-to *top, 0
}
fn code-point-utf8-stack-empty? _self: (addr code-point-utf8 -stack) -> _/eax: boolean {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn grapheme-stack-empty? _self: (addr grapheme -stack) -> _/eax: boolean {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var top/eax: (addr int) <- get self, t o p
compare *top, 0
{
@ -30,14 +30,14 @@ fn code-point-utf8-stack-empty? _self: (addr code-point-utf8-stack) -> _/eax: bo
return 0 / f a l s e
}
fn code-point-utf8-stack-length _self: (addr code-point-utf8 -stack) -> _/eax: int {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn grapheme-stack-length _self: (addr grapheme -stack) -> _/eax: int {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var top/eax: (addr int) <- get self, t o p
return * t o p
}
fn push-code-point-utf8-stack _self: (addr code-point-utf8 -stack), _val: code-point-utf8 {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn push-grapheme-stack _self: (addr grapheme -stack), _val: code-point-utf8 {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var top-addr/ecx: (addr int) <- get self, t o p
var data-ah/edx: (addr handle array code-point-utf8) <- get self, d a t a
var data/eax: (addr array code-point-utf8) <- lookup * d a t a - a h
@ -48,8 +48,8 @@ fn push-code-point-utf8-stack _self: (addr code-point-utf8-stack), _val: code-po
add-to *top-addr, 1
}
fn pop-code-point-utf8-stack _self: (addr code-point-utf8 -stack) -> _/eax: code-point-utf8 {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn pop-grapheme-stack _self: (addr grapheme -stack) -> _/eax: code-point-utf8 {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var top-addr/ecx: (addr int) <- get self, t o p
{
compare *top-addr, 0
@ -64,8 +64,8 @@ fn pop-code-point-utf8-stack _self: (addr code-point-utf8-stack) -> _/eax: code-
return * r e s u l t - a d d r
}
fn copy-code-point-utf8-stack _src: (addr code-point-utf8-stack), dest: (addr code-point-utf8 -stack) {
var src/esi: (addr code-point-utf8 -stack) <- copy _ s r c
fn copy-grapheme-stack _src: (addr grapheme-stack), dest: (addr grapheme -stack) {
var src/esi: (addr grapheme -stack) <- copy _ s r c
var data-ah/edi: (addr handle array code-point-utf8) <- get src, d a t a
var _data/eax: (addr array code-point-utf8) <- lookup * d a t a - a h
var data/edi: (addr array code-point-utf8) <- copy _ d a t a
@ -75,7 +75,7 @@ fn copy-code-point-utf8-stack _src: (addr code-point-utf8-stack), dest: (addr co
compare i, * t o p - a d d r
b r e a k - i f - > =
var g/edx: (addr code-point-utf8) <- index data, i
push-code-point-utf8 -stack dest, * g
push-grapheme -stack dest, * g
i <- i n c r e m e n t
l o o p
}
@ -84,8 +84,8 @@ fn copy-code-point-utf8-stack _src: (addr code-point-utf8-stack), dest: (addr co
# dump stack to screen from bottom to t o p
# hardcoded c o l o r s :
# matching p a r e n
fn render-stack-from-bottom-wrapping-right-then-down screen: (addr screen), _self: (addr code-point-utf8 -stack), xmin: int, ymin: int, xmax: int, ymax: int, _x: int, _y: int, highlight-matching-open-paren?: boolean, open-paren-depth: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn render-stack-from-bottom-wrapping-right-then-down screen: (addr screen), _self: (addr grapheme -stack), xmin: int, ymin: int, xmax: int, ymax: int, _x: int, _y: int, highlight-matching-open-paren?: boolean, open-paren-depth: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var matching-open-paren-index/edx: int <- get-matching-open-paren-index self, highlight-matching-open-paren?, o p e n - p a r e n - d e p t h
var data-ah/edi: (addr handle array code-point-utf8) <- get self, d a t a
var _data/eax: (addr array code-point-utf8) <- lookup * d a t a - a h
@ -123,7 +123,7 @@ fn render-stack-from-bottom-wrapping-right-then-down screen: (addr screen), _sel
}
# helper for small w o r d s
fn render-stack-from-bottom screen: (addr screen), self: (addr code-point-utf8 -stack), x: int, y: int, highlight-matching-open-paren?: boolean, open-paren-depth: int -> _/eax: int {
fn render-stack-from-bottom screen: (addr screen), self: (addr grapheme -stack), x: int, y: int, highlight-matching-open-paren?: boolean, open-paren-depth: int -> _/eax: int {
var _width/eax: int <- copy 0
var _height/ecx: int <- copy 0
_width, _height <- screen-size s c r e e n
@ -140,8 +140,8 @@ fn render-stack-from-bottom screen: (addr screen), self: (addr code-point-utf8-s
# hard-coded c o l o r s :
# matching p a r e n
# c u r s o r
fn render-stack-from-top-wrapping-right-then-down screen: (addr screen), _self: (addr code-point-utf8 -stack), xmin: int, ymin: int, xmax: int, ymax: int, _x: int, _y: int, render-cursor?: boolean, color: int, background-color: int -> _/eax: int, _/ecx: int {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn render-stack-from-top-wrapping-right-then-down screen: (addr screen), _self: (addr grapheme -stack), xmin: int, ymin: int, xmax: int, ymax: int, _x: int, _y: int, render-cursor?: boolean, color: int, background-color: int -> _/eax: int, _/ecx: int {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var matching-close-paren-index/edx: int <- get-matching-close-paren-index self, r e n d e r - c u r s o r ?
var data-ah/eax: (addr handle array code-point-utf8) <- get self, d a t a
var _data/eax: (addr array code-point-utf8) <- lookup * d a t a - a h
@ -196,7 +196,7 @@ fn render-stack-from-top-wrapping-right-then-down screen: (addr screen), _self:
}
# helper for small w o r d s
fn render-stack-from-top screen: (addr screen), self: (addr code-point-utf8 -stack), x: int, y: int, render-cursor?: boolean -> _/eax: int {
fn render-stack-from-top screen: (addr screen), self: (addr grapheme -stack), x: int, y: int, render-cursor?: boolean -> _/eax: int {
var _width/eax: int <- copy 0
var _height/ecx: int <- copy 0
_width, _height <- screen-size s c r e e n
@ -208,190 +208,190 @@ fn render-stack-from-top screen: (addr screen), self: (addr code-point-utf8-stac
return x2 # y2? y o l o
}
fn test-render-code-point-utf8 -stack {
fn test-render-grapheme -stack {
# setup: gs = " a b c "
var gs-storage: c o d e - p o i n t - u t f 8 - s t a c k
var gs/edi: (addr code-point-utf8 -stack) <- address g s - s t o r a g e
initialize-code-point-utf8 -stack gs, 5
var gs-storage: g r a p h e m e - s t a c k
var gs/edi: (addr grapheme -stack) <- address g s - s t o r a g e
initialize-grapheme -stack gs, 5
var g/eax: code-point-utf8 <- copy 0 x 61 / a
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 62 / b
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 63 / c
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
# setup: s c r e e n
var screen-storage: s c r e e n
var screen/esi: (addr screen) <- address s c r e e n - s t o r a g e
initialize-screen screen, 5 , 4 , 0 / n o - p i x e l - g r a p h i c s
#
var x/eax: int <- render-stack-from-bottom screen, gs, 0 /x, 0 /y, 0 /no-highlight-matching-open-paren, 0 / o p e n - p a r e n - d e p t h
check-screen-row screen, 0 /y, "abc ", "F - test-render-code-point-utf8 -stack from b o t t o m "
check-ints-equal x, 3 , "F - test-render-code-point-utf8 -stack from bottom: r e s u l t "
check-background-color-in-screen-row screen, 3 /bg=reverse, 0 /y, " ", "F - test-render-code-point-utf8 -stack from bottom: b g "
check-screen-row screen, 0 /y, "abc ", "F - test-render-grapheme -stack from b o t t o m "
check-ints-equal x, 3 , "F - test-render-grapheme -stack from bottom: r e s u l t "
check-background-color-in-screen-row screen, 3 /bg=reverse, 0 /y, " ", "F - test-render-grapheme -stack from bottom: b g "
#
var x/eax: int <- render-stack-from-top screen, gs, 0 /x, 1 /y, 0 / c u r s o r = f a l s e
check-screen-row screen, 1 /y, "cba ", "F - test-render-code-point-utf8 -stack from top without c u r s o r "
check-ints-equal x, 3 , "F - test-render-code-point-utf8 -stack from top without cursor: r e s u l t "
check-background-color-in-screen-row screen, 3 /bg=reverse, 1 /y, " ", "F - test-render-code-point-utf8 -stack from top without cursor: b g "
check-screen-row screen, 1 /y, "cba ", "F - test-render-grapheme -stack from top without c u r s o r "
check-ints-equal x, 3 , "F - test-render-grapheme -stack from top without cursor: r e s u l t "
check-background-color-in-screen-row screen, 3 /bg=reverse, 1 /y, " ", "F - test-render-grapheme -stack from top without cursor: b g "
#
var x/eax: int <- render-stack-from-top screen, gs, 0 /x, 2 /y, 1 / c u r s o r = t r u e
check-screen-row screen, 2 /y, "cba ", "F - test-render-code-point-utf8 -stack from top with c u r s o r "
check-ints-equal x, 3 , "F - test-render-code-point-utf8 -stack from top with cursor: r e s u l t "
check-background-color-in-screen-row screen, 3 /bg=reverse, 2 /y, "| ", "F - test-render-code-point-utf8 -stack from top with cursor: b g "
check-screen-row screen, 2 /y, "cba ", "F - test-render-grapheme -stack from top with c u r s o r "
check-ints-equal x, 3 , "F - test-render-grapheme -stack from top with cursor: r e s u l t "
check-background-color-in-screen-row screen, 3 /bg=reverse, 2 /y, "| ", "F - test-render-grapheme -stack from top with cursor: b g "
}
fn test-render-code-point-utf8 -stack-while-highlighting-matching-close-paren {
fn test-render-grapheme -stack-while-highlighting-matching-close-paren {
# setup: gs = " ( b ) "
var gs-storage: c o d e - p o i n t - u t f 8 - s t a c k
var gs/edi: (addr code-point-utf8 -stack) <- address g s - s t o r a g e
initialize-code-point-utf8 -stack gs, 5
var gs-storage: g r a p h e m e - s t a c k
var gs/edi: (addr grapheme -stack) <- address g s - s t o r a g e
initialize-grapheme -stack gs, 5
var g/eax: code-point-utf8 <- copy 0 x 29 / c l o s e - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 62 / b
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 28 / o p e n - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
# setup: s c r e e n
var screen-storage: s c r e e n
var screen/esi: (addr screen) <- address s c r e e n - s t o r a g e
initialize-screen screen, 5 , 4 , 0 / n o - p i x e l - g r a p h i c s
#
var x/eax: int <- render-stack-from-top screen, gs, 0 /x, 2 /y, 1 / c u r s o r = t r u e
check-screen-row screen, 2 /y, "(b) ", "F - t e s t - r e n d e r - c o d e - p o i n t - u t f 8 - s t a c k - w h i l e - h i g h l i g h t i n g - m a t c h i n g - c l o s e - p a r e n "
check-background-color-in-screen-row screen, 3 /bg=reverse, 2 /y, "| ", "F - test-render-code-point-utf8 -stack-while-highlighting-matching-close-paren: c u r s o r "
check-screen-row-in-color screen, 0 xf/fg=white, 2 /y, " ) ", "F - test-render-code-point-utf8 -stack-while-highlighting-matching-close-paren: matching p a r e n "
check-screen-row screen, 2 /y, "(b) ", "F - t e s t - r e n d e r - g r a p h e m e - s t a c k - w h i l e - h i g h l i g h t i n g - m a t c h i n g - c l o s e - p a r e n "
check-background-color-in-screen-row screen, 3 /bg=reverse, 2 /y, "| ", "F - test-render-grapheme -stack-while-highlighting-matching-close-paren: c u r s o r "
check-screen-row-in-color screen, 0 xf/fg=white, 2 /y, " ) ", "F - test-render-grapheme -stack-while-highlighting-matching-close-paren: matching p a r e n "
}
fn test-render-code-point-utf8 -stack-while-highlighting-matching-close-paren-2 {
fn test-render-grapheme -stack-while-highlighting-matching-close-paren-2 {
# setup: gs = "(a (b)) c "
var gs-storage: c o d e - p o i n t - u t f 8 - s t a c k
var gs/edi: (addr code-point-utf8 -stack) <- address g s - s t o r a g e
initialize-code-point-utf8 -stack gs, 0 x 10
var gs-storage: g r a p h e m e - s t a c k
var gs/edi: (addr grapheme -stack) <- address g s - s t o r a g e
initialize-grapheme -stack gs, 0 x 10
var g/eax: code-point-utf8 <- copy 0 x 63 / c
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 20 / s p a c e
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 29 / c l o s e - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 29 / c l o s e - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 62 / b
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 28 / o p e n - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 20 / s p a c e
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 61 / a
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 28 / o p e n - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
# setup: s c r e e n
var screen-storage: s c r e e n
var screen/esi: (addr screen) <- address s c r e e n - s t o r a g e
initialize-screen screen, 5 , 4 , 0 / n o - p i x e l - g r a p h i c s
#
var x/eax: int <- render-stack-from-top screen, gs, 0 /x, 2 /y, 1 / c u r s o r = t r u e
check-screen-row screen, 2 /y, "(a (b)) c ", "F - t e s t - r e n d e r - c o d e - p o i n t - u t f 8 - s t a c k - w h i l e - h i g h l i g h t i n g - m a t c h i n g - c l o s e - p a r e n -2 "
check-background-color-in-screen-row screen, 3 /bg=reverse, 2 /y, "| ", "F - test-render-code-point-utf8 -stack-while-highlighting-matching-close-paren-2: c u r s o r "
check-screen-row-in-color screen, 0 xf/fg=white, 2 /y, " ) ", "F - test-render-code-point-utf8 -stack-while-highlighting-matching-close-paren-2: matching p a r e n "
check-screen-row screen, 2 /y, "(a (b)) c ", "F - t e s t - r e n d e r - g r a p h e m e - s t a c k - w h i l e - h i g h l i g h t i n g - m a t c h i n g - c l o s e - p a r e n -2 "
check-background-color-in-screen-row screen, 3 /bg=reverse, 2 /y, "| ", "F - test-render-grapheme -stack-while-highlighting-matching-close-paren-2: c u r s o r "
check-screen-row-in-color screen, 0 xf/fg=white, 2 /y, " ) ", "F - test-render-grapheme -stack-while-highlighting-matching-close-paren-2: matching p a r e n "
}
fn test-render-code-point-utf8 -stack-while-highlighting-matching-open-paren-with-close-paren-at-end {
fn test-render-grapheme -stack-while-highlighting-matching-open-paren-with-close-paren-at-end {
# setup: gs = " ( b ) "
var gs-storage: c o d e - p o i n t - u t f 8 - s t a c k
var gs/edi: (addr code-point-utf8 -stack) <- address g s - s t o r a g e
initialize-code-point-utf8 -stack gs, 5
var gs-storage: g r a p h e m e - s t a c k
var gs/edi: (addr grapheme -stack) <- address g s - s t o r a g e
initialize-grapheme -stack gs, 5
var g/eax: code-point-utf8 <- copy 0 x 28 / o p e n - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 62 / b
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 29 / c l o s e - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
# setup: s c r e e n
var screen-storage: s c r e e n
var screen/esi: (addr screen) <- address s c r e e n - s t o r a g e
initialize-screen screen, 5 , 4 , 0 / n o - p i x e l - g r a p h i c s
#
var x/eax: int <- render-stack-from-bottom screen, gs, 0 /x, 2 /y, 1 /highlight-matching-open-paren, 1 / o p e n - p a r e n - d e p t h
check-screen-row screen, 2 /y, "(b) ", "F - t e s t - r e n d e r - c o d e - p o i n t - u t f 8 - s t a c k - w h i l e - h i g h l i g h t i n g - m a t c h i n g - o p e n - p a r e n - w i t h - c l o s e - p a r e n - a t - e n d "
check-screen-row-in-color screen, 0 xf/fg=white, 2 /y, "( ", "F - test-render-code-point-utf8 -stack-while-highlighting-matching-open-paren-with-close-paren-at-end: matching p a r e n "
check-screen-row screen, 2 /y, "(b) ", "F - t e s t - r e n d e r - g r a p h e m e - s t a c k - w h i l e - h i g h l i g h t i n g - m a t c h i n g - o p e n - p a r e n - w i t h - c l o s e - p a r e n - a t - e n d "
check-screen-row-in-color screen, 0 xf/fg=white, 2 /y, "( ", "F - test-render-grapheme -stack-while-highlighting-matching-open-paren-with-close-paren-at-end: matching p a r e n "
}
fn test-render-code-point-utf8 -stack-while-highlighting-matching-open-paren-with-close-paren-at-end-2 {
fn test-render-grapheme -stack-while-highlighting-matching-open-paren-with-close-paren-at-end-2 {
# setup: gs = " a ( ( b ) ) "
var gs-storage: c o d e - p o i n t - u t f 8 - s t a c k
var gs/edi: (addr code-point-utf8 -stack) <- address g s - s t o r a g e
initialize-code-point-utf8 -stack gs, 0 x 10
var gs-storage: g r a p h e m e - s t a c k
var gs/edi: (addr grapheme -stack) <- address g s - s t o r a g e
initialize-grapheme -stack gs, 0 x 10
var g/eax: code-point-utf8 <- copy 0 x 61 / a
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 28 / o p e n - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 28 / o p e n - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 62 / b
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 29 / c l o s e - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 29 / c l o s e - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
# setup: s c r e e n
var screen-storage: s c r e e n
var screen/esi: (addr screen) <- address s c r e e n - s t o r a g e
initialize-screen screen, 5 , 4 , 0 / n o - p i x e l - g r a p h i c s
#
var x/eax: int <- render-stack-from-bottom screen, gs, 0 /x, 2 /y, 1 /highlight-matching-open-paren, 1 / o p e n - p a r e n - d e p t h
check-screen-row screen, 2 /y, "a((b)) ", "F - t e s t - r e n d e r - c o d e - p o i n t - u t f 8 - s t a c k - w h i l e - h i g h l i g h t i n g - m a t c h i n g - o p e n - p a r e n - w i t h - c l o s e - p a r e n - a t - e n d -2 "
check-screen-row-in-color screen, 0 xf/fg=white, 2 /y, " ( ", "F - test-render-code-point-utf8 -stack-while-highlighting-matching-open-paren-with-close-paren-at-end-2: matching p a r e n "
check-screen-row screen, 2 /y, "a((b)) ", "F - t e s t - r e n d e r - g r a p h e m e - s t a c k - w h i l e - h i g h l i g h t i n g - m a t c h i n g - o p e n - p a r e n - w i t h - c l o s e - p a r e n - a t - e n d -2 "
check-screen-row-in-color screen, 0 xf/fg=white, 2 /y, " ( ", "F - test-render-grapheme -stack-while-highlighting-matching-open-paren-with-close-paren-at-end-2: matching p a r e n "
}
fn test-render-code-point-utf8 -stack-while-highlighting-matching-open-paren {
fn test-render-grapheme -stack-while-highlighting-matching-open-paren {
# setup: gs = " ( b "
var gs-storage: c o d e - p o i n t - u t f 8 - s t a c k
var gs/edi: (addr code-point-utf8 -stack) <- address g s - s t o r a g e
initialize-code-point-utf8 -stack gs, 5
var gs-storage: g r a p h e m e - s t a c k
var gs/edi: (addr grapheme -stack) <- address g s - s t o r a g e
initialize-grapheme -stack gs, 5
var g/eax: code-point-utf8 <- copy 0 x 28 / o p e n - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 62 / b
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
# setup: s c r e e n
var screen-storage: s c r e e n
var screen/esi: (addr screen) <- address s c r e e n - s t o r a g e
initialize-screen screen, 5 , 4 , 0 / n o - p i x e l - g r a p h i c s
#
var x/eax: int <- render-stack-from-bottom screen, gs, 0 /x, 2 /y, 1 /highlight-matching-open-paren, 0 / o p e n - p a r e n - d e p t h
check-screen-row screen, 2 /y, "(b ", "F - t e s t - r e n d e r - c o d e - p o i n t - u t f 8 - s t a c k - w h i l e - h i g h l i g h t i n g - m a t c h i n g - o p e n - p a r e n "
check-screen-row-in-color screen, 0 xf/fg=white, 2 /y, "( ", "F - test-render-code-point-utf8 -stack-while-highlighting-matching-open-paren: matching p a r e n "
check-screen-row screen, 2 /y, "(b ", "F - t e s t - r e n d e r - g r a p h e m e - s t a c k - w h i l e - h i g h l i g h t i n g - m a t c h i n g - o p e n - p a r e n "
check-screen-row-in-color screen, 0 xf/fg=white, 2 /y, "( ", "F - test-render-grapheme -stack-while-highlighting-matching-open-paren: matching p a r e n "
}
fn test-render-code-point-utf8 -stack-while-highlighting-matching-open-paren-2 {
fn test-render-grapheme -stack-while-highlighting-matching-open-paren-2 {
# setup: gs = " a ( ( b ) "
var gs-storage: c o d e - p o i n t - u t f 8 - s t a c k
var gs/edi: (addr code-point-utf8 -stack) <- address g s - s t o r a g e
initialize-code-point-utf8 -stack gs, 0 x 10
var gs-storage: g r a p h e m e - s t a c k
var gs/edi: (addr grapheme -stack) <- address g s - s t o r a g e
initialize-grapheme -stack gs, 0 x 10
var g/eax: code-point-utf8 <- copy 0 x 61 / a
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 28 / o p e n - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 28 / o p e n - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 62 / b
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
g <- copy 0 x 29 / c l o s e - p a r e n
push-code-point-utf8 -stack gs, g
push-grapheme -stack gs, g
# setup: s c r e e n
var screen-storage: s c r e e n
var screen/esi: (addr screen) <- address s c r e e n - s t o r a g e
initialize-screen screen, 5 , 4 , 0 / n o - p i x e l - g r a p h i c s
#
var x/eax: int <- render-stack-from-bottom screen, gs, 0 /x, 2 /y, 1 /highlight-matching-open-paren, 0 / o p e n - p a r e n - d e p t h
check-screen-row screen, 2 /y, "a((b) ", "F - t e s t - r e n d e r - c o d e - p o i n t - u t f 8 - s t a c k - w h i l e - h i g h l i g h t i n g - m a t c h i n g - o p e n - p a r e n -2 "
check-screen-row-in-color screen, 0 xf/fg=white, 2 /y, " ( ", "F - test-render-code-point-utf8 -stack-while-highlighting-matching-open-paren-2: matching p a r e n "
check-screen-row screen, 2 /y, "a((b) ", "F - t e s t - r e n d e r - g r a p h e m e - s t a c k - w h i l e - h i g h l i g h t i n g - m a t c h i n g - o p e n - p a r e n -2 "
check-screen-row-in-color screen, 0 xf/fg=white, 2 /y, " ( ", "F - test-render-grapheme -stack-while-highlighting-matching-open-paren-2: matching p a r e n "
}
# return the index of the matching close-paren of the code-point-utf8 at cursor (top of s t a c k )
# or top index if there's no matching c l o s e - p a r e n
fn get-matching-close-paren-index _self: (addr code-point-utf8 -stack), render-cursor?: boolean -> _/edx: int {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn get-matching-close-paren-index _self: (addr grapheme -stack), render-cursor?: boolean -> _/edx: int {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var top-addr/edx: (addr int) <- get self, t o p
# if not rendering cursor, r e t u r n
compare render-cursor?, 0 / f a l s e
@ -446,8 +446,8 @@ fn get-matching-close-paren-index _self: (addr code-point-utf8-stack), render-cu
# return the index of the first open-paren at the given d e p t h
# or top index if there's no matching c l o s e - p a r e n
fn get-matching-open-paren-index _self: (addr code-point-utf8 -stack), control: boolean, depth: int -> _/edx: int {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn get-matching-open-paren-index _self: (addr grapheme -stack), control: boolean, depth: int -> _/edx: int {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var top-addr/edx: (addr int) <- get self, t o p
# if not rendering cursor, r e t u r n
compare control, 0 / f a l s e
@ -494,8 +494,8 @@ fn get-matching-open-paren-index _self: (addr code-point-utf8-stack), control: b
# compare from b o t t o m
# beware: modifies 'stream', which must be disposed of after a false r e s u l t
fn prefix-match? _self: (addr code-point-utf8 -stack), s: (addr stream byte) -> _/eax: boolean {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn prefix-match? _self: (addr grapheme -stack), s: (addr stream byte) -> _/eax: boolean {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var data-ah/edi: (addr handle array code-point-utf8) <- get self, d a t a
var _data/eax: (addr array code-point-utf8) <- lookup * d a t a - a h
var data/edi: (addr array code-point-utf8) <- copy _ d a t a
@ -522,8 +522,8 @@ fn prefix-match? _self: (addr code-point-utf8-stack), s: (addr stream byte) -> _
# compare from b o t t o m
# beware: modifies 'stream', which must be disposed of after a false r e s u l t
fn suffix-match? _self: (addr code-point-utf8 -stack), s: (addr stream byte) -> _/eax: boolean {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn suffix-match? _self: (addr grapheme -stack), s: (addr stream byte) -> _/eax: boolean {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var data-ah/edi: (addr handle array code-point-utf8) <- get self, d a t a
var _data/eax: (addr array code-point-utf8) <- lookup * d a t a - a h
var data/edi: (addr array code-point-utf8) <- copy _ d a t a
@ -549,15 +549,15 @@ fn suffix-match? _self: (addr code-point-utf8-stack), s: (addr stream byte) -> _
return 1 # t r u e
}
fn code-point-utf8 -stack-is-decimal-integer? _self: (addr code-point-utf8 -stack) -> _/eax: boolean {
var self/esi: (addr code-point-utf8 -stack) <- copy _ s e l f
fn grapheme -stack-is-decimal-integer? _self: (addr grapheme -stack) -> _/eax: boolean {
var self/esi: (addr grapheme -stack) <- copy _ s e l f
var data-ah/eax: (addr handle array code-point-utf8) <- get self, d a t a
var _data/eax: (addr array code-point-utf8) <- lookup * d a t a - a h
var data/edx: (addr array code-point-utf8) <- copy _ d a t a
var top-addr/ecx: (addr int) <- get self, t o p
var i/ebx: int <- copy 0
var result/eax: boolean <- copy 1 / t r u e
$c ode-point-utf8 -stack-is-integer?:loop: {
$grapheme -stack-is-integer?:loop: {
compare i, * t o p - a d d r
b r e a k - i f - > =
var g/edx: (addr code-point-utf8) <- index data, i