Skip to content

Commit 3f38c5f

Browse files
Steve Gehrmanalvarolb
authored andcommitted
no more wacko scrollbar, and supports clear backgrounds
1 parent 8bc13c8 commit 3f38c5f

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Sources/SwiftTerm/Mac/MacTerminalView.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,18 @@ open class TerminalView: NSView, NSTextInputClient, NSUserInterfaceValidations,
307307
if settingBg { return }
308308
settingBg = true
309309
_nativeBg = newValue
310+
layer?.backgroundColor = newValue.cgColor
310311
terminal.backgroundColor = nativeBackgroundColor.getTerminalColor ()
311312
settingBg = false
312313
}
313314
}
315+
316+
override public var isOpaque: Bool {
317+
if let bg = _nativeBg {
318+
return bg.alphaComponent >= 1.0
319+
}
320+
return true
321+
}
314322

315323
/// Controls weather to use high ansi colors, if false terminal will use bold text instead of high ansi colors
316324
public var useBrightColors: Bool = true
@@ -393,13 +401,18 @@ open class TerminalView: NSView, NSTextInputClient, NSUserInterfaceValidations,
393401

394402
func setupScroller()
395403
{
396-
let scrollerFrame = getScrollerFrame()
404+
let scrollerWidth = NSScroller.scrollerWidth(for: .regular, scrollerStyle: scrollerStyle)
405+
// Use a tall-enough frame so NSScroller initializes as vertical (orientation is determined by frame aspect)
406+
let initialFrame = bounds.height > scrollerWidth
407+
? getScrollerFrame()
408+
: NSRect(x: 0, y: 0, width: scrollerWidth, height: scrollerWidth + 1)
409+
397410
if scroller == nil {
398-
scroller = NSScroller(frame: scrollerFrame)
411+
scroller = NSScroller(frame: initialFrame)
399412
} else {
400-
scroller?.frame = scrollerFrame
413+
scroller?.frame = initialFrame
401414
}
402-
scroller.autoresizingMask = [.minXMargin, .height]
415+
scroller.autoresizingMask = []
403416
scroller.scrollerStyle = scrollerStyle
404417
scroller.knobProportion = 0.1
405418
scroller.isEnabled = false

0 commit comments

Comments
 (0)