changeset 29:c4f53bc01732

Fix searching (and main display).
author David Barts <n5jrn@me.com>
date Wed, 29 Jan 2020 14:36:16 -0800
parents f1fcc1281dad
children 0e88c6bed11e
files src/name/blackcap/clipman/Main.kt src/name/blackcap/clipman/PasteboardQueue.kt src/name/blackcap/clipman/PasteboardView.kt src/name/blackcap/clipman/SearchDialog.kt
diffstat 4 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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)
--- 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 }
 
     /**
--- 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()
     }
 
     /**
--- 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 */