about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2018-02-15 21:14:30 -0800
committerKartik K. Agaram <vc@akkartik.com>2018-02-15 21:14:30 -0800
commit43ac7bef4b4ca484877ce1a53d9d54a51e1aab86 (patch)
treeee4212ee0322145a895626a657f53c8121d2d7f2
parent745a6dee7875154e3512bed5d2c73869dddef13e (diff)
downloadmu-43ac7bef4b4ca484877ce1a53d9d54a51e1aab86.tar.gz
4205
-rw-r--r--edit/003-shortcuts.mu90
-rw-r--r--sandbox/003-shortcuts.mu90
2 files changed, 90 insertions, 90 deletions
diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu
index e24f7e72..02ea77d0 100644
--- a/edit/003-shortcuts.mu
+++ b/edit/003-shortcuts.mu
@@ -1060,6 +1060,51 @@ def move-to-previous-line editor:&:editor -> go-render?:bool, editor:&:editor [
   }
 ]
 
+# Takes a pointer into the doubly-linked list, scans back to before start of
+# previous *wrapped* line.
+# Returns original if no next newline.
+# Beware: never return null pointer.
+def before-previous-screen-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [
+  local-scope
+  load-inputs
+  curr:&:duplex-list:char <- copy in
+  c:char <- get *curr, value:offset
+  # compute max, number of characters to skip
+  #   1 + len%(width-1)
+  #   except rotate second term to vary from 1 to width-1 rather than 0 to width-2
+  left:num <- get *editor, left:offset
+  right:num <- get *editor, right:offset
+  max-line-length:num <- subtract right, left, -1/exclusive-right, 1/wrap-icon
+  sentinel:&:duplex-list:char <- get *editor, data:offset
+  len:num <- previous-line-length curr, sentinel
+  {
+    break-if len
+    # empty line; just skip this newline
+    prev:&:duplex-list:char <- prev curr
+    return-unless prev, curr
+    return prev
+  }
+  _, max:num <- divide-with-remainder len, max-line-length
+  # remainder 0 => scan one width-worth
+  {
+    break-if max
+    max <- copy max-line-length
+  }
+  max <- add max, 1
+  count:num <- copy 0
+  # skip 'max' characters
+  {
+    done?:bool <- greater-or-equal count, max
+    break-if done?
+    prev:&:duplex-list:char <- prev curr
+    break-unless prev
+    curr <- copy prev
+    count <- add count, 1
+    loop
+  }
+  return curr
+]
+
 scenario editor-adjusts-column-at-previous-line [
   local-scope
   assume-screen 10/width, 5/height
@@ -3168,51 +3213,6 @@ after <scroll-up> [
   return-if no-movement?, 0/don't-render
 ]
 
-# Takes a pointer into the doubly-linked list, scans back to before start of
-# previous *wrapped* line.
-# Returns original if no next newline.
-# Beware: never return null pointer.
-def before-previous-screen-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [
-  local-scope
-  load-inputs
-  curr:&:duplex-list:char <- copy in
-  c:char <- get *curr, value:offset
-  # compute max, number of characters to skip
-  #   1 + len%(width-1)
-  #   except rotate second term to vary from 1 to width-1 rather than 0 to width-2
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  max-line-length:num <- subtract right, left, -1/exclusive-right, 1/wrap-icon
-  sentinel:&:duplex-list:char <- get *editor, data:offset
-  len:num <- previous-line-length curr, sentinel
-  {
-    break-if len
-    # empty line; just skip this newline
-    prev:&:duplex-list:char <- prev curr
-    return-unless prev, curr
-    return prev
-  }
-  _, max:num <- divide-with-remainder len, max-line-length
-  # remainder 0 => scan one width-worth
-  {
-    break-if max
-    max <- copy max-line-length
-  }
-  max <- add max, 1
-  count:num <- copy 0
-  # skip 'max' characters
-  {
-    done?:bool <- greater-or-equal count, max
-    break-if done?
-    prev:&:duplex-list:char <- prev curr
-    break-unless prev
-    curr <- copy prev
-    count <- add count, 1
-    loop
-  }
-  return curr
-]
-
 scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys [
   local-scope
   # screen has 1 line for menu + 3 lines
diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu
index c152f504..c12429f0 100644
--- a/sandbox/003-shortcuts.mu
+++ b/sandbox/003-shortcuts.mu
@@ -1047,6 +1047,51 @@ def move-to-previous-line editor:&:editor -> editor:&:editor [
   }
 ]
 
+# Takes a pointer into the doubly-linked list, scans back to before start of
+# previous *wrapped* line.
+# Returns original if no next newline.
+# Beware: never return null pointer.
+def before-previous-screen-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [
+  local-scope
+  load-inputs
+  curr:&:duplex-list:char <- copy in
+  c:char <- get *curr, value:offset
+  # compute max, number of characters to skip
+  #   1 + len%(width-1)
+  #   except rotate second term to vary from 1 to width-1 rather than 0 to width-2
+  left:num <- get *editor, left:offset
+  right:num <- get *editor, right:offset
+  max-line-length:num <- subtract right, left, -1/exclusive-right, 1/wrap-icon
+  sentinel:&:duplex-list:char <- get *editor, data:offset
+  len:num <- previous-line-length curr, sentinel
+  {
+    break-if len
+    # empty line; just skip this newline
+    prev:&:duplex-list:char <- prev curr
+    return-unless prev, curr
+    return prev
+  }
+  _, max:num <- divide-with-remainder len, max-line-length
+  # remainder 0 => scan one width-worth
+  {
+    break-if max
+    max <- copy max-line-length
+  }
+  max <- add max, 1
+  count:num <- copy 0
+  # skip 'max' characters
+  {
+    done?:bool <- greater-or-equal count, max
+    break-if done?
+    prev:&:duplex-list:char <- prev curr
+    break-unless prev
+    curr <- copy prev
+    count <- add count, 1
+    loop
+  }
+  return curr
+]
+
 scenario editor-adjusts-column-at-previous-line [
   local-scope
   assume-screen 10/width, 5/height
@@ -2517,51 +2562,6 @@ def before-start-of-next-line original:&:duplex-list:char, max:num -> curr:&:dup
   return curr
 ]
 
-# takes a pointer into the doubly-linked list, scans back to before start of
-# previous *wrapped* line
-# returns original if no next newline
-# beware: never return null pointer
-def before-previous-screen-line in:&:duplex-list:char, editor:&:editor -> out:&:duplex-list:char [
-  local-scope
-  load-inputs
-  curr:&:duplex-list:char <- copy in
-  c:char <- get *curr, value:offset
-  # compute max, number of characters to skip
-  #   1 + len%(width-1)
-  #   except rotate second term to vary from 1 to width-1 rather than 0 to width-2
-  left:num <- get *editor, left:offset
-  right:num <- get *editor, right:offset
-  max-line-length:num <- subtract right, left, -1/exclusive-right, 1/wrap-icon
-  sentinel:&:duplex-list:char <- get *editor, data:offset
-  len:num <- previous-line-length curr, sentinel
-  {
-    break-if len
-    # empty line; just skip this newline
-    prev:&:duplex-list:char <- prev curr
-    return-unless prev, curr
-    return prev
-  }
-  _, max:num <- divide-with-remainder len, max-line-length
-  # remainder 0 => scan one width-worth
-  {
-    break-if max
-    max <- copy max-line-length
-  }
-  max <- add max, 1
-  count:num <- copy 0
-  # skip 'max' characters
-  {
-    done?:bool <- greater-or-equal count, max
-    break-if done?
-    prev:&:duplex-list:char <- prev curr
-    break-unless prev
-    curr <- copy prev
-    count <- add count, 1
-    loop
-  }
-  return curr
-]
-
 # ctrl-/ - comment/uncomment current line
 
 after <handle-special-character> [