-
Notifications
You must be signed in to change notification settings - Fork 65
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
Adding descriptions for each option #114
Conversation
Added the option to show description messages for each option by moving the cursor on to them.
Fixed some screen size math
I feel like it would be better to have descriptions and options stored as a dictionary rather than two lists. |
That's a nice idea. I'll try it. |
…scriptions. 2) changed the example to work with the new way of using the code. 3) wrote a new test for descriptions
So I just added a new commit which incorporates @SnowzNZ's idea with minimal changes to the way the code is written to still be backwards compatible (Although the descriptions will only work properly with python3.7+ because the dictionaries weren't ordered before that). please read the commit notes too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove .idea
folder
In case you don't know, the item passed to https://github.com/wong2/pick/blob/master/src/pick/__init__.py#L22 |
Hi @iamalisalehi, if you want to continue the work, please merge the latest code from the master branch, which has fixed the CI, and we should ensure that it passes before merging. |
Hi @wong2 , thanks for the review.
P.S. I didn't change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some comments for the PR, and the CI should be passed, I see it failed mainly because the type checker, you can run mypy
on your local machine to check and then fix them.
hi @aisk , so I'm seeing that type checks failed for python<3.10. The thing is that I used mypy cheatsheet to rewrite the type hints for python>=3.10: For example: |
Yes, since we support old version of Python, we have to use some old grammars for type hints. |
This comment was marked as off-topic.
This comment was marked as off-topic.
When picking a dict, the pick result is an So I think the pick result of a |
Hi @aisk , I fixed the issues you raised, and checked the example again. It worked well on my computer (I am running python3.11.8). Can you please check it again? |
Hmm, I thought about this but I am not so sure that it would be the best way to do it. As I understood from the code before I worked on it, there is a simple way and a more complex way to use it. In the first versions that I wrote, adding descriptions was considered a part of the simple way of doing things but then at the suggestion of @wong2 , I changed it to be a part of the complex way of doing it (this also makes more sense to me). |
It's the same result, but I'm using Linux with Tilix as terminal emulator. Maybe this is OS dependent issue, I'll check the result in other OS tomorrow. Update: Kitty on Linux have no issue: |
Does the P.S. I tested them on Konsole, Terminator and Pycharm's terminal and they work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I resolved the problem; it's not caused by Tilix, but by a wider screen. With a wider screen, the last value passed to addstr
in draw
method will be larger than 256, which will draw the description text with the same color as the background, leading to invisibility.
Kitty works fine on my machine because the default font is larger than Tilix's, so the screen is not wide enoght to triger the bug.
I guess you want to use addnstr
instead of addstr
to specify the maximum line width, but you missed an n
, which caused the bug.
Co-authored-by: AN Long <aisk@users.noreply.github.com>
I have some slight concerns about the complexity too, so I think for now, maybe we should only support using In this way, we can ensure that the |
So I should get rid of the
Question: In the |
Yes, and thus we can revert specify the
You reminded me, I think it's not accepted, because I guess mypy or pyright will complain about this, I'm not using my development machine so I don't try it, but you can have a try. I think we should add a type checker to the examples on the GHA. |
I did that, and also updated the tests.
mypy did complain so I had to only feed it
I am a bit confused, is it something different than what mypy checks already do? |
Co-authored-by: AN Long <aisk@users.noreply.github.com>
LGTM. I'll wait a few days before merge to give @wong2 a chance to take a look if he has time. Thanks for your contribution! @iamalisalehi |
Thank you for the great reviews @aisk . I learned a lot from you ;-) |
Hi,
This patch provides a feature to show descriptions for each options. The description for each option shows on the right side of the screen as the cursor moves on to it.
A function was also added that divides long description into multiple lines based on the terminal size.
An example was also provided.
Hope it is useful.
P.S. I couldn't think of a way to write a test for it so I didn't.