Add an entry to history.
(self, text: str)
| 802 | self._cursor: int = -1 |
| 803 | |
| 804 | def add(self, text: str) -> None: |
| 805 | """Add an entry to history.""" |
| 806 | if not text.strip(): |
| 807 | return |
| 808 | # Don't add duplicates of the last entry |
| 809 | if self._entries and self._entries[-1] == text: |
| 810 | return |
| 811 | self._entries.append(text) |
| 812 | if len(self._entries) > self._max_entries: |
| 813 | self._entries.pop(0) |
| 814 | self._cursor = len(self._entries) |
| 815 | |
| 816 | def previous(self) -> str | None: |
| 817 | """Get previous history entry (up arrow).""" |