cpp-terminal icon indicating copy to clipboard operation
cpp-terminal copied to clipboard

Resize

Open paveb85394 opened this issue 4 years ago • 12 comments

There is a problem in windows. in the menu example. when you resize the height the menu doubles up because it not clearing or over writing the full console. I think in windows you need to write to the consoles buffer directly.

paveb85394 avatar Feb 26 '21 12:02 paveb85394

Linux might have the same issue --- we need to notice that the terminal was resized and if so, redraw the whole screen.

certik avatar Feb 26 '21 14:02 certik

I think should be able to redraw the console every render call with a buffer. It’s not like it would use much process power on a console.

paveb85394 avatar Feb 26 '21 14:02 paveb85394

That is another option.

certik avatar Feb 26 '21 14:02 certik

I have no idea how to do this. Hope someone that’s working on the code and reads this. Would be great if there was even a option to do this.

paveb85394 avatar Feb 26 '21 14:02 paveb85394

Linux has the same problem. I would suggest to add an option on the Window class for "auto" hight. If that's set the render() function would simply redraw the whole screen with the new terminal size. We would need something like a system that automatically scales the contents - if someone has a good idea for that.

Another option would be to just place the defined Window size into the middle of the screen and not into the left upper corner and edit the render() function to always center the contents. Then we wouldn't even need to touch the vectors for the terminal class (because they have a fixed terminal seize). When the screen gets too small, we would need to print a small message, like "Error: Terminal too smal. Please resize it to make it bigger" or something like that. If the Terminal gets bigger, we can just add spaces or something like that.

MCWertGaming avatar Feb 26 '21 16:02 MCWertGaming

Either way would work I think. @MCWertGaming if you want to give it a shot, go ahead!

certik avatar Feb 26 '21 22:02 certik

I have thought already about doing that, especially because it would make game creation a lot easier. I would give it a shot, but after I finishes the 24bit color addition. I would suggest adding that to the windows class improvements (better render() function). We should talk about those changes in more detail after I finished the color pull-request.

MCWertGaming avatar Feb 26 '21 22:02 MCWertGaming

I imagine this task a bit tricky, if we make a full screen terminal application, we would have to scale everything every 0.0X seconds to make it look really smooth (on a fast terminal, like kitty). Also how should the user draw into a 2D screen without knowing the size? I think the best approach for that would be to either provide the Window class with scaling by centering the pre defined area, or by just allowing the user to create widgets / frames that get scaled automatically inside of the full screen frame. Or just provide both. Another thing would be to separate the render function into a thread, that simply loops and updates the screen as soon as the buffer changes. That would make the resizing really smooth (but will be really tricky on slow terminals, like cmd, powershell, xterm and so on). But something like that will do the trick I think.

MCWertGaming avatar Feb 26 '21 22:02 MCWertGaming

I don't understand what you mean by "scaling". Are you talking about when the user resizes the terminal? I think the terminal might be configured to send some escape codes so that we know when that happens and can redraw.

certik avatar Feb 27 '21 17:02 certik

I mean 'scaling' like the user resizes his terminal and cpp-terminal just make its contents larger. I mean it like if we would have a window class explicit for using widgets and such only, we could just make the widget bigger. It's just an Idea though (and there are already libraries like FTXUI to do that). But that would take some more work of course.

MCWertGaming avatar Feb 28 '21 14:02 MCWertGaming