From 176d9003c8e53074ce9147855afd71d960e68a27 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 5 Aug 2015 17:12:33 -0700 Subject: 1943 --- edit.mu | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/edit.mu b/edit.mu index a39b007e..30929d92 100644 --- a/edit.mu +++ b/edit.mu @@ -2536,6 +2536,8 @@ container editor-data [ previous-page:address:list:address:duplex-list:character ] +# page-down skips entire wrapped lines, so it can't scroll past lines +# taking up the entire screen recipe page-down [ local-scope editor:address:editor-data <- next-ingredient @@ -2889,6 +2891,46 @@ i] ] ] +scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys-2 [ + # screen has 1 line for menu + 3 lines + assume-screen 10/width, 4/height + # editor starts with a long line wrapping twice + 1:address:array:character <- new [abcdefghij +k +l +m] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right + # position cursor at last line, then try to move further down + assume-console [ + left-click 3, 0 + press 65516 # down-arrow + ] + run [ + editor-event-loop screen:address, console:address, 2:address:editor-data + ] + # screen shows partial wrapped line containing a wrap icon + screen-should-contain [ + . . + .efgh↩ . + .ij . + .k . + ] + # scroll down again + assume-console [ + press 65516 # down-arrow + ] + run [ + editor-event-loop screen:address, console:address, 2:address:editor-data + ] + # screen shows partial wrapped line + screen-should-contain [ + . . + .ij . + .k . + .l . + ] +] + # cursor-up can scroll if necessary scenario editor-can-scroll-up-using-arrow-keys [ @@ -2929,7 +2971,6 @@ after +scroll-up [ left:number <- get *editor, left:offset right:number <- get *editor, right:offset max:number <- subtract right, left - max <- subtract max, 1 # include wrapped line but without newline *top-of-screen <- start-of-previous-line *top-of-screen, max ] @@ -2943,6 +2984,13 @@ recipe start-of-previous-line [ count:number <- copy 0 curr:address:duplex-list <- copy original reply-unless curr, original + # if top is at start of line, don't count the previous newline + { + c:character <- get *curr, value:offset + at-newline?:boolean <- equal c, 10/newline + break-unless at-newline? + max <- subtract max, 1 + } # skip newline at original curr <- prev-duplex curr count <- add count, 1 @@ -3007,6 +3055,76 @@ i] ] ] +scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys-2 [ + # screen has 1 line for menu + 4 lines + assume-screen 10/width, 5/height + # editor starts with a long line wrapping twice, occupying 3 of the 4 lines + 1:address:array:character <- new [abcdefghij +k +l +m] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right + # position cursor at top of second page + assume-console [ + press 65518 # page-down + ] + run [ + editor-event-loop screen:address, console:address, 2:address:editor-data + ] + screen-should-contain [ + . . + .k . + .l . + .m . + . . + ] + # move up one line + assume-console [ + press 65517 # up-arrow + ] + run [ + editor-event-loop screen:address, console:address, 2:address:editor-data + ] + # screen shows partial wrapped line + screen-should-contain [ + . . + .ij . + .k . + .l . + .m . + ] + # move up a second line + assume-console [ + press 65517 # up-arrow + ] + run [ + editor-event-loop screen:address, console:address, 2:address:editor-data + ] + # screen shows partial wrapped line + screen-should-contain [ + . . + .efgh↩ . + .ij . + .k . + .l . + ] + # move up a third line + assume-console [ + press 65517 # up-arrow + ] + run [ + editor-event-loop screen:address, console:address, 2:address:editor-data + ] + # screen shows partial wrapped line + screen-should-contain [ + . . + .abcd↩ . + .efgh↩ . + .ij . + .k . + ] +] + ## putting the environment together out of editors container programming-environment-data [ -- cgit 1.4.1-2-gfad0 ef='#n27'>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