about summary refs log tree commit diff stats
path: root/prototypes
diff options
context:
space:
mode:
Diffstat (limited to 'prototypes')
-rw-r--r--prototypes/browse/24-bold/main.mu76
1 files changed, 75 insertions, 1 deletions
diff --git a/prototypes/browse/24-bold/main.mu b/prototypes/browse/24-bold/main.mu
index cf2fef0d..f0a74687 100644
--- a/prototypes/browse/24-bold/main.mu
+++ b/prototypes/browse/24-bold/main.mu
@@ -11,6 +11,7 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
   var screen-position-state-storage: screen-position-state
   var screen-position-state/eax: (addr screen-position-state) <- address screen-position-state-storage
   init-screen-position-state screen-position-state
+  start-color 0xec, 7  # 236 = darkish gray
   {
     render fs, screen-position-state
     var key/eax: byte <- read-key
@@ -28,7 +29,73 @@ fn render fs: (addr file-state), state: (addr screen-position-state) {
 }
 
 fn render-normal fs: (addr file-state), state: (addr screen-position-state) {
-  {
+$render-normal:body: {
+    # if done-drawing?(state) break
+    var done?/eax: boolean <- done-drawing? state
+    compare done?, 0  # false
+    break-if-!=
+    #
+    var c/eax: byte <- next-char fs
+    # if (c == EOF) break
+    compare c, 0xffffffff  # EOF marker
+    break-if-=
+    # if (c == '*') print it and break
+    compare c, 0x2a  # '*'
+    {
+      break-if-!=
+      start-color 0xec, 7  # 236 = darkish gray
+      start-bold
+        add-char state, c
+        render-until-asterisk fs, state
+      reset-formatting
+      start-color 0xec, 7  # 236 = darkish gray
+      loop $render-normal:body
+    }
+    compare c, 0x5f  # '_'
+    {
+      break-if-!=
+      start-color 0xec, 7  # 236 = darkish gray
+      start-bold
+        add-char state, c
+        render-until-underscore fs, state
+      reset-formatting
+      start-color 0xec, 7  # 236 = darkish gray
+      loop $render-normal:body
+    }
+    #
+    add-char state, c
+    #
+    loop
+  }
+}
+
+fn render-until-asterisk fs: (addr file-state), state: (addr screen-position-state) {
+$render-until-asterisk:body: {
+    # if done-drawing?(state) break
+    var done?/eax: boolean <- done-drawing? state
+    compare done?, 0  # false
+    break-if-!=
+    #
+    var c/eax: byte <- next-char fs
+    # if (c == EOF) break
+    compare c, 0xffffffff  # EOF marker
+    break-if-=
+    # if (c == '*') print it and break
+    compare c, 0x2a  # '*'
+    {
+      break-if-!=
+      add-char state, c
+      break $render-until-asterisk:body
+    }
+    #
+    add-char state, c
+    #
+    loop
+  }
+}
+
+fn render-until-underscore fs: (addr file-state), state: (addr screen-position-state) {
+$render-until-underscore:body: {
     # if done-drawing?(state) break
     var done?/eax: boolean <- done-drawing? state
     compare done?, 0  # false
@@ -38,6 +105,13 @@ fn render-normal fs: (addr file-state), state: (addr screen-position-state) {
     # if (c == EOF) break
     compare c, 0xffffffff  # EOF marker
     break-if-=
+    # if (c == '_') print it and break
+    compare c, 0x5f  # '_'
+    {
+      break-if-!=
+      add-char state, c
+      break $render-until-underscore:body
+    }
     #
     add-char state, c
     #