rensbreur / SwiftTUI

SwiftUI for terminal applications
MIT License
1.23k stars 47 forks source link

Renderer Brakes when compiling most basic app #28

Closed devinhayward closed 7 months ago

devinhayward commented 7 months ago

Hi I tried to compile and run the basic app:

import SwiftTUI

struct MyTerminalView: View { var body: some View { Text("Hello, world!") } }

Application(rootView: MyTerminalView()).start()

and broke at runtime;

/// Draw a specific area, or the entire layer if the area is nil. func draw(rect: Rect? = nil) { if rect == nil { layer.invalidated = nil } let rect = rect ?? Rect(position: .zero, size: layer.frame.size) for line in rect.minLine ... rect.maxLine { (Fatal error: Range requires lowerBound <= upperBound) for column in rect.minColumn ... rect.maxColumn { let position = Position(column: column, line: line) if let cell = layer.cell(at: position) { drawPixel(cell, at: Position(column: column, line: line)) } } } }

rensbreur commented 7 months ago

Hi @devinhayward, it works fine for me. Which terminal are you using?

devinhayward commented 7 months ago

I am using standard macOS Sonoma 14.5 Beta, with Xcode 15.3.

Builds fine but when it runs I get the crash (Fatal error: Range requires lowerBound <= upperBound) for the draw func in your Renderer Class.

rensbreur commented 7 months ago

It doesn't work in the Xcode console, you need to use a proper terminal emulator. For example, open the built-in macOS Terminal app, change to the directory of your package and run

swift run
devinhayward commented 7 months ago

Got it. Will work without Xcode and the Swift Package Manager workflow only. Thanks!