         bottom (dec (get-param vt 1 height))]
     (if (< -1 top bottom height)
       (-> vt
-          (assoc :top-margin top :bottom-margin bottom)
+          (set-margin top bottom)
           move-cursor-to-home)
       vt)))
 

(defn execute-decstr [{:keys [height] :as vt}]
  (if (= (get-intermediate vt 0) 0x21)
    (-> vt
        (assoc :insert-mode false
               :origin-mode false
               :char-attrs {}
               :top-margin 0
               :bottom-margin (dec height)
               :saved initial-saved-cursor)
        (assoc-in [:cursor :visible] true))
    vt))

(defn execute-decstbm [{:keys [height] :as vt}]


;; helper functions

(defn show-cursor
  ([vt] (show-cursor vt true))
  ([vt show?]
   (assoc-in vt [:cursor :visible] show?)))

(defn set-margin [vt top bottom]
  (assoc vt :top-margin top :bottom-margin bottom))

(defn scroll-up [{:keys [width top-margin bottom-margin char-attrs] :as vt}]
  (update-in vt [:lines] (fn [lines]
                           (vec (concat
