On Monday, 19 March 2012 02:45:45 UTC-7, JohnW wrote:
>
> For all you format string writers out there: oh, I mean, yeah -- you.
>
> A value expression within a format string now has access to a new function,
> curr_offset.  The value is always an integer giving the column where the
> string will be interpolated.  Example:
>
>    "12345%(curr_offset)" => "123456"
>
> This makes writing complex reports which use the justify() function much
> simpler.  Here is what the built-in --register-format looks like now:
>
>     %(ansify_if(
>       ansify_if(justify(format_date(date), int(date_width)),
>                 green if color and date > today),
>                 bold if should_bold))
>      %(ansify_if(
>        ansify_if(justify(truncated(payee, int(payee_width)),
>                          int(payee_width)), 
>                  bold if color and !cleared and actual),
>                  bold if should_bold))
>      %(ansify_if(
>        ansify_if(justify(truncated(display_account, int(account_width), 
>                                    int(abbrev_len)), int(account_width)),
>                  blue if color),
>                  bold if should_bold))
>      %(ansify_if(justify(scrub(display_amount), int(amount_width), 
>                          curr_offset + int(meta_width) + 
> int(prepend_width),
>                          true, color),
>                  bold if should_bold))
>      %(ansify_if(justify(scrub(display_total), int(total_width), 
>                          curr_offset + int(meta_width) + 
> int(prepend_width),
>                          true, color),
>                  bold if should_bold))\n%/
>     %(justify(" ", int(date_width)))
>      %(ansify_if(justify(truncated(has_tag("Payee") ? payee : " ", 
>                          int(payee_width)), int(payee_width)),
>                  bold if should_bold))
>      %$3 %$4 %$5\n
>
> Um, yeah.  It doth scintillate with clarity, don't it?  So, back to what 
> you
> were doing. :)
>
> John
>
>

Reply via email to