about summary refs log tree commit diff stats
path: root/apps/browse
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-09-07 22:18:44 -0700
committerKartik Agaram <vc@akkartik.com>2020-09-07 22:18:44 -0700
commit664910816ce599adf4bbb5ce842424c49ec70359 (patch)
tree962aab2eb8d4dd45b06539f27f1a2493c9ebe5c9 /apps/browse
parentfc42975cf429a75f15b079d9d0d216311b42f7a9 (diff)
downloadmu-664910816ce599adf4bbb5ce842424c49ec70359.tar.gz
6752
Diffstat (limited to 'apps/browse')
-rw-r--r--apps/browse/main.mu18
-rw-r--r--apps/browse/paginated-screen.mu (renamed from apps/browse/screen-position-state.mu)32
2 files changed, 26 insertions, 24 deletions
diff --git a/apps/browse/main.mu b/apps/browse/main.mu
index 8467f01f..98d69588 100644
--- a/apps/browse/main.mu
+++ b/apps/browse/main.mu
@@ -10,12 +10,12 @@ fn main args: (addr array addr array byte) -> exit-status/ebx: int {
   enable-screen-grid-mode
   enable-keyboard-immediate-mode
   # initialize screen state from screen size
-  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
+  var paginated-screen-storage: paginated-screen
+  var paginated-screen/eax: (addr paginated-screen) <- address paginated-screen-storage
+  init-paginated-screen paginated-screen
   normal-text 0
   {
-    render 0, fs, screen-position-state
+    render 0, fs, paginated-screen
     var key/eax: byte <- read-key
     compare key, 0x71  # 'q'
     loop-if-!=
@@ -25,12 +25,12 @@ fn main args: (addr array addr array byte) -> exit-status/ebx: int {
   exit-status <- copy 0
 }
 
-fn render screen: (addr screen), fs: (addr buffered-file), state: (addr screen-position-state) {
+fn render screen: (addr screen), fs: (addr buffered-file), state: (addr paginated-screen) {
   start-drawing state
   render-normal screen, fs, state
 }
 
-fn render-normal screen: (addr screen), fs: (addr buffered-file), state: (addr screen-position-state) {
+fn render-normal screen: (addr screen), fs: (addr buffered-file), state: (addr paginated-screen) {
   var newline-seen?/esi: boolean <- copy 0  # false
   var start-of-paragraph?/edi: boolean <- copy 1  # true
   var previous-grapheme/ebx: grapheme <- copy 0
@@ -140,7 +140,7 @@ $render-normal:whitespace-separated-regions: {
   }  # $render-normal:loop
 }
 
-fn render-header-line screen: (addr screen), fs: (addr buffered-file), state: (addr screen-position-state) {
+fn render-header-line screen: (addr screen), fs: (addr buffered-file), state: (addr paginated-screen) {
 $render-header-line:body: {
   # compute color based on number of '#'s
   var header-level/esi: int <- copy 1  # caller already grabbed one
@@ -219,7 +219,7 @@ $start-heading:body: {
 }
 }
 
-fn render-until-asterisk fs: (addr buffered-file), state: (addr screen-position-state) {
+fn render-until-asterisk fs: (addr buffered-file), state: (addr paginated-screen) {
   {
     # if done-drawing?(state) break
     var done?/eax: boolean <- done-drawing? state
@@ -240,7 +240,7 @@ fn render-until-asterisk fs: (addr buffered-file), state: (addr screen-position-
   }
 }
 
-fn render-until-underscore fs: (addr buffered-file), state: (addr screen-position-state) {
+fn render-until-underscore fs: (addr buffered-file), state: (addr paginated-screen) {
   {
     # if done-drawing?(state) break
     var done?/eax: boolean <- done-drawing? state
diff --git a/apps/browse/screen-position-state.mu b/apps/browse/paginated-screen.mu
index f342faab..564411f8 100644
--- a/apps/browse/screen-position-state.mu
+++ b/apps/browse/paginated-screen.mu
@@ -1,4 +1,6 @@
-type screen-position-state {
+# if a screen is too wide, split it up into a fixed size of pages
+
+type paginated-screen {
   nrows: int  # const
   ncols: int  # const
   toprow: int
@@ -9,12 +11,12 @@ type screen-position-state {
   col: int
 }
 
-fn init-screen-position-state _self: (addr screen-position-state) {
+fn init-paginated-screen _self: (addr paginated-screen) {
   # hardcoded parameters:
   #   top-margin
   #   page-margin
   #   page-width
-  var self/esi: (addr screen-position-state) <- copy _self
+  var self/esi: (addr paginated-screen) <- copy _self
   var nrows/eax: int <- copy 0xa
   var ncols/ecx: int <- copy 0x20
   nrows, ncols <- screen-size 0  # Comment this out to debug with a tiny page. You'll also need to adjust rightcol below.
@@ -35,8 +37,8 @@ fn init-screen-position-state _self: (addr screen-position-state) {
   start-drawing self
 }
 
-fn start-drawing _self: (addr screen-position-state) {
-  var self/esi: (addr screen-position-state) <- copy _self
+fn start-drawing _self: (addr paginated-screen) {
+  var self/esi: (addr paginated-screen) <- copy _self
   var tmp/eax: (addr int) <- copy 0
   var tmp2/ecx: int <- copy 0
   clear-screen 0
@@ -61,9 +63,9 @@ fn start-drawing _self: (addr screen-position-state) {
   reposition-cursor self
 }
 
-fn add-grapheme _self: (addr screen-position-state), c: grapheme {
+fn add-grapheme _self: (addr paginated-screen), c: grapheme {
 $add-grapheme:body: {
-  var self/esi: (addr screen-position-state) <- copy _self
+  var self/esi: (addr paginated-screen) <- copy _self
   {
     compare c, 0xa  # newline
     break-if-!=
@@ -88,8 +90,8 @@ $add-grapheme:body: {
 }
 }
 
-fn next-line _self: (addr screen-position-state) {
-  var self/esi: (addr screen-position-state) <- copy _self
+fn next-line _self: (addr paginated-screen) {
+  var self/esi: (addr paginated-screen) <- copy _self
   var tmp/eax: (addr int) <- copy 0
   var tmp2/ecx: int <- copy 0
   # self->col = self->leftcol
@@ -110,8 +112,8 @@ fn next-line _self: (addr screen-position-state) {
   }
 }
 
-fn next-page _self: (addr screen-position-state) {
-  var self/esi: (addr screen-position-state) <- copy _self
+fn next-page _self: (addr paginated-screen) {
+  var self/esi: (addr paginated-screen) <- copy _self
   var tmp/eax: (addr int) <- copy 0
   var tmp2/ecx: int <- copy 0
 #?   # temporary: stop
@@ -143,10 +145,10 @@ fn next-page _self: (addr screen-position-state) {
   copy-to *tmp, tmp2
 }
 
-fn done-drawing? _self: (addr screen-position-state) -> result/eax: boolean {
+fn done-drawing? _self: (addr paginated-screen) -> result/eax: boolean {
 $done-drawing?:body: {
   # return self->rightcol >= self->ncols
-  var self/esi: (addr screen-position-state) <- copy _self
+  var self/esi: (addr paginated-screen) <- copy _self
   var max/ecx: (addr int) <- get self, ncols
   var tmp/eax: (addr int) <- get self, rightcol
   var right/eax: int <- copy *tmp
@@ -163,8 +165,8 @@ $done-drawing?:body: {
 }
 }
 
-fn reposition-cursor _self: (addr screen-position-state) {
-  var self/esi: (addr screen-position-state) <- copy _self
+fn reposition-cursor _self: (addr paginated-screen) {
+  var self/esi: (addr paginated-screen) <- copy _self
   var r/eax: (addr int) <- get self, row
   var c/ecx: (addr int) <- get self, col
   move-cursor 0, *r *c