# HG changeset patch # User David Barts # Date 1580337376 28800 # Node ID c4f53bc017324fcc0108f9a6899e4b324995654b # Parent f1fcc1281dade0eeae0e39d6e5d5924716110f65 Fix searching (and main display). diff -r f1fcc1281dad -r c4f53bc01732 src/name/blackcap/clipman/Main.kt --- a/src/name/blackcap/clipman/Main.kt Wed Jan 29 13:39:14 2020 -0800 +++ b/src/name/blackcap/clipman/Main.kt Wed Jan 29 14:36:16 2020 -0800 @@ -76,6 +76,7 @@ contentType = "text/plain" text = plain font = Font(Font.MONOSPACED, Font.PLAIN, MONO_SIZE) + resize() }) } else { val (dhtml, style) = preproc(html) @@ -86,6 +87,7 @@ PasteboardItemView("Styled text", ClipText().apply { editorKit = hek text = dhtml + resize() }) } piv.searchable.addMouseListener(this) diff -r f1fcc1281dad -r c4f53bc01732 src/name/blackcap/clipman/PasteboardQueue.kt --- a/src/name/blackcap/clipman/PasteboardQueue.kt Wed Jan 29 13:39:14 2020 -0800 +++ b/src/name/blackcap/clipman/PasteboardQueue.kt Wed Jan 29 14:36:16 2020 -0800 @@ -34,7 +34,7 @@ } } - data class Offset(var inQueue: Int, var inItem: Int) + data class Offset(val inQueue: Int, val inItem: Int) enum class Direction { FORWARDS, BACKWARDS } /** diff -r f1fcc1281dad -r c4f53bc01732 src/name/blackcap/clipman/PasteboardView.kt --- a/src/name/blackcap/clipman/PasteboardView.kt Wed Jan 29 13:39:14 2020 -0800 +++ b/src/name/blackcap/clipman/PasteboardView.kt Wed Jan 29 14:36:16 2020 -0800 @@ -29,7 +29,6 @@ border = normalBorder setEditable(false) alignmentX = JTextPane.LEFT_ALIGNMENT - resize() } /** diff -r f1fcc1281dad -r c4f53bc01732 src/name/blackcap/clipman/SearchDialog.kt --- a/src/name/blackcap/clipman/SearchDialog.kt Wed Jan 29 13:39:14 2020 -0800 +++ b/src/name/blackcap/clipman/SearchDialog.kt Wed Jan 29 14:36:16 2020 -0800 @@ -163,8 +163,19 @@ } if (result == null) { Toolkit.getDefaultToolkit().beep() + origin = null + } else { + origin = when(direction) { + PasteboardQueue.Direction.FORWARDS -> + PasteboardQueue.Offset(result.inQueue, result.inItem + 1) + PasteboardQueue.Direction.BACKWARDS -> + if (result.inItem == 0) { + if (result.inQueue == 0) null else PasteboardQueue.Offset(result.inQueue - 1, -1) + } else { + PasteboardQueue.Offset(result.inQueue, result.inItem - 1) + } + } } - origin = result } /* changing the search string resets the search origin */