Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

horizontal scrollbar #147

Open
myg3nx opened this issue Jul 11, 2021 · 3 comments
Open

horizontal scrollbar #147

myg3nx opened this issue Jul 11, 2021 · 3 comments

Comments

@myg3nx
Copy link

myg3nx commented Jul 11, 2021

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
Copy link
Owner

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:

  • add a property leftShift to support horizontal scrolling
  • update processMouseClick to catch scrollbar clicks. Do not forget about: 1) vertical scrollbar is shorter when horizontal one is disaplyed 2) it makes right-bottom corner do nothing on click
  • fix Draw and its children to support: 1) drawing correctly all items 2) draw horizontal scrollbar
  • maybe add new hotkeys to scroll left/right?

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
Copy link
Author

myg3nx commented Jul 14, 2021

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

@VladimirMarkelov
Copy link
Owner

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants