object Document_View { /* document view of text area */
privateval key = newObject
def get(text_area: TextArea): Option[Document_View] = {
GUI_Thread.require {}
text_area.getClientProperty(key) match { case doc_view: Document_View => Some(doc_view) case _ => None
}
}
def exit(text_area: JEditTextArea): Unit = {
GUI_Thread.require {}
get(text_area) match { case None => case Some(doc_view) =>
doc_view.deactivate()
text_area.putClientProperty(key, null)
}
}
def init(model: Buffer_Model, text_area: JEditTextArea): Document_View = {
exit(text_area) val doc_view = new Document_View(model, text_area)
text_area.putClientProperty(key, doc_view)
doc_view.activate()
doc_view
}
def rendering(doc_view: Document_View): JEdit_Rendering = { val model = doc_view.model val snapshot = Document_Model.snapshot(model) val options = PIDE.options.value new JEdit_Rendering(snapshot, model, options)
}
val buffer = model.buffer
JEdit_Lib.buffer_lock(buffer) { val rendering = Document_View.rendering(doc_view)
for (i <- physical_lines.indices) { if (physical_lines(i) != -1) { val line_range = Text.Range(start(i), end(i))
rendering.gutter_content(line_range) match { case Some((icon, color)) =>
// icons within selection area if (gutter_icons && icon.getIconWidth > 0 && icon.getIconHeight > 0) { val w0 = icon.getIconWidth val h0 = icon.getIconHeight val s = Math.min(scale(icon_width, w0), scale(icon_height, h0))
val w = (s * w0).ceil val h = (s * h0).ceil val x0 = skip_left + (((icon_width - w) / 2) max 0) val y0 = y + i * line_height + (((icon_height - h) / 2) max 0)
val tr0 = gfx.getTransform val tr = new AffineTransform(tr0); tr.translate(x0, y0); tr.scale(s, s)
gfx.setTransform(tr)
icon.paintIcon(gutter, gfx, 0, 0)
gfx.setTransform(tr0)
}
// background only else { val y0 = y + i * line_height
gfx.setColor(color)
gfx.fillRect(0, y0, gutter_width, line_height)
} case None =>
}
}
}
}
}
}
}