1
0
Fork 0

- prevented out of bound condition when scrolling message-window's

contents.

  When  user switched  from a  page to  another shorter  the scrolling
  position was  not restored,  pointing outside  the actual  text line
  counts. This prevent the correct rendering of the page (a blank page
  is shown instead) and crash the software if scrolling up.

  Thanks op!
This commit is contained in:
cage 2021-05-02 16:28:50 +02:00
parent 92ee1357b6
commit e319ccd112
3 changed files with 32 additions and 8 deletions

View File

@ -133,6 +133,8 @@
(defgeneric select-row (object index))
(defgeneric select-first-row (object))
(defgeneric selected-row (object))
(defgeneric selected-row-fields (object))
@ -218,6 +220,19 @@
(setf row-selected-index 0)))
object))
(defmethod select-first-row ((object row-oriented-widget))
(select-row object 0))
(defun adjust-rows-select-first (window)
(select-first-row window))
(defmethod adjust-selected-rows ((object row-oriented-widget) (strategy function))
(with-accessors ((row-selected-index row-selected-index)) object
(when (< (rows-length object)
row-selected-index)
(funcall strategy object)))
object)
(defmethod selected-row ((object row-oriented-widget))
"Return the current selected row"
(with-accessors ((rows rows)

View File

@ -31,7 +31,11 @@
(metadata
:initform nil
:initarg :metadata
:accessor metadata)))
:accessor metadata)
(adjust-rows-strategy
:initform #'adjust-rows-select-first
:initarg :adjust-rows-strategy
:accessor adjust-rows-strategy)))
(defgeneric prepare-for-rendering (object text-data &key jump-to-first-row))
@ -143,13 +147,15 @@
(print-text window line-position-mark mark-x mark-y))))
(defmethod draw ((object message-window))
(when-window-shown (object)
(win-clear object :redraw nil)
(win-box object)
(draw-text object)
(when (not (line-oriented-window:rows-empty-p object))
(draw-buffer-line-mark object))
(call-next-method)))
(with-accessors ((adjust-rows-strategy adjust-rows-strategy)) object
(when-window-shown (object)
(adjust-selected-rows object adjust-rows-strategy)
(win-clear object :redraw nil)
(win-box object)
(draw-text object)
(when (not (line-oriented-window:rows-empty-p object))
(draw-buffer-line-mark object))
(call-next-method))))
(defgeneric row-add-original-object (lines original-object))

View File

@ -1816,6 +1816,9 @@
:renderizable-rows-data
:unselect-all
:select-row
:select-first-row
:adjust-rows-select-first
:adjust-selected-rows
:selected-row
:ignore-selecting-action
:set-default-index