from __future__ import annotations
from typing import Optional, Sequence, Tuple, overload
from .types import RectLike, Rect, Point, Size, Color, KeyCode, KeyMods, MouseKind, MouseButton, Event
from ._ffi import FfiRect, FfiStyle

class Style:
    fg: int | Color
    bg: int | Color
    mods: int
    def __init__(self, fg: int | Color = ..., bg: int | Color = ..., mods: int = ...) -> None: ...
    def to_ffi(self) -> FfiStyle: ...

class Paragraph:
    _handle: object
    def __init__(self, handle: int, lib: object | None = ...) -> None: ...
    @classmethod
    def from_text(cls, text: str) -> Paragraph: ...
    @classmethod
    def new_empty(cls) -> Paragraph: ...
    def append_span(self, text: str, style: Style | None = ...) -> None: ...
    def line_break(self) -> None: ...
    def set_block_title(self, title: str | None, show_border: bool = ...) -> None: ...
    def append_line(self, text: str, style: Style | None = ...) -> None: ...
    def close(self) -> None: ...

class Terminal:
    _handle: object
    def __init__(self) -> None: ...
    def clear(self) -> None: ...
    @overload
    def draw_paragraph(self, p: Paragraph) -> bool: ...
    @overload
    def draw_paragraph(self, p: Paragraph, rect: RectLike) -> bool: ...
    def draw_list(self, lst: List, rect: RectLike) -> bool: ...
    def draw_table(self, tbl: Table, rect: RectLike) -> bool: ...
    def draw_gauge(self, g: Gauge, rect: RectLike) -> bool: ...
    def draw_tabs(self, t: Tabs, rect: RectLike) -> bool: ...
    def draw_barchart(self, b: BarChart, rect: RectLike) -> bool: ...
    def draw_sparkline(self, s: Sparkline, rect: RectLike) -> bool: ...
    def draw_chart(self, c: Chart, rect: RectLike) -> bool: ...
    def draw_frame(self, cmds: Sequence[DrawCmd]) -> bool: ...
    def size(self) -> tuple[int, int]: ...
    def next_event(self, timeout_ms: int) -> dict | None: ...
    def next_event_typed(self, timeout_ms: int) -> Event | None: ...
    def frame(self) -> Frame: ...
    def close(self) -> None: ...
    def __enter__(self) -> Terminal: ...
    def __exit__(self, exc_type, exc, tb) -> None: ...

class List: ...
class Table: ...
class Gauge: ...
class Tabs: ...
class BarChart: ...
class Sparkline: ...
class Chart: ...
class Scrollbar: ...

class DrawCmd:
    kind: int
    handle: object
    rect: FfiRect
    owner: object | None
    def __init__(self, kind: int, handle: object, rect: FfiRect, owner: object | None = ...) -> None: ...
    @staticmethod
    def paragraph(p: Paragraph, rect: RectLike) -> DrawCmd: ...
    @staticmethod
    def list(lst: List, rect: RectLike) -> DrawCmd: ...
    @staticmethod
    def table(t: Table, rect: RectLike) -> DrawCmd: ...
    @staticmethod
    def gauge(g: Gauge, rect: RectLike) -> DrawCmd: ...
    @staticmethod
    def tabs(t: Tabs, rect: RectLike) -> DrawCmd: ...
    @staticmethod
    def barchart(b: BarChart, rect: RectLike) -> DrawCmd: ...
    @staticmethod
    def sparkline(s: Sparkline, rect: RectLike) -> DrawCmd: ...
    @staticmethod
    def chart(c: Chart, rect: RectLike) -> DrawCmd: ...

class Frame:
    ok: bool | None
    def __enter__(self) -> Frame: ...
    def __exit__(self, exc_type, exc, tb) -> None: ...
    def extend(self, cmds: Sequence[DrawCmd]) -> None: ...
    def paragraph(self, p: Paragraph, rect: RectLike) -> None: ...
    def list(self, lst: List, rect: RectLike) -> None: ...
    def table(self, t: Table, rect: RectLike) -> None: ...
    def gauge(self, g: Gauge, rect: RectLike) -> None: ...
    def tabs(self, t: Tabs, rect: RectLike) -> None: ...
    def barchart(self, b: BarChart, rect: RectLike) -> None: ...
    def sparkline(self, s: Sparkline, rect: RectLike) -> None: ...
    def chart(self, c: Chart, rect: RectLike) -> None: ...

class App:
    def __init__(self, *, render, on_event = ..., on_tick = ..., on_start = ..., on_stop = ..., tick_ms: int = ..., clear_each_frame: bool = ...) -> None: ...
    def run(self, state = ...) -> None: ...

def headless_render_paragraph(width: int, height: int, p: Paragraph) -> str: ...
def headless_render_list(width: int, height: int, lst: List) -> str: ...
def headless_render_table(width: int, height: int, tbl: Table) -> str: ...
def headless_render_gauge(width: int, height: int, g: Gauge) -> str: ...
def headless_render_tabs(width: int, height: int, t: Tabs) -> str: ...
def headless_render_barchart(width: int, height: int, b: BarChart) -> str: ...
def headless_render_sparkline(width: int, height: int, s: Sparkline) -> str: ...
def headless_render_chart(width: int, height: int, c: Chart) -> str: ...
