from typing import Protocol, runtime_checkable, Iterable

from textual.widget import Widget

from toad.menus import MenuItem


@runtime_checkable
class BlockProtocol(Protocol):
    def block_cursor_up(self) -> Widget | None: ...
    def block_cursor_down(self) -> Widget | None: ...
    def get_cursor_block(self) -> Widget | None: ...
    def block_cursor_clear(self) -> None: ...
    def block_select(self, widget: Widget) -> None: ...


@runtime_checkable
class MenuProtocol(Protocol):
    def get_block_menu(self) -> Iterable[MenuItem]: ...
    def get_block_content(self, destination: str) -> str | None: ...


@runtime_checkable
class ExpandProtocol(Protocol):
    def can_expand(self) -> bool: ...
    def expand_block(self) -> None: ...
    def collapse_block(self) -> None: ...
    def is_block_expanded(self) -> bool: ...
