Skip to content

Conversation

migueldeicaza
Copy link

It renames 'CursesBackend' to TermKit, as now TermKit has various console drivers, and curses is just one of them.

The challenge is that TermKit deals with screen sizes like 80x24, not things like 600x400, so both the default sizes and spacing in the codebase will need to compensate for that.

The AppBackend introduces a defaultStackSpacingAmount which is the spacing that VStack and HStack would use, it is currently kept as a default to the existing value, but for the TermKit backend, this value is set to zero.

Now HStack and VStack rather than storing a resolved value like 'spacing: Int', they store the request 'spacing: Int?', which is resolved before it is actually needed by querying the backend for this data.

There is also a new 'limitScreenBounds' that is a no-op for most, but on the curses cases, ensures that a misuse of the defaultSize does not trickle up and down the stack with unrealistic view sizes.

It renames 'CursesBackend' to TermKit, as now TermKit has various
console drivers, and curses is just one of them.

The challenge is that TermKit deals with screen sizes like 80x24, not
things like 600x400, so both the default sizes and spacing in the
codebase will need to compensate for that.

The AppBackend introduces a defaultStackSpacingAmount which is the
spacing that VStack and HStack would use, it is currently kept as a
default to the existing value, but for the TermKit backend, this value
is set to zero.

Now HStack and VStack rather than storing a resolved value like
'spacing: Int', they store the request 'spacing: Int?', which is
resolved before it is actually needed by querying the backend for this
data.

There is also a new 'limitScreenBounds' that is a no-op for most, but
on the curses cases, ensures that a misuse of the defaultSize does not
trickle up and down the stack with unrealistic view sizes.
Copy link
Owner

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had a quick look out of interest and left a few comments (mostly formatting related). I'll change this PR to a draft for now

// name: "CursesBackend",
// dependencies: ["SwiftCrossUI", "TermKit"]
// ),
.target(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation (and for the TermKit package above and TermKitBackend product above that)

// ),
.target(
name: "TermKitBackend",
dependencies: ["SwiftCrossUI", .product(name: "TermKit", package: "TermKit")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use "TermKit" spelling instead of .product(name: "TermKit", package: "TermKit")

todo()
}

public func limitScreenBounds(_ bounds: SIMD2<Int>) -> SIMD2<Int> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should be reworked to func clampWindowSize(_ size: SIMD2<Int>, for window: Window) -> SIMD2<Int>. Renamed for clarity, and extra parameter added for future proofing (future purposes could want the window in question to access properties such as scaling factors).

proposedWindowSize: isFirstUpdate && isProgramaticallyResizable
? (newScene ?? scene).defaultSize
: backend.size(ofWindow: window),
? backend.limitScreenBounds((newScene ?? scene).defaultSize)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent these two hanging lines

}

public func runInMainThread(action: @escaping @MainActor () -> Void) {
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent this body two levels

@stackotter stackotter marked this pull request as draft September 17, 2025 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants