Category talk:Wren-fmt: Difference between revisions

→‎Source code: Added a verb to enable a string to be commatized directly.
(→‎Source code: Bug fix.)
(→‎Source code: Added a verb to enable a string to be commatized directly.)
Line 263:
// Negative 'w' left justifies, non-negative 'w' right justifies.
static s(w, v) { (w >= 0) ? rjust(w, v) : ljust(-w, v) }
 
// Formats a string or value 'v' in commatized form, space padded, using ',' as the separator.
static sc(w, v) {
if (!(v is String)) v = "%(v)"
return (w >= 0) ? rjust(w, commatize(v)): ljust(-w, commatize(v))
}
 
// Middles a string or value 'v' within a field of minimum width 'w'. Pads with spaces.
Line 394 ⟶ 400:
(fn == "dm") ? dm(w, e) :
(fn == "dc") ? dc(w, e) :
(fn == "sc") ? sc(w, e) :
(fn == "fc") ? fc(w, e, p) :
(fn == "gc") ? gc(w, e, p) : Fiber.abort("Method not recognized.")
Line 538 ⟶ 545:
fn = "dc"
}
} else if ((fn == "s" || fn == "f" || fn == "g") && comma) {
fn = fn + "c"
}
9,479

edits