Shizcow / dmenu-rs

A pixel perfect port of dmenu, rewritten in Rust with extensive plugin support
GNU General Public License v3.0
197 stars 9 forks source link

Reduce lineheight #60

Open jbirnick opened 7 months ago

jbirnick commented 7 months ago

I use minimal height 0, but still the menu draws has a pretty big padding to the top and bottom (from the text of each line). How can I remove that padding/margin?

It's enough if you point me to the relevant line in the source code, I can patch it myself.

Thank you very much!

Shizcow commented 7 months ago

The minimal height option is used to increase the height above the default rendering. It's not used to decrease the height from the default rendering (I guess this would be a maximum height option).

To further reduce the height, I think these lines are a good place to start looking. This sets the menu height to {the height of the font, AKA the height of the character which extends the highest above the baseline (tallest character) overlapped with the character that extends the lowest below the baseline (for example, 'g' extends below the baseline)} + 4 pixels for padding. IIRC this line make sure that the text is centered relative to that padding (ty is the y coordinate of the baseline). You could remove those 4 pixels of padding, but any more than that and you'd risk drawing text outside of the menu box.

Hopefully this points you in the right direction. If you're able to get a result you're happy with (maybe even adding a new flag to control this) please submit a PR for review -- I'm sure you're not the only one who wants this functionality. Let me know if you need any more info on how to achieve the desired result or how to make your chosen solution integrate cleanly with the existing program infrastructure.

Good luck!

jbirnick commented 7 months ago

Thanks! This looks more low-level (or rather C-style) than I thought... I guess I have to postpone the analysis till when I have more free time.