anchor.diff:                    (:up    (setf i (max (1- i) 0)))
                     (:down  (setf i (min (1+ i) (1- m))))
                     (:left  (setf j (max (1- j) 0)))
  -                  (:right (setf j (min (1+ j) (1- n))))))))
  +                  (:right (setf j (min (1+ j) (1- n)))))))
  +
  +      ;; after updating i,j, update the current-item-number
         (setf item (sub2rmi layout (list i j))))))
   
   (defun format-menu-item (menu item-number)
  
positive.code:       (flet ((make-title-string (len)
                 (concatenate 'string "|~" (write-to-string (+ len 2)) ":@<~A~>|")))
          (add menu (format nil (make-title-string (length title)) title) :y 0 :x 2)))
      ;; todo: when we refresh a window with a subwin, we shouldnt have to refresh the subwin separately.
      ;; make refresh specialize on menu and decorated window in a way to do both.
      (refresh menu)
      (refresh sub-win)))
  
negative.code:                    (scrolled-layout .scrolled-layout) (scrolled-region-start .scrolled-region-start)
                     (title .title) (border .border) (color-pair .color-pair) (len .max-item-length) (sub-win .sub-window)) menu
      (clear sub-win)
      (let ((m  (car  layout))
            (n  (cadr layout))
            (m0 (car  scrolled-region-start))
            (n0 (cadr scrolled-region-start))
            (m1 (car  scrolled-layout))
            (n1 (cadr scrolled-layout)))
        (if scrolled-layout
            ;; when the menu is too big to be displayed at once, only a part
            ;; is displayed, and the menu can be scrolled
            ;; draw a menu with a scrolling layout enabled
            (loop for i from 0 to (1- m1)
               do (loop for j from 0 to (1- n1)
                     do
                     ;; the menu is given as a flat list, so we have to access it as a 2d array in row major order
                     ;; TODO: rename to item-number
                       (let ((item (sub2rmi layout (list (+ m0 i) (+ n0 j)))))
                         ;;(format menu "~A ~A," j n0)
                         (move sub-win i (* j len))
                         (format-menu-item menu item)
                         ;; change the attributes of the current item
                         (when (= current-item-number item)
                           (move sub-win i (* j len))
                           (change-attributes sub-win len '(:reverse) )))))
  
            ;; when there is no scrolling, and the whole menu is displayed at once
            ;; cycling is enabled.
            (loop for i from 0 to (1- m)
               do (loop for j from 0 to (1- n)
                     do
                       (let ((item (sub2rmi layout (list i j))))
                         (move sub-win i (* j len))
                         (format-menu-item menu item)
                         ;; change the attributes of the current item
                         (when (= current-item-number item)
                           (move sub-win i (* j len))
                           (change-attributes sub-win len '(:reverse) )))))))
  
      ;; we have to explicitely touch the background win, because otherwise it wont get refreshed.
      (touch menu)
      ;; draw the title only when we have a border too, because we draw the title on top of the border.
  