comparison src/name/blackcap/clipman/PasteboardQueue.kt @ 40:c803a2c89ea0

Make the JScrollPane scroll properly to highlighted text.
author David Barts <n5jrn@me.com>
date Wed, 05 Feb 2020 16:47:25 -0800
parents 0c6c18a733b7
children 33fbe3a78d84
comparison
equal deleted inserted replaced
39:2a5808156f99 40:c803a2c89ea0
108 val text = doc.getText(0, doc.length) 108 val text = doc.getText(0, doc.length)
109 pos = if (norigin.inItem >= 0) norigin.inItem else text.length - 1 109 pos = if (norigin.inItem >= 0) norigin.inItem else text.length - 1
110 pos = search(needle, text, pos) 110 pos = search(needle, text, pos)
111 if (pos >= 0) { 111 if (pos >= 0) {
112 si.highlighter.addHighlight(pos, pos+needle.length, painter) 112 si.highlighter.addHighlight(pos, pos+needle.length, painter)
113 si.scrollRectToVisible(si.getBounds(null)) 113 val r = si.modelToView(pos).apply {
114 add(si.modelToView(pos + needle.length - 1))
115 }
116 si.scrollRectToVisible(r)
114 break 117 break
115 } 118 }
116 norigin = Offset(norigin.inQueue + incr, start) 119 norigin = Offset(norigin.inQueue + incr, start)
117 } 120 }
118 return if (pos >= 0) Offset(norigin.inQueue, pos) else null 121 return if (pos >= 0) Offset(norigin.inQueue, pos) else null