sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

index.md (2043B)


      1 centertitle proportionally
      2 ==========================
      3 
      4 Description
      5 -----------
      6 Center the title with proportion to the area that the title has, unlike the
      7 other center title patches that center proportion to the screen size width
      8 (`m->ww`).
      9 
     10 
     11 ![center](center.png)
     12 
     13 
     14 
     15 
     16 If the title name is to long (if the title area it's too small for the title
     17 string) it will back up to the default behaviour, which is to truncate the title.
     18 
     19 
     20 ![trunc](trunc.png)
     21 
     22 
     23 Patchibility
     24 ------------
     25 _Compatibility with other patches_
     26 
     27 
     28 This is a simple enough patch and I'm leaving you with a logic text, I believe
     29 you can figure out how to make it work with "X" patch.
     30 
     31 
     32 In other notes I have [winicons](../winicons) compatible on my build.
     33 
     34 Logic
     35 -----
     36 Imagine you are on a word processor (word, writter..). To center the text is as
     37 easy as cliking a button. When I click it (there is no text) the input line
     38 (`|`) is exactly on the middle of the page, which means that the `x` axis (or
     39 the padding of the text, in this case the input line only) **is** the width of
     40 the page divided by two (w / 2).
     41 
     42 What if we add a character? The same logic can be applied. To make the text
     43 center we need to **mesure** 'a distance' between the text and the edge of the
     44 page. To do that we do the same thing above but now the `x` or padding isn't
     45 only the width of the page, since we added a character we have to sutract the
     46 width of that character on the width of the page. We want 2 result with the
     47 same value to give the ilusion of a 'centered text'.
     48 
     49 ```
     50 width of the page / 2 - width of the character / 2
     51 ```
     52 in short:
     53 ```
     54 w / 2 - TEXTW(title) / 2
     55 ```
     56 where _title_ is a string.
     57 
     58 ```
     59 ( w - TEXTW(title) ) / 2
     60 ```
     61 
     62 Okay, what if I have an icon?
     63 ```
     64 ( w - TEXTW(title) + iconwidth ) / 2
     65 ```
     66 
     67 
     68 Download
     69 --------
     70 * [dwm-centertitle-proporcionally.diff](dwm-centertitle-proporcionally-6.2.diff)
     71 * [github mirror](https://github.com/explosion-mental/Dwm/blob/main/Patches/dwm-centertitle-proporcionally-6.2.diff)
     72 
     73 Author
     74 ------
     75 * explosion-mental - <explosion0mental@gmail.com>