diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-06-06 15:41:42 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-06-06 15:43:42 -0700 |
commit | fb778c1d86df966a159427459a7d9315ae0c63a3 (patch) | |
tree | e8fed79c026ea9713f1d9836a82524da798941cd | |
parent | 6e8f8c549a8bcb7e5c156ffd3017e8febc7b485e (diff) | |
download | mu-fb778c1d86df966a159427459a7d9315ae0c63a3.tar.gz |
6496
-rw-r--r-- | prototypes/browse/28/main.mu | 2 | ||||
-rw-r--r-- | prototypes/browse/29/README.md | 1 | ||||
-rw-r--r-- | prototypes/browse/29/file-state.mu | 44 | ||||
-rw-r--r-- | prototypes/browse/29/main.mu | 257 | ||||
-rw-r--r-- | prototypes/browse/29/screen-position-state.mu | 171 |
5 files changed, 474 insertions, 1 deletions
diff --git a/prototypes/browse/28/main.mu b/prototypes/browse/28/main.mu index 79e07a60..b12ddc34 100644 --- a/prototypes/browse/28/main.mu +++ b/prototypes/browse/28/main.mu @@ -86,7 +86,7 @@ $render-normal:loop-body: { # If there's a newline buffered and c is not a newline or space, print a # space (soft newline). compare newline-seen?, 0 # false - $render-normal:flush-buffered-newline: { +$render-normal:flush-buffered-newline: { break-if-= newline-seen? <- copy 0 # false { diff --git a/prototypes/browse/29/README.md b/prototypes/browse/29/README.md new file mode 100644 index 00000000..e1bb7799 --- /dev/null +++ b/prototypes/browse/29/README.md @@ -0,0 +1 @@ +Be more selective about bold sections. diff --git a/prototypes/browse/29/file-state.mu b/prototypes/browse/29/file-state.mu new file mode 100644 index 00000000..35f40229 --- /dev/null +++ b/prototypes/browse/29/file-state.mu @@ -0,0 +1,44 @@ +type file-state { + source: (handle buffered-file) + eof?: boolean +} + +fn init-file-state _self: (addr file-state), filename: (addr array byte) { + var self/eax: (addr file-state) <- copy _self + load-file self, filename + var eof/eax: (addr boolean) <- get self, eof? + copy-to *eof, 0 # false +} + +fn load-file _self: (addr file-state), filename: (addr array byte) { + var self/eax: (addr file-state) <- copy _self + var out/esi: (addr handle buffered-file) <- get self, source + open filename, 0, out # 0 = read mode +} + +fn next-char _self: (addr file-state) -> result/eax: byte { + var self/ecx: (addr file-state) <- copy _self + var source/eax: (addr handle buffered-file) <- get self, source + var in/eax: (addr buffered-file) <- lookup *source + result <- read-byte-buffered in + # if result == EOF, set eof? + compare result, 0xffffffff # EOF marker + { + var eof/ecx: (addr boolean) <- get self, eof? + copy-to *eof, 1 # true + } +} + +fn done-reading? _self: (addr file-state) -> result/eax: boolean { + var self/eax: (addr file-state) <- copy _self + var eof/eax: (addr boolean) <- get self, eof? + result <- copy *eof +} + +fn dump in: (addr buffered-file) { + var c/eax: byte <- read-byte-buffered in + compare c, 0xffffffff # EOF marker + break-if-= + print-byte c + loop +} diff --git a/prototypes/browse/29/main.mu b/prototypes/brow-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ |