# Path: asciinema/term.py
# class raw:
#     def __init__(self, fd: Union[IO[str], int]) -> None:
#         self.fd = fd
#         self.restore: bool = False
#         self.mode: Optional[List[Any]] = None
# 
#     def __enter__(self) -> None:
#         try:
#             self.mode = tty.tcgetattr(self.fd)
#             setraw(self.fd)
#             self.restore = True
#         except tty.error:  # this is `termios.error`
#             pass
# 
#     def __exit__(self, type_: str, value: str, traceback: str) -> None:
#         if self.restore:
#             sleep(0.01)  # give the terminal time to send answerbacks
#             assert isinstance(self.mode, list)
#             tty.tcsetattr(self.fd, tty.TCSAFLUSH, self.mode)


import array
import errno
import fcntl
import os
import pty
import select
import signal
import struct
import termios
import time
from typing import Any, Callable, Dict, List, Optional, Tuple
from .term import raw
        buf = array.array("h", [rows, cols, 0, 0])
        fcntl.ioctl(pty_fd, termios.TIOCSWINSZ, buf)

    def handle_master_read(data: Any) -> None:
        os.write(tty_stdout_fd, data)

        if not pause_time:
            assert start_time is not None
            writer.write_stdout(time.time() - start_time, data)

    def handle_stdin_read(data: Any) -> None:
        nonlocal pause_time
        nonlocal start_time
        nonlocal prefix_mode

        if not prefix_mode and prefix_key and data == prefix_key:
            prefix_mode = True
            return

        if prefix_mode or (not prefix_key and data in [pause_key]):
            prefix_mode = False

            if data == pause_key:
                if pause_time:
                    assert start_time is not None
                    start_time += time.time() - pause_time
                    pause_time = None
                    notify("Resumed recording")
                else:
                    pause_time = time.time()

# Path: asciinema/term.py
# class raw:
#     def __init__(self, fd: Union[IO[str], int]) -> None:
#         self.fd = fd
#         self.restore: bool = False
#         self.mode: Optional[List[Any]] = None
# 
#     def __enter__(self) -> None:
#         try:
#             self.mode = tty.tcgetattr(self.fd)
#             setraw(self.fd)
#             self.restore = True
#         except tty.error:  # this is `termios.error`
#             pass
# 
#     def __exit__(self, type_: str, value: str, traceback: str) -> None:
#         if self.restore:
#             sleep(0.01)  # give the terminal time to send answerbacks
#             assert isinstance(self.mode, list)
#             tty.tcsetattr(self.fd, tty.TCSAFLUSH, self.mode)


# Path: asciinema/pty_.py
import array
import errno
import fcntl
import os
import pty
import select
import signal
import struct
import termios
import time
from typing import Any, Callable, Dict, List, Optional, Tuple
from .term import raw

        buf = array.array("h", [rows, cols, 0, 0])
        fcntl.ioctl(pty_fd, termios.TIOCSWINSZ, buf)

    def handle_master_read(data: Any) -> None:
        os.write(tty_stdout_fd, data)

        if not pause_time:
            assert start_time is not None
            writer.write_stdout(time.time() - start_time, data)

    def handle_stdin_read(data: Any) -> None:
        nonlocal pause_time
        nonlocal start_time
        nonlocal prefix_mode

        if not prefix_mode and prefix_key and data == prefix_key:
            prefix_mode = True
            return

        if prefix_mode or (not prefix_key and data in [pause_key]):
            prefix_mode = False

            if data == pause_key:
                if pause_time:
                    assert start_time is not None
                    start_time += time.time() - pause_time
                    pause_time = None
                    notify("Resumed recording")
                else:
                    pause_time = time.time()

                    notify("Paused recording")