proper metric for blanks -- NB: 70f7483df9cb discontinues coincidence of char_width with space width;
--- a/src/Pure/General/pretty.scala Thu Mar 21 16:35:53 2013 +0100
+++ b/src/Pure/General/pretty.scala Thu Mar 21 16:58:14 2013 +0100
@@ -72,14 +72,6 @@
case XML.Text(text) => Library.separate(FBreak, split_lines(text).map(XML.Text))
}
- private sealed case class Text(tx: XML.Body = Nil, val pos: Double = 0.0, val nl: Int = 0)
- {
- def newline: Text = copy(tx = FBreak :: tx, pos = 0.0, nl = nl + 1)
- def string(s: String, len: Double): Text = copy(tx = XML.Text(s) :: tx, pos = pos + len)
- def blanks(wd: Int): Text = string(spaces(wd), wd.toDouble)
- def content: XML.Body = tx.reverse
- }
-
private val margin_default = 76
private def metric_default(s: String) = s.length.toDouble
@@ -95,6 +87,18 @@
def formatted(input: XML.Body, margin: Int = margin_default,
metric: String => Double = metric_default): XML.Body =
{
+ sealed case class Text(tx: XML.Body = Nil, val pos: Double = 0.0, val nl: Int = 0)
+ {
+ def newline: Text = copy(tx = FBreak :: tx, pos = 0.0, nl = nl + 1)
+ def string(s: String, len: Double): Text = copy(tx = XML.Text(s) :: tx, pos = pos + len)
+ def blanks(wd: Int): Text =
+ {
+ val s = spaces(wd)
+ string(s, metric(s))
+ }
+ def content: XML.Body = tx.reverse
+ }
+
val breakgain = margin / 20
val emergencypos = margin / 2