# _compat

URL: /milo-cli/api/milo/_compat/
Section: milo
Description: Cross-platform compatibility helpers.

Centralizes all platform-specific code so the rest of milo
can remain platform-agnostic.

---

> For a complete page index, fetch /milo-cli/llms.txt.

Open LLM text
(/milo-cli/api/milo/_compat/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2F_compat%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2F_compat%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2F_compat%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2F_compat%2Findex.txt)

Module

#
`_compat`

Cross-platform compatibility helpers.

Centralizes all platform-specific code so the rest of milo
can remain platform-agnostic.

6Functions

## Functions

`enable_vt_processing`

0

`None`

▼

Enable virtual-terminal processing on Windows.

Calls ``SetConsoleMode`` with `…

`def enable_vt_processing() -> None`

Enable virtual-terminal processing on Windows.

Calls`SetConsoleMode` with `ENABLE_VIRTUAL_TERMINAL_PROCESSING`
so that ANSI escape sequences are interpreted by cmd.exe and
PowerShell. No-op on Unix and when stdout is not a real console.

`data_dir`

0

`Path`

▼

Return the platform-appropriate milo data directory.

* Windows: ``%LOCALAPPDAT…

`def data_dir() -> Path`

Return the platform-appropriate milo data directory.

- Windows:`%LOCALAPPDATA%/milo` (e.g. `C:\Users\alice\AppData\Local\milo`)

- Unix:`~/.milo`

##### Returns

`Path`

`watch_terminal_resize`

1

`Callable[[], None]`

▼

Register *callback(cols, rows)* to fire on terminal resize.

On Unix this insta…

`def watch_terminal_resize(callback: Callable[[int, int], None]) -> Callable[[], None]`

Register callback(cols, rows) to fire on terminal resize.

On Unix this installs a`SIGWINCH`handler.
On Windows it spawns a daemon thread that polls`os.get_terminal_size()`.

Returns a stop callable that unregisters the handler / stops the
polling thread.

##### Parameters

Name
Type
Description

`callback`
`Callable[[int, int], None]`

##### Returns

`Callable[[], None]`

`_sigwinch_resize`

1

`Callable[[], None]`

▼

Unix: use SIGWINCH.

`def _sigwinch_resize(callback: Callable[[int, int], None]) -> Callable[[], None]`

##### Parameters

Name
Type
Description

`callback`
`Callable[[int, int], None]`

##### Returns

`Callable[[], None]`

`_poll_resize`

2

`Callable[[], None]`

▼

Windows: poll terminal size in a daemon thread.

`def _poll_resize(callback: Callable[[int, int], None], interval: float = 0.5) -> Callable[[], None]`

##### Parameters

Name
Type
Description

`callback`
`Callable[[int, int], None]`

`interval`
`float`

Default:`0.5`

##### Returns

`Callable[[], None]`

`default_shell`

0

`str`

▼

Detect the user's shell.

On Windows, checks for PowerShell first, then falls b…

`def default_shell() -> str`

Detect the user's shell.

On Windows, checks for PowerShell first, then falls back to`cmd`.
On Unix, reads`$SHELL`and maps to bash/zsh/fish.

##### Returns

`str`
