(self, steps: int, unit: Literal["m", "h", "d"])
| 867 | |
| 868 | # @work(thread=True) |
| 869 | def action_navigate(self, steps: int, unit: Literal["m", "h", "d"]) -> None: |
| 870 | |
| 871 | initial_line_no = line_no = ( |
| 872 | self.scroll_offset.y if self.pointer_line is None else self.pointer_line |
| 873 | ) |
| 874 | |
| 875 | count = 0 |
| 876 | # If the current line doesn't have a timestamp, try to find the next one |
| 877 | while (timestamp := self.get_timestamp(line_no)) is None: |
| 878 | line_no += 1 |
| 879 | count += 1 |
| 880 | if count >= self.line_count or count > 10: |
| 881 | self.app.bell() |
| 882 | return |
| 883 | |
| 884 | direction = +1 if steps > 0 else -1 |
| 885 | line_no += direction |
| 886 | |
| 887 | if unit == "m": |
| 888 | target_timestamp = timestamp + timedelta(minutes=steps) |
| 889 | elif unit == "h": |
| 890 | target_timestamp = timestamp + timedelta(hours=steps) |
| 891 | elif unit == "d": |
| 892 | target_timestamp = timestamp + timedelta(hours=steps * 24) |
| 893 | |
| 894 | if direction == +1: |
| 895 | line_count = self.line_count |
| 896 | while line_no < line_count: |
| 897 | timestamp = self.get_timestamp(line_no) |
| 898 | if timestamp is not None and timestamp >= target_timestamp: |
| 899 | break |
| 900 | line_no += 1 |
| 901 | else: |
| 902 | while line_no > 0: |
| 903 | timestamp = self.get_timestamp(line_no) |
| 904 | if timestamp is not None and timestamp <= target_timestamp: |
| 905 | break |
| 906 | line_no -= 1 |
| 907 | |
| 908 | self.pointer_line = line_no |
| 909 | self.scroll_pointer_to_center(animate=abs(initial_line_no - line_no) < 100) |
| 910 | |
| 911 | def watch_tail(self, tail: bool) -> None: |
| 912 | self.set_class(tail, "-tail") |
nothing calls this directly
no test coverage detected