src/Pure/PIDE/line.scala
changeset 64822 c8bac4b0ef07
parent 64821 37bf7acf6a4b
child 64830 9bc44bef99e6
equal deleted inserted replaced
64821:37bf7acf6a4b 64822:c8bac4b0ef07
    93       Document(logical_lines(text).map(s => Line(Library.trim_substring(s))), text_length)
    93       Document(logical_lines(text).map(s => Line(Library.trim_substring(s))), text_length)
    94   }
    94   }
    95 
    95 
    96   sealed case class Document(lines: List[Line], text_length: Text.Length)
    96   sealed case class Document(lines: List[Line], text_length: Text.Length)
    97   {
    97   {
       
    98     lazy val text_range: Text.Range =
       
    99     {
       
   100       val length =
       
   101         if (lines.isEmpty) 0
       
   102         else ((0 /: lines) { case (n, line) => n + line.text.length + 1 }) - 1
       
   103       Text.Range(0, length)
       
   104     }
    98     lazy val text: String = lines.mkString("", "\n", "")
   105     lazy val text: String = lines.mkString("", "\n", "")
    99     lazy val bytes: Bytes = Bytes(text)
   106     lazy val bytes: Bytes = Bytes(text)
   100     lazy val chunk: Symbol.Text_Chunk = Symbol.Text_Chunk(text)
   107     lazy val chunk: Symbol.Text_Chunk = Symbol.Text_Chunk(text)
   101 
       
   102     lazy val length: Int =
       
   103       if (lines.isEmpty) 0
       
   104       else ((0 /: lines) { case (n, line) => n + line.text.length + 1 }) - 1
       
   105 
       
   106     def text_range: Text.Range = Text.Range(0, length)
       
   107 
   108 
   108     override def toString: String = text
   109     override def toString: String = text
   109 
   110 
   110     override def equals(that: Any): Boolean =
   111     override def equals(that: Any): Boolean =
   111       that match {
   112       that match {