                  (set-fg 1)
                  (feed-esc "7") ; save cursor
                  (feed-csi "!p"))] ; soft reset
-      (is (= (:lines vt) [[[0x41 {}] [0x42 {}] [0x43 {}] [0x44 {}]]
-                          [[0x45 {}] [0x46 {}] [0x47 {}] [0x48 {}]]
-                          [[0x49 {}] [0x20 {}] [0x20 {}] [0x20 {}]]
-                          [[0x20 {}] [0x20 {}] [0x20 {}] [0x20 {}]]]))
+      (is (= (compact-lines (:lines vt)) [[["ABCD" {}]]
+                                          [["EFGH" {}]]
+                                          [["I   " {}]]
+                                          [["    " {}]]]))
       (is (= (:cursor vt) {:x 2 :y 2 :visible true}))
       (is (= (:char-attrs vt) {}))
       (is (= (:insert-mode vt) false))

                 (set-bg 3)
                 (move-cursor 1 1))]
      (let [{lines :lines {x :x y :y} :cursor} (feed-csi vt "J")]
        (is (= lines [[[0x41 {}] [0x42 {}] [0x43 {}] [0x44 {}]]
                      [[0x45 {}] [0x20 {:bg 3}] [0x20 {:bg 3}] [0x20 {:bg 3}]]
                      [[0x20 {:bg 3}] [0x20 {:bg 3}] [0x20 {:bg 3}] [0x20 {:bg 3}]]]))
        (is (= x 1))
        (is (= y 1)))
      (let [{lines :lines {x :x y :y} :cursor} (feed-csi vt "1J")]
        (is (= lines [[[0x20 {:bg 3}] [0x20 {:bg 3}] [0x20 {:bg 3}] [0x20 {:bg 3}]]
                      [[0x20 {:bg 3}] [0x20 {:bg 3}] [0x47 {}] [0x48 {}]]
                      [[0x49 {}] [0x4a {}] [0x20 {}] [0x20 {}]]]))
        (is (= x 1))
        (is (= y 1)))
      (let [{lines :lines {x :x y :y} :cursor} (feed-csi vt "2J")]
        (is (= lines [[[0x20 {:bg 3}] [0x20 {:bg 3}] [0x20 {:bg 3}] [0x20 {:bg 3}]]
                      [[0x20 {:bg 3}] [0x20 {:bg 3}] [0x20 {:bg 3}] [0x20 {:bg 3}]]
                      [[0x20 {:bg 3}] [0x20 {:bg 3}] [0x20 {:bg 3}] [0x20 {:bg 3}]]]))
        (is (= x 1))
        (is (= y 1)))))


              {:keys [lines] {:keys [x y]} :cursor} vt]
          (is (= x 2))
          (is (= y 1))
          (is (= (compact-lines lines) [[["ABC " {}]]
                                        [["DE  " {}]]
                                        [["    " {}]]]))))))

  (testing "CSI ?h (DECSM)" ; set multiple modes
    (let [vt (-> (make-vt 80 24)
