Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Sources/TerminalCore/Logger.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Foundation

/// Simple file logger for debugging crashes.
/// Logs are written synchronously to ensure they persist before crashes.
/// No initialization required - just call `debugLog("message")` anywhere.
/**
Simple file logger for debugging crashes.
Logs are written synchronously to ensure they persist before crashes.
No initialization required - just call `debugLog("message")` anywhere.
*/
public func debugLog(_ message: String, file: String = #file, line: Int = #line, function: String = #function) {
let logDir = FileManager.default.homeDirectoryForCurrentUser
.appendingPathComponent(".swift-cli/logs")
Expand Down
8 changes: 5 additions & 3 deletions Sources/TerminalCore/Terminal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,11 @@ public actor Terminal {

// MARK: - Input

/// Wait for input to be available using poll(2).
/// Returns true if input is available, false on timeout.
/// This is much faster than polling with sleep loops.
/**
Wait for input to be available using poll(2).
Returns true if input is available, false on timeout.
This is much faster than polling with sleep loops.
*/
public func waitForInput(timeoutMs: Int) -> Bool {
var pfd = pollfd(fd: inputFD, events: Int16(POLLIN), revents: 0)
let result = poll(&pfd, 1, Int32(timeoutMs))
Expand Down
8 changes: 5 additions & 3 deletions Sources/TerminalGraphics/ITerm2Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import Foundation
import ANSI
import TerminalCore

/// iTerm2 inline image protocol.
///
/// Reference: https://iterm2.com/documentation-images.html
/**
iTerm2 inline image protocol.

Reference: https://iterm2.com/documentation-images.html
*/
public struct ITerm2Image: TerminalImageProtocol, Sendable {
/// Raw image data (PNG, JPEG, GIF, etc.).
public let data: Data
Expand Down
8 changes: 5 additions & 3 deletions Sources/TerminalGraphics/KittyImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import Foundation
import ANSI
import TerminalCore

/// Kitty graphics protocol implementation.
///
/// Reference: https://sw.kovidgoyal.net/kitty/graphics-protocol/
/**
Kitty graphics protocol implementation.

Reference: https://sw.kovidgoyal.net/kitty/graphics-protocol/
*/
public struct KittyImage: TerminalImageProtocol, Sendable {
/// Raw image data (PNG recommended).
public let data: Data
Expand Down
8 changes: 5 additions & 3 deletions Sources/TerminalInput/Terminal+Input.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import TerminalStyle

/// Terminal extensions for input handling.
extension Terminal {
/// Read a single key with timeout (requires raw mode).
/// Returns nil if no input is received within the timeout period.
/// Uses poll(2) for sub-millisecond latency on local terminals.
/**
Read a single key with timeout (requires raw mode).
Returns nil if no input is received within the timeout period.
Uses poll(2) for sub-millisecond latency on local terminals.
*/
public func readKeyWithTimeout(milliseconds: Int) async throws -> KeyCode? {
// Use poll(2) to wait for input - returns immediately when data arrives
guard waitForInput(timeoutMs: milliseconds) else {
Expand Down