VladimirMarkelov / clui

Command Line User Interface (Console UI inspired by TurboVision)
MIT License
670 stars 50 forks source link

horizontal scrollbar #147

Open myg3nx opened 3 years ago

myg3nx commented 3 years ago

hi, thanks for your project, i realy like it so much... i have one question that how to enable horizontal scrolbar for long text item in listbox? if you dont mind, please add this fiture. thx (i had take a look your code at "textview.go", it has scrolbar, but i dont know how to implement this to listbox)

VladimirMarkelov commented 3 years ago

Thank you! I am glad you like it.

Listbox was created as simple as possible. As horizontal scroll is considered inconvenient even in GUI, I did not implement it in TUI. As of TextView, it has a feature that simplifies the code a lot: both scrollbars are always visible. I do not think it works good for Listbox. Ideally, Listbox horizontal scroll should be automatically hidden if its width is sufficient, or a horizontal scroll should be enabled manually. Though, it makes drawing function more complex.

To add horizontal scrollbar to a Listbox here is the list of tasks:

Another and easier way (if you do not care much about mouse support): do not draw horizontal scrollbar at all. Just add two hotkeys to shift the content left/right. And fix DrawItems so it displayed a special mark in the beginning of every item marking that the items is displayed not from the first character. E.g, a file manager FAR uses this way - it displays '{' on a file listbox border instead of '|' to indicate that the file name in this line is not displayed from its first character.

myg3nx commented 3 years ago

hi, thanks for answer my question... the explanation is clear for me. i will try it to get this work.. :)

VladimirMarkelov commented 3 years ago

You are welcome!

At this moment I do not have go compiler on my home machine(as I removed old version due to incompatibilities with another software), so I cannot debug improve the library. But feel free to open PR :)