Commit Graph

12 Commits

Author SHA1 Message Date
Behdad Esfahbod 85c7fb67ce [fcformat] Refactor code to avoid malloc 2009-02-15 13:40:30 -08:00
Behdad Esfahbod d4f7a4c6af [fcformat] Start adding builtins 2009-02-15 13:40:29 -08:00
Behdad Esfahbod c8f5933d13 [fcformat] Implement 'delete', 'escape', and 'translate' filter functions
The format '%{family|delete( )}' expands to family values with space removed.
The format '%{family|translate( ,-)}' expands to family values with space
replaced by dash.  Multiple chars are supported, like tr(1).
The format '%{family|escape(\\ )}' expands to family values with space
escaped using backslash.
2009-02-15 13:40:29 -08:00
Behdad Esfahbod b6a23028be [fcformat] Add value-count syntax
The format '%{#family}' expands to the number of values for the element
'family', or '0' if no such element exists in the pattern.
2009-02-15 13:40:29 -08:00
Behdad Esfahbod ced38254b4 [fcformat] Implement 'cescape', 'shescape', and 'xmlescape' converters 2009-02-15 13:40:28 -08:00
Behdad Esfahbod 2017a5eb79 [fcformat] Add simple converters
The format '%{family|downcase}' for example prints the lowercase of
the family element.  Three converters are defined right now:
'downcase', 'basename', and 'dirname'.
2009-02-15 13:40:27 -08:00
Behdad Esfahbod 7717b25ffd [fcformat] Add conditionals
The conditional '%{?elt1,elt2,!elt3{expr1}{expr2}}' will evaluate
expr1 if elt1 and elt2 exist in pattern and elt3 doesn't exist, and
expr2 otherwise.  The '{expr2}' part is optional.
2009-02-15 13:40:27 -08:00
Behdad Esfahbod 8c31a2434d [fcformat] Add element filtering and deletion
The filtering, '%{+elt1,elt2,elt3{subexpr}}' will evaluate subexpr
with a pattern only having the listed elements from the surrounding
pattern.

The deletion, '%{-elt1,elt2,elt3{subexpr}}' will evaluate subexpr
with a the surrounding pattern sans the listed elements.
2009-02-15 13:40:26 -08:00
Behdad Esfahbod d6506ff6ee [fcformat] Add support for subexpressions
The syntax is '{{expr}}'.  Can be used for aligning/justifying an entire
subexpr for example.
2009-02-15 13:40:26 -08:00
Behdad Esfahbod 27b3e2dddf [fcformat] Refactor and restructure code for upcoming changes
Also makes it thread-safe.
2009-02-15 13:40:26 -08:00
Behdad Esfahbod c493c3b770 [fcformat] Add support for width modifiers
One can do '%30{family}' for example.  Or '%-30{family}' for the
left-aligned version.
2009-02-15 13:40:25 -08:00
Behdad Esfahbod 0c93b91db0 Implement FcPatternFormat and use it in cmdline tools (bug #17107)
Still need to add more features, but the API is there, and used
by cmdline tools with -f or --format.
2009-02-13 16:54:04 -08:00