Closed reibitto closed 4 years ago
You can resize the component as any other Java UI component and the terminal will be resized to fit accordingly.
Thanks. Let me recheck that.
Ideally I'd like to resize the frame by TerminalSize
though. Or I'm fine calculating that myself, but I would need access to getFontWidth
and getFontHeight
at least. Not sure if that's currently available. I think all access to it might be internal?
You're right, that's actually not retrivable after the Swing/AWT terminal has been created. I'll add a method to get that.
Also, there was another request to add support for the CSI 8 t
terminal sequence which (supposedly) resizes the terminal based on a supplied size (in rows and columns). That seems like what you are asking for too, although directly on the Terminal interface instead.
Okay, that's committed now to both 3.0 and master
Thanks @mabe02. Sorry for the late reply. I tried out the latest master. I can access the FontConfiguration now, but I can't really use it since the methods within it are mostly package-private (such as getFontWidth
and getFontHeight
).
Ignoring that for a moment though, just for testing purposes I'm resizing the frame (which should automatically also resize the underlying terminal component I believe) to some arbitrary dimensions and I'm seeing getting weird leftover rendering issues. I was using RefreshType.DELTA
, but I'm seeing the same thing with RefreshType.COMPLETE
. I'll have to investigate this further though. I might be doing something wrong. If I can't find out what's wrong I'll see if I can create a minimal example to reproduce it (probably a separate issue though).
Also, I didn't know about the resizing terminal sequence. Thanks. I'm mostly interested in resizing the terminal only in the emulator though, so I'm not sure if I'll really be using it.
I did confirm that CSI 8 t
works in iTerm2 though. It requires that you uncheck "Disable session-initiated window resizing" in the settings in order to use it.
Okay, I've made those two methods public now. Regarding your resize issue, is this only when you programatically resize the window or also when you manually resize it using the mouse?
I was having issues both when programmatically resizing and manually resizing.
I've since moved to using lanterna for my CLI case and created my own Swing emulator + custom components for the non-CLI case. Feel free to close this issue. I'm not sure it's really a problem for most users who use the Swing emulator the way it was intended to be used. My app is a bit unusual so I don't think it was a typical case.
Ok, will do. Thanks!
I don't currently see a way to programmatically resize the terminal emulator. I'm thinking something like a
setTerminalSize(TerminalSize newSize)
onGraphicalTerminalImplementation
that does the right thing with the backbuffer and so on. Which I think SwingTerminal would also need to call into.My use case is that I have a search field which starts off as a rows=1. Once I start typing I want to expand the terminal window with autocomplete suggest below it (let's say up to rows=10).
I'm currently investigating this and it looks somewhat tricky to do. Though it's possible I'm missing something important.