- # move (newly cleared) top line to the bottom of the scrolling region
- @text = [
- @text[0...@scroll_top]..., # up to but not including scroll top
- @text[@scroll_top + 1 .. @scroll_bottom]..., # scroll region except top line of it
- @text[@scroll_top], # top line of scroll region (already cleared)
- @text[@scroll_bottom + 1 ... @height]... # rest of screen
- ]
- @attributes = [
- @attributes[0...@scroll_top]..., # up to but not including scroll top
- @attributes[@scroll_top + 1 .. @scroll_bottom]..., # scroll region except top line of it
- @attributes[@scroll_top], # top line of scroll region (already cleared)
- @attributes[@scroll_bottom + 1 ... @height]... # rest of screen
- ]
+ rearrange = (a) =>
+ return [
+ a[0...@scroll_top]..., # up to but not including scroll top
+ a[@scroll_top + 1 .. @scroll_bottom]..., # scroll region except top line of it
+ a[@scroll_top], # top line of scroll region (already cleared)
+ a[@scroll_bottom + 1 ... @height]... # rest of screen
+ ]
+ @text = rearrange @text
+ @attributes = rearrange @attributes