1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Types for pgt TUI pages and navigation."""
from __future__ import annotations
from dataclasses import dataclass
from enum import Enum, auto
from pathlib import Path
from typing import Protocol, runtime_checkable
from pygit2 import Repository
class PageAction(Enum):
NONE = auto()
QUIT = auto()
REPLACE = auto()
PUSH = auto()
POP = auto()
@dataclass(frozen=True, slots=True)
class PageResult:
action: PageAction = PageAction.NONE
next_page: Page | None = None
switch_repo: Path | None = None
@dataclass(frozen=True, slots=True)
class PageContext:
repo: Repository
repo_path: Path
@runtime_checkable
class Page(Protocol):
"""A full-screen view in the pgt TUI."""
@property
def title(self) -> str: ...
def on_enter(self, ctx: PageContext) -> None: ...
def draw(self, stdscr: int, height: int, width: int) -> None: ...
def status_text(self) -> str: ...
def handle_key(self, key: int) -> PageResult: ...