-
Notifications
You must be signed in to change notification settings - Fork 475
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
Change default formatting? #1304
Comments
Option 4 i see and my favorite solution would be to do what's asked in (the second part of) #1272 and allow a number format as discussed in #240 and implemented in #704 that can have a fixed width and still not show any gaps, even if it's sometimes a bit suboptimal in the number of significant digits shown. That might be difficult to enable with the current placeholder syntax, but is probably possible. Alternatively we could also just change the default. I'll propose something when i have time |
Not sure if this entirely relevant, however, blocks like the brightness block don't have a format key, which makes sense, but that means it can't make use of the formatting available in other blocks. Not sure if it worth adding the format key just so I can change the min_width of the brightness block to 3 though. |
I think it does. |
Yeah now that we have the universal logic that's not an issue. Plus it will provide additional options like showing the brightness as a bar. But i wouldn't consider that relevant to this issue, feel free to open another one :) |
I thought about this a bit again and realized it's only possible for value placeholders with a Starting at 4 characters we can easily do something like what was discussed in the other issue:
Now i'm not sure if it's worth the effort/complexity just for avoiding some ugly padding, but we probably could add this as a special case for What do you think @MaxVerevkin? |
I still don't like when
No, I think setting And actually, |
Okay, perhaps it's time to reconsider the formatting "subsystem". When choosing between verbosity and shortness we've chosen shortness. Was this a good choice? Formatting configuration is already sort of messy, but it will be even worse it we'll add more options (like how to choose between "always N digits" and engineering notation, no one have proposed anything yet). Looking back at the work done by @remi-dupre, #750 (comment) looks quite interesting. I can imagine doing something like this:
Yes, those are breaking changes, and most likely it will not be a solution in the near future, but still. @ammgws @GladOSkar @remi-dupre your thoughts? |
Yeah i had originally vouched for shortness as well and still prefer it. And although i kinda like your suggestion, I'd prefer not to break configs again. I wonder if there's a way to do this within the confines of currently valid syntax? Something like another "modifier" character to specify the formatter?:
With the default being either Granted, we'd be keeping a lot of dead syntax around, but maybe it's not that bad? Unsure about this, you probably know better given you wrote the formatter |
In addition, I would also like to bring up two more issues:
Lets imagine that current formatting system is not yet implemented. Now, I would propose something like this: Format
Format
While it's more verbose, It's way more flexible. This can be partially (without the typing part) implemented without breaking compatibility (well, it will break stuff if |
I like it. You've convinced me. Seems pretty well thought through. One detail question: Do you intend to delimit the variable name? Or is it distinguished from the literal text in another way? In other words, would you literally write I prefer delimiting either the variable or the literal text over using the dot |
I don't have a strong opinion on this one, but using I was also thinking about using single quotes (the parsing is still simple) for literal text but it seems to be messy. |
Also two more details: How exactly should arguments be represented? For example, in
The second option is to use something similar to what we have now (note:
Again, tradeoffs between shortness and verbosity must be taken. But the first one is much more readable, isn't it? Should integers and floats be distinguished? Currently they are, sort of. |
How about just positional arguments? Like:
that way we loose the ability to eg. set the prefix without setting the unit, but if the order is thought through enough and the defaults are documented, i think it'd be fine while not being overly verbose. Regarding floats vs. integers: currently, the differentiation is made to make sure units like bits never get the lower SI prefixes (a microbit probably only makes sense probabilistically). But if the formatting syntax is well designed i don't think the differentiation is necessary. Unless you see something else. |
That might be a good idea. Looks clean and simple to parse.
Not quite - integers are not formatted at all (they're only padded), and currently, bytes are passed as floats. So, the issue with micropercents / microbytes and so on is fixed by just checking the unit. |
Ah okay - In that case i don't see a reason to keep the differentiation |
Now I think it might make sence to avoid |
Also true. How about a bash/php style |
And about the positional arguments, if, for example, string formatter's arguments were |
But we should really try to order the arguments in such a way that it reduces the number of occasions where one has to consider something like this. |
Actually,
Yeah, but... I don't know, in str's case |
I guess you're right. It could also be |
Given that most of the placeholders are guaranteed to be presented, perhaps Also, maybe multiple placeholders can be combined together? Like And to take this even further perhaps [[block]]
block = "net"
format = "{$signal.eng(2) $ssid.str() $frequency.eng()|Wired connection} via $device.str()|N/A" It tries to print signal, ssid and frequency and if any of those fails "Wired connection" is printed. This is followed by the device name. If device name is missing, then just "N/A" is printed. So... I've implemented it in https://github.com/MaxVerevkin/swaystatus/tree/new-formatting, mostly because I wanted to write a recursive descent parser (I don't think more than two levels of |
Yeah i like it. The At this point the new format strings are so different we could probably determine whether a format specifier is old or new at parse time and use the old formatter for old configs while spewing out a deprecation warning. WDYT? |
Yeah, I suppose a simple criteria to determine old formatting is However I'm not sure if it even makes sense since the whole point of the new formatting system it to allow missing placeholders. |
So, And by the way, if width is greater of equal to 5 then
|
And at this point I don't understand what |
Well, It was always supposed to be fixed # of characters, since that's what's supposed to stay constant without using any padding for a visually pleasing, but non-shifting bar. But you're right, that might only make sense for width<=4, but i think width=4 is a very commonly used amount of digits (3). That's why i was in favor of just special-casing it at first. |
If we were to allow a trailing dot (with something like
Still, displaying (width=5) By the way, anyone wants to implement |
Yeah it is. But i don't see another option for some of the cases in the
Want, yeah, have the time? No. The version i wrote that was used in #704 isn't very nice though, but can probably be adapted though. I'll have a look if/when i have time |
So I've got a working prototype 🎉 : rec.mp4[[block]]
block = "sway_kbd"
format = "Layout \"$layout.rot-str(10,0.5)\"" |
So, are three any comments on the proposed syntax? |
I like it, but i'm still not sure if it's worth breaking configs again. If we manage a graceful transition this time i'm in favor. |
Even with a graceful transition you'd still end up having to change your config in the future, right? We can mention the future changes in the release notes for the next bug fix release, but apart from that there's not much we can do... |
Yeah absolutely. I suppose if we're gonna break it again it might as well be as close to the last breakage as possible |
@MaxVerevkin Are there any breaking changes necessary for merging swaystatus' async here? If so then it could be done at the same timing. |
@ammgws I'm not sure what exactly do you mean, but I expect this formatting to be merged (if even merged) with swaystatus, so not so soon. |
Like, maybe we should provide default formatters? ( |
Not sure if graceful transition is even possible:
|
Oh yeah i had assumed there was a default. If a user doesn't care about formatting, they shouldn't have to specify it. |
So... |
|
I just realized that the new formatting system can make use of something similar to if statements! This can be used in pacman/dnf/apt block:
where It is even possible to create
|
Oh no. If you manage to get some sort of loop in there we're probably Turing complete -.- :D |
I've tried to formalize what is available so far in https://maxverevkin.github.io/swaystatus/swaystatus/formatting/index.html |
So... Any comments on this topic? I've been using my proposed formatting all this time and it seems fine to me. |
Closing as this is now the default on master. |
Originally posted by @GladOSkar in #1303 (comment)
_Originally posted by @MaxVerevkin in #1303
The text was updated successfully, but these errors were encountered: