src/Tools/jEdit/src/jedit/document_view.scala
changeset 37188 b78ff6b4f4b3
parent 37187 dc1927a0f534
child 37201 8517a650cfdc
equal deleted inserted replaced
37187:dc1927a0f534 37188:b78ff6b4f4b3
   112       def to_current(pos: Int) = model.to_current(document, pos)
   112       def to_current(pos: Int) = model.to_current(document, pos)
   113       val metrics = text_area.getPainter.getFontMetrics
   113       val metrics = text_area.getPainter.getFontMetrics
   114       val saved_color = gfx.getColor
   114       val saved_color = gfx.getColor
   115       try {
   115       try {
   116         for ((command, command_start) <-
   116         for ((command, command_start) <-
   117           document.command_range(from_current(start), from_current(end)))
   117           document.command_range(from_current(start), from_current(end)) if !command.is_ignored)
   118         {
   118         {
   119           val begin = start max to_current(command_start)
   119           val begin = start max to_current(command_start)
   120           val finish = (end - 1) min to_current(command_start + command.length)
   120           val finish = (end - 1) min to_current(command_start + command.length)
   121           encolor(gfx, y, metrics.getHeight, begin, finish,
   121           encolor(gfx, y, metrics.getHeight, begin, finish,
   122             Document_View.choose_color(document, command), true)
   122             Document_View.choose_color(document, command), true)
   243     override def paintComponent(gfx: Graphics)
   243     override def paintComponent(gfx: Graphics)
   244     {
   244     {
   245       super.paintComponent(gfx)
   245       super.paintComponent(gfx)
   246       val buffer = model.buffer
   246       val buffer = model.buffer
   247       val document = model.recent_document()
   247       val document = model.recent_document()
   248 
   248       def to_current(pos: Int) = model.to_current(document, pos)
   249       for ((command, start) <- document.command_range(0)) {
   249       val saved_color = gfx.getColor
   250         val line1 = buffer.getLineOfOffset(model.to_current(document, start))
   250       try {
   251         val line2 = buffer.getLineOfOffset(model.to_current(document, start + command.length)) + 1
   251         for ((command, start) <- document.command_range(0) if !command.is_ignored) {
   252         val y = line_to_y(line1)
   252           val line1 = buffer.getLineOfOffset(to_current(start))
   253         val height = HEIGHT * (line2 - line1)
   253           val line2 = buffer.getLineOfOffset(to_current(start + command.length)) + 1
   254         gfx.setColor(Document_View.choose_color(document, command))
   254           val y = line_to_y(line1)
   255         gfx.fillRect(0, y, getWidth - 1, height)
   255           val height = HEIGHT * (line2 - line1)
   256       }
   256           gfx.setColor(Document_View.choose_color(document, command))
       
   257           gfx.fillRect(0, y, getWidth - 1, height)
       
   258         }
       
   259       }
       
   260       finally { gfx.setColor(saved_color) }
   257     }
   261     }
   258 
   262 
   259     private def line_to_y(line: Int): Int =
   263     private def line_to_y(line: Int): Int =
   260       (line * getHeight) / (text_area.getBuffer.getLineCount max text_area.getVisibleLines)
   264       (line * getHeight) / (text_area.getBuffer.getLineCount max text_area.getVisibleLines)
   261 
   265