-
-
Notifications
You must be signed in to change notification settings - Fork 639
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
Added support for 'length' attribute for plugins. #131
Conversation
Why not just truncate in your shell script?
|
That's nice ! Should we provide a way to see the full text though ? Maybe by hovering over the menu item ? |
NSString * title = [params objectForKey:@"title"]; | ||
NSString * fullTitle = params[@"title"]; | ||
|
||
CGFloat lineLength = params[@"length"] ? [params[@"length"] floatValue] : 20; |
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.
you could define these values somewhere, so they are not hardcoded
@jcaille I figure some people may have a need for a zero-length string, so making We definitely need a way to view the full length though. I think that hovering is our safest bet. Scrolling would be tough because our script should ideally be stateless, @0wnrepo You're probably right. Especially if BitBar ever gets a config file, and this ends up as one of the config variables. |
@jcaille So having a tooltip provide the full string doesn't look terrible. I was also thinking that we could do what most native menu's do, and provide more detail (i.e. the full string) when you press and hold the This is a 100 character tooltip truncated to the default 20 characters: This is a 300 character tooltip truncated to the default 20 characters: |
When it's truncated, we should add |
Heh, probably. Otherwise people may not realize why their output is missing. |
So the option key modifier works well, as long as your string isn't ridiculously long...It seems like anything over ~200 characters gets automatically truncated. So we may be better off with the tooltip, obviously it's up to the community to decide. (Also, I implemented the ellipsis per request.) |
I think the tooltip is a good idea - maybe we can push the default limit up a bit? We should keep the Like:
|
I agree. I've found, even with some simple scripts, that 20 characters is a bit too small. Are you referring to passing an |
(see my edit) |
Yes. But that interface might not work - because it's essentially a different option completely. Needs some thought. |
I think the
Just keeping the |
@jcaille makes some good points. |
Fair enough. I didn't consider the issue with errors. But being considered a bug by anyone is definitely not ideal. That's good enough of an argument for me. I'll kill the default, and implement the tooltips. |
…trings. Added tooltips to strings that are truncated.
I pushed a new commit. It includes the following:
I tested this param with multiple different cases:
All mentioned tests worked flawlessly. |
Excellent - I wonder if you could update the README too? Here: https://github.com/matryer/bitbar#plugin-api Something like:
|
Absolutely. I didn't realize that the API section was moved here. |
Nice work :) |
... while you're in there, could you stick this link on the shebang word? https://en.wikipedia.org/wiki/Shebang_(Unix) |
Haha certainly |
Alright, README has been updated with the shebang link and the necessary |
Added support for 'length' attribute for plugins.
Excellent. Nice work. Thanks to everyone for their input. |
Is there a way to pad a string using the length parameter? The output from the ping plugin has different widths, depending on the ping time - I would love to have a fixed width - say 10 characters so that the output doesn't "jump" when it's getting longer/shorter. Or is there a way to do it with bash? I tried using printf (printf "%10s" "$MSG") but this didn't work. It works in the terminal but somehow the leading spaces are removed. |
Hi. Not sure if this is the appropriate place to ask this, but since I know this is part of the feature above, is there any way to add tooltips manually to each line of script output for a plug-in? For example, if my lines are not long enough to end up being truncated, can I add a manual tooltip with custom text to the line? Something that when hovered over will pop up explaining what the line is referencing? I could definitely make use of such a feature, and I think it might be useful since it would prevent the need to include a verbose string on a menu line, i.e., the less relevant info can go under a tooltip to make the menu appear tidier. |
@mm2270 Please open a new issue. |
Will do. Thanks. |
This feature allows one to truncate the line length of any line (title or menu bar item) to a specified length, per line.
I have also implemented a default line length of 20 characters, to prevent scripts from outputting an unnecessarily long title, or menu bar item, such as in #124.
One may override the default line length by using the
length
attribute.Example:
I will also have to submit a PR for the plugins repo to list this attribute.