SwiftTerm icon indicating copy to clipboard operation
SwiftTerm copied to clipboard

Mac Terminal View shows scroller

Open aaronvegh opened this issue 3 years ago • 6 comments

I've been using SwiftTerm for my Mac app, injecting a TerminalView. Recently I noticed that there's a white square on my view's background:

Screen Shot 2021-01-05 at 4 09 31 PM

I realized it was a scrollbar. Although this is apparently a vertical scrollbar, it's rendering a horizontal one that moves left/right as you scroll up/down, and while the thing has a correct frame, the rendered version only uses the intrinsic height and the width of the bar. Weird!

I found where you're creating the scroller, and experimentation revealed that not adding the scroller to the view obviously removed the problem, while also keeping the ability to scroll intact.

Screen Shot 2021-01-05 at 4 10 05 PM

I wonder what you think of this approach? I wonder if the use of the legacy scrollbar (compare to Terminal.app's use of the overlay scrollbar) is appropriate? If I had a choice of whether to show a funny-looking square scroller, or no scroller that still scrolled, I'd choose the latter, but I wonder if I'm screwing something up and this is just me. I can never overlook that possibility.

Thanks so much for this wonderful package.

A.

aaronvegh avatar Jan 05 '21 21:01 aaronvegh

This was part of syncing the features that were being added to XtermSharp by the Visual Studio team to the Swift version:

https://github.com/migueldeicaza/XtermSharp/commit/9581543faf558989451ddf0ce03666153ae636fd

When I ported the code, I vaguely remember struggling with that, and seeing it, and fixing it. Or at least, I thought I had fixed it. Does this just happen when embedding, or also when using the off the shelf terminal?

One thing that I recall, is that at the time, I did try to use the natural scrollers, but somehow, they did not work, or had a strange visual glitch, hence the ".legacy" setting. At least, that I believe that is what happened. Open to changing this to a better scroller if you have tried it out and it worked for you.

migueldeicaza avatar Jan 06 '21 15:01 migueldeicaza

I just ran the standalone Mac Terminal, and the scroller works "fine", in that it's the legacy scroller and shows up okay:

Screen Shot 2021-01-06 at 10 23 56 AM

Indeed, the .overlay scroller doesn't look right either!

Screen Shot 2021-01-06 at 10 24 54 AM

It puts the scroller view on, but there's no knob.

It's peculiar that this manifests differently in the embedded version.

However, I note that refraining from adding the scroller to its superview "works" in the standalone version as well: you don't see a scrollbar at all, but you can still scroll. 🤔

Hope this helps...

aaronvegh avatar Jan 06 '21 15:01 aaronvegh

@aaronvegh How did you eventually solve this for your use case? Just running into the same thing while embedding a TerminalView into a Mac app. I'd be fine with not having a scrollbar at all. Did you manage to hide it without poking in SwiftTerm's source code?

ewilken avatar Sep 23 '23 21:09 ewilken

@ewilken OMG this is a blast from the past! While it's only been the better part of 3 years, this project is something that I eventually abandoned. For funsies, I just opened it up to see how I left that problem, and... Screenshot 2023-09-23 at 9 46 49 PM

So yeah, there was no answer, and if I were finishing this today, I would opt to omit the scroller altogether.

aaronvegh avatar Sep 24 '23 01:09 aaronvegh

Thanks a lot for the answer from the past! 😄 How did you approach getting rid of it though? Make setupScroller open in SwiftTerm's code to be able to override it to do nothing in your code?

ewilken avatar Sep 24 '23 10:09 ewilken

I mean... it's been a few years, but you could just comment out the line where the scroller is added to the view...

aaronvegh avatar Sep 24 '23 21:09 aaronvegh