Files
MyGolandRelease/docs/plans/2026-10-29-terminal.md
T
zerorigin a80c0f886a MyGoland 首次提交:Go 轻量 IDE
- 编辑器:多标签、语法高亮、gopls 全套(补全/诊断/跳转/重命名/代码动作/内联提示/签名大纲)
- 调试:Delve DAP(断点/条件断点/变量树/表达式求值/goroutine 列表)
- 测试:结果树、覆盖率行着色、失败跳源码、-run 精确运行、行号可跑标记
- Git:状态着色、选择性暂存提交、pull/push、历史并排对比
- 本地历史 + 自动快照 + 崩溃恢复、会话/光标恢复
- 全局搜索替换(预览+确认,GBK 安全)、多终端、gopls 崩溃自愈
- 设计文档与验证记录见 docs/plans/
2026-11-04 16:37:05 +08:00

52 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 终端面板(2026-10-29)
## 1. 方案
用 mygo 官方 `plugins/terminal`(Ghostty 的 VT 模拟器 libghostty-vt),底部面板新增第 4 个页签「终端」,
`Alt+F12` 打开。外壳可切换:PowerShell / Git Bash / CMD。
| 外壳 | 查找顺序 |
|---|---|
| PowerShell | `pwsh.exe`(7.x)→ `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe` |
| Git Bash | `%ProgramFiles%`、`%ProgramFiles(x86)%`、`%LOCALAPPDATA%` 下的 `Git\bin\bash.exe` → PATH 里的 `bash.exe` |
| CMD | `%ComSpec%` → `cmd.exe` |
- 工作目录 = 当前工作区根。
- 切换外壳会重启终端;切换工作区会重置终端,下次显示时落到新目录。
- 用 `ui.Segmented` 选外壳,右侧有「重启」按钮。
## 2. 关键坑:原生库
`terminal.New` 会 `Load()` 一个原生库 libghostty-vt(Windows 侧文件名 `ghostty-vt.dll`,2.07 MB)。
加载顺序:`$MYGO_GHOSTTY_VT` → 应用资源目录 → **exe 同目录** → 用户缓存。
本机实测:直连 GitHub Releases 下载 **120 秒超时**(国内网络)。解决方式:
1. 通过镜像 `https://ghfast.top/<原始地址>` 下载;
2. 校验 SHA-256 与 `plugins/terminal/mygo-plugin.json` 声明一致
(windows-amd64:`53e8e2dd…65da41`);
3. 放 `resources/ghostty-vt.dll`,`build.cmd` 构建后自动复制到 exe 同目录。
因为 exe 同目录优先级高于缓存,程序不会再尝试联网下载。
## 3. 验证
| 项目 | 方法 | 结果 |
|---|---|---|
| 外壳检测 | `TestDetectShells` | 三个外壳都找到(本机为系统自带 5.1 版 + Git Bash 在 Program Files) |
| 终端真能跑 | `TestTerminalRunsCommand` | `cmd /c echo` 0.6 s 内出现在 `History()` |
| 端到端 | 启动应用并自动切到终端页签 | 日志 `terminal started: PowerShell`,外壳子进程存在 |
| 退出清理 | 强制结束应用后查进程 | 外壳进程随之消失,无残留 |
## 4. 已知限制
- 终端配色独立于编辑器主题,还没做同步(插件支持 `UseTheme`)。
- 单终端,没有分屏或多终端标签。
- 原生库缺失时给出下载指引而不是崩溃,但分发时仍需把 DLL 一起带上。
- 体积:exe 从 12.0 MB 增至 14.9 MB(终端插件),另需附带 2.07 MB DLL。
## 5. 给部署方的说明
把 `MyGoland.exe` 和 `ghostty-vt.dll` 放在同一目录即可。若 DLL 缺失,程序不会崩溃:
终端页签会显示提示,包含下载地址与两种修复方式(同目录放 DLL,或设置 `MYGO_GHOSTTY_VT`)。