about summary refs log tree commit diff stats
path: root/sandbox
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-06-25 01:48:56 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-06-25 01:48:56 -0700
commit5405a972e44259d65c374a3c9e583e026ad7cd8e (patch)
tree84842958f20e836c1c82163dcd7781785104051a /sandbox
parentd5a492d384994af1c4840d51b3251f384af80e86 (diff)
downloadmu-5405a972e44259d65c374a3c9e583e026ad7cd8e.tar.gz
3954
As a blanket rule, down-arrow now stops scrolling once the bottom margin
comes on screen.

Now that we have page-wise scrolling with ctrl-f/b and line-wise
scrolling with ctrl-s/x, we don't need to conflate scroll positioning
with the arrow keys. And as a result, early students no longer have to
struggle with accidentally scrolling part of the sandbox off the screen
when there's tons of empty space available.

`move-to-next-line` is still super messy and will need further
rethinking, but this commit simplifies the codebase as a whole by
eliminating a couple of historical accidents:

  a) We only introduced scrolling past the bottom of the screen to allow
  more sandboxes to come into view before we had scrolling for the
  sandbox side.

  b) We undid scrolling past the bottom in just the recipe side to allow
  errors to come into view.

Since these historical details are now irrelevant, we no longer need
separate logic for the recipe and sandbox sides, and we don't need to
keep track of the recipe-bottom separate from the bottom margin of
arbitrary editors.
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/003-shortcuts.mu47
1 files changed, 26 insertions, 21 deletions
diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu
index 6fdd70b8..adee48a7 100644
--- a/sandbox/003-shortcuts.mu
+++ b/sandbox/003-shortcuts.mu
@@ -1348,38 +1348,43 @@ def move-to-next-line editor:&:editor, screen-height:num -> editor:&:editor [
   left:num <- get *editor, left:offset
   right:num <- get *editor, right:offset
   last-line:num <- subtract screen-height, 1
+  bottom:num <- get *editor, bottom:offset
+  at-bottom-of-screen?:bool <- greater-or-equal bottom, last-line
+  return-unless before-cursor
+  next:&:duplex-list:char <- next before-cursor
+  return-unless next
   already-at-bottom?:bool <- greater-or-equal cursor-row, last-line
-    # incorrect indent to help diff with edit/
     # if cursor not at bottom, move it
     return-if already-at-bottom?
-    # scan to start of next line, then to right column or until end of line
-    max:num <- subtract right, left
-    next-line:&:duplex-list:char <- before-start-of-next-line before-cursor, max
-    # already at end of buffer? do nothing
-    no-motion?:bool <- equal next-line, before-cursor
-    return-if no-motion?
-    cursor-row <- add cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    before-cursor <- copy next-line
-    *editor <- put *editor, before-cursor:offset, before-cursor
     target-column:num <- copy cursor-column
+    # scan to start of next line
+    {
+      next:&:duplex-list:char <- next before-cursor
+      break-unless next
+      done?:bool <- greater-or-equal cursor-column, right
+      break-if done?
+      cursor-column <- add cursor-column, 1
+      before-cursor <- copy next
+      c:char <- get *next, value:offset
+      at-newline?:bool <- equal c, 10/newline
+      break-if at-newline?
+      loop
+    }
+    return-unless next
+    cursor-row <- add cursor-row, 1
     cursor-column <- copy left
-    *editor <- put *editor, cursor-column:offset, cursor-column
     {
+      next:&:duplex-list:char <- next before-cursor
+      break-unless next
       done?:bool <- greater-or-equal cursor-column, target-column
       break-if done?
-      curr:&:duplex-list:char <- next before-cursor
-      break-unless curr
-      currc:char <- get *curr, value:offset
-      at-newline?:bool <- equal currc, 10/newline
-      break-if at-newline?
-      #
-      before-cursor <- copy curr
-      *editor <- put *editor, before-cursor:offset, before-cursor
       cursor-column <- add cursor-column, 1
-      *editor <- put *editor, cursor-column:offset, cursor-column
+      before-cursor <- copy next
       loop
     }
+    *editor <- put *editor, before-cursor:offset, before-cursor
+    *editor <- put *editor, cursor-column:offset, cursor-column
+    *editor <- put *editor, cursor-row:offset, cursor-row
 ]
 
 scenario editor-adjusts-column-at-next-line [
mmon into layers' href='/akkartik/mu/commit/076next-word.subx?h=hlt&id=fd91f7f61bfa84cbc24590d5394d75891cc1cfcc'>fd91f7f6 ^
71eb22a5 ^
fd91f7f6 ^












































7a583220 ^
fd91f7f6 ^




7a583220 ^
fd91f7f6 ^









71eb22a5 ^
fd91f7f6 ^























7a583220 ^
fd91f7f6 ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252