Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

termwiz: leave the tty layer out of iOS builds

RoversX7debdd3cc4ab
diff --git a/termwiz/Cargo.toml b/termwiz/Cargo.toml
index ce397f5b..e3b0a733 100644
--- a/termwiz/Cargo.toml
+++ b/termwiz/Cargo.toml
@@ -62,11 +62,13 @@ k9.workspace = true
# Only the terminal:: implementations need this, and those are already gated on
# unix/windows. Keeping it off other targets is what lets the escape parsing,
-# cell model and surface layers build for wasm32.
-[target."cfg(any(unix, windows))".dependencies]
+# cell model and surface layers build for wasm32. iOS is unix by family but
+# has no tty to drive, and the termios crate does not build there, so it is
+# excluded along with the implementations.
+[target.'cfg(any(all(unix, not(target_os = "ios")), windows))'.dependencies]
filedescriptor.workspace = true
-[target."cfg(unix)".dependencies]
+[target.'cfg(all(unix, not(target_os = "ios")))'.dependencies]
signal-hook.workspace = true
termios.workspace = true
nix = {workspace=true, features=["mman", "fs"]}
diff --git a/termwiz/src/error.rs b/termwiz/src/error.rs
index f5374cc4..b687be33 100644
--- a/termwiz/src/error.rs
+++ b/termwiz/src/error.rs
@@ -69,7 +69,7 @@ pub enum InternalError {
// Produced only by the terminal:: implementations, which exist on unix and
// windows alone; the crate otherwise builds for targets that have no such
// descriptors at all.
- #[cfg(any(unix, windows))]
+ #[cfg(any(all(unix, not(target_os = "ios")), windows))]
#[error(transparent)]
FileDescriptor(#[from] filedescriptor::Error),
diff --git a/termwiz/src/lib.rs b/termwiz/src/lib.rs
index 24f9622c..823227e8 100644
--- a/termwiz/src/lib.rs
+++ b/termwiz/src/lib.rs
@@ -53,7 +53,7 @@ pub mod istty;
pub mod keymap;
// The line editor and the tty probe both drive a live terminal, so they
// follow the Terminal trait in being unavailable where there is none.
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
pub mod lineedit;
mod macros;
pub use wezterm_char_props::nerdfonts;
diff --git a/termwiz/src/render/terminfo.rs b/termwiz/src/render/terminfo.rs
index ac6cb18e..847cf739 100644
--- a/termwiz/src/render/terminfo.rs
+++ b/termwiz/src/render/terminfo.rs
@@ -739,7 +739,7 @@ impl TerminfoRenderer {
}
}
-#[cfg(all(test, unix))]
+#[cfg(all(test, unix, not(target_os = "ios")))]
mod test {
use super::*;
use crate::bail;
diff --git a/termwiz/src/terminal/mod.rs b/termwiz/src/terminal/mod.rs
index 290350b6..8d2eee98 100644
--- a/termwiz/src/terminal/mod.rs
+++ b/termwiz/src/terminal/mod.rs
@@ -1,20 +1,20 @@
//! An abstraction over a terminal device
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
use crate::caps::probed::ProbeCapabilities;
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
use crate::caps::Capabilities;
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
use crate::input::InputEvent;
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
use crate::surface::Change;
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
use crate::{format_err, Result};
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
use num_traits::NumCast;
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
use std::fmt::Display;
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
use std::time::Duration;
#[cfg(feature = "use_serde")]
@@ -22,7 +22,7 @@ use serde::Deserialize;
#[cfg(feature = "use_serde")]
use serde::Serialize;
-#[cfg(unix)]
+#[cfg(all(unix, not(target_os = "ios")))]
pub mod unix;
#[cfg(windows)]
pub mod windows;
@@ -31,10 +31,10 @@ pub mod windows;
// buffered wrapper and new_terminal -- exists only where there is a terminal
// to drive. ScreenSize and Blocking stay unconditional: they are plain data
// that the surface and cell layers use on every target, wasm included.
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
pub mod buffered;
-#[cfg(unix)]
+#[cfg(all(unix, not(target_os = "ios")))]
pub use self::unix::{UnixTerminal, UnixTerminalWaker as TerminalWaker};
#[cfg(windows)]
pub use self::windows::{WindowsTerminal, WindowsTerminalWaker as TerminalWaker};
@@ -71,7 +71,7 @@ pub enum Blocking {
/// If the `set_raw_mode` or `set_cooked_mode` functions are used in
/// any combination, the implementation is required to restore the
/// terminal mode that was in effect when it was created.
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
pub trait Terminal {
/// Raw mode disables input line buffering, allowing data to be
/// read as the user presses keys, disables local echo, so keys
@@ -126,7 +126,7 @@ pub trait Terminal {
/// Ideally you wouldn't reference `SystemTerminal` in consuming
/// code. This type is exposed for convenience if you are doing
/// something unusual and want easier access to the constructors.
-#[cfg(unix)]
+#[cfg(all(unix, not(target_os = "ios")))]
pub type SystemTerminal = UnixTerminal;
#[cfg(windows)]
pub type SystemTerminal = WindowsTerminal;
@@ -140,12 +140,12 @@ pub type SystemTerminal = WindowsTerminal;
/// If you have a more advanced use case you will want to look to the
/// constructors for `UnixTerminal` and `WindowsTerminal` and call whichever
/// one is most suitable for your needs.
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
pub fn new_terminal(caps: Capabilities) -> Result<impl Terminal> {
SystemTerminal::new(caps)
}
-#[cfg(any(unix, windows))]
+#[cfg(any(all(unix, not(target_os = "ios")), windows))]
pub(crate) fn cast<T: NumCast + Display + Copy, U: NumCast>(n: T) -> Result<U> {
num_traits::cast(n).ok_or_else(|| format_err!("{} is out of bounds for this system", n))
}