about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-02-26 21:57:54 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-26 21:57:54 -0800
commitd54c3dda5a32fe22989d66e266864132489a08b8 (patch)
tree856734f8161d6ce94bc9c575f3ae4e3b8efa8a90
parentd92d7fbb555217890469d5c5f28d224cc827da7c (diff)
downloadmu-d54c3dda5a32fe22989d66e266864132489a08b8.tar.gz
847
-rw-r--r--trace.arc.t14
-rw-r--r--trace.mu7
2 files changed, 21 insertions, 0 deletions
diff --git a/trace.arc.t b/trace.arc.t
index b138d55a..9278fcf9 100644
--- a/trace.arc.t
+++ b/trace.arc.t
@@ -669,6 +669,20 @@ run: main 7: n")
             "+ main/ 7 : n    "
             "                 "))
   (prn "F - 'page-down' skips to same place regardless of cursor position"))
+; now page-up
+(run-code main8
+  (default-space:space-address <- new space:literal 30:literal/capacity)
+  (s:string-address <- new "jJ")
+  (k:keyboard-address <- init-keyboard s:string-address)
+  (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
+  (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
+  )
+; page-down behaves the same regardless of where the cursor was
+(when (~screen-contains memory*.4 17
+         (+ "+ main/ 6 : m    "
+            "+ main/ 7 : n    "
+            "                 "))
+  (prn "F - 'page-down' skips to same place regardless of cursor position"))
 
 ; todo
 ;   pgup/pgdn to navigate pages (minimize up/down responsibilities for performance)
diff --git a/trace.mu b/trace.mu
index 3209e941..466e5ec9 100644
--- a/trace.mu
+++ b/trace.mu
@@ -484,6 +484,13 @@
     (K?:boolean <- equal c:character ((#\K literal)))
     (page-up?:boolean <- or page-up?:boolean K?:boolean)
     (break-unless page-up?:boolean)
+    (first-page?:boolean <- lesser-or-equal first-index-on-page:integer/space:1 0:literal)
+    (break-if first-page?:boolean)
+    ; move cursor to top of screen
+    (to-top 0:space-address/browser-state screen:terminal-address)
+    ; start drawing from previous page
+    (new-page-start:integer <- subtract first-index-on-page:integer/space:1 screen-height:integer/space:1)
+    (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address new-page-start:integer)
   }
   { begin
     (page-down?:boolean <- equal c:character ((page-up literal)))