- # FIXME handle alt screen
- for y in [0...term.height]
- for x in [0...term.width]
- if term.attributes[y][x] isnt a
- state += attr_diff a, term.attributes[y][x]
- a = term.attributes[y][x]
- state += term.text[y][x]
- if y < term.height - 1
- state += '\n'
+ if term.saved_normal_screen?
+ state += encode_screen term.height, term.width, term.saved_normal_screen.text, term.saved_normal_screen.attributes
+ state += "\x1b[#{term.saved_normal_screen.y + 1};#{term.saved_normal_screen.x + 1}H"
+ state += "\x1b[?1049h\x1b[H" # flip to alt screen and move cursor home
+ state += encode_screen term.height, term.width, term.text, term.attributes