about summary refs log tree commit diff stats
path: root/prototypes/browse/17-file-state-broken/screen-position-state.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-05-31 23:43:49 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-31 23:43:49 -0700
commit9cc69d69c6cd83ed4aa367b4a08ca379cae45805 (patch)
treeb469fd1bf0b3e46258cd835f82da72ee3d26e310 /prototypes/browse/17-file-state-broken/screen-position-state.mu
parent2f16a74783d830caf2cc01bd67996317195c94c9 (diff)
downloadmu-9cc69d69c6cd83ed4aa367b4a08ca379cae45805.tar.gz
6456 - new directory for live-blogging prototypes
I don't have layers yet in Mu. But I can still create lots of versions
of a program.
Diffstat (limited to 'prototypes/browse/17-file-state-broken/screen-position-state.mu')
-rw-r--r--prototypes/browse/17-file-state-broken/screen-position-state.mu50
1 files changed, 50 insertions, 0 deletions
diff --git a/prototypes/browse/17-file-state-broken/screen-position-state.mu b/prototypes/browse/17-file-state-broken/screen-position-state.mu
new file mode 100644
index 00000000..af623d16
--- /dev/null
+++ b/prototypes/browse/17-file-state-broken/screen-position-state.mu
@@ -0,0 +1,50 @@
+type screen-position-state {
+  nrows: int  # const
+  ncols: int  # const
+  toprow: int
+  botrow: int
+  leftcol: int
+  rightcol: int
+  row: int
+  col: int
+}
+
+fn init-screen-position-state self: (addr screen-position-state), nrows: int, ncols: int {
+  # hardcoded parameters:
+  #   top-margin
+  #   page-margin
+  #   text-width
+  var dest/eax: (addr int) <- copy 0
+  # self->nrows = nrows
+  # self->ncols = ncols
+  # self->toprow = top-margin
+  # self->botrow = nrows
+  # self->leftcol = page-margin
+  # self->rightcol = self->leftcol + text-width
+  # start-drawing(self)
+}
+
+fn start-drawing self: (addr screen-position-state) {
+  # self->row = toprow
+  # self->col = leftcol
+}
+
+fn add-char self: (addr screen-position-state), c: byte {
+  # print c
+  # self->col++
+  # if (self->col > self->rightcol) next-line(self)
+}
+
+fn next-line self: (addr screen-position-state) {
+  # self->row++
+  # if (self->row > self->botrow) next-page(self)
+}
+
+fn next-page self: (addr screen-position-state) {
+  # self->leftcol = self->rightcol + 5
+  # self->rightcol = self->leftcol + text-width
+}
+
+fn done-drawing? self: (addr screen-position-state) -> result/eax: boolean {
+  # self->rightcol >= self->ncols
+}