099fc62bbf
Nix / check-zig-cache-hash (push) Has been cancelled
Test / skip (push) Has been cancelled
Test / trigger-snap (push) Has been cancelled
Nix / Required Checks: Nix (push) Has been cancelled
Test / trigger-flatpak (push) Has been cancelled
Test / test (push) Has been cancelled
Test / build-flatpak (push) Has been cancelled
Test / build-snap (push) Has been cancelled
Test / build-libghostty-vt (aarch64-linux) (push) Has been cancelled
Test / build-libghostty-vt (aarch64-macos) (push) Has been cancelled
Test / build-libghostty-vt (wasm32-freestanding) (push) Has been cancelled
Test / build-libghostty-vt (x86_64-linux) (push) Has been cancelled
Test / build-libghostty-vt (x86_64-linux-musl) (push) Has been cancelled
Test / build-libghostty-vt (x86_64-macos) (push) Has been cancelled
Test / build-libghostty-vt (x86_64-windows-gnu) (push) Has been cancelled
Test / build-libghostty-vt-macos (aarch64-ios) (push) Has been cancelled
Test / build-libghostty-vt-macos (aarch64-macos) (push) Has been cancelled
Test / build-libghostty-vt-macos (x86_64-macos) (push) Has been cancelled
Test / build-libghostty-vt-android (aarch64-linux-android) (push) Has been cancelled
Test / build-libghostty-vt-android (arm-linux-androideabi) (push) Has been cancelled
Test / Required Checks: Test (push) Has been cancelled
Test / build-bench (push) Has been cancelled
Test / list-examples (push) Has been cancelled
Test / Example ${{ matrix.dir }} (Windows) (push) Has been cancelled
Test / build-cmake (push) Has been cancelled
Test / test-lib-vt-pkgconfig (push) Has been cancelled
Test / build-dist (push) Has been cancelled
Test / build-dist-lib-vt (push) Has been cancelled
Test / build-macos (push) Has been cancelled
Test / build-macos-freetype (push) Has been cancelled
Test / build-libghostty-vt-android (x86_64-linux-android) (push) Has been cancelled
Test / build-libghostty-vt-windows (push) Has been cancelled
Test / build-libghostty-windows-gnu (push) Has been cancelled
Test / build-linux (namespace-profile-ghostty-md) (push) Has been cancelled
Test / build-linux (namespace-profile-ghostty-md-arm64) (push) Has been cancelled
Test / build-linux-libghostty (push) Has been cancelled
Test / build-nix (namespace-profile-ghostty-md) (push) Has been cancelled
Test / build-nix (namespace-profile-ghostty-md-arm64) (push) Has been cancelled
Test / test-lib-vt (push) Has been cancelled
Test / GTK x11=false wayland=false (push) Has been cancelled
Test / GTK x11=true wayland=false (push) Has been cancelled
Test / GTK x11=false wayland=true (push) Has been cancelled
Test / GTK x11=true wayland=true (push) Has been cancelled
Test / Build -Dsimd=false (push) Has been cancelled
Test / Build -Dsimd=true (push) Has been cancelled
Test / Build -Dsentry=false (push) Has been cancelled
Test / Build -Dsentry=true (push) Has been cancelled
Test / test-macos (push) Has been cancelled
Test / test-windows (push) Has been cancelled
Test / Build -Di18n=false (push) Has been cancelled
Test / Build -Di18n=true (push) Has been cancelled
Test / Build test/fuzz-libghostty (push) Has been cancelled
Test / zig-fmt (push) Has been cancelled
Test / GitHub Actions Pins (push) Has been cancelled
Test / prettier (push) Has been cancelled
Test / swiftlint (push) Has been cancelled
Test / alejandra (push) Has been cancelled
Test / typos (push) Has been cancelled
Test / shellcheck (push) Has been cancelled
Test / translations (push) Has been cancelled
Test / blueprint-compiler (push) Has been cancelled
Test / Test pkg/wuffs (push) Has been cancelled
Test / Test build on Debian 13 (push) Has been cancelled
Test / valgrind (push) Has been cancelled
Test / Example ${{ matrix.dir }} (push) Has been cancelled
146 lines
10 KiB
Markdown
146 lines
10 KiB
Markdown
<!-- WEHUB_ZH_README -->
|
||
> [!NOTE]
|
||
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
|
||
> [English](./README.en.md) · [原始项目](https://github.com/ghostty-org/ghostty) · [上游 README](https://github.com/ghostty-org/ghostty/blob/HEAD/README.md)
|
||
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
|
||
|
||
<!-- LOGO -->
|
||
<h1>
|
||
<p align="center">
|
||
<img src="https://github.com/user-attachments/assets/fe853809-ba8b-400b-83ab-a9a0da25be8a" alt="Logo" width="128">
|
||
<br>Ghostty
|
||
</h1>
|
||
<p align="center">
|
||
快速、原生、功能丰富的终端模拟器,推进现代特性。
|
||
<br />
|
||
可通过 <code>libghostty</code> 提供原生 GUI 或可嵌入库。
|
||
<br />
|
||
<a href="#about">关于</a>
|
||
·
|
||
<a href="https://ghostty.org/download">下载</a>
|
||
·
|
||
<a href="https://ghostty.org/docs">文档</a>
|
||
·
|
||
<a href="CONTRIBUTING.md">贡献</a>
|
||
·
|
||
<a href="HACKING.md">开发</a>
|
||
</p>
|
||
</p>
|
||
|
||
## About
|
||
|
||
Ghostty 是一款终端模拟器,其差异化在于快速、功能丰富且原生。虽然市面上已有许多优秀的终端模拟器,但它们往往迫使你在速度、功能或原生 UI 之间做出取舍。Ghostty 三者兼得。
|
||
|
||
**`libghostty`** 是一个跨平台、零依赖的 C 与 Zig 库,用于构建终端模拟器或利用终端功能(例如样式解析)。任何人都可以使用 `libghostty` 来构建终端模拟器,或将终端嵌入到自己的应用中。参见 [Ghostling](https://github.com/ghostty-org/ghostling) 获取一个最小完整项目示例,或查看 [`examples` 目录](https://github.com/ghostty-org/ghostty/tree/main/example) 了解在 C 与 Zig 中使用 `libghostty` 的更小示例。
|
||
|
||
更多详情,请参阅 [About Ghostty](https://ghostty.org/docs/about).
|
||
|
||
## Download
|
||
|
||
请访问 Ghostty 网站上的[下载页面](https://ghostty.org/download)。
|
||
|
||
## Documentation
|
||
|
||
请访问 Ghostty 网站上的[文档](https://ghostty.org/docs)。
|
||
|
||
## Contributing and Developing
|
||
|
||
如果你对 Ghostty 有任何想法、问题等,或希望通过 pull request 为 Ghostty 做贡献,请查阅我们的 ["Contributing to Ghostty"](CONTRIBUTING.md) 文档。希望参与 Ghostty 开发的人员还应阅读 ["Developing Ghostty"](HACKING.md) 文档以了解更多技术细节。
|
||
|
||
## Roadmap and Status
|
||
|
||
Ghostty 已稳定,每天有数百万用户和机器在使用。
|
||
|
||
项目的高层次宏伟计划,按顺序如下:
|
||
|
||
| # | Step | Status |
|
||
| :-: | ------------------------------------------------------- | :----: |
|
||
| 1 | 符合标准的终端模拟 | ✅ |
|
||
| 2 | 具有竞争力的性能 | ✅ |
|
||
| 3 | 丰富的窗口功能——多窗口、标签页、分屏 | ✅ |
|
||
| 4 | 原生平台体验(Native Platform Experiences) | ✅ |
|
||
| 5 | 用于可嵌入终端的跨平台 `libghostty` | ✅ |
|
||
| 6 | Ghostty 专属终端控制序列 | ❌ |
|
||
|
||
以下是大路线图中各步骤的更多细节:
|
||
|
||
#### Standards-Compliant Terminal Emulation
|
||
|
||
Ghostty 实现了所有常用控制序列,可毫无问题地运行各类主流终端程序。对于遗留序列,我们进行了[全面的 xterm 审计](https://github.com/ghostty-org/ghostty/issues/632),将 Ghostty 的行为与 xterm 对比,并建立了一套一致性测试用例。
|
||
|
||
除遗留序列(即你所理解的真正“终端”模拟)外,Ghostty 还支持比几乎所有其他终端模拟器都更现代的序列。这些功能包括 Kitty 图形协议(Kitty graphics protocol)、Kitty 图像协议(Kitty image protocol)、剪贴板序列、同步渲染(synchronized rendering)、明暗模式通知等,以及更多特性。
|
||
|
||
我们相信 Ghostty 是目前最符合标准、功能最丰富的终端模拟器之一。
|
||
|
||
终端行为部分属于法定标准(de jure standard,即 [ECMA-48](https://ecma-international.org/publications-and-standards/standards/ecma-48/)),但更多是由全球流行终端模拟器定义的事实标准(de facto standard)。Ghostty 采取的做法是:行为按以下顺序定义——(1) 若有标准则遵循标准,(2) 若功能存在则参照 xterm,(3) 再参照其他流行终端。这定义了 Ghostty 项目所认为的“标准”。
|
||
|
||
#### Competitive Performance
|
||
|
||
Ghostty 通常与其他性能最高的终端模拟器处于同一性能梯队。
|
||
|
||
“同一性能梯队”意味着 Ghostty 远快于传统或“较慢”的终端,且与知名的“快速”终端相比处于几乎察觉不到的差距内。例如,Ghostty 与 Alacritty 在各类基准测试中通常相差几个百分点,但两者都比 Terminal.app 和 iTerm 快约 100 倍。不过,Ghostty 比 Alacritty 功能更丰富,原生应用体验也更好。
|
||
|
||
这一性能得益于高层架构决策与底层优化。在高层,Ghostty 采用多线程架构,每个终端各有专用的读线程、写线程和渲染线程。我们的渲染器在 Linux 上使用 OpenGL,在 macOS 上使用 Metal。读线程包含高度优化的终端解析器,利用 CPU 专用的 SIMD 指令。等等。
|
||
|
||
#### Rich Windowing Features
|
||
|
||
Mac 与 Linux(使用 GTK 构建)应用支持多窗口、标签页和分屏,并提供标签重命名、着色等附加功能。这些功能相比单窗口终端,可实现更高程度的组织与自定义。
|
||
|
||
#### Native Platform Experiences
|
||
|
||
Ghostty 是跨平台终端模拟器,但我们并不追求“最小公分母”体验。核心部分大量共享,使用 Zig 编写,但我们在各平台上做了许多原生实现:
|
||
|
||
- macOS 应用是真正的基于 SwiftUI 的应用,具备你所期望的一切,例如真正的窗口管理、菜单栏、设置 GUI 等。
|
||
- macOS 使用真正的 Metal 渲染器,并通过 CoreText 进行字体发现。
|
||
- macOS 支持 AppleScript、Apple Shortcuts(AppIntents)等。
|
||
- Linux 应用使用 GTK 构建。
|
||
- 若可用,Linux 应用会与 systemd 深度集成,用于常驻、单实例新窗口、cgroup 隔离等功能。
|
||
|
||
我们对 Ghostty 的目标是:无论用户在哪个平台上运行 Ghostty,都应觉得 Ghostty 是优先、甚至可能是专门为该平台打造的。我们希望 Ghostty 在每个平台上都像原生应用——以各平台对“原生”的最佳定义为准。
|
||
|
||
#### Cross-platform `libghostty` for Embeddable Terminals
|
||
|
||
除作为独立终端模拟器外,Ghostty 还是一个 C 兼容库,可在任何第三方项目中嵌入快速、功能丰富的终端模拟器。该库名为 `libghostty`。
|
||
|
||
鉴于项目范围,我们将 libghostty 拆分为多个独立库,首先从 `libghostty-vt` 开始。该项目的目标是专注于解析终端序列并维护终端状态。更多细节见这篇[博客文章](https://mitchellh.com/writing/libghostty-is-coming).
|
||
|
||
`libghostty-vt` 现已可用于 Zig 与 C,并兼容 macOS、Linux、Windows 与 WebAssembly。功能极其稳定(因其在 Ghostty GUI 中已长期使用得到验证),但 API 签名仍在变动中。
|
||
|
||
`libghostty` 已被大量使用。参见 [`examples`](https://github.com/ghostty-org/ghostty/tree/main/example) 了解在 C 与 Zig 中使用 `libghostty` 的小示例,或参见 [Ghostling](https://github.com/ghostty-org/ghostling) 项目获取完整示例。参见 [awesome-libghostty](https://github.com/Uzaaft/awesome-libghostty) 查看与 `libghostty` 相关的项目与资源列表。
|
||
|
||
我们尚未为 libghostty 打版本标签,也仍在改进文档体验,但我们的 [Doxygen 网站](https://libghostty.tip.ghostty.org/) 是了解 C API 的良好资源。
|
||
|
||
#### Ghostty-only Terminal Control Sequences
|
||
|
||
我们希望并相信,终端应用能够且应该做到更多。我们已努力支持其他终端模拟器创建的多种现代序列以实现这一目标,同时也希望通过自创序列来填补空白。
|
||
|
||
到目前为止,我们一直对这件事犹豫不决,因为我们不想通过创建仅在 Ghostty 中生效的序列,而在终端生态系统中造成更多碎片化。不过,我们也希望在这种顾虑与推动终端进步的愿望之间取得平衡——毕竟现有标准停滞不前,终端生态系统的变革步伐也十分缓慢。
|
||
|
||
我们尚未实现上述任何内容。
|
||
|
||
## 崩溃报告
|
||
|
||
Ghostty 内置崩溃报告器,会生成崩溃报告并将其保存到磁盘。崩溃报告保存在 `$XDG_STATE_HOME/ghostty/crash` 目录中。如果未设置 `$XDG_STATE_HOME`,则默认为 `~/.local/state`。**崩溃报告_不会_自动发送到您机器以外的任何位置。**
|
||
|
||
崩溃报告只会在崩溃后下次启动 Ghostty 时生成。如果 Ghostty 崩溃后您想生成崩溃报告,必须至少重启 Ghostty 一次。您应该在日志中看到已生成崩溃报告的提示消息。
|
||
|
||
> [!NOTE]
|
||
>
|
||
> 使用 `ghostty +crash-report` CLI 命令可获取可用崩溃报告的列表。未来版本的 Ghostty 将通过 CLI 和 GUI 让您更方便地查看崩溃报告内容。
|
||
|
||
崩溃报告的文件扩展名为 `.ghosttycrash`。崩溃报告采用 [Sentry envelope 格式](https://develop.sentry.dev/sdk/envelopes/). 您可以将它们上传到您自己的 Sentry 账户以查看其内容,但该格式也有公开文档,因此也可使用任何其他可用工具。
|
||
The `ghostty +crash-report` CLI command can be used to list any crash reports.
|
||
A future version of Ghostty will show you the contents of the crash report
|
||
directly in the terminal.
|
||
|
||
To send the crash report to the Ghostty project, you can use the following
|
||
CLI command using the [Sentry CLI](https://docs.sentry.io/cli/installation/):
|
||
|
||
```shell-session
|
||
SENTRY_DSN=https://e914ee84fd895c4fe324afa3e53dac76@o4507352570920960.ingest.us.sentry.io/4507850923638784 sentry-cli send-envelope --raw <path to ghostty crash>
|
||
```
|
||
|
||
> [!WARNING]
|
||
>
|
||
> 崩溃报告可能包含敏感信息。报告并非刻意包含敏感信息,但其中包含崩溃时各线程的完整栈内存。这些信息用于重建堆栈跟踪,但根据崩溃发生的时机,也可能包含敏感数据。
|