+ 'Store next idx to what most recent line we have (been) scrolled.'
+ bookmark = (self._BOOKMARK_HISTORY_IDX_POS, '-' * self._sizes.x)
+ if bookmark in self._wrapped:
+ bookmark_idx_neg\
+ = self._wrapped.index(bookmark) - len(self._wrapped)
+ del self._wrapped[bookmark_idx_neg]
+ if bookmark_idx_neg > self._wrapped_idx_neg:
+ self._wrapped_idx_neg += 1
+ bookmark_wrapped_idx_pos = (
+ 0 if (not self._wrapped)
+ else (1 + self._last_wrapped_idx_pos_for_hist_idx_pos(
+ self._newest_read_history_idx_pos)))
+ self._wrapped.insert(bookmark_wrapped_idx_pos, bookmark)
+ if bookmark_wrapped_idx_pos - len(self._wrapped)\
+ > self._wrapped_idx_neg:
+ self._wrapped_idx_neg -= 1
+
+ def _last_wrapped_idx_pos_for_hist_idx_pos(self, hist_idx_pos: int) -> int:
+ return [idx for idx, t in enumerate(self._wrapped)
+ if t[0] == hist_idx_pos][-1]