about summary refs log tree commit diff stats
path: root/apps/browse/paginated-screen.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-09-07 23:43:23 -0700
committerKartik Agaram <vc@akkartik.com>2020-09-07 23:43:23 -0700
commit8c9b8e8f77df88f1fb12339c5d548ae973f0fbde (patch)
treeae15b126ec0cce2f37b01b34fbe349e1e189ff1e /apps/browse/paginated-screen.mu
parent571ff107a26a2bc1932ec9dc0d62365f99e385f9 (diff)
downloadmu-8c9b8e8f77df88f1fb12339c5d548ae973f0fbde.tar.gz
6758
Diffstat (limited to 'apps/browse/paginated-screen.mu')
-rw-r--r--apps/browse/paginated-screen.mu42
1 files changed, 29 insertions, 13 deletions
diff --git a/apps/browse/paginated-screen.mu b/apps/browse/paginated-screen.mu
index 0ceb3856..88a3d206 100644
--- a/apps/browse/paginated-screen.mu
+++ b/apps/browse/paginated-screen.mu
@@ -14,6 +14,8 @@ type paginated-screen {
   nrows: int  # const
   ncols: int  # const
   page-width: int
+  top-margin: int
+  left-margin: int
   toprow: int
   botrow: int
   leftcol: int
@@ -22,10 +24,7 @@ type paginated-screen {
   col: int
 }
 
-fn initialize-paginated-screen _self: (addr paginated-screen), page-width: int {
-  # hardcoded parameters:
-  #   top-margin
-  #   page-margin
+fn initialize-paginated-screen _self: (addr paginated-screen), page-width: int, top-margin: int, left-margin: int {
   var self/esi: (addr paginated-screen) <- copy _self
   var screen-ah/eax: (addr handle screen) <- get self, screen
   var _screen-addr/eax: (addr screen) <- lookup *screen-ah
@@ -42,16 +41,33 @@ fn initialize-paginated-screen _self: (addr paginated-screen), page-width: int {
   copy-to *dest, ncols
   # self->page-width = page-width
   {
-    var pg/eax: int <- copy page-width
+    var tmp/eax: int <- copy page-width
     dest <- get self, page-width
-    copy-to *dest, pg
+    copy-to *dest, tmp
+  }
+  # self->top-margin = top-margin
+  {
+    var tmp/eax: int <- copy top-margin
+    dest <- get self, top-margin
+    copy-to *dest, tmp
+  }
+  # self->left-margin = left-margin
+  {
+    var tmp/eax: int <- copy left-margin
+    dest <- get self, left-margin
+    copy-to *dest, tmp
   }
   # self->toprow = top-margin
-  dest <- get self, toprow
-  copy-to *dest, 2  # top-margin
+  {
+    var tmp/eax: int <- copy top-margin
+    dest <- get self, toprow
+    copy-to *dest, tmp
+  }
   # self->botrow = nrows
-  dest <- get self, botrow
-  copy-to *dest, nrows
+  {
+    dest <- get self, botrow
+    copy-to *dest, nrows
+  }
   #
   start-drawing self
 }
@@ -134,13 +150,13 @@ $add-grapheme:body: {
 
 ## tests
 
-fn initialize-fake-paginated-screen _self: (addr paginated-screen), nrows: int, ncols: int, page-width: int {
+fn initialize-fake-paginated-screen _self: (addr paginated-screen), nrows: int, ncols: int, page-width: int, top-margin: int, left-margin: int {
   var self/esi: (addr paginated-screen) <- copy _self
   var screen-ah/eax: (addr handle screen) <- get self, screen
   allocate screen-ah
   var screen-addr/eax: (addr screen) <- lookup *screen-ah
   initialize-screen screen-addr, nrows, ncols
-  initialize-paginated-screen self, page-width
+  initialize-paginated-screen self, page-width, top-margin, left-margin
 }
 
 ## simple delegates
@@ -229,7 +245,6 @@ fn next-line _self: (addr paginated-screen) {
 
 fn next-page _self: (addr paginated-screen) {
   var self/esi: (addr paginated-screen) <- copy _self
-  var pg/edi: (addr int) <- get self, page-width
   var tmp/eax: (addr int) <- copy 0
   var tmp2/ecx: int <- copy 0
 #?   # temporary: stop
@@ -246,6 +261,7 @@ fn next-page _self: (addr paginated-screen) {
   copy-to *tmp, tmp2
   # self->rightcol = self->leftcol + page-width
   tmp2 <- copy *tmp
+  var pg/edi: (addr int) <- get self, page-width
   tmp2 <- add *pg
   tmp <- get self, rightcol
   copy-to *tmp, tmp2