Elius94 / console-gui-tools

A simple library to draw option menu or other popup inputs and layout on Node.js console.
MIT License
106 stars 17 forks source link

[Feature]: addColumn (instead of double or quad) #74

Open exetico opened 9 months ago

exetico commented 9 months ago

What do you want?

Allow columns, too. Like used in Bootstrap's Grid-system (Columns, rows) to give the dev better options on how to setup a given layout. I'd also like to control, if the "Logs" should be be rendered in a specific column or row.

Why do you want it?

It would enable the dev to generate GUI-elements, instead of having to force the design in a "double" or "quad" layout.

How do you implement it?

Two rows, each with two columns: billede Yes, that's actually a QuadLayout, but done manually.

I'd also like it to support two "horizontal views", where the first one contains two rows, and no. 2 is a single big one: billede

Another solution would be to just support a "triple` layout, maybe two (one for 100% left colum height, and one for 100 right column height - like the example).

Also, just to add it: Personally I had a hard find spotting the "quad" option. Maybe I just missed the example, but after i noticed [https://github.com/Elius94/console-gui-tools/blob/main/docs/QuadLayout.md) in the docs, I though.... The quad-option must be part of the "type" on ConsoleGuiOptions, and luckily it was.

I understand that the addColumn doesnt really fit into the current solution, if I understand the code-base correctly, so the other alternative with two new Layouts would be a good alternative. Maybe even just one, and a "mirror" function (but that's not that logical, for most users). Yet another take would be to just allow one to be stretched to 100% height, and tell the user to set the proper pageRatio (Like [[0.3, 0.7],[0.3, 0.7]], where page 2 (1) is defined with 100% height). But right now, I even struggle to find the function to render a 100% height ConsoleManager.

I'm new to the console-gui-tools, but I've looked at terminal-kit (node), and solutions like urwid (python) and bash solutions like whiptail / dialog and a few others. But console-gui-tools looks very great! In urwid I find myself using way too much time creating simple GUI changes, instead of the functions behind it.

Are you interested in developing this feature?

exetico commented 9 months ago

I can see there's a triple option for type, but it looks like it's "just" rendering three "pages" after each other (vertical, like rows). I tried it in ConsoleManager where it's just throwing a error with setPage

TypeError: Cannot read properties of undefined (reading 'setPage')
    at file:///Users/user/Documents/git/node_terminal_flash_tool/node_modules/console-gui-tools/dist/esm/ConsoleGui.mjs:27:73344
    at Array.forEach (<anonymous>)
    at mt.setPages (file:///Users/user/Documents/git/node_terminal_flash_tool/node_modules/console-gui-tools/dist/esm/ConsoleGui.mjs:27:73244)
    at y.setPages (file:///Users/user/Documents/git/node_terminal_flash_tool/node_modules/console-gui-tools/dist/esm/ConsoleGui.mjs:27:83818)
    at y.updateLayout (file:///Users/user/Documents/git/node_terminal_flash_tool/node_modules/console-gui-tools/dist/esm/ConsoleGui.mjs:27:79091)
    at new y (file:///Users/user/Documents/git/node_terminal_flash_tool/node_modules/console-gui-tools/dist/esm/ConsoleGui.mjs:27:78421)
    at file:///Users/user/Documents/git/node_terminal_flash_tool/index.js:30:13
    at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:281:24)

Double and quad works as expected. But I guess this comment should be part of another issue... πŸ‘Œ

billede

Elius94 commented 9 months ago

Hi! thanks for reporting this issue! It should be planned to feature list! I hope to get the time as soon as possible. Any help is well accepted πŸ‘πŸΌ

exetico commented 9 months ago

While I have your attention, are there any way to force the render to be 100% of my terminal?

billede So I dont have the space in the buttom, but instead, have all pages to, in total, take up 100% height, even though the content doesn't need it.

So it will always use 100% of the screen?

I've tried to play around with settings and functions, but sadly with no luck.

Elius94 commented 9 months ago

Hello! I've released v3.2.0 that includes "fitHeight" prop in the layout options object. It should solve your secondary issue. For the main question you hasked. I'll keep in mind but currently I can't spend too much time to this. I hope in autumn to find time. Thanks

Elius94 commented 9 months ago

image

exetico commented 9 months ago

@Elius94 Thank you for pushing this. I'll check and let you know πŸ˜„ .

For the primary request, what did you think about the work-around, where you just add two more layouts, where it's just growing full height, so you dont have to implement the addColumn()?

Elius94 commented 9 months ago

I think that DynamicLayout (like your idea) should be a feature for the new major release 4.x.x. I'll add it to the milestone Thanks

exetico commented 9 months ago

Thank you Elia!

exetico commented 9 months ago

@Elius94 Im sorry for pinging you again, but I'd just like to ask id you have a milestone public on GitHub?

I didn't manage to find it by myself. https://github.com/users/Elius94/projects/1

Thank you for the fitHeight prop, which works as expected πŸ˜„ !

billede
Elius94 commented 9 months ago

https://github.com/Elius94/console-gui-tools/milestone/3

Hi! I've updated the 4.0.0 milestone! I will start the development when some other significant feature requests will be asked.

exetico commented 9 months ago

@Elius94 Thanks πŸ˜„ .

One last thing: I've used the htop example to generate a new Box({}) called Table, as in the htop example. But I'd like to use the ConsoleManager layout with two or four pages, where I render the Table in one of the pages.

I've tried to run through the examples and docs, but I've not spotted a way to add the table to a specific page (to a PageBuilder, right?).

Is it correct that I can't add a Box inside my PageBuilder, like my Box (table)?

I'm not sure if it's somewhat related to #47. Fingers crossed that I'm missed something 🀞.

Elius94 commented 9 months ago

Yeah! this is the main intent of #47