Comments (8)
I think something like this is a good idea. I think I would prefer to incorporate it into the format string directly though, but I will see what I can do. Thanks for the suggestions!
from vimpc.
This could be solved similar to how multi-line equations can be aligned in LaTeX, where one may insert a &
to mark a place that should be aligned with the corresponding ampersand on the other lines.
from vimpc.
To elaborate a bit, I think specifying an alignment string is a) limiting the possibilities for layout (imagine just aligning things with just a space in between) and b) prone to errors (" - " seems like it could be a common divider, but also occurs in song titles).
from vimpc.
Wheee, I was just searching for some functionality like this.
I really like the approach of having some sort of explicit marker in the songformat string, that says what should be aligned.
But I would also suggest a slightly different approach: Have a marker that says: Up to here should fill up of the line width.
Why?
Two reasons:
-
It looks better. Consider the case where there are only songs with short artist names in the list. Now I insert one song with a long artist name. To keep alignment, the tab stop where all lines are aligned would need to move to accomodate the long artist name. So the screen has to be redrawn and the song titles move to the right. Now, I add the next song...
-
Difficulty of implementation.
1.) Possibility: Alignment is kept only for the songs currently visible on screen. When scrolling, we would need to re-check, if the tab stop till provides enough space for all artist names. So we would need to re-iterate the visible lines looing for the longes tab stop for each line that the user scrolles. Inefficient and it would lead to the same ugly moving effect described before.
2.) Alignment could be done globally, fitting all items in the list. It looks good, at least when scrolling, and does not complicate scrolling very much. However, obtaining the longes tab stop is a problem. Or, to be more exact, keeping it. Assume the user adds songs to the list. We can simply compare that songs tab stop requirement (artist name length) and if it is bigger than the current tab stop, update it. But when the user deletes songs, there will be the moment, when the song with the longes tab stop is removed. We would now need to re-scan all remaining songs in the list to find the new longes tab stop. This would turn list removal from O(1) to O(n) complexity. Probably no good idea.
Instead we could add two new tokens to the format string:
- $A<absolute number> : When printing, the output is padded with ' ' up to the column specified in , then the rest is added. If the window is too small, the text would be cut off where the right-aligned part begins.
- $P<percentage> : When printing, the output is padded with ' ' until of the window width is filled, then the rest is added. This way, if there are multiple tab stops, each field would receive some clipping if the window is too small.
$P and $A might not be the best names, it might also be feasible to omit the absolute padding, instead having the P in $P stand for padding or chose a completely different name altogether.
Pros:
- Minimaly intrusive: Only recognition for the new token in the format string and the padding logic is needed. No additional storage is needed per line or window and runtime complexity class does not change.
- Nice looking.
- I might give at least the percentage padding a shot.
Btw: I like the coding style. Not many comments, but well readable :)
from vimpc.
Update: That means, only the parsing function void ScrollWindow::Print(uint32_t line) const
needs an update.
from vimpc.
Side note: I noticed, that using the $A to mean align really was the most intuitive "name" and since I don't really see why one would need absolute alignment, I used that name. However, really any letter can be chosen by changing 'A' to another letter in two places.
from vimpc.
@mox-mox Thanks! On initial testing this appears to work as stated. It fails hard when the specified percentage is <= 9 as stated in the code. Also, when the playlist only contains a few songs with short titles this approach spaces them out quite a bit, but it's definitely a useful contribution.
from vimpc.
-
About the numbers:
Numbers smaller than 10 work fine for me, if stated as e.g. $A05.
I wrote a check to allow a variable number of digits from 0 to 3 but I think this is not really sensible. It adds quite a bit of conditional code at runtime while providing relatively little improvement. Aligning to 100% is not sensible as there would be no space left to put the aligned text and for all other percentages, the two-digit style of writing the numbers is sufficient. -
About the spacing:
The spacing is admittedly not so nice and makes it a tad hard to find the remaining part of the line.
For testing, I used an underscore as fill character which made it easier to follow the line. Maybe having the fill character as a setting would help here?
Edit: I tested that, and I find it help full :)
See the updated pull request.
from vimpc.
Related Issues (20)
- password support in $MPD_HOST
- Incorrect version packaged as a Release; "v0.09.2" is actually v0.09.1 HOT 1
- Lyrics fetching doesn't work HOT 4
- Tag for version 0.90.1 HOT 4
- Feature Request/Idea
- error adding symbols: DSO missing from command line HOT 1
- [Feature Request] Library listing
- On systems with libtinfo separate from libncurses: src/vimpc-screen.o: undefined reference to symbol 'keypad'
- New release HOT 3
- Jump to current song in playlist? HOT 1
- Please add Meta- mappings
- Compilation error with --enable-boost: src/clientstate.hpp:125:12: error: โthreadโ in namespace โstdโ does not name a type HOT 2
- terminate called after throwing instance of 'std::out_of_range' HOT 1
- Case sensitive search disabled by default.
- Play Next HOT 1
- Library incomplete or not showing up at all HOT 2
- Segmentation Fault in directory HOT 1
- .vimpcrc settings have no effect (not read?) HOT 2
- Ncurses glitch on startup HOT 4
- Segfault when going up directory HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vimpc.