diff --git a/Sources/SwiftTerm/Apple/AppleTerminalView.swift b/Sources/SwiftTerm/Apple/AppleTerminalView.swift index 046a089f..17b6985f 100644 --- a/Sources/SwiftTerm/Apple/AppleTerminalView.swift +++ b/Sources/SwiftTerm/Apple/AppleTerminalView.swift @@ -100,11 +100,11 @@ extension TerminalView { search = SearchService (terminal: terminal) - #if os(macOS) +#if os(macOS) needsDisplay = true - #else +#else setNeedsDisplay(frame) - #endif +#endif } /// Returns the underlying terminal emulator that the `TerminalView` is a view for @@ -730,7 +730,7 @@ extension TerminalView { nativeBackgroundColor.setFill() context.fill ([box]) } -#elseif false +#else // Currently the caller on iOS is clearing the entire dirty region due to the ordering of // font change sizes, but once we fix that, we should remove the clearing of the dirty // region in the calling code, and enable this code instead. @@ -811,7 +811,7 @@ extension TerminalView { terminal.clearUpdateRange () - #if os(macOS) +#if os(macOS) let baseLine = frame.height var region = CGRect (x: 0, y: baseLine - (cellDimension.height + CGFloat(rowEnd) * cellDimension.height), @@ -826,11 +826,13 @@ extension TerminalView { region = CGRect (x: 0, y: 0, width: frame.width, height: oh + oy) } setNeedsDisplay(region) - #else - // TODO iOS: need to update the code above, but will do that when I get some real - // life data being fed into it. - setNeedsDisplay(bounds) - #endif +#else + let region = CGRect (x: 0, + y: CGFloat (rowStart)*cellDimension.height+contentOffset.y, + width: frame.width, + height: CGFloat (rowEnd-rowStart+1) * cellDimension.height) + setNeedsDisplay(region) +#endif pendingDisplay = false updateDebugDisplay () diff --git a/Sources/SwiftTerm/iOS/iOSTerminalView.swift b/Sources/SwiftTerm/iOS/iOSTerminalView.swift index 56ac63d6..fddefa7f 100644 --- a/Sources/SwiftTerm/iOS/iOSTerminalView.swift +++ b/Sources/SwiftTerm/iOS/iOSTerminalView.swift @@ -961,18 +961,36 @@ open class TerminalView: UIScrollView, UITextInputTraits, UIKeyInput, UIScrollVi guard let context = getCurrentGraphicsContext() else { return } - + + //print (dirtyRect) // Without these two lines, on font changes, some junk is being displayed // Once we test the font change, we could disable these two lines, and // enable the #if false in drawterminalContents that should be coping with this now nativeBackgroundColor.set () - context.fill ([dirtyRect]) + //print (nativeBackgroundColor) + //UIColor.black.set() + context.clear (dirtyRect) + //context.fill ([dirtyRect]) + //context.saveGState() // drawTerminalContents and CoreText expect the AppKit coordinate system context.scaleBy (x: 1, y: -1) context.translateBy(x: 0, y: -frame.height) drawTerminalContents (dirtyRect: dirtyRect, context: context, bufferOffset: 0) +// context.restoreGState() +// +// switch Int.random(in: 0..<3) { +// case 0: +// context.setFillColor(red: 1.0, green: 0, blue: 0, alpha: 0.3) +// case 1: +// context.setFillColor(red: 0, green: 1.0, blue: 0, alpha: 0.3) +// case 2: +// context.setFillColor(red: 0, green: 0, blue: 1.0, alpha: 0.3) +// default: +// context.setFillColor(red: 0.4, green: 0, blue: 1.0, alpha: 0.3) +// } +// context.fill ([dirtyRect]) } open override var bounds: CGRect { diff --git a/TerminalApp/MacTerminal/ViewController.swift b/TerminalApp/MacTerminal/ViewController.swift index d532e5b4..3464afdb 100644 --- a/TerminalApp/MacTerminal/ViewController.swift +++ b/TerminalApp/MacTerminal/ViewController.swift @@ -124,6 +124,7 @@ class ViewController: NSViewController, LocalProcessTerminalViewDelegate, NSUser terminal = LocalProcessTerminalView(frame: view.frame) zoomGesture = NSMagnificationGestureRecognizer(target: self, action: #selector(zoomGestureHandler)) terminal.addGestureRecognizer(zoomGesture!) + terminal.getTerminal().backgroundColor = SwiftTerm.Color(red: 0, green: 0x8000, blue: 0) ViewController.lastTerminal = terminal terminal.processDelegate = self terminal.feed(text: "Welcome to SwiftTerm") diff --git a/TerminalApp/iOSTerminal/ViewController.swift b/TerminalApp/iOSTerminal/ViewController.swift index d61278a4..907dc129 100644 --- a/TerminalApp/iOSTerminal/ViewController.swift +++ b/TerminalApp/iOSTerminal/ViewController.swift @@ -92,6 +92,7 @@ class ViewController: UIViewController { } view.addSubview(tv) + tv.getTerminal().backgroundColor = SwiftTerm.Color.init(red: 0x8080, green: 0, blue: 0) setupKeyboardMonitor() tv.becomeFirstResponder() self.tv.feed(text: "Welcome to SwiftTerm - connecting to my localhost\r\n\n")