初始提交:terminalX 可运行态(M0/M1/M1.5 已真机验证)
- M0: libghostty SSH 终端(渲染/输入/连接)+ 白屏修复(OutputGate) + 会话状态机/自动重连 - M1: tsnet 用户态组网 + SSH-over-tsnet(fd 桥),shell 级真机验证;R5(Go+gvisor+C+++Swift 同进程) retire - M1.5: tmux -CC 原生 tab(MVP) - 结构: packages/(TXCore·TXTransport), apps/TerminalX, vendor/(libghostty-spm/libssh2/mbedtls/tsnet-bridge), artifacts/ - 文档: CLAUDE.md + docs/HANDOFF.md(新会话入口) - 环境: 认证代理→依赖 vendor 本地化;Go 在 ~/.local/go;仅模拟器/未签名 - 待续: M2 mosh, tmux 多 pane, M4 安全(host key/SE) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
115
vendor/libghostty-spm/Sources/GhosttyTerminal/State/TerminalViewState.swift
vendored
Normal file
115
vendor/libghostty-spm/Sources/GhosttyTerminal/State/TerminalViewState.swift
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// TerminalViewState.swift
|
||||
// libghostty-spm
|
||||
//
|
||||
// Created by Lakr233 on 2026/3/16.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
public final class TerminalViewState: ObservableObject {
|
||||
@Published public internal(set) var title: String = ""
|
||||
@Published public internal(set) var surfaceSize: TerminalGridMetrics?
|
||||
@Published public internal(set) var isFocused: Bool = false
|
||||
|
||||
@Published public internal(set) var bellCount: Int = 0
|
||||
@Published public internal(set) var lastBellAt: Date?
|
||||
|
||||
@Published public internal(set) var lastDesktopNotificationTitle: String?
|
||||
@Published public internal(set) var lastDesktopNotificationBody: String?
|
||||
@Published public internal(set) var lastDesktopNotificationAt: Date?
|
||||
|
||||
@Published public internal(set) var workingDirectory: String?
|
||||
|
||||
@Published public internal(set) var lastCommandExitCode: Int?
|
||||
@Published public internal(set) var lastCommandDurationNanos: UInt64?
|
||||
|
||||
/// Latest scrollbar geometry reported by the terminal (nil until the first
|
||||
/// update). Drives a host-drawn scrollbar.
|
||||
@Published public internal(set) var scrollbar: TerminalScrollbar?
|
||||
|
||||
public internal(set) weak var surface: TerminalSurface?
|
||||
|
||||
@Published public var configuration: TerminalSurfaceOptions = .init()
|
||||
public var onClose: ((Bool) -> Void)?
|
||||
@Published public internal(set) var controller: TerminalController
|
||||
|
||||
/// Sends text to the attached surface.
|
||||
@discardableResult
|
||||
public func send(_ text: String) -> Bool {
|
||||
guard let surface else {
|
||||
TerminalDebugLog.log(.input, "view state send ignored: missing surface")
|
||||
return false
|
||||
}
|
||||
return surface.sendText(text)
|
||||
}
|
||||
|
||||
/// Invoke a named Ghostty binding action on the attached surface.
|
||||
@discardableResult
|
||||
public func performBindingAction(_ action: String) -> Bool {
|
||||
surface?.performBindingAction(action) ?? false
|
||||
}
|
||||
|
||||
/// Jump the viewport by a number of shell prompts.
|
||||
///
|
||||
/// Negative offsets move toward older prompts and positive offsets move
|
||||
/// toward newer prompts. Prompt navigation requires shell integration.
|
||||
@discardableResult
|
||||
public func jumpToPrompt(by offset: Int16) -> Bool {
|
||||
surface?.jumpToPrompt(by: offset) ?? false
|
||||
}
|
||||
|
||||
/// Reveal an absolute scrollback row, where zero is the first row.
|
||||
@discardableResult
|
||||
public func scrollToRow(_ row: UInt) -> Bool {
|
||||
surface?.scrollToRow(row) ?? false
|
||||
}
|
||||
|
||||
public convenience init() {
|
||||
self.init(configSource: .none)
|
||||
}
|
||||
|
||||
public convenience init(configFilePath: String?) {
|
||||
if let configFilePath {
|
||||
self.init(configSource: .file(configFilePath))
|
||||
} else {
|
||||
self.init(configSource: .none)
|
||||
}
|
||||
}
|
||||
|
||||
public init(
|
||||
configSource: TerminalController.ConfigSource = .none,
|
||||
theme: TerminalTheme = .default,
|
||||
terminalConfiguration: TerminalConfiguration = .init()
|
||||
) {
|
||||
controller = TerminalController(
|
||||
configSource: configSource,
|
||||
theme: theme,
|
||||
terminalConfiguration: terminalConfiguration
|
||||
)
|
||||
}
|
||||
|
||||
public init(controller: TerminalController) {
|
||||
self.controller = controller
|
||||
}
|
||||
|
||||
// MARK: - Forwarded from Controller (single source of truth)
|
||||
|
||||
public var renderedConfig: String {
|
||||
controller.renderedConfig
|
||||
}
|
||||
|
||||
public var effectiveColorScheme: TerminalColorScheme {
|
||||
controller.effectiveColorScheme
|
||||
}
|
||||
|
||||
public var theme: TerminalTheme {
|
||||
controller.theme
|
||||
}
|
||||
|
||||
public var terminalConfiguration: TerminalConfiguration {
|
||||
controller.terminalConfiguration
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user