VladimirMarkelov/clui

Few quick questions

MostHated opened this issue ยท 9 comments

Hey there,
I started playing around with the library last night, it seems fantastic! A few quick questions if you don't mind.

  1. Is it at all somehow possible to force color consistency in the terminal in any way that you know of? I attempted to run a test in a few different terminal and they all had different results due to terminal themes and things of that nature. I was hoping there might be a way to temporarily disable or override terminal theme colors to make the app itself consistent.

  2. What are the colors that are actually available? I tried to simply put grey (just to test I also put gray), but both came back as error. It seemed a bit odd that cyan was available in one of the themes, but grey cause issue.

  3. What is the best way to force a template to become the application default instead of the built-in default? If I have one I have made and I want that to always be "default". I know you can use the selector in the demo, but the original actual built in default is always the first one to load. Either by setting which one to use as default at the start of the application, or possibly changing what the built-in default is without modifying core code?

  4. Though you may not be able to answer, I figured it is worth a try. I have only been using Go for about 2 weeks, so I am far from an expert yet. I was wondering if it is possible to use this library as well as another console ui library at the same time? I love the buttons and controls this provides but also like how some of the text areas work in another library. I know with this you have to run the mainloop, and one of the other libraries also uses a mainloop, so I was not sure if it's possible to run them at the same time. It would be somewhat nested.
    An example is, I wanted to have a window and a frame of left side menu of buttons using this library and then when you click on one of them there would be a right side frame and inside of that have a text area from another library. So perhaps if the func main() ran the mainloop of this library but then the button press called another function which contained the mainloop of the other library? I suppose that is just something I might have to test out.

Anyways, thanks for all your hard work on this library!
Can't wait to put it to good use. : )
Thanks,
-MH

Hi!

Thank you!

  1. I do not know a way to do this. And I doubt there is a way to do it. The library always thinks that it sends certain colors and it has no clue how these numbers (0 through 7) would be transformed by a terminal emulator.
  2. You can see available colors in the file textutil.go. In the beginning there is map of color names and their values. In the same file by the end there are functions StringToColor and ColorToString that show how to make Bold/Italic/Bright color and how they look
  3. Do you mean how to use a theme as default one? You can do it line main demo does: please see demos\maindemo\clui_demo.go and its function mainloop - it sets theme at start. But to do it, you must provide a directory with the theme inside always. Sometimes it is inconvenient. You can hack the sources and change ThemeReset in theme.go - and change in it colors to any you like. Third way(it is not implemented yet) - provide a method to add a custom theme from structure in memory along with existing theme loader. But the function must be robust and do validation (e.g, nobody must replace default theme because having a default theme allows people to omit colors/characters in their own themes)
  4. I do not think it is possible - they would fight for terminal and the most probable result is that only one library displays its data. Even simple fmt.Printf does not work - termbox-go overwrites the screen.

Thanks, I appreciate the info!

Sorry for so many questions, I am just trying to make best use of this as I can. So far in the short time I have worked with it, it has been great. I was wondering if there was a way to somehow limit the amount of space in which the drop shadow of the buttons comes down, and also limit the width of the buttons? I tried a few different things such as ui.fixed and things of that nature, but the buttons keep on taking up the entire width.

It can be seen here. https://i.imgur.com/4iIKmPB.gifv

I would like to keep the content window and the border frame larger width, but limit the width of the actual buttons, and also not have them take up so much room height wise because of the drop shadow. Perhaps even removing it completely might be an option depending on how it looked.

Also, if working in Horizontal, is there a way to cause an element to drop to the next line, similar to adding in a linebreak for elements without having to try and put it into it's own new frame? Similar question for when working with Vertical, a way to keep two elements on the same line and not automatically drop it to the next line? Or so I have have to take the multiple elements that I want to either be veritical / horizontal, put them in a frame and set the position explicitly and then just create another frame for the next set of elements?

if there was a way to somehow limit the amount of space in which the drop shadow of the buttons comes down

Drop shadow is only 1 character height and width. So, the only way to limit its size is to 1) turn shadow off 2) use for shadow different set of characters, e.g half-height ones. None of ways is available in the library at this moment

limit the width of the buttons

At this moment the size of all buttons in a group is the size of the biggest button. And a button cannot be smaller than its text+2 spaces around it. So, the only way to make buttons smaller is to set shorter title for the longest one - it is Discord Settings * at this moment

No worries, I got it all figured out how I liked it for the most part. : D

I created a fork and changed a up a few things,

Some areas I liked buttons with no shadow and some with, so I created a new buttons type and a few other things.

I am quite pleased with how it's turning out!

Looks great!
Anyway, I think making shadows slimmer(at list bottom shadow that looks so big) is a good idea and I'll think of it

That would be great. I like the shadows, but as it is, it's just a bit too big. Slimmer would be perfect.

I made bottom shadow slimmer. I did not decrease the right-side shadow because I did not find a character that has filed only its top-left quarter. Anyway, even with slim bottom shadow buttons look nicer now. Three shadow types availabe: Full, Half, and None. Please see, demos\buttons for different type of shadows. Default type is a fat current one.

Great news. I will check it out first thing in the morning. Much appreciated. ๐Ÿ‘

This is looking much better, thanks for that. I did notice this one thing though, it seems like somewhere in the range of a 1px gap somehow in the right/vertical part of the shadow. It is honestly not a huge deal to me, I am not even sure if something could be done about it? It is a bit strange though so I wanted to share it with you.

It looks like the ability to pass the adjustment is missing from the selection dialog boxes. I tried to see if I could set it for CreateSelectDialog, but the field is missing for the buttons inside of the dialog boxes.


With regard to accuracy, it also looks like in the right side of the shadow, it might need the addition of one more 1/2 sized character at the top, as the distance between the button and the shadow at the bottom is 1/2 but the distance from the right side shadow to the top of the button is 1 full character.

What is the possibility of having a 1/2 sized character, not only vertically, but also horizontally so that the shadow is not only shorter like it is now (which is great, looks awesome now) but also shorter on the right hand side?

I just used an image editor to make a representation of what I think looks perfect.

I made the right side 1/2 width horizontally, made the right side 1/2 character taller, and then added one more section to the far left of the bottom of the shadow.

Perhaps something like this? bottomCh, rightCh, cornerCh = 'โ–€', 'โ–Œ', 'โ–˜'

I suppose I am just being picky at this point, lol.

Let me know your thoughts!

Thanks,
-MH