Go to a future state of the database. Returns the database to the state associated with the specified mark. Both the identifier of a mark and its name can be used. If the `mark` is omitted, the next created mark is used. If there are no future marks, or the specifi
(self, mark: int | str | None = None)
| 2769 | # (self._curaction, self._curmark)) |
| 2770 | |
| 2771 | def redo(self, mark: int | str | None = None) -> None: |
| 2772 | """Go to a future state of the database. |
| 2773 | |
| 2774 | Returns the database to the state associated with the specified |
| 2775 | mark. Both the identifier of a mark and its name can be used. |
| 2776 | If the `mark` is omitted, the next created mark is used. If |
| 2777 | there are no future marks, or the specified mark is not newer |
| 2778 | than the current one, an UndoRedoError is raised. |
| 2779 | |
| 2780 | This method can only be called when the Undo/Redo mechanism has |
| 2781 | been enabled. Otherwise, an UndoRedoError is raised. |
| 2782 | |
| 2783 | """ |
| 2784 | self._check_open() |
| 2785 | self._check_undo_enabled() |
| 2786 | |
| 2787 | # print("(pre)REDO: (curaction, curmark) = (%s, %s)" % \ |
| 2788 | # (self._curaction, self._curmark)) |
| 2789 | if self._curaction >= self._actionlog.nrows - 1: |
| 2790 | # We are at the end of log, so no action |
| 2791 | return |
| 2792 | |
| 2793 | if mark is None: |
| 2794 | mark = self._curmark + 1 |
| 2795 | elif mark == -1: |
| 2796 | mark = int(self._nmarks) # Go beyond the mark bounds up to the end |
| 2797 | # Get the mark ID number |
| 2798 | markid = self._get_mark_id(mark) |
| 2799 | finalaction = self._get_final_action(markid) |
| 2800 | if finalaction < self._curaction + 1: |
| 2801 | raise UndoRedoError( |
| 2802 | "Mark ``%s`` is older than the current mark. " |
| 2803 | "Use `redo()` or `goto()` instead." % (mark,) |
| 2804 | ) |
| 2805 | |
| 2806 | # The file is going to be changed. |
| 2807 | self._check_writable() |
| 2808 | |
| 2809 | # Get the final action ID to go |
| 2810 | self._curaction += 1 |
| 2811 | |
| 2812 | # Try to reach this mark by redoing the actions in the log |
| 2813 | self._doundo(finalaction, 1) |
| 2814 | # Increment the current mark only if we are not at the end of marks |
| 2815 | if self._curmark < self._nmarks - 1: |
| 2816 | self._curmark += 1 |
| 2817 | if self._curaction > self._actionlog.nrows - 1: |
| 2818 | self._curaction = self._actionlog.nrows - 1 |
| 2819 | |
| 2820 | # print("(post)REDO: (curaction, curmark) = (%s,%s)" % \ |
| 2821 | # (self._curaction, self._curmark)) |
| 2822 | |
| 2823 | def goto(self, mark: int | str) -> None: |
| 2824 | """Go to a specific mark of the database. |