diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/gap-buffer.mu | 21 | ||||
-rw-r--r-- | shell/grapheme-stack.mu | 12 |
2 files changed, 18 insertions, 15 deletions
diff --git a/shell/gap-buffer.mu b/shell/gap-buffer.mu index 88285a43..13f66f40 100644 --- a/shell/gap-buffer.mu +++ b/shell/gap-buffer.mu @@ -395,6 +395,7 @@ fn render-gap-buffer-wrapping-right-then-down screen: (addr screen), _gap: (addr var right/edx: (addr grapheme-stack) <- get gap, right x2, y2 <- render-stack-from-top-wrapping-right-then-down screen, right, xmin, ymin, xmax, ymax, x2, y2, render-cursor?, color, background-color # decide whether we still need to print a cursor + var fg/edi: int <- copy color var bg/ebx: int <- copy background-color compare render-cursor?, 0/false { @@ -403,11 +404,13 @@ fn render-gap-buffer-wrapping-right-then-down screen: (addr screen), _gap: (addr var empty?/eax: boolean <- grapheme-stack-empty? right compare empty?, 0/false break-if-= - bg <- copy 7/cursor + # swap foreground and background + fg <- copy background-color + bg <- copy color } # print a grapheme either way so that cursor position doesn't affect printed width var space/edx: grapheme <- copy 0x20 - x2, y2 <- render-grapheme screen, space, xmin, ymin, xmax, ymax, x2, y2, color, bg + x2, y2 <- render-grapheme screen, space, xmin, ymin, xmax, ymax, x2, y2, fg, bg return x2, y2 } @@ -823,7 +826,7 @@ fn test-render-gap-buffer-without-cursor { check-screen-row screen, 0/y, "abc ", "F - test-render-gap-buffer-without-cursor" check-ints-equal x, 4, "F - test-render-gap-buffer-without-cursor: result" # abc - check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, " ", "F - test-render-gap-buffer-without-cursor: bg" + check-background-color-in-screen-row screen, 3/bg=reverse, 0/y, " ", "F - test-render-gap-buffer-without-cursor: bg" } fn test-render-gap-buffer-with-cursor-at-end { @@ -842,7 +845,7 @@ fn test-render-gap-buffer-with-cursor-at-end { # we've drawn one extra grapheme for the cursor check-ints-equal x, 4, "F - test-render-gap-buffer-with-cursor-at-end: result" # abc - check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, " |", "F - test-render-gap-buffer-with-cursor-at-end: bg" + check-background-color-in-screen-row screen, 3/bg=reverse, 0/y, " |", "F - test-render-gap-buffer-with-cursor-at-end: bg" } fn test-render-gap-buffer-with-cursor-in-middle { @@ -861,7 +864,7 @@ fn test-render-gap-buffer-with-cursor-in-middle { check-screen-row screen, 0/y, "abc ", "F - test-render-gap-buffer-with-cursor-in-middle" check-ints-equal x, 4, "F - test-render-gap-buffer-with-cursor-in-middle: result" # abc - check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, " | ", "F - test-render-gap-buffer-with-cursor-in-middle: bg" + check-background-color-in-screen-row screen, 3/bg=reverse, 0/y, " | ", "F - test-render-gap-buffer-with-cursor-in-middle: bg" } fn test-render-gap-buffer-with-cursor-at-start { @@ -878,7 +881,7 @@ fn test-render-gap-buffer-with-cursor-at-start { check-screen-row screen, 0/y, "abc ", "F - test-render-gap-buffer-with-cursor-at-start" check-ints-equal x, 4, "F - test-render-gap-buffer-with-cursor-at-start: result" # abc - check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, "| ", "F - test-render-gap-buffer-with-cursor-at-start: bg" + check-background-color-in-screen-row screen, 3/bg=reverse, 0/y, "| ", "F - test-render-gap-buffer-with-cursor-at-start: bg" } fn test-render-gap-buffer-highlight-matching-close-paren { @@ -894,7 +897,7 @@ fn test-render-gap-buffer-highlight-matching-close-paren { var x/eax: int <- render-gap-buffer screen, gap, 0/x, 0/y, 1/show-cursor, 3/fg, 0xc5/bg=blue-bg check-screen-row screen, 0/y, "(a) ", "F - test-render-gap-buffer-highlight-matching-close-paren" check-ints-equal x, 4, "F - test-render-gap-buffer-highlight-matching-close-paren: result" - check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, "| ", "F - test-render-gap-buffer-highlight-matching-close-paren: cursor" + check-background-color-in-screen-row screen, 3/bg=reverse, 0/y, "| ", "F - test-render-gap-buffer-highlight-matching-close-paren: cursor" check-screen-row-in-color screen, 0xf/fg=highlight, 0/y, " ) ", "F - test-render-gap-buffer-highlight-matching-close-paren: matching paren" } @@ -912,7 +915,7 @@ fn test-render-gap-buffer-highlight-matching-open-paren { var x/eax: int <- render-gap-buffer screen, gap, 0/x, 0/y, 1/show-cursor, 3/fg, 0xc5/bg=blue-bg check-screen-row screen, 0/y, "(a) ", "F - test-render-gap-buffer-highlight-matching-open-paren" check-ints-equal x, 4, "F - test-render-gap-buffer-highlight-matching-open-paren: result" - check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, " | ", "F - test-render-gap-buffer-highlight-matching-open-paren: cursor" + check-background-color-in-screen-row screen, 3/bg=reverse, 0/y, " | ", "F - test-render-gap-buffer-highlight-matching-open-paren: cursor" check-screen-row-in-color screen, 0xf/fg=highlight, 0/y, "( ", "F - test-render-gap-buffer-highlight-matching-open-paren: matching paren" } @@ -929,7 +932,7 @@ fn test-render-gap-buffer-highlight-matching-open-paren-of-end { var x/eax: int <- render-gap-buffer screen, gap, 0/x, 0/y, 1/show-cursor, 3/fg, 0xc5/bg=blue-bg check-screen-row screen, 0/y, "(a) ", "F - test-render-gap-buffer-highlight-matching-open-paren-of-end" check-ints-equal x, 4, "F - test-render-gap-buffer-highlight-matching-open-paren-of-end: result" - check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, " |", "F - test-render-gap-buffer-highlight-matching-open-paren-of-end: cursor" + check-background-color-in-screen-row screen, 3/bg=reverse, 0/y, " |", "F - test-render-gap-buffer-highlight-matching-open-paren-of-end: cursor" check-screen-row-in-color screen, 0xf/fg=highlight, 0/y, "( ", "F - test-render-gap-buffer-highlight-matching-open-paren-of-end: matching paren" } diff --git a/shell/grapheme-stack.mu b/shell/grapheme-stack.mu index 16a9a596..13f0e31c 100644 --- a/shell/grapheme-stack.mu +++ b/shell/grapheme-stack.mu @@ -153,7 +153,7 @@ fn render-stack-from-top-wrapping-right-then-down screen: (addr screen), _self: compare i, 0 break-if-< var g/esi: (addr grapheme) <- index data, i - x, y <- render-grapheme screen, *g, xmin, ymin, xmax, ymax, x, y, color, 7/bg=cursor + x, y <- render-grapheme screen, *g, xmin, ymin, xmax, ymax, x, y, background-color, color i <- decrement } # remaining iterations @@ -212,17 +212,17 @@ fn test-render-grapheme-stack { var x/eax: int <- render-stack-from-bottom screen, gs, 0/x, 0/y, 0/no-highlight-matching-open-paren, 0/open-paren-depth check-screen-row screen, 0/y, "abc ", "F - test-render-grapheme-stack from bottom" check-ints-equal x, 3, "F - test-render-grapheme-stack from bottom: result" - check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, " ", "F - test-render-grapheme-stack from bottom: bg" + check-background-color-in-screen-row screen, 3/bg=reverse, 0/y, " ", "F - test-render-grapheme-stack from bottom: bg" # var x/eax: int <- render-stack-from-top screen, gs, 0/x, 1/y, 0/cursor=false check-screen-row screen, 1/y, "cba ", "F - test-render-grapheme-stack from top without cursor" check-ints-equal x, 3, "F - test-render-grapheme-stack from top without cursor: result" - check-background-color-in-screen-row screen, 7/bg=cursor, 1/y, " ", "F - test-render-grapheme-stack from top without cursor: bg" + check-background-color-in-screen-row screen, 3/bg=reverse, 1/y, " ", "F - test-render-grapheme-stack from top without cursor: bg" # var x/eax: int <- render-stack-from-top screen, gs, 0/x, 2/y, 1/cursor=true check-screen-row screen, 2/y, "cba ", "F - test-render-grapheme-stack from top with cursor" check-ints-equal x, 3, "F - test-render-grapheme-stack from top with cursor: result" - check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "| ", "F - test-render-grapheme-stack from top with cursor: bg" + check-background-color-in-screen-row screen, 3/bg=reverse, 2/y, "| ", "F - test-render-grapheme-stack from top with cursor: bg" } fn test-render-grapheme-stack-while-highlighting-matching-close-paren { @@ -243,7 +243,7 @@ fn test-render-grapheme-stack-while-highlighting-matching-close-paren { # var x/eax: int <- render-stack-from-top screen, gs, 0/x, 2/y, 1/cursor=true check-screen-row screen, 2/y, "(b) ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren" - check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "| ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren: cursor" + check-background-color-in-screen-row screen, 3/bg=reverse, 2/y, "| ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren: cursor" check-screen-row-in-color screen, 0xf/fg=white, 2/y, " ) ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren: matching paren" } @@ -277,7 +277,7 @@ fn test-render-grapheme-stack-while-highlighting-matching-close-paren-2 { # var x/eax: int <- render-stack-from-top screen, gs, 0/x, 2/y, 1/cursor=true check-screen-row screen, 2/y, "(a (b)) c ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren-2" - check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "| ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren-2: cursor" + check-background-color-in-screen-row screen, 3/bg=reverse, 2/y, "| ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren-2: cursor" check-screen-row-in-color screen, 0xf/fg=white, 2/y, " ) ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren-2: matching paren" } |